index.vue
9.9 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<template>
<div class="system-container">
<div class="user-container">
<search-form
class="searchTop border-shadow"
:formModel="searchForm"
:formList="userFormList"
>
<slot name="form-slot">
<el-button
type="primary"
:size="btn_size"
icon="el-icon-search"
:id="tableParams.btnId"
>搜索</el-button>
<el-button
type="primary"
:size="btn_size"
icon="el-icon-refresh"
>重置</el-button>
</slot>
</search-form>
<div class="table-btn">
<el-button
type="primary"
:size="btn_size"
icon="el-icon-plus"
@click="handleClose"
>新增</el-button>
</div>
<el-table
v-loading="loading"
align="center"
ref="multipleTable"
:data="listData"
tooltip-effect="dark"
style="width: 100%"
@row-click="rowClick"
:header-cell-style="{background:'#f5f7fa'}"
>
<table-tree-column
ref='OrgiSort'
@table-click="tableClick"
prop="departmentName"
header-align="center"
treeKey="id"
width="300"
label="组织名称"
></table-tree-column>
<el-table-column
v-for="(item,index) in listHeadData"
:key="index"
:prop="item.prop"
:sortable="item.sortable"
:ref="item.ref"
:width="item.width"
:label="item.label"
show-overflow-tooltip
>
<template slot-scope="scope">
<template v-if="item.prop === 'orgStatus'">
dfs
<!-- <span
class="dot"
:class="ORGINIZASTATUS[scope.row[item.prop]].split(',')[1]"
></span>
<span class="statusText">{{ORGINIZASTATUS[scope.row[item.prop]].split(',')[0]}}</span> -->
</template>
<template v-else>
{{scope.row[item.prop]?scope.row[item.prop]:'--'}}
</template>
</template>
</el-table-column>
<el-table-column
align="center"
width="170"
fixed="right"
prop="btn"
label="操作"
>
<template slot-scope="scope">
<el-button
v-for="(j, idx) in tableParams.tableOption.btnList"
:key="idx"
:type="j.type"
size="mini"
plain
@click="btnClick(j.pType, scope.scope)"
>{{j.name}}</el-button>
</template>
</el-table-column>
</el-table>
<basic-dialog
:title="userDialogTitle"
:isVisible="userVisible"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<slot>
<rule-form
:ruleForm="userForm"
:rules="userRules"
:ruleData="userData"
ref='userForm'
></rule-form>
</slot>
</basic-dialog>
<basic-dialog
:title="filterDialogTitle"
:isVisible="filterVisible"
@confirmDialog="filterConfirm"
@closeDialog="closeFilter"
>
<slot>
<el-input
placeholder="输入关键字进行过滤"
v-model="filterText"
>
</el-input>
<el-tree
class="filter-tree"
:data="filterTextData"
:props="defaultProps"
:filter-node-method="filterNode"
ref="tree"
node-key="id"
check-on-click-node
>
</el-tree>
</slot>
</basic-dialog>
</div>
</div>
</template>
<script>
import OrginizaService from 'services/orginizaManage';
const orginizaService = new OrginizaService();
export default {
data() {
return {
ORGINIZASTATUS: this.$Constants.ORGINIZASTATUS,
searchForm: {},
userFormList: [
{
type: 'input',
inputType: 'text',
prop: 'organizationName',
placeholder: '请输入组织名称'
},
{
type: 'select',
prop: 'enableStatus',
placeholder: '请选择组织状态',
options: [{
value: '0',
label: '正常'
}, {
value: '1',
label: '停用'
}]
}
],
listHeadData: [ // 列表 头部设置 数据
{ prop: 'orderNum', label: '排序' },
{ prop: 'enableStatus', label: '状态' },
{ prop: 'createTime', label: '创建时间' }
],
tableParams: {
tableOption: {
btnList: [
{
type: 'primary',
name: '新增',
pType: 'create'
},
{
type: 'primary',
name: '编辑',
pType: 'edit'
},
{
type: 'danger',
name: '删除',
pType: 'delete'
}
]
}
},
// 弹窗数据
userDialogTitle: '新增用户',
userVisible: false,
userForm: {
account: '',
departmentId: '',
superiorId: '',
enableStatus: true
},
userData: [
{ label: '组织名称', prop: 'account', type: 'input' },
{ label: '显示排序', prop: 'departmentId', type: 'input' },
{ label: '组织状态', prop: 'superiorId', type: 'input' }
],
userRules: {
account: [{ required: true, message: '请输入登录名称', trigger: blur }]
},
// 部门弹窗
filterDialogTitle: '选择组织',
filterVisible: false,
filterText: '',
filterTextData: [
{
id: 1,
label: '广汇集团',
children: [
{
id: 10,
label: '东北大区'
}, {
id: 11,
label: '华南大区'
}, {
id: 12,
label: '西北大区',
children: [
{
id: 100,
label: '新疆',
children: [
{
id: 1000,
label: '新疆克拉玛依华威4S店'
}, {
id: 1001,
label: '新疆克拉玛依华威4S店'
}
]
}, {
id: 101,
label: '陕西'
}
]
}
]
}, {
id: 2,
label: '成都轱辘汽车服务公司',
children: [
{
id: 20,
label: '新疆克拉玛依华威4S店'
}, {
id: 21,
label: '深圳市',
children: [
{
id: 200,
label: '南山区',
children: [
{
id: 2000,
label: '南山科技园片区'
}
]
}, {
id: 201,
label: '福田竹子林金融产业园区'
}
]
}
]
}
],
defaultProps: {
children: 'children',
label: 'label'
},
listData: [
],
loading: false
}
},
watch: {
filterText(val) {
this.$refs.tree.filter(val)
}
},
mounted() {
this.getList()
},
methods: {
// 确定,新增用户、编辑用户
handleConfirm() {
console.log(this.$refs.userForm)
this.$refs.userForm.$children[0].validate((valid) => {
if (valid) {
this.handleClose()
} else {
console.log('error')
}
})
},
// 取消
handleClose() {
if (!this.userVisible && this.$refs.userForm) {
this.$refs.userForm.$children[0].resetFields()
}
this.userVisible = !this.userVisible
},
// 按钮事件
btnClick(pType, scope) {
console.log(pType, scope)
switch (pType) {
case 'edit':
this.editEvent(scope)
break
case 'delete':
this.deleteEvent(scope.id)
break
}
},
// 编辑触发事件
editEvent(row) {
this.handleClose()
},
// 删除触发事件
deleteEvent(id) {
const that = this
const tipData = {
that: that,
tipText: '是否删除当前记录',
tipTitle: '提示',
type: 'error',
callBack: () => {
this.$message({
type: 'success',
message: '删除成功!'
})
}
}
this.$Common.confirmDialog(tipData)
},
// 部门弹窗
selectDepart() {
this.filterDialogTitle = '选择组织'
this.closeFilter()
},
// 上级弹窗
selectSuperior() {
this.filterDialogTitle = '选择直接上级'
this.closeFilter()
},
closeFilter() {
this.filterVisible = !this.filterVisible
},
filterConfirm() {
console.log(this.$refs.tree.getCheckedKeys(false, true))
// this.closeFilter()
},
filterNode(value, data) {
console.log(value, data)
if (!value) return true
return data.label.indexOf(value) !== -1
},
// 表格方法
rowClick(row, e, col) {
console.log(row, e, col, 'row cliock data')
orginizaService.getChildren(row.id).then(res => {
console.log(res)
row.children = res.data.list
})
},
// 业务
tableClick(that, index, row, data) {
console.log(that, index, row, data, 'tableClick')
},
getList() {
orginizaService.getTableList().then((res) => {
console.log(res);
this.listData = res.data.list
}, (err) => {
});
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>