index.vue
18 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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<template>
<div class="container">
<div class="container-left">
<div class="title-label">组织列表</div>
<div class="title-content">可以选择对应的组织下的成员信息</div>
<div><el-input v-model="filterText" placeholder="请输入组织关键词搜索" suffix-icon="el-icon-search" cleaable></el-input></div>
<div>
<el-tree
class="filter-tree"
:data="treeData"
@node-click="handleNodeClick"
:props="defaultProps"
highlight-current
default-expand-all
:filter-node-method="filterNode"
ref="tree">
<template v-slot="{node}">
<span :title="node.label" class="node-label">{{node.label}}</span>
</template>
</el-tree>
</div>
</div>
<div class="container-right">
<div class="container-right-head">
<el-form :model="queryForm" ref="queryForm" :inline="true" style="display: flex; justify-content: space-between">
<div>
<el-form-item label="姓名:">
<el-input v-model="queryForm.name" placeholder="请输入姓名" clearable></el-input>
</el-form-item>
<el-form-item label="电话:">
<el-input v-model="queryForm.phone" placeholder="请输入电话" clearable></el-input>
</el-form-item>
<el-form-item label="状态:">
<el-select v-model="queryForm.status" placeholder="请选择状态" clearable>
<el-option v-for="item in statusOption" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
</div>
<el-form-item>
<el-button type="primary" icon="el-icon-refresh"
style="border: 1px solid #5875eb; background: #ffffff; color: #5875eb; border-radius: 5px;"
@click="handleReset" plain>重置
</el-button>
<el-button type="primary" style="background: #5875eb; border: 1px solid #5875eb; border-radius: 5px;"
icon="el-icon-search" @click="handleSearch"> 查询
</el-button>
</el-form-item>
</el-form>
</div>
<div class="container-right-main">
<div>
<el-button type="primary" style="background: #5875eb; border: 1px solid #5875eb; border-radius: 5px;"
icon="el-icon-plus" @click="handleAdd"> 新增用户
</el-button>
</div>
<div style="height: calc(100% - 75px);overflow: auto;">
<el-table :data="dataList" border key="table" ref="multipleTable" :span-method="arraySpanMethod" style="width: 100%;margin-bottom: 10px; margin-top: 10px;" v-loading='loading'>
<el-table-column prop="shopId" type="index" label="序号" width="80" align="center">
</el-table-column>
<el-table-column prop="fSsqymc" label="所属企业" min-width="100" :show-overflow-tooltip='true' align="center">
<template slot-scope="scope">
<span v-if="scope.row.fSsqymc">{{scope.row.fSsqymc}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fSsczmc" label="所属气站" min-width="100" :show-overflow-tooltip='true' align="center">
<template slot-scope="scope">
<span v-if="scope.row.fSsczmc">{{scope.row.fSsczmc}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fXm" label="姓名" min-width="120" :show-overflow-tooltip="true" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fXm">{{scope.row.fXm}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fSjh" label="电话" min-width="120" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fsjh">{{scope.row.fSjh}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="ygewm" label="员工二维码" min-width="120" align="center">
<template slot-scope="scope">
<span v-if="scope.row.ygewm">{{scope.row.ygewm}}</span>
<span v-else style="color: #5875EB;cursor: pointer;" @click="hanldeViewQrCode('yhgl',scope.row)">查看</span>
</template>
</el-table-column>
<el-table-column prop="fJsmc" label="角色" min-width="120" :show-overflow-tooltip="true" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fsjh">{{scope.row.fJsmc}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fRzsj" min-width="120" label="入职时间" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fRzsj">{{parseTime(scope.row.fRzsj,"{y}-{m}-{d}")}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fSfzh" label="身份证号" min-width="180" :show-overflow-tooltip="true" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fSfzh">{{scope.row.fSfzh}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fZt" label="状态" width="80" align="center">
<template slot-scope="scope">
<span style="color:rgb(0, 174, 170);" v-if="scope.row.fZt=='正常'">正常</span>
<span style="color:rgb(255, 165, 0);" v-else>停用</span>
</template>
</el-table-column>
<el-table-column prop="fZxzsbh" label="执业证书编号" :show-overflow-tooltip="true" min-width="180" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fZxzsbh">{{scope.row.fZxzsbh}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fZxzsyxqx" label="执业证书有效期" min-width="120" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fZxzsyxqx">{{parseTime(scope.row.fZxzsyxqx,"{y}-{m}-{d}")}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="fCjsj" label="创建时间" min-width="160" align="center">
<template slot-scope="scope">
<span v-if="scope.row.fCjsj">{{scope.row.fCjsj}}</span>
<span v-else>— —</span>
</template>
</el-table-column>
<el-table-column prop="state" label="操作" fixed="right" min-width="160" align="center">
<template slot-scope="scope">
<div>
<!-- <i class="el-icon-edit"></i>-->
<el-button type="text" @click="handleOptBtn('edit',scope.row)">编辑</el-button>
<el-button type="text" @click="handleOptBtn('password',scope.row)">重置密码</el-button>
<el-button type="text" @click="handleOptBtn('delete',scope.row)" style="color:red;">删除</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
<div>
<el-pagination
style="display: flex; justify-content: end"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
:current-page="pageParam.page"
:page-sizes="[10,20,,50,100]"
:page-size="pageParam.size"
layout="total, prev, pager, next"
:total="pageParam.total"
>
</el-pagination>
</div>
</div>
</div>
<dialog-info v-if="showDialog" ref="showDialog" :orgId="queryForm.orgId" @closeDialog="handleSearch"></dialog-info>
<el-dialog
title="重置密码"
:visible.sync="resetPswForm.dialogVisible"
width="400px"
@close="handleClose('resetPswForm')">
<el-row>
<el-form :model="resetPswForm" :rules="resetPwdRules" :label-position="'top'" ref="resetPswForm">
<el-col :span="24">
<el-form-item :label="resetPswForm.label" prop="password">
<el-input v-model="resetPswForm.password" style="width: 100%;" placeholder="请输入新的密码" clearable></el-input>
</el-form-item>
</el-col>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button @click="handleClose('resetPswForm')">取 消</el-button>
<el-button type="primary" @click="handleOK('resetPswForm')">确 定</el-button>
</span>
</el-dialog>
<employee-qr-code v-if="showQrCodeVisible" ref="employeeQrCode"></employee-qr-code>
</div>
</template>
<script>
import {getTreeNode,getTableData,deleteUser,resetPassword} from '@/api/userManage'
import DialogInfo from "./components/dialogInfo";
import employeeQrCode from '@/components/employeeQRCode/index'
export default {
name: "index",
components: {DialogInfo,employeeQrCode},
data(){
return {
filterText:'',
showQrCodeVisible:false,
showDialog:false,
resetPswForm:{
dialogVisible:false,
password:'',
fUserId:'',
label:'请输入"张三-18000000081"的新密码'
},
resetPwdRules:{
password: [
{ required: true, message: '请输入新的密码', trigger: 'change' }
]
},
defaultProps: {
children: 'children',
label: 'name'
},
treeData:[
{
id: 1,
label: '一级 1',
children: [{
id: 4,
label: '二级 1-1',
children: [{
id: 9,
label: '三级 1-1-1等哈数据的卡上等哈圣诞节撒谎的的hash科技大厦的回答赛季开打黄金大神发动机四分零四'
}, {
id: 10,
label: '三级 1-1-2'
}]
}]
},
],
queryForm:{
name:'',
phone:'',
status:'',
orgId:''
},
pageParam:{
page:1,
size:10,
total:0
},
statusOption:[
{
label:'停用',
value:'停用'
},
{
label:'正常',
value:'正常'
}
],
loading:false,
dataList:[],
}
},
mounted(){
this.initData();
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
methods:{
initData(){
this.getTreeNodeList();
this.getDataList();
},
async getDataList(){
let params={
size:this.pageParam.size,
current:this.pageParam.page,
name:this.queryForm.name,
phone:this.queryForm.phone,
state:this.queryForm.status,
orgId:this.queryForm.orgId,
flag:true
}
await getTableData(params).then((res)=>{
console.log('Day热s',res);
const {total,records} = res.value;
this.dataList = this.mergeTableRow(records, ['fSsqymc','fSsczmc']);;
this.pageParam.total = total;
})
},
async getTreeNodeList(){
await getTreeNode().then((res)=>{
console.log('打印res',res);
this.treeData=[{
...res.value
}];
console.log('打印this.treeDAta',this.treeData);
})
},
//点击查看员工气瓶二维码的事件
hanldeViewQrCode(type,row){
this.showQrCodeVisible = true;
this.$nextTick(()=>{
this.$refs.employeeQrCode.show(type,row);
})
console.log('打印row',row);
},
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
//处理dataList中table列表的数据
mergeTableRow(data, merge) {
if (!merge || merge.length === 0) {
return data
}
merge.forEach((m) => {
const mList = {}
data = data.map((v, index) => {
const rowVal = v[m]
if (mList[rowVal] && mList[rowVal].newIndex === index) {
mList[rowVal]['num']++
mList[rowVal]['newIndex']++
data[mList[rowVal]['index']][m + 'SPAN'].rowspan++
v[m + 'SPAN'] = {
rowspan: 0,
colspan: 0
}
} else {
mList[rowVal] = { num: 1, index: index, newIndex: index + 1 }
v[m + 'SPAN'] = {
rowspan: 1,
colspan: 1
}
}
return v
})
})
return data
},
//table列表中相同的数据合并功能
arraySpanMethod({ row, column, rowIndex, columnIndex }){
// console.log('打印row', row,column,columnIndex);
// if (columnIndex == 0) {
// return [row.fSsqymcSPAN.rowspan, row.fSsqymcSPAN.colspan]
// }else
if (column.property == 'fSsqymc') {
return [row.fSsqymcSPAN.rowspan, row.fSsqymcSPAN.colspan]
}else if (column.property == 'fSsczmc') {
return [row.fSsczmcSPAN.rowspan, row.fSsczmcSPAN.colspan]
}
return [1, 1];
},
//el-tree节点的点击事件
handleNodeClick(data,node){
this.queryForm.orgId = data.id;
this.pageParam.page = 1;
this.handleSearch();
console.log('打印data',data);
console.log('打印node',node)
},
//重置按钮事件
handleReset(){
this.queryForm.name ='';
this.queryForm.phone ='';
this.queryForm.status ='';
this.pageParam.page = 1;
this.handleSearch();
},
//查询按钮事件
handleSearch(){
this.getDataList();
},
//新增用户事件
handleAdd(){
this.showDialog = true;
this.$nextTick(()=>{
this.$refs.showDialog.open('add');
})
},
//分页中页数跳转事件
handleCurrentChange(val){
this.pageParam.page = val;
this.handleSearch();
},
//分页中size改变的界面跳转事件
handleSizeChange(val){
this.pageParam.size = val;
this.handleSearch();
},
//操作栏按钮点击事件
handleOptBtn(type,row){
switch (type){
case 'edit':
this.showDialog = true;
this.$nextTick(()=>{
this.$refs.showDialog.open(type,row);
});
break;
case 'password':
let labelString = '请输入 " '+row.fXm+'-'+row.fSjh+' " 的新密码'
this.resetPswForm.label = labelString;
console.log('打印重置密码的row',row);
this.resetPswForm.fUserId = row.fUserid;
this.resetPswForm.dialogVisible = true;
break;
case 'delete':
let params ={
id:row.id
}
this.deleteClick(params);
break;
}
},
deleteClick(param){
this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
await deleteUser(param).then((res)=>{
console.log('打印res', res);
if(res.code == 200){
this.handleSearch();
this.$message({
type: 'success',
message: '删除成功!'
});
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
//重置密码中取消按钮的事件
handleClose(formName){
this.resetPswForm.dialogVisible = false;
this.$refs[formName].resetFields();
},
//重置密码中确定按钮的事件
handleOK(formName){
this.$refs[formName].validate((valid) => {
if ( valid) {
let params ={
fUserId:this.resetPswForm.fUserId?this.resetPswForm.fUserId:'',
pwd:this.resetPswForm.password?this.resetPswForm.password:'',
}
resetPassword(params).then((res)=>{
console.log('打印Res',res);
if(res.code == 200){
this.$message.success('重置密码成功!');
this.handleSearch();
}
})
this.resetPswForm.dialogVisible = false;
} else {
console.log('error submit!!');
return false;
}
});
console.log('打印formName',formName)
},
}
}
</script>
<style lang="scss" scoped>
.container{
display: flex;
width: 100%;
height: 100%;
.container-left{
height: 96%;
overflow: auto;
min-width: 220px;
max-width: 220px;
padding: 10px;
background-color: #FFFFFF;
border-radius: 3px;
.title-label{
font-family: '苹方 中等', '苹方', sans-serif;
font-weight: 400;
font-style: normal;
font-size: 16px;
text-align: left;
margin-bottom: 5px;
}
.title-content{
font-family: '苹方 中等', '苹方', sans-serif;
font-weight: 400;
font-style: normal;
font-size: 12px;
color: #999999;
margin-bottom: 10px;
}
.filter-tree{
::v-deep.el-tree-node__expand-icon.expanded {
/* 修改为你想要的图标 */
color:#5875eb;
}
::v-deep.el-tree-node__expand-icon.collapsed {
/* 修改为你想要的图标 */
color:blue;
}
.node-label{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.container-right{
flex: 1;
height: 100%;
overflow-x: auto;
padding-left: 10px;
.container-right-head{
border-radius: 3px;
padding: 10px;
background-color: #FFFFFF;
}
.container-right-main{
margin-top: 10px;
border-radius: 3px;
height: calc(100% - 105px);
padding: 10px;
background-color: #FFFFFF;
}
}
}
</style>