index.vue
3.76 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
<el-drawer title="字典分类管理" :visible.sync="drawer" :wrapperClosable="false" ref="drawer"
size="700px" :before-close="handleDrawerClose" class="NCC-common-drawer">
<div class="NCC-flex-main">
<div class="NCC-common-head">
<topOpts @refresh="getDictionaryTypeList()" @add="handleAddEditType()">
<upload-btn url="/api/system/DictionaryData/Action/Import"
@on-success="getDictionaryTypeList" />
</topOpts>
<div class="NCC-common-head-right">
<el-tooltip effect="dark" :content="$t('common.refresh')" placement="top">
<el-link icon="icon-ym icon-ym-Refresh
NCC-common-head-icon" :underline="false" @click="reset()" />
</el-tooltip>
</div>
</div>
<NCC-table v-loading="listLoading" :data="tableData" row-key="id" default-expand-all
:tree-props="{children: 'children', hasChildren: ''}">
<el-table-column prop="fullName" label="名称" />
<el-table-column prop="enCode" label="编码" />
<el-table-column prop="sortCode" label="排序" width="70" align="center" />
<el-table-column prop="isTree" label="是否树" width="60" align="center">
<template slot-scope="scope">
<el-tag v-if="scope.row.isTree === 1" type="success" size="mini">是</el-tag>
<el-tag v-else type="danger" size="mini">否</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="130">
<template slot-scope="scope">
<tableOpts @edit="handleAddEditType(scope.row.id)" @del="handleDel(scope.row.id)">
<el-button size="mini" type="text" @click="exportData(scope.row.id)">导出
</el-button>
</tableOpts>
</template>
</el-table-column>
</NCC-table>
<TypeForm v-if="typeFormVisible" ref="TypeForm" @refreshDataList="getDictionaryTypeList" />
</div>
</el-drawer>
</template>
<script>
import {
getDictionaryType,
delDictionaryType,
exportData
} from '@/api/systemData/dictionary'
import TypeForm from './Form'
export default {
components: {
TypeForm
},
data() {
return {
drawer: false,
listLoading: false,
btnLoading: false,
typeFormVisible: false,
tableData: []
}
},
methods: {
init() {
this.drawer = true
this.$nextTick(() => {
this.getDictionaryTypeList()
})
},
getDictionaryTypeList() {
this.listLoading = true
getDictionaryType().then(res => {
this.tableData = res.data.list
this.listLoading = false
}).catch(() => {
this.listLoading = false
})
},
handleAddEditType(id) {
this.typeFormVisible = true
this.$nextTick(() => {
this.$refs.TypeForm.init(id)
})
},
handleDel(id) {
this.$confirm(this.$t('common.delTip'), this.$t('common.tipTitle'), {
type: 'warning'
}).then(() => {
delDictionaryType(id).then(res => {
this.$message({
type: 'success',
message: res.msg,
duration: 1500,
onClose: () => {
this.$store.commit('base/SET_DICTIONARY_LIST', [])
this.getDictionaryTypeList()
}
})
})
}).catch(() => { })
},
reset() {
this.getDictionaryTypeList()
},
handleDrawerClose(done) {
done();
this.$emit('refreshDataList')
},
exportData(id) {
this.$confirm('您确定要导出该字典分类, 是否继续?', '提示', {
type: 'warning'
}).then(() => {
exportData(id).then(res => {
if (res.data.url) window.location.href = this.define.comUrl + res.data.url
})
}).catch(() => { });
}
}
}
</script>