From a4965736d3f6e0293f16fafd044de08882958413 Mon Sep 17 00:00:00 2001
From: qx <1084500556@qq.com>
Date: 星期一, 11 八月 2025 18:08:48 +0800
Subject: [PATCH] :qx

---
 src/views/system/user/index.vue |  256 ++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 183 insertions(+), 73 deletions(-)

diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 88539d2..936ad1a 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -2,27 +2,45 @@
   <div class="app-container">
     <el-row :gutter="20">
       <!--閮ㄩ棬鏁版嵁-->
-      <el-col :span="3" :xs="24">
+      <el-col :span="4" :xs="24">
         <div class="head-container">
           <el-input v-model="deptName" placeholder="璇疯緭鍏ョ瀹ゅ悕绉�" clearable size="small" prefix-icon="el-icon-search"
             style="margin-bottom: 15px" />
         </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
-            @node-click="handleNodeClick" />
+        <!-- <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
+            :default-expanded-keys="treeId"
+            highlight-current
+            @node-click="handleNodeClick"
+          />
+        </div> -->
+        <div class="scrollable-container">
+          <div class="content">
+            <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
+              :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="treeId"
+              highlight-current @node-click="handleNodeClick" />
+          </div>
         </div>
       </el-col>
 
       <!--鐢ㄦ埛鏁版嵁-->
       <el-col :span="20" :xs="24">
-        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="72px">
+        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
+          label-width="72px">
           <el-form-item label="鐢ㄦ埛鍚嶇О" prop="nickName">
             <el-input v-model="queryParams.nickName" placeholder="璇疯緭鍏ョ敤鎴峰悕绉�" clearable style="width: 180px"
               @keyup.enter.native="handleQuery" />
           </el-form-item>
-          <el-form-item label="鎵嬫満鍙风爜" prop="phonenumber">
-            <el-input v-model="queryParams.phonenumber" placeholder="璇疯緭鍏ユ墜鏈哄彿鐮�" clearable style="width: 180px"
+
+          <el-form-item label="鐢ㄦ埛宸ュ彿" prop="userName">
+            <el-input v-model="queryParams.userName" placeholder="璇疯緭鍏ョ敤鎴峰伐鍙�" clearable style="width: 180px"
               @keyup.enter.native="handleQuery" />
           </el-form-item>
           <el-form-item label="鐘舵��" prop="status">
@@ -106,7 +124,6 @@
           <el-table-column label="鍖讳繚缂栫爜" align="center" key="medicalId" prop="medicalId" width="90px"
             :show-overflow-tooltip="true" />
 
-
           <el-table-column label="鍒涘缓浜�" align="center" key="createBy" prop="createBy" width="80px" />
           <el-table-column label="淇敼浜�" align="center" key="updateBy" prop="updateBy" width="80px" />
           <!-- <el-table-column
@@ -134,10 +151,10 @@
           <el-table-column label="鎿嶄綔" fixed="right" align="center" width="100px" class-name="small-padding fixed-width">
             <template slot-scope="scope" v-if="scope.row.userId !== 1">
               <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
-                v-hasPermi="['system:user:edit']" title="淇敼"></el-button>
+                v-hasPermi="['system:user:edit']" title="淇敼" close-on-click-modal="false"></el-button>
 
               <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
-                v-hasPermi="['system:user:remove']" title="鍒犻櫎"></el-button>
+                v-hasPermi="['system:user:remove']" title="鍒犻櫎" close-on-click-modal="false"></el-button>
 
               <!-- 娣诲姞鐢ㄦ埛璇︽儏鎸夐挳 鐐瑰嚮璺冲嚭璇ョ敤鎴风殑璇︾粏淇℃伅椤甸潰
               <el-button
@@ -152,20 +169,11 @@
               <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"
                 v-hasPermi="['system:user:resetPwd', 'system:user:edit']">
                 <el-button size="mini" type="text" icon="el-icon-d-arrow-right" title="鏇村"></el-button>
-                <el-dropdown-menu slot="dropdown">
+                <el-dropdown-menu slot="dropdown" :append-to-body="true">
                   <el-dropdown-item command="handleResetPwd" icon="el-icon-key"
                     v-hasPermi="['system:user:resetPwd']">閲嶇疆瀵嗙爜</el-dropdown-item>
                   <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
                     v-hasPermi="['system:user:edit']">鍒嗛厤瑙掕壊</el-dropdown-item>
-                  <!-- 娣诲姞鐢ㄦ埛璇︽儏鎸夐挳 鐐瑰嚮璺冲嚭璇ョ敤鎴风殑璇︾粏淇℃伅椤甸潰 -->
-                  <!-- <el-button
-                    size="mini"
-                    type="text"
-                    icon="el-icon-share"
-                    @click="handleSearch(scope.row)"
-                    v-hasPermi="['hosp:Userinfo:list']"
-                    >璇︾粏淇℃伅</el-button
-                  > -->
                 </el-dropdown-menu>
               </el-dropdown>
             </template>
@@ -192,6 +200,9 @@
           <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,8 +245,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-if="hospList.length > 0" 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>
@@ -244,8 +255,9 @@
           <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-option v-for="dict in DepartmentList" :key="dict.deptName" :label="dict.deptName"
+            <el-select v-if="DepartmentList.length > 0" v-model="form.deptId" placeholder="璇烽�夋嫨褰掑睘绉戝" clearable
+              style="width: 200px" filterable>
+              <el-option v-for="dict in DepartmentList" :key="dict.deptId" :label="dict.deptName"
                 :value="dict.deptId" />
             </el-select>
           </el-form-item>
@@ -542,7 +554,8 @@
                 <el-input v-model="form.phaCertifiedNo" placeholder="璇疯緭鍏ヤ笓瀹�-璧勬牸璇佸彿" style="width: 200px" />
               </el-form-item>
               <el-form-item label="鑱岀О绾у埆" prop="expJobLevelCode">
-                <el-select v-model="form.expJobLevelCode" placeholder="璇烽�夋嫨鑱岀О绾у埆" style="width: 200px" filterable clearable>
+                <el-select v-model="form.expJobLevelCode" placeholder="璇烽�夋嫨鑱岀О绾у埆" style="width: 200px" filterable
+                  clearable>
                   <el-option v-for="dict in dict.type.dict_user_zcjb" :key="dict.value" :label="dict.label"
                     :value="dict.value"></el-option>
                 </el-select>
@@ -577,7 +590,8 @@
               />
             </el-form-item> -->
               <el-form-item label="鏀挎不闈㈣矊" prop="politicalStatus">
-                <el-select v-model="form.politicalStatus" placeholder="璇烽�夋嫨鏀挎不闈㈣矊" style="width: 200px" filterable clearable>
+                <el-select v-model="form.politicalStatus" placeholder="璇烽�夋嫨鏀挎不闈㈣矊" style="width: 200px" filterable
+                  clearable>
                   <el-option v-for="dict in dict.type.dict_political" :key="dict.value" :label="dict.label"
                     :value="dict.value"></el-option>
                 </el-select>
@@ -627,14 +641,14 @@
           </el-collapse>
         </el-form>
         <div slot="footer" class="dialog-footer1">
-          <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
+          <el-button :disabled="submit" type="primary" @click="submitForm">纭� 瀹�</el-button>
           <el-button @click="cancel">鍙� 娑�</el-button>
         </div>
       </el-dialog>
     </div>
 
     <!-- 鐢ㄦ埛瀵煎叆瀵硅瘽妗� -->
-    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+    <!-- <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
       <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
         :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
         :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
@@ -654,7 +668,7 @@
         <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
         <el-button @click="upload.open = false">鍙� 娑�</el-button>
       </div>
-    </el-dialog>
+    </el-dialog> -->
 
     <!-- 閲嶇疆瀵嗙爜瀵硅瘽妗� -->
     <el-dialog title="鎻愮ず" :visible.sync="dialogVisible1" width="30%" :before-close="handleClose">
@@ -672,10 +686,12 @@
         <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,
@@ -688,6 +704,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";
@@ -713,17 +730,30 @@
     "dict_user_work",
     "dict_qhdm",
   ],
-  components: { Treeselect },
+  components: { Treeselect, yonghu },
   data() {
+    let checkPhoneNum = (rule, value, callback) => {
+      let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
+      if (value == "" && value == undefined && !value) {
+        return callback("");
+      } else if (value != undefined && value != "") {
+        return callback();
+      } else if (!patter.test(value)) {
+        return callback("");
+      }
+    };
     return {
       row: [],
       flag: false,
+      submit: false,
       password: "",
       dialogVisible1: false,
       nums: "",
       userInfoList: [],
       hospList: [],
       activeNames: ["1"],
+      treeId: [],
+      selectedDeptId: null,
       // 閬僵灞�
       loading: true,
       // 閫変腑鏁扮粍
@@ -825,37 +855,37 @@
       // 琛ㄥ崟鏍¢獙
       rules: {
         userName: [
-          { required: true, message: "", trigger: "blur" },
+          { required: true, validator: checkPhoneNum, trigger: "blur" },
           {
             min: 2,
             max: 20,
-            message: "",
+            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: "",
+            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",
           },
         ],
@@ -878,6 +908,15 @@
     deptName(val) {
       this.$refs.tree.filter(val);
     },
+    treeId(newVal, oldVal) {
+      if (newVal) {
+        this.$nextTick(() => {
+          document
+            .querySelector(".el-tree-node__children .el-tree-node__content")
+            .click();
+        });
+      }
+    },
   },
   computed: {
     type() {
@@ -885,34 +924,41 @@
     },
     elIcon() {
       return this.flag ? "el-icon-minus" : "el-icon-view";
-    }
+    },
   },
   created() {
-    this.getList();
     this.getDeptTree();
+    this.getList();
+    if (this.form.hospId) {
+      this.sendhospName(); // 椤甸潰鍔犺浇鏃惰嚜鍔ㄥ姞杞界瀹ゆ暟鎹�
+    }
+
     // this.getRoleList();
     // this.getConfigKey("sys.user.initPassword").then((response) => {
     //   this.initPassword = response.msg;
     // });
   },
+
   methods: {
     handleChange(val) { },
     /** 鏌ヨ鐢ㄦ埛鍒楄〃 */
     getList() {
       this.loading = true;
-      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
-        (response) => {
-          response.rows.forEach((item, index) => {
-            item.newID =
-              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
-              index +
-              1;
-          });
-          this.userList = response.rows;
-          this.total = response.total;
-          this.loading = false;
-        }
-      );
+      if (this.queryParams.deptId) {
+        listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
+          (response) => {
+            response.rows.forEach((item, index) => {
+              item.newID =
+                (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
+                index +
+                1;
+            });
+            this.userList = response.rows;
+            this.total = response.total;
+            this.loading = false;
+          }
+        );
+      }
     },
     /** 鏌ヨ宀椾綅鍒楄〃 */
     getPostList() {
@@ -932,6 +978,7 @@
     getlistHosp() {
       listHosp(this.queryParams).then((response) => {
         this.hospList = response.rows;
+
         this.total = response.total;
       });
     },
@@ -944,6 +991,8 @@
     getDeptTree() {
       deptTreeSelect().then((response) => {
         this.deptOptions = response.data;
+        this.treeId.push(this.deptOptions[0].id);
+        this.queryParams.deptId = this.deptOptions[0].id;
       });
     },
     // 绛涢�夎妭鐐�
@@ -954,7 +1003,21 @@
     // 鑺傜偣鍗曞嚮浜嬩欢
     handleNodeClick(data) {
       this.queryParams.deptId = data.id;
+      this.selectedDeptId = 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) {
@@ -975,10 +1038,11 @@
     cancel() {
       this.open = false;
       this.reset();
-      this.$tab.refreshPage();
+      // this.$tab.refreshPage();
     },
     handleClose() {
-      this.$tab.refreshPage();
+      this.cancel();
+      // this.$tab.refreshPage();
     },
     // 琛ㄥ崟閲嶇疆
     reset() {
@@ -1026,7 +1090,11 @@
       this.ids = selection.map((item) => item.userId);
       this.single = selection.length != 1;
       this.multiple = !selection.length;
+      if (selection.length >= 1) {
+        this.queryParams.userName = selection[0].userName
+      }
     },
+
     // 鏇村鎿嶄綔瑙﹀彂
     handleCommand(command, row) {
       switch (command) {
@@ -1047,6 +1115,15 @@
       this.title = "鐢ㄦ埛淇℃伅缁存姢";
       this.getPostList();
       this.getlistHosp();
+      getInfo(this.queryParams).then((response) => {
+        this.form.hospId = response.user.hospId;
+        if (this.form.hospId) {
+          this.sendhospName();
+        }
+      });
+      if (this.selectedDeptId) {
+        this.form.deptId = this.selectedDeptId;
+      }
       // getUser().then((response) => {
       //   this.postOptions = response.posts;
       //   this.roleOptions = response.roles;
@@ -1057,24 +1134,28 @@
 
     sendhospName() {
       let data = {
-        id: this.form.hospId
-      }
-      getDeptListByDictHospId(data).then(res => {
-        this.DepartmentList = res.data
-      })
+        id: this.form.hospId,
+      };
+      getDeptListByDictHospId(data).then((res) => {
+        this.DepartmentList = res.data;
+        // this.form.deptId = String(this.form.deptId);
+      });
     },
 
     handleUp(row) {
       this.title = "鐢ㄦ埛淇℃伅缁存姢";
+
+      // this.form = row;
+
       this.open = true;
-      this.form = row;
-      // listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
-      //   (response) => {
-      //     response.rows.forEach((item, index) => {
-      //       this.form = item;
-      //     });
-      //   }
-      // );
+      this.submit = false
+      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(
+        (response) => {
+          response.rows.forEach((item, index) => {
+            this.form = item;
+          });
+        }
+      );
     },
     select(val) {
       this.postList.forEach((item) => {
@@ -1090,11 +1171,19 @@
       this.getlistHosp();
       this.reset();
       this.form = row;
+      this.form = {
+        ...row,
+        deptId: row.deptId != null ? String(row.deptId) : null, // 馃憟 纭繚涓哄瓧绗︿覆
+      };
+      if (this.form.hospId) {
+        this.sendhospName();
+      }
       // this.form.userInfo.id = null;
       // if(this.form.userInfo != null){
       //   this.forms = this.form.userInfo;
       // }
       this.open = true;
+      this.submit = false
       this.title = "鐢ㄦ埛淇℃伅缁存姢";
     },
 
@@ -1104,9 +1193,11 @@
       this.$refs["form"].validate((valid) => {
         if (valid) {
           if (_this.form.userId !== undefined) {
+            _this.submit = true
             updateUser(_this.form).then((response) => {
               _this.$modal.msgSuccess("淇敼鎴愬姛");
               _this.open = false;
+              _this.submit = false
               _this.getList();
             });
           } else {
@@ -1144,17 +1235,16 @@
         let data = {
           password: this.password,
           userId: this.row.userId,
-        }
-        resetUserPwd(data).then(res => {
+        };
+        resetUserPwd(data).then((res) => {
           if (res.code == 200) {
             this.$modal.msgSuccess("淇敼鎴愬姛");
             this.dialogVisible1 = false;
           }
-        })
-      }else{
+        });
+      } else {
         this.$modal.msgError("鐢ㄦ埛鍚嶅瘑鐮佷笉鑳戒负绌�");
       }
-
     },
     /** 鍒嗛厤瑙掕壊鎿嶄綔 */
     handleAuthRole: function (row) {
@@ -1243,6 +1333,26 @@
   width: 200px;
 }
 
+.scrollable-container {
+  width: 200px;
+  /* 璁剧疆瀹瑰櫒鐨勫搴� */
+  height: 629px;
+  /* 璁剧疆瀹瑰櫒鐨勯珮搴� */
+  overflow: auto;
+  /* 鍏佽鍐呭婧㈠嚭鏃舵樉绀烘粴鍔ㄦ潯 */
+  border: 1px solid #ccc;
+  /* 鍙�夛細娣诲姞杈规浠ユ洿濂藉湴鏄剧ず瀹瑰櫒 */
+  position: relative;
+  /* 鍙�夛細浣垮鍣ㄥ唴鐨勭粷瀵瑰畾浣嶅厓绱犺兘澶熸纭樉绀� */
+}
+
+.content {
+  width: 600px;
+  /* 璁剧疆鍐呭鐨勫搴︼紝浠ヨЕ鍙戞按骞虫粴鍔ㄦ潯 */
+  height: 1000px;
+  /* 璁剧疆鍐呭鐨勯珮搴︼紝浠ヨЕ鍙戝瀭鐩存粴鍔ㄦ潯 */
+}
+
 .pag {
   width: 100%;
   display: flex;

--
Gitblit v1.8.0