hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
<template>
  <div
    class="box-card"
    v-loading="loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
  >
    <div class="box-content">
      <!-- 搜索操作 -->
      <div class="search-input-box">
        <div class="fl-co">
          <h3 class="mr-b-20">纠纷专家库</h3>
          <div class="fl-al mr-b-10">
            <el-input
              clearable
              style="width: 400px"
              v-model.trim="searchVal.keyWord"
              placeholder="请输入专家姓名、手机账号进行查找"
              @keyup.enter="handleAction('search')"
            ></el-input>
            <div class="fl-al">
              <!-- <div class="fz-7 label-width-search"></div> -->
              <el-button
                class="mr-l-20"
                type="primary"
                @click="handleAction('search')"
                >搜索</el-button
              >
              <el-button @click="handleAction('reset')">重置</el-button>
            </div>
          </div>
        </div>
      </div>
      <!-- 列表 -->
      <div class="table-content">
        <!-- 新增按钮 -->
        <div class="fl-al mr-b-10">
          <el-button type="primary" @click="handleAction('add')"
            >新增</el-button
          >
        </div>
        <!-- 列表 -->
        <TablePro :tableLsit="tableLsit" :columnList="columnList">
          <template v-slot:status="scope">
            <el-tag v-if="scope.row.status === 1">启用</el-tag>
            <el-tag type="info" v-if="scope.row.status === 0">禁用</el-tag>
          </template>
          <template v-slot:btn="scope">
            <!-- <el-button
              type="text"
              @click="handleAction('setPassword', scope.row)"
              >密码重置</el-button
            > -->
            <el-button type="text" @click="handleAction('edit', scope.row)"
              >编辑</el-button
            >
            <el-button type="text" @click="handleAction('delete', scope.row)"
              >删除</el-button
            >
          </template>
        </TablePro>
        <!-- 分页 -->
        <div class="bottom-page">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageSize"
            background
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </div>
      </div>
      <!-- 新增编辑弹框 -->
      <el-dialog
        :close-on-click-modal="false"
        :title="dialogTitle"
        :visible.sync="dialogVisible"
        :before-close="handleClose"
        center
        append-to-body
      >
        <el-form
          :model="formInfo"
          :rules="rules"
          label-position="right"
          ref="ruleForm"
          label-width="130px"
          class="demo-ruleForm"
        >
          <div v-if="!setPasswordType">
            <el-form-item label="专家级别" prop="level">
              <el-select
                class="input-width"
                v-model="formInfo.level"
                clearable
                placeholder="请选择"
              >
                <el-option
                  v-for="item in expertLeveList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="所属单位" >
              <span>{{ formInfo.unitName||'普达社区' }}</span>
              <!-- <el-select class="input-width" v-model="formInfo.unit" clearable placeholder="请选择">
                                <el-option v-for="item in expertLeveList" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select> -->
              <!-- <el-cascader
                v-model="localCityValue"
                :options="rangeList"
                :props="propsAreaEdit"
                @change="areaHandleChange"
                clearable
                filterable
                class="input-width"
                ref="cascaderRef"
                placeholder="选择在所属单位"
              /> -->
            </el-form-item>
            <div class="fl-fw">
              <el-form-item label="专家姓名" prop="name">
                <el-input
                  class="input-width"
                  maxlength="15"
                  placeholder="请输入专家姓名"
                  v-model.trim="formInfo.name"
                ></el-input>
              </el-form-item>
              <el-form-item label="工作时间" prop="workTime">
                <el-input
                  class="input-width"
                  maxlength="25"
                  placeholder="请输入工作时间"
                  v-model.trim="formInfo.workTime"
                ></el-input>
              </el-form-item>
            </div>
            <div class="fl-co">
              <el-form-item label="擅长办理" prop="goodAt">
                <el-select
                  class="input-width"
                  v-model="typeValue"
                  clearable
                  placeholder="请选择事件类型"
                >
                  <el-option
                    v-for="item in typeList"
                    :key="item.id"
                    :label="item.name"
                    :value="item.name"
                  >
                  </el-option>
                </el-select>
                <el-button @click="comfirmClick">确认添加</el-button>
                <div class="fl-fw mr-t-10">
                  <div
                    class="fl-cen type-item mr-r-10 mr-b-10"
                    v-for="(it, ix) in goodAtList"
                    :key="ix"
                  >
                    {{ it }}
                    <div class="delete-item fl-cen cp" @click="deleteItem(ix)">
                      X
                    </div>
                  </div>
                </div>
              </el-form-item>
            </div>
            <el-form-item label="简介">
              <el-input
                style="width: 400px"
                type="textarea"
                v-model="formInfo.introduction"
                resize="none"
                placeholder="专家简介"
                maxlength="100"
                :rows="4"
                show-word-limit
              >
              </el-input>
            </el-form-item>
            <el-form-item label="专家头像" prop="avatar">
              <UploadImg
                @fileHandle="fileHandle"
                :imgShow="formInfo.avatar"
                :imgNum="1"
              />
            </el-form-item>
            <el-form-item label="手机账号" prop="phone">
              <el-input
                class="input-width"
                maxlength="16"
                placeholder="请输入专家注册手机号"
                v-model.trim="formInfo.phone"
              ></el-input>
            </el-form-item>
            <!-- <el-form-item label="登录账号" prop="account">
              <el-input
                style="width: 300px"
                :disabled="dialogTitle === '编辑'"
                class="input-width"
                maxlength="16"
                placeholder="请输入4-16位字母的组合"
                v-model.trim="formInfo.account"
              ></el-input>
            </el-form-item>
            <el-form-item
              :disabled="dialogTitle === '编辑'"
              label="登录密码"
              prop="password"
            >
              <el-input
                type="password"
                style="width: 300px"
                :disabled="dialogTitle === '编辑'"
                class="input-width"
                maxlength="20"
                placeholder="请输入8-16位,且包含字母、数字、字符"
                v-model.trim="formInfo.password"
              >
              </el-input>
            </el-form-item>
            <el-form-item
              label="确认密码"
              prop="confirmPssword"
              v-if="dialogTitle != '编辑'"
            >
              <el-input
                type="password"
                style="width: 300px"
                maxlength="20"
                placeholder="请输入8-16位,且包含字母、数字、字符"
                v-model.trim="formInfo.confirmPssword"
              ></el-input>
            </el-form-item>
            <el-form-item label="账号状态" prop="status">
              <div class="input-width">
                <el-radio v-model="formInfo.status" :label="1">启用</el-radio>
                <el-radio v-model="formInfo.status" :label="0">禁用</el-radio>
              </div>
            </el-form-item> -->
          </div>
          <!-- <div v-else>
            <el-form-item label="登录密码" prop="password">
              <el-input
                type="password"
                style="width: 300px"
                class="input-width"
                maxlength="20"
                placeholder="请输入8-16位,且包含字母、数字、字符"
                v-model.trim="formInfo.password"
              ></el-input>
            </el-form-item>
            <el-form-item label="确认密码" prop="confirmPssword">
              <el-input
                type="password"
                style="width: 300px"
                class="input-width"
                maxlength="20"
                placeholder="请输入8-16位,且包含字母、数字、字符"
                v-model.trim="formInfo.confirmPssword"
              ></el-input>
            </el-form-item>
          </div> -->
        </el-form>
        <div class="fl-cen">
          <el-button @click="handleClose">取 消</el-button>
          <el-button
            type="primary"
            @click="handleAction('submit')"
            :loading="btnloading"
            >提交</el-button
          >
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import { objCopyPro, showToast } from "../../../utils/common";
import { PHONE } from "../../../utils/validation";
import UploadImg from "../../../components/upload/uploadImg.vue";
const REX_VAL =
  /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*.`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&.*`~()-+=]+$)(?![0-9\W_!@#$%^.&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&.*`~()-+=]{8,16}$/;
export default {
  data() {
    const USER_NAME = (rule, value, callback) => {
      const regExp = /^[A-Za-z]{4,16}$/;
      if (!value) return callback(new Error("不能为空"));
      if (regExp.test(value) === false) {
        callback(new Error("请输入4-16位字母的组合"));
      } else {
        callback();
      }
    };
    const VALIDATE_PASSWOID = (rule, value, callback) => {
      const regExp = REX_VAL;
      if (!value) return callback(new Error("不能为空"));
      if (regExp.test(value) === false) {
        callback(new Error("请输入4-请输入8-16位,且包含字母、数字、字符"));
      } else {
        callback();
      }
    };
    const COMFIRM_PASSWOID = (rule, value, callback) => {
      if (!value) return callback(new Error("不能为空"));
      if (value !== this.formInfo.password) {
        callback(new Error("两次密码不一样"));
      } else {
        callback();
      }
    };
    return {
      loading: false, // 页面loading
      btnloading: false, // 提交按钮loading
      tableLsit: [], // 列表
      columnList: [
        { type: "index" },
        { label: "专家级别", key: "level" },
        { label: "所属单位", key: "unit" },
        { label: "专家姓名", key: "name" },
        { label: "工作时间", key: "workTime" },
        { label: "擅长办理", key: "goodAt" },
        { label: "简介", key: "introduction" },
        { label: "手机账号", key: "phone" },
        { label: "登录账号", key: "account" },
        { label: "办结事项", key: "solveEvents" },
        { type: "custom", label: "状态", slot: "status" },
        {
          type: "custom",
          label: "操作",
          width: "150",
          slot: "btn",
        },
      ], // 列表属性
      dialogTitle: "", // 弹框标题
      dialogVisible: false, // 弹框状态
      pageNum: 1, // 当前页
      pageSize: 10, // 当前条数
      total: 0, // 总数
      expertLeveList: [
        // {
        //   value: 3,
        //   label: "街道调解站",
        // },
        // {
        //   value: 1,
        //   label: "纠纷调解",
        // },
        {
          value: 4,
          label: "社区调解室",
        },
        // {
        //   value: 2,
        //   label: "行业分中心调解室",
        // },
      ],
      formInfo: {
        name: "",
        level: 4,
        unit: "",
        workTime: "工作日9:00-18:00",
        goodAt: "",
        introduction: "",
        avatar: "",
        phone: "",
        // account: "",
        // password: "",
        status: 1,
        // confirmPssword: "",
        unitName: "",
      }, // 表单
      rules: {
        avatar: [
          {
            required: true,
            message: "请上传专家头像",
            trigger: "change",
          },
        ],
        level: [
          {
            required: true,
            message: "请选择专家级别",
            trigger: "change",
          },
        ],
        unit: [
          {
            required: true,
            message: "请选择所属单位",
            trigger: "change",
          },
        ],
        goodAt: [
          {
            required: true,
            message: "请选择擅长办理",
            trigger: "blur",
          },
        ],
        name: [
          {
            required: true,
            message: "请输入专家姓名",
            trigger: "blur",
          },
        ],
        introduction: [
          {
            required: true,
            message: "请输入专家简介",
            trigger: "blur",
          },
        ],
        workTime: [
          {
            required: true,
            message: "请输入工作时间",
            trigger: "blur",
          },
        ],
        phone: [
          {
            required: true,
            trigger: "blur",
            validator: PHONE,
          },
        ],
        account: [
          {
            required: true,
            trigger: "blur",
            validator: USER_NAME,
          },
        ],
        password: [
          {
            required: true,
            trigger: "blur",
            validator: VALIDATE_PASSWOID,
          },
        ],
        confirmPssword: [
          {
            required: true,
            trigger: "blur",
            validator: COMFIRM_PASSWOID,
          },
        ],
        status: [
          {
            required: true,
            message: "请选择账号状态",
            trigger: "blur",
          },
        ],
      }, // 表单验证
      searchVal: {
        keyWord: "",
      },
      setPasswordType: false,
      typeList: [],
      typeValue: "",
      goodAtList: [],
      rangeList: [],
      localCityValue: "",
      propsAreaEdit: {
        label: "name",
        value: "id",
        children: "childList",
      },
      pageLevel: "",
    };
  },
  components: {
    UploadImg,
  },
  mounted() {
    const USER_INFO = demo.$session.get("user") || {};
    this.formInfo.unit = USER_INFO.communityId;
    this.formInfo.unitName = USER_INFO.title;
    // this.pageLevel = USER_INFO.level;
    // this.getExpertList(this.pageLevel);
    this.getUnitList();
    this.getTypeList();
    this.getTable();
  },
  methods: {
    getExpertList(l) {
      switch (l) {
        case 2: {
          this.expertLeveList = [
            {
              value: 2,
              label: "行业分中心调解室",
            },
          ];
          break;
        }
        case 3: {
          this.expertLeveList = [
            {
              value: 3,
              label: "街道调解站",
            },
          ];
          break;
        }
        case 4: {
          this.expertLeveList = [
            {
              value: 4,
              label: "社区调解室",
            },
          ];
          break;
        }
        case 5: {
          this.expertLeveList = [
            {
              value: 4,
              label: "社区调解室",
            },
          ];
          break;
        }
        case 5: {
          break;
        }
        default: {
          break;
        }
      }
    },
    getUnitList() {
      this.$api.get("sanshuo/sanshuo/expertRange", {}, (res) => {
        this.rangeList = res;
      });
    },
    areaHandleChange(val) {
      this.formInfo.unit = val.join(",");
      // console.log(this.$refs.cascaderRef.getCheckedNodes())
      this.$refs.ruleForm.validateField("unit");
    },
    comfirmClick() {
      const IS_TYPE = this.goodAtList.some((item) => {
        return item === this.typeValue;
      });
      if (IS_TYPE) {
        demo.toast("不能添加重复分类");
        return;
      }
      this.typeList.forEach((item) => {
        if (item.name === this.typeValue) {
          this.goodAtList.push(item.name);
        }
      });
      this.formInfo.goodAt = this.goodAtList.join(",");
      this.$refs.ruleForm.validateField("goodAt");
    },
    getTypeList() {
      this.$api.get("sanshuo/event/backList", { page: 1, size: 99999 }, (e) => {
        this.typeList = e.records;
      });
    },
    fileHandle(data) {
      if (data.type === "loading") {
        this.btnloading = data.val;
      } else {
        this.formInfo.avatar = data.val;
        this.$refs.ruleForm.validateField("avatar");
      }
    },
    // 获取列表
    getTable() {
      this.loading = false;
      const requestData = Object.assign(
        {
          page: this.pageNum,
          size: this.pageSize,
          level: this.pageLevel,
        },
        this.searchVal
      );
      this.$api.get("sanshuo/expert/backstageList", requestData, (res) => {
        this.loading = false;
        this.tableLsit = res.records;
        this.total = res.total;
      });
    },
    // 切换条数
    handleSizeChange(val) {
      this.pageSize = val;
      this.getTable();
    },
    // 切换页
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getTable();
    },
    deleteItem(ix) {
      this.goodAtList.splice(ix, 1);
    },
    // 页面操作
    async handleAction(type, row) {
      switch (type) {
        // 新增
        case "add": {
          this.dialogTitle = "新增";
          this.dialogVisible = true;
          break;
        }
        // 编辑
        case "edit": {
          this.dialogTitle = "编辑";
          this.goodAtList = [];
          this.$api.get(`sanshuo/expert/${row.id}`, {}, (res) => {
            this.formInfo = objCopyPro(this.formInfo, res);
            this.formInfo.avatar = res.avatar || "";
            this.localCityValue = res.unit.split(",");
            this.goodAtList = res.goodAt.split(",");
            this.dialogVisible = true;
          });
          break;
        }
        // 重置
        case "reset": {
          this.pageNum = 1;
          this.pageSize = 10;
          this.searchVal = { keyWord: "" };
          this.getTable();
          break;
        }
        // 重置
        case "setPassword": {
          this.dialogTitle = "重置密码";
          this.formInfo.id = row.id;
          this.dialogVisible = true;
          this.setPasswordType = true;
          break;
        }
        // 删除
        case "delete": {
          this.$confirm("确定要删除该专家吗?", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "info",
          }).then(() => {
            this.$api.get(
              `sanshuo/expert/remove/${row.id}`,
              { id: row.id },
              () => {
                showToast("删除成功");
                this.getTable();
              }
            );
          });
          break;
        }
        // 提交
        case "submit": {
          this.$refs.ruleForm.validate((val) => {
            if (val) {
              this.btnloading = false;
              this.formInfo.unitId = '10172'
              delete this.formInfo.unit
              if (this.setPasswordType) {
                this.$api.post(
                  "sanshuo/expert/resetPassword",
                  this.formInfo,
                  () => {
                    this.btnloading = false;
                    showToast(this.dialogTitle + "成功");
                    this.handleClose();
                    // this.getTable();
                  }
                );
              } else {
                if (this.dialogTitle === "新增") {
                  this.$api.post("sanshuo/expert", this.formInfo, () => {
                    this.btnloading = false;
                    showToast(this.dialogTitle + "成功");
                    this.handleClose();
                    this.getTable();
                  });
                } else {
                  this.$api.put("sanshuo/expert", this.formInfo, () => {
                    this.btnloading = false;
                    showToast(this.dialogTitle + "成功");
                    this.handleClose();
                    this.getTable();
                  });
                }
              }
            }
          });
          break;
        }
        // 搜索
        case "search": {
          this.pageNum = 1;
          this.pageSize = 10;
          this.getTable();
          break;
        }
        default: {
          break;
        }
      }
    },
    // 关闭弹框
    handleClose() {
      this.$refs.ruleForm.resetFields(); // 重置form表单
      this.formInfo = {
        name: "",
        level: 4,
        unit: "",
        workTime: "工作日9:00-18:00",
        goodAt: "",
        introduction: "",
        avatar: "",
        phone: "",
        account: "",
        password: "",
        status: 1,
        confirmPssword: "",
        unitName: "",
      };
      this.setPasswordType = false;
      this.dialogVisible = false;
      this.btnloading = false;
      this.typeValue = "";
      this.localCityValue = "";
      this.goodAtList = [];
    },
  },
};
</script>
<style>
.el-dialog {
  width: 800px !important;
}
</style>
<style scoped>
.input-width {
  width: 250px;
}
 
.type-item {
  position: relative;
  padding: 2px 14px;
  border: 1px solid;
}
 
.delete-item {
  position: absolute;
  right: -8px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: red;
  color: #fff;
}
</style>