export-box.vue
2.3 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
<template>
<el-dialog
title="导出数据"
:close-on-click-modal="false"
:visible.sync="visible"
class="NCC-dialog NCC-dialog_center"
lock-scroll
width="600px"
append-to-body
>
<el-form label-position="top" label-width="80px">
<el-form-item label="数据选择">
<el-radio-group v-model="type">
<el-radio :label="0">当前页面数据</el-radio>
<el-radio :label="1">全部页面数据</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="导出字段">
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">
全选
</el-checkbox>
<el-checkbox-group v-model="columns" @change="handleCheckedChange">
<el-checkbox v-for="item in columnList" :key="item.prop" :label="item.prop">
{{ item.label }}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="visible = false">取 消</el-button>
<el-button type="primary" size="small" :loading="btnLoading" @click="downLoad">导 出</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
name: 'TrainingCheckinExportBox',
data() {
return {
visible: false,
btnLoading: false,
type: 0,
columns: [],
checkAll: true,
isIndeterminate: false,
columnList: []
}
},
methods: {
init(columnList) {
this.visible = true
this.columnList = columnList
this.columns = columnList.map(o => o.prop)
this.checkAll = true
this.isIndeterminate = false
this.type = 0
},
handleCheckAllChange(val) {
this.columns = val ? this.columnList.map(o => o.prop) : []
this.isIndeterminate = false
},
handleCheckedChange(value) {
const checkedCount = value.length
this.checkAll = checkedCount === this.columnList.length
this.isIndeterminate = checkedCount > 0 && checkedCount < this.columnList.length
},
downLoad() {
if (!this.columns.length) {
this.$message.warning('请至少选择一个导出字段')
return
}
this.$emit('download', { dataType: this.type, selectKey: this.columns.join(',') })
}
}
}
</script>