personManage.vue
14.3 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
<template>
<div class="componentsSty">
<el-row style="width: 100%; height: 100%;">
<el-col :span="24">
<el-form :model="queryForm" ref="queryForm" :inline="true">
<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,index) in statusOption" :key="index" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" style="background: #5875eb; border: 1px solid #5875eb; border-radius: 5px;"
icon="el-icon-plus" @click="handleAdd"> 新增用户
</el-button>
<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>
</el-col>
<el-col :span="24" style="height: calc(100% - 95px);overflow: auto;">
<el-table :data="dataList" border key="table" ref="multipleTable" :span-method="arraySpanMethod" style="width: 100%;" 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">
<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>
</template>
</el-table-column>
</el-table>
</el-col>
<el-col :span="24">
<el-pagination
style="float: right;margin-top: 10px;"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
:current-page="pageParam.page"
:page-sizes="[10,20,,50,100]"
:page-size="pageParam.size"
layout="total, sizes, prev, pager, next, jumper"
:total="pageParam.total"
>
</el-pagination>
</el-col>
</el-row>
<dialog-info v-if="showDialog" ref="showDialog" :orgId="queryForm.orgId" @closeDialog="handleSearch"></dialog-info>
<el-dialog
v-if="showResetDialog"
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 {getTableData,deleteUser,resetPassword} from '@/api/userManage'
import DialogInfo from "./personDialogInfo";
import employeeQrCode from '@/components/employeeQRCode/index'
export default {
name: "personManage",
components: {DialogInfo,employeeQrCode},
props:{
rowData:{
type:Object,
default:()=>{}
}
},
async mounted() {
await this.getDataList();
},
data(){
return {
filterText:'',
showResetDialog:false,
showQrCodeVisible:false,
showDialog:false,
resetPswForm:{
dialogVisible:false,
password:'',
fUserId:'',
label:'请输入"张三-18000000081"的新密码'
},
resetPwdRules:{
password: [
{ required: true, message: '请输入新的密码', trigger: 'change' }
]
},
queryForm:{
name:'',
phone:'',
status:'',
orgId:''
},
pageParam:{
page:1,
size:10,
total:0
},
statusOption:[
{
label:'停用',
value:'停用'
},
{
label:'正常',
value:'正常'
}
],
loading:false,
dataList:[],
}
},
methods:{
//查询列表事件
async getDataList(){
this.loading = true;
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;
setTimeout(()=>{
this.loading = false;
},500);
})
},
//处理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 }){
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];
},
//点击查看员工气瓶二维码的事件
hanldeViewQrCode(type,row){
this.showQrCodeVisible = true;
this.$nextTick(()=>{
this.$refs.employeeQrCode.show(type,row);
})
console.log('打印row',row);
},
//重置按钮事件
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':
this.showResetDialog = true;
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>
.componentsSty{
width: calc(100% - 30px);
height: 100%;
}
</style>