mixin.js
2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// import { getDetailById } from "@api/notice"
import { httpStatus } from "@api/config"
let mixin = {
data() {
return {
// 表格选择数据
selectionChangeList:[]
}
},
methods: {
tableRowClassName({row, rowIndex}) {
if ((rowIndex+1) % 2 === 0) {
return 'success-row';
}
return '';
},
handleSelectionChange(value) {
this.selectionChangeList.length = 0
value.map((item,index)=>{
this.selectionChangeList[index] = item.id
})
},
// 导出数据
getExportList (url,name='列表数据') {
this.$confirm('此操作将进行文件导出, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let loading = this.$loading({
lock: true,
text: '生在生成请稍后',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
require.ensure([], () => {
let { export_json_to_excel } = require('../../../vendor/Export2Excel');
let tHeader = ['id', '名称', '开始时间', '结束时间']
let filterVal = ['id', 'title', 'startTime', 'endTime'];
let data = this.formatJson(filterVal, this.PageData.records)
export_json_to_excel(tHeader, data, name)
loading.close();
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
})
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
// 编辑
// getIdDetail(data) {
// getDetailById(data.id)
// .then(res => {
// if(res.code = httpStatus.OK.code){
// this.detailsData = res.data
// }
// })
// .catch(error => {
// reject(error)
// })
// },
// 表格索引得问题
indexMethod(index) {
return index + 1 + (this.PageData.current - 1) * this.PageData.size;
},
handleCurrentChange(val) {
this.initData.currentPage = val
this._initData()
},
handleSizeChange(val) {
console.log(val)
this.initData.pageSize = val
this._initData()
}
}
}
export default mixin