From 00212ed8e808fc7b76c04389224e65f27f074fb2 Mon Sep 17 00:00:00 2001
From: su1124 <1583764726@qq.com>
Date: 星期五, 26 四月 2024 15:30:04 +0800
Subject: [PATCH] su

---
 src/views/system/user/index.vue |  170 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 119 insertions(+), 51 deletions(-)

diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 1c496fd..7a63e71 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -9,7 +9,7 @@
         </div>
         <div class="head-container">
           <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
-            :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all highlight-current
+            :filter-node-method="filterNode" ref="tree" node-key="id" default-expand-all  :default-expanded-keys="treeId" highlight-current
             @node-click="handleNodeClick" />
         </div>
       </el-col>
@@ -78,7 +78,7 @@
           <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
         </el-row>
 
-        <el-table  :data="userList" border @selection-change="handleSelectionChange" v-loading="loading"
+        <el-table :data="userList" border @selection-change="handleSelectionChange" v-loading="loading"
           highlight-current-row>
           <el-table-column type="selection" width="50" align="center" fixed="left" />
           <el-table-column label="搴忓彿" align="center" key="newID" prop="newID" width="50px" fixed="left" />
@@ -192,6 +192,13 @@
           <el-input v-model="form.userId" placeholder="璇疯緭鍏ョ敤鎴穒d" />
         </el-form-item> -->
           <el-form-item label="鐢ㄦ埛鍚嶇О" prop="nickName">
+             <span
+            slot="label"
+            style="display: inline-block; border-bottom: 2px solid blue"
+            @click="handlePackage"
+          >
+            鐢ㄦ埛鍚嶇О
+          </span>
             <el-input v-model="form.nickName" placeholder="璇疯緭鍏ョ敤鎴锋樀绉�" maxlength="30" style="width: 130px" />
           </el-form-item>
           <el-form-item label="鐢ㄦ埛宸ュ彿" prop="userName">
@@ -234,7 +241,8 @@
           </el-form-item>
 
           <el-form-item label="鎵�鍦ㄥ尰闄�" prop="hospId">
-            <el-select v-model="form.hospId" placeholder="璇烽�夋嫨鎵�鍦ㄥ尰闄�" clearable style="width: 200px" filterable  @change="sendhospName">
+            <el-select v-model="form.hospId" placeholder="璇烽�夋嫨鎵�鍦ㄥ尰闄�" clearable style="width: 200px" filterable
+              @change="sendhospName">
               <el-option v-for="dict in hospList" :key="dict.hospAreaName" :label="dict.hospAreaName"
                 :value="dict.hospAreaId" />
             </el-select>
@@ -243,7 +251,7 @@
           <el-form-item label="褰掑睘绉戝" prop="deptId">
             <!-- <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="璇烽�夋嫨褰掑睘绉戝"
               style="width: 200px" /> -->
-              <el-select v-model="form.deptId" placeholder="璇烽�夋嫨褰掑睘绉戝" clearable style="width: 200px" filterable  >
+            <el-select v-model="form.deptId" placeholder="璇烽�夋嫨褰掑睘绉戝" clearable style="width: 200px" filterable>
               <el-option v-for="dict in DepartmentList" :key="dict.deptName" :label="dict.deptName"
                 :value="dict.deptId" />
             </el-select>
@@ -265,8 +273,8 @@
             <el-input v-model="form.medicalId" placeholder="璇疯緭鍏ュ尰淇濈紪鐮�" style="width: 200px" />
           </el-form-item>
           <el-form-item label="浼樻儬鎶樻墸">
-            <el-input-number ref="inputNumber" style="width: 200px" v-model="form.discount" :precision="2"
-              :step="0.1" :max="10" :min="1" @change="numberChange"></el-input-number>
+            <el-input-number ref="inputNumber" style="width: 200px" v-model="form.discount" :precision="2" :step="0.1"
+              :max="10" :min="1" @change="numberChange"></el-input-number>
           </el-form-item>
           <el-form-item label="鐜颁綇鍧�" prop="liveAddr">
             <el-input v-model="form.userInfo.liveAddr" placeholder="璇疯緭鍏ョ幇灞呬綇鍦板潃" style="width: 440px" />
@@ -656,29 +664,27 @@
     </el-dialog>
 
     <!-- 閲嶇疆瀵嗙爜瀵硅瘽妗� -->
-    <el-dialog
-      title="鎻愮ず"
-      :visible.sync="dialogVisible1"
-      width="30%"
-      :before-close="handleClose">
+    <el-dialog title="鎻愮ず" :visible.sync="dialogVisible1" width="30%" :before-close="handleClose">
       <el-form :rules="rules1">
-        <span>璇疯緭鍏モ�渰{row.userName}}鈥濈殑鏂板瘑鐮�</span>
+        <span>璇疯緭鍏モ�渰{ row.userName }}鈥濈殑鏂板瘑鐮�</span>
         <el-form-item prop="password">
           <el-input v-model="password" :type="type" auto-complete="off" placeholder="瀵嗙爜" ref="barcodeMsg">
             <svg-icon slot="prefix" icon-class="password" class="el-input__icon input-icon" />
             <i slot="suffix" class="icon-style" :class="elIcon" autocomplete="auto" @click="flag = !flag" /></el-input>
         </el-form-item>
       </el-form>
-      
+
       <span slot="footer" class="dialog-footer">
-        <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+        <el-button @click="dialogVisible1 = false">鍙� 娑�</el-button>
         <el-button type="primary" @click="tijiao">纭� 瀹�</el-button>
       </span>
     </el-dialog>
+    <yonghu ref="aaa" @add="handleChanges" />
   </div>
 </template>
 
 <script>
+import yonghu from "@/components/yonghu";
 import {
   listUser,
   getUser,
@@ -691,6 +697,7 @@
   getDeptListByDictHospId,
 } from "@/api/system/user";
 import { getToken } from "@/utils/auth";
+import { getInfo } from "@/api/login";
 import { listHosp } from "@/api/hosp/hosp";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -716,17 +723,32 @@
     "dict_user_work",
     "dict_qhdm",
   ],
-  components: { Treeselect },
+  components: { Treeselect, yonghu },
   data() {
+    let checkPhoneNum = (rule, value, callback) => {
+         console.log( value)
+      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
+      if (value == "" && value == undefined && !value) {
+        console.log(11111)
+        return callback('');
+      }  else if(value != undefined && value != ""){
+        console.log(22222)
+        return callback();
+      }else if (!patter.test(value)) {
+        console.log(33333)
+        return callback('');
+      }
+    };
     return {
-      row:[],
+      row: [],
       flag: false,
-      password:"",
-      dialogVisible1:false,
+      password: "",
+      dialogVisible1: false,
       nums: "",
       userInfoList: [],
       hospList: [],
       activeNames: ["1"],
+      treeId: [],
       // 閬僵灞�
       loading: true,
       // 閫変腑鏁扮粍
@@ -750,7 +772,7 @@
       dialogVisible: false,
       // 鐢ㄦ埛琛ㄦ牸鏁版嵁
       sysUserList: [],
-      DepartmentList:[],
+      DepartmentList: [],
       // 宀椾綅琛ㄦ牸鏁版嵁
       postList: [],
       // 瑙掕壊琛ㄦ牸鏁版嵁
@@ -775,7 +797,7 @@
           brithday: "",
           nationDesc: "",
           entryDate: "",
-          hospName: "",          
+          hospName: "",
         },
       },
       forms: {},
@@ -828,59 +850,68 @@
       // 琛ㄥ崟鏍¢獙
       rules: {
         userName: [
-          { required: true, message: "鐢ㄦ埛鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
+          { required: true, validator: checkPhoneNum,  trigger: "blur" },
           {
             min: 2,
             max: 20,
-            message: "鐢ㄦ埛鍚嶇О闀垮害蹇呴』浠嬩簬 2 鍜� 20 涔嬮棿",
+            validator: checkPhoneNum, 
             trigger: "blur",
           },
         ],
         nickName: [
-          { required: true, message: "鐢ㄦ埛鏄电О涓嶈兘涓虹┖", trigger: "blur" },
+          { required: true, validator: checkPhoneNum,  trigger: "blur" },
         ],
         password: [
-          { required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" },
+          { required: true, validator: checkPhoneNum,  trigger: "blur" },
           {
             min: 5,
             max: 20,
-            message: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿",
+            validator: checkPhoneNum, 
             trigger: "blur",
           },
         ],
         email: [
           {
             type: "email",
-            message: "璇疯緭鍏ユ纭殑閭鍦板潃",
+            validator: checkPhoneNum, 
             trigger: ["blur", "change"],
           },
         ],
         phonenumber: [
           {
             pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
-            message: "璇疯緭鍏ユ纭殑鎵嬫満鍙风爜",
+            validator: checkPhoneNum, 
             trigger: "blur",
           },
         ],
       },
       rules1: {
-        password: [
-          { required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" },
-          {
-            min: 5,
-            max: 20,
-            message: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿",
-            trigger: "blur",
-          },
-        ],
+        // password: [
+        //   { required: true, message: "鐢ㄦ埛瀵嗙爜涓嶈兘涓虹┖", trigger: "blur" },
+        //   {
+        //     min: 5,
+        //     max: 20,
+        //     message: "鐢ㄦ埛瀵嗙爜闀垮害蹇呴』浠嬩簬 5 鍜� 20 涔嬮棿",
+        //     trigger: "blur",
+        //   },
+        // ],
       },
     };
   },
   watch: {
     // 鏍规嵁鍚嶇О绛涢�夐儴闂ㄦ爲
     deptName(val) {
-      this.$refs.tree.filter(val);
+      console.log(val)
     },
+    treeId(newVal, oldVal) {
+      if (newVal) {
+        this.$nextTick(() => {
+          document
+            .querySelector('.el-tree-node__children .el-tree-node__content')
+            .click();
+        });
+      }
+    }
   },
   computed: {
     type() {
@@ -891,8 +922,9 @@
     }
   },
   created() {
-    this.getList();
     this.getDeptTree();
+    this.getList();
+   
     // this.getRoleList();
     // this.getConfigKey("sys.user.initPassword").then((response) => {
     //   this.initPassword = response.msg;
@@ -903,7 +935,8 @@
     /** 鏌ヨ鐢ㄦ埛鍒楄〃 */
     getList() {
       this.loading = true;
-      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
+      if(this.queryParams.deptId){
+        listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
         (response) => {
           response.rows.forEach((item, index) => {
             item.newID =
@@ -916,6 +949,8 @@
           this.loading = false;
         }
       );
+      }
+      
     },
     /** 鏌ヨ宀椾綅鍒楄〃 */
     getPostList() {
@@ -935,6 +970,7 @@
     getlistHosp() {
       listHosp(this.queryParams).then((response) => {
         this.hospList = response.rows;
+
         this.total = response.total;
       });
     },
@@ -947,6 +983,10 @@
     getDeptTree() {
       deptTreeSelect().then((response) => {
         this.deptOptions = response.data;
+        console.log( this.deptOptions)
+        this.treeId.push(this.deptOptions[0].id)
+        this.queryParams.deptId = this.deptOptions[0].id
+        console.log(this.queryParams.deptId)
       });
     },
     // 绛涢�夎妭鐐�
@@ -958,6 +998,19 @@
     handleNodeClick(data) {
       this.queryParams.deptId = data.id;
       this.handleQuery();
+    },
+     handlePackage() {
+      this.$refs.aaa.open = true;
+      this.$refs.aaa.getList();
+      this.$refs.aaa.title = "鏁版嵁瀛楀吀";
+    },
+    handleChanges(param1) {
+      this.form.nickName = param1[0].staffName;
+      // this.form.hisPacId = param1[0].pacId;
+      // if (param1[0].price) {
+      //   this.form.counterPrice = param1[0].price;
+      //   this.form.retailPrice = param1[0].price;
+      // }
     },
     // 鐢ㄦ埛鐘舵�佷慨鏀�
     handleStatusChange(row) {
@@ -1050,6 +1103,12 @@
       this.title = "鐢ㄦ埛淇℃伅缁存姢";
       this.getPostList();
       this.getlistHosp();
+      getInfo(this.queryParams).then((response) => {
+        this.form.hospId = response.user.hospId;
+        if (this.form.hospId) {
+          this.sendhospName()
+        }
+      });
       // getUser().then((response) => {
       //   this.postOptions = response.posts;
       //   this.roleOptions = response.roles;
@@ -1058,9 +1117,9 @@
       // });
     },
 
-    sendhospName(){
+    sendhospName() {
       let data = {
-        id:this.form.hospId
+        id: this.form.hospId
       }
       getDeptListByDictHospId(data).then(res => {
         this.DepartmentList = res.data
@@ -1071,6 +1130,7 @@
       this.title = "鐢ㄦ埛淇℃伅缁存姢";
       this.open = true;
       this.form = row;
+      this.form.hospId = Number(row.hospId)
       // listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
       //   (response) => {
       //     response.rows.forEach((item, index) => {
@@ -1093,6 +1153,9 @@
       this.getlistHosp();
       this.reset();
       this.form = row;
+      if (this.form.hospId) {
+        this.sendhospName()
+      }
       // this.form.userInfo.id = null;
       // if(this.form.userInfo != null){
       //   this.forms = this.form.userInfo;
@@ -1142,17 +1205,22 @@
       //   })
       //   .catch(() => { });
     },
-    tijiao(){
-      let data = {
-        password:this.password,
-        userId:this.row.userId,
-      }
-      resetUserPwd(data).then(res=>{
-        if(res.code == 200){
-          this.$modal.msgSuccess("淇敼鎴愬姛");
-          this.dialogVisible1 = false;
+    tijiao() {
+      if (this.password) {
+        let data = {
+          password: this.password,
+          userId: this.row.userId,
         }
-      })
+        resetUserPwd(data).then(res => {
+          if (res.code == 200) {
+            this.$modal.msgSuccess("淇敼鎴愬姛");
+            this.dialogVisible1 = false;
+          }
+        })
+      } else {
+        this.$modal.msgError("鐢ㄦ埛鍚嶅瘑鐮佷笉鑳戒负绌�");
+      }
+
     },
     /** 鍒嗛厤瑙掕壊鎿嶄綔 */
     handleAuthRole: function (row) {

--
Gitblit v1.8.0