123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import Vue from 'vue'
- import { cloneDeep } from 'lodash'
- export const newTableMixin = {
- data() {
- return {
- ipagination: {
- current: 1,
- pageSize: 10,
- pageSizeOptions: ['10', '20', '30', '50', '100'],
- showTotal: (total, range) => {
- return range[0] + '-' + range[1] + ' 共' + total + '条'
- },
- showQuickJumper: true,
- showSizeChanger: true,
- total: 0,
- },
- /* table选中keys*/
- selectedRowKeys: [],
- /* table选中records*/
- selectionRows: [],
- /* 排序参数 */
- isorter: {
- column: 'createTime',
- order: 'desc',
- },
- editableData: {},
- // colList: ['categoryName', 'newPosition', 'differenceCount', 'differenceReason'],
- colList: ['categoryName'],
- }
- },
- methods: {
- //table功能
- onSelectChange(selectedRowKeys, selectionRows) {
- this.selectedRowKeys = selectedRowKeys
- this.selectionRows = selectionRows
- },
- handleTableChange(pagination, filters, sorter) {
- //分页、排序、筛选变化时触发
- if (Object.keys(sorter).length > 0) {
- if (sorter.order) {
- this.isorter.column = sorter.field
- this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc'
- } else {
- this.isorter.column = 'createTime'
- this.isorter.order = 'desc'
- }
- }
- if (pagination && pagination.current) {
- this.ipagination = pagination
- }
- this.getList()
- },
- //禁止点击表格某一行
- getCheckboxProps(record) {
- return {
- props: {
- disabled: record.taskStatus !== 1,
- },
- }
- },
- getTaskkboxProps(record) {
- return {
- props: {
- disabled: record.taskStatus !== 1 && record.taskStatus !== 4,
- },
- }
- },
- // --------------------------------------------------------------------
- formateTaskStatus(type) {
- switch (type) {
- case 1:
- return '未开始'
- case 2:
- return '进行中'
- case 3:
- return '已完成'
- case 4:
- return '已取消'
- default:
- return ''
- }
- },
- onSearch() {
- this.ipagination.current = 1
- this.getList()
- },
- onReset() {
- this.queryParam = {}
- this.onSearch()
- this.$forceUpdate()
- },
- edit(id, col) {
- this.editableData[id] = cloneDeep(this.dataSource.filter((item) => id === item.id)[0])
- this.$forceUpdate()
- },
- save(id) {
- Object.assign(this.dataSource.filter((item) => id === item.id)[0], this.editableData[id])
- delete this.editableData[id]
- },
- cancel(id) {
- delete this.editableData[id]
- },
- },
- }
|