index.vue
5.74 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<template>
<div>
<el-drawer :title="dialogTitle" :visible.sync="buttonAuthorizeListDrawer"
:wrapperClosable="false" ref="drawer" size="700px" class="NCC-common-drawer">
<div class="NCC-flex-main">
<div class="NCC-common-head">
<div>
<topOpts @add="handleAddEdit('')" />
<el-dropdown style="margin-left: 10px">
<el-button icon="el-icon-plus" :loading="loading" type="text">
常用按钮权限<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item @click.native="addHandle(item)" v-for="item in btnList"
:key="item.enCode">{{item.fullName}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<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="getList()" />
</el-tooltip>
</div>
</div>
<NCC-table v-loading="listLoading" :data="treeList" row-key="id" default-expand-all
:tree-props="{children: 'children', hasChildren: ''}">
<el-table-column prop="fullName" label="按钮名称" width="160" />
<el-table-column prop="enCode" label="按钮编码" />
<el-table-column prop="sortCode" label="排序" width="90" align="center" />
<el-table-column label="状态" width="90">
<template slot-scope="scope">
<el-tag :type="scope.row.enabledMark == 1 ? 'success' : 'danger'" disable-transitions>
{{scope.row.enabledMark==1?'正常':'停用'}}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="100">
<template slot-scope="scope">
<tableOpts @edit="handleAddEdit(scope.row.id)" @del="handleDel(scope.row.id)" />
</template>
</el-table-column>
</NCC-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">关闭</el-button>
</span>
</el-drawer>
<ButtonAuthorizeForm v-if="buttonAuthorizeFormVisible" ref="ButtonAuthorizeForm"
@refreshDataList="getList" />
</div>
</template>
<script>
import {
getButtonAuthorizeList,
updateButtonState,
delButton,
createButton
} from '@/api/system/buttonAuthorize'
import ButtonAuthorizeForm from './Form'
export default {
components: {
ButtonAuthorizeForm
},
inheritAttrs: false,
data() {
return {
buttonAuthorizeListDrawer: false,
buttonAuthorizeFormVisible: false,
dialogTitle: '',
params: {
keyword: ''
},
moduleId: '',
loading: false,
btnLoading: false,
listLoading: false,
treeList: [],
btnList: [
{ fullName: '新增', enCode: 'btn_add' },
{ fullName: '编辑', enCode: 'btn_edit' },
{ fullName: '详情', enCode: 'btn_detail' },
{ fullName: '删除', enCode: 'btn_remove' },
{ fullName: '批量删除', enCode: 'btn_batchRemove' },
{ fullName: '复制', enCode: 'btn_copy' },
{ fullName: '导入', enCode: 'btn_upload' },
{ fullName: '导出', enCode: 'btn_download' }
]
}
},
methods: {
init(moduleId, fullName) {
this.buttonAuthorizeListDrawer = true
this.moduleId = moduleId
this.dialogTitle = `按钮权限 - ${fullName}`
this.$nextTick(() => {
this.params.keyword = ''
this.getList()
})
},
getList() {
this.listLoading = true
getButtonAuthorizeList(this.moduleId, this.params).then(res => {
this.treeList = res.data.list
this.listLoading = false
this.btnLoading = false
}).catch(() => {
this.listLoading = false
this.btnLoading = false
})
},
handleReLoad() {
this.btnLoading = true
this.getList()
},
handleUpdateState(row) {
const txt = row.enabledMark ? '禁用' : '开启'
this.$confirm(`您确定要${txt}当前按钮权限吗, 是否继续?`, '提示', {
type: 'warning'
}).then(() => {
updateButtonState(row.id).then(res => {
this.$message({
type: 'success',
message: res.msg,
duration: 1000,
onClose: () => {
row.enabledMark = row.enabledMark ? 0 : 1
}
})
})
}).catch(() => { })
},
handleAddEdit(id) {
this.buttonAuthorizeFormVisible = true
this.$nextTick(() => {
this.$refs.ButtonAuthorizeForm.init(this.moduleId, id)
})
},
addHandle(item) {
this.loading = true
let query = {
parentId: '-1',
moduleId: this.moduleId,
fullName: item.fullName,
enCode: item.enCode,
sortCode: 0,
icon: '',
enabledMark: 1,
description: ''
}
createButton(query).then(res => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.getList()
this.loading = false
}
})
}).catch(() => { this.loading = false })
},
handleDel(id) {
this.$confirm(this.$t('common.delTip'), this.$t('common.tipTitle'), {
type: 'warning'
}).then(() => {
delButton(id).then(res => {
this.$message({
type: 'success',
message: res.msg,
duration: 1500,
onClose: () => {
this.getList()
}
})
})
}).catch(() => { })
}
}
}
</script>