index.vue
7.48 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<template>
<div>
<el-drawer :title="dialogTitle" :visible.sync="dataAuthorizeListDrawer" :wrapperClosable="false"
ref="drawer" size="700px" class="NCC-common-drawer">
<div class="NCC-flex-main">
<el-tabs type="border-card" v-model="tabActiveName" @tab-click="handleClick"
class="NCC-flex-tabs">
<el-tab-pane label="方案管理" name="dataAuthorizeScheme">
<div class="NCC-common-head">
<topOpts @add="handleAddEdit('')" />
<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="getAuthorizeSchemeList()" />
</el-tooltip>
</div>
</div>
<NCC-table v-loading="listLoading" :data="dataAuthorizeSchemeList" row-key="id"
default-expand-all :tree-props="{children: 'children', hasChildren: ''}">
<el-table-column prop="fullName" label="方案名称" width="160" />
<el-table-column prop="conditionText" label="过滤条件" />
<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>
</el-tab-pane>
<el-tab-pane label="字段管理" name="dataAuthorize">
<div class="NCC-common-head">
<topOpts @add="handleAddEdit('')" />
<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="getAuthorizeList()" />
</el-tooltip>
</div>
</div>
<NCC-table v-loading="dataListLoading" :data="dataAuthorizeList" row-key="id"
default-expand-all :tree-props="{children: 'children', hasChildren: ''}">
<el-table-column prop="enCode" label="字段名称" />
<el-table-column prop="fullName" label="字段说明" show-overflow-tooltip />
<el-table-column prop="type" label="字段类型" width="70" />
<el-table-column prop="conditionSymbol" label="条件符号" show-overflow-tooltip />
<el-table-column label="条件内容" width="120">
<template slot-scope="scope">
<span v-if="scope.row.conditionText === 'text'">任意文本</span>
<span v-if="scope.row.conditionText === '@userId'">当前用户</span>
<span v-if="scope.row.conditionText === '@organizeId'">当前组织</span>
<span
v-if="scope.row.conditionText === '@organizationAndSuborganization'">当前组织及子组织</span>
<span v-if="scope.row.conditionText === '@userAraSubordinates'">当前用户及下属</span>
</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>
</el-tab-pane>
</el-tabs>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">关闭</el-button>
</span>
</el-drawer>
<DataSchemeForm v-if="dataSchemeFormVisible" ref="DataSchemeForm"
@refreshDataList="getAuthorizeSchemeList" />
<DataAuthorizeForm v-if="dataAuthorizeFormVisible" ref="DataAuthorizeForm"
@refreshDataList="getAuthorizeList" />
</div>
</template>
<script>
import {
getDataAuthorizeSchemeList,
getDataAuthorizeList,
delDataScheme,
delDataAuthorize
} from '@/api/system/dataAuthorize'
import DataSchemeForm from './DataSchemeForm'
import DataAuthorizeForm from './DataAuthorizeForm'
export default {
components: {
DataSchemeForm,
DataAuthorizeForm
},
data() {
return {
tabActiveName: 'dataAuthorizeScheme',
dataAuthorizeListDrawer: false,
dialogTitle: '',
moduleId: '',
loading: false,
btnLoading: false,
listLoading: false,
dataListLoading: false,
dataAuthorizeSchemeList: [],
dataAuthorizeList: [],
dataSchemeFormVisible: false,
dataAuthorizeFormVisible: false
}
},
methods: {
init(moduleId, fullName) {
this.dataAuthorizeListDrawer = true
this.moduleId = moduleId
this.tabActiveName = 'dataAuthorizeScheme'
this.dialogTitle = `数据权限 - ${fullName}`
this.$nextTick(() => {
this.listLoading = true
this.dataListLoading = true
this.getAuthorizeSchemeList()
})
},
getAuthorizeSchemeList() {
// 获取方案管理列表
getDataAuthorizeSchemeList(this.moduleId).then(res => {
this.dataAuthorizeSchemeList = res.data.list
this.listLoading = false
this.btnLoading = false
}).catch(() => {
this.listLoading = false
this.btnLoading = false
})
},
getAuthorizeList() {
// 获取字段列表
getDataAuthorizeList(this.moduleId).then(res => {
this.dataAuthorizeList = res.data.list
this.dataListLoading = false
this.btnLoading = false
}).catch(() => {
this.dataListLoading = false
this.btnLoading = false
})
},
handleClick(tab, event) {
this.btnLoading = false
const activeTab = this.tabActiveName
if (activeTab === 'dataAuthorizeScheme') {
this.getAuthorizeSchemeList()
} else {
this.getAuthorizeList()
}
},
handleReLoad() {
this.btnLoading = true
const activeTab = this.tabActiveName
if (activeTab === 'dataAuthorizeScheme') {
this.getAuthorizeSchemeList()
} else {
this.getAuthorizeList()
}
},
handleAddEdit(id) {
const activeTab = this.tabActiveName
if (activeTab === 'dataAuthorizeScheme') {
this.dataSchemeFormVisible = true
this.$nextTick(() => {
this.$refs.DataSchemeForm.init(this.moduleId, id)
})
} else {
this.dataAuthorizeFormVisible = true
this.$nextTick(() => {
this.$refs.DataAuthorizeForm.init(this.moduleId, id)
})
}
},
handleDel(id) {
this.$confirm(this.$t('common.delTip'), this.$t('common.tipTitle'), {
type: 'warning'
}).then(() => {
const delMethod = this.tabActiveName === 'dataAuthorizeScheme' ? delDataScheme : delDataAuthorize
delMethod(id).then(res => {
this.$message({
type: 'success',
message: res.msg,
duration: 1500,
onClose: () => {
this.handleReLoad()
}
})
})
}).catch(() => { })
}
}
}
</script>
<style lang="scss" scoped>
.NCC-flex-main {
.el-tabs--border-card {
border: none;
box-shadow: none;
>>> .el-tabs__content {
padding: 0 !important;
}
}
}
.NCC-flex-tabs {
height: 100%;
display: flex;
flex-direction: column;
>>> .el-tabs__content {
flex: 1;
.el-tab-pane {
height: 100%;
display: flex;
flex-direction: column;
}
}
}
</style>