From a99e82da2b087d7019cdce015c25befc620b9d61 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 10 十一月 2026 14:14:16 +0800
Subject: [PATCH] 测试完成

---
 src/views/system/user/index.vue |  389 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 304 insertions(+), 85 deletions(-)

diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 23cce5e..9c5693e 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -2,7 +2,7 @@
   <div class="app-container">
     <el-row :gutter="20">
       <!--閮ㄩ棬鏁版嵁-->
-      <el-col :span="4" :xs="24">
+      <!-- <el-col :span="4" :xs="24">
         <div class="head-container">
           <el-input
             v-model="deptName"
@@ -26,9 +26,9 @@
             @node-click="handleNodeClick"
           />
         </div>
-      </el-col>
+      </el-col> -->
       <!--鐢ㄦ埛鏁版嵁-->
-      <el-col :span="20" :xs="24">
+      <el-col :span="24" :xs="24">
         <el-form
           :model="queryParams"
           ref="queryForm"
@@ -37,10 +37,19 @@
           v-show="showSearch"
           label-width="68px"
         >
-          <el-form-item label="鐢ㄦ埛鍚嶇О" prop="userName">
+          <el-form-item label="鐢ㄦ埛宸ュ彿" prop="userName">
             <el-input
               v-model="queryParams.userName"
-              placeholder="璇疯緭鍏ョ敤鎴峰悕绉�"
+              placeholder="璇疯緭鍏ョ敤鎴峰伐鍙�"
+              clearable
+              style="width: 240px"
+              @keyup.enter.native="handleQuery"
+            />
+          </el-form-item>
+          <el-form-item label="鐢ㄦ埛鏄电О" prop="nickName">
+            <el-input
+              v-model="queryParams.nickName"
+              placeholder="璇疯緭鍏ョ敤鎴锋樀绉�"
               clearable
               style="width: 240px"
               @keyup.enter.native="handleQuery"
@@ -70,7 +79,8 @@
               />
             </el-select>
           </el-form-item>
-          <el-form-item label="鍒涘缓鏃堕棿">
+
+          <!-- <el-form-item label="鍒涘缓鏃堕棿">
             <el-date-picker
               v-model="dateRange"
               style="width: 240px"
@@ -80,7 +90,7 @@
               start-placeholder="寮�濮嬫棩鏈�"
               end-placeholder="缁撴潫鏃ユ湡"
             ></el-date-picker>
-          </el-form-item>
+          </el-form-item> -->
           <el-form-item>
             <el-button
               type="primary"
@@ -115,7 +125,7 @@
               size="mini"
               :disabled="single"
               @click="handleUpdate"
-              v-hasPermi="['system:user:edit']"
+
               >淇敼</el-button
             >
           </el-col>
@@ -174,7 +184,7 @@
             v-if="columns[0].visible"
           />
           <el-table-column
-            label="鐢ㄦ埛鍚嶇О"
+            label="鐢ㄦ埛宸ュ彿"
             align="center"
             key="userName"
             prop="userName"
@@ -190,13 +200,38 @@
             :show-overflow-tooltip="true"
           />
           <el-table-column
-            label="閮ㄩ棬"
+            label="绉戝"
             align="center"
-            key="deptName"
-            prop="dept.deptName"
+            key="deptNames"
             v-if="columns[3].visible"
             :show-overflow-tooltip="true"
-          />
+          >
+            <template slot-scope="scope">
+              <span>{{ scope.row._deptNames || "-" }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="鐥呭尯"
+            align="center"
+            key="wardNames"
+            v-if="columns[7].visible"
+            :show-overflow-tooltip="true"
+          >
+            <template slot-scope="scope">
+              <span>{{ scope.row._wardNames || "-" }}</span>
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="闄㈠尯"
+            align="center"
+            key="campusName"
+            v-if="columns[8].visible && (orgname === '绗竴浜烘皯鍖婚櫌婀栨花闄㈠尯' || orgname === '绗竴浜烘皯鍖婚櫌鍚村北闄㈠尯' || orgname === '绗竴浜烘皯鍖婚櫌鍩庝笢闄㈠尯')"
+            :show-overflow-tooltip="true"
+          >
+            <template slot-scope="scope">
+              <span>{{ scope.row._campusName || "-" }}</span>
+            </template>
+          </el-table-column>
           <el-table-column
             label="鎵嬫満鍙风爜"
             align="center"
@@ -243,7 +278,7 @@
                 type="text"
                 icon="el-icon-edit"
                 @click="handleUpdate(scope.row)"
-                v-hasPermi="['system:user:edit']"
+
                 >淇敼</el-button
               >
               <el-button
@@ -272,7 +307,7 @@
                   <el-dropdown-item
                     command="handleAuthRole"
                     icon="el-icon-circle-check"
-                    v-hasPermi="['system:user:edit']"
+
                     >鍒嗛厤瑙掕壊</el-dropdown-item
                   >
                 </el-dropdown-menu>
@@ -304,52 +339,55 @@
               />
             </el-form-item>
           </el-col>
-          <!-- <el-col :span="12">
-            <el-form-item label="褰掑睘閮ㄩ棬" prop="deptId">
-              <treeselect
-                v-model="form.depts"
-                :options="deptOptions"
-                :multiple="true"
-                :show-count="true"
-                placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬"
-              />
+          <el-col :span="12">
+            <el-form-item label="鎮h�呰寖鍥�" prop="status">
+              <el-select
+                v-model="form.searchscope"
+                placeholder="鎮h�呰寖鍥�"
+                clearable
+              >
+                <el-option
+                  v-for="dict in searchscopelist"
+                  :key="dict.value"
+                  :label="dict.label"
+                  :value="dict.value"
+                />
+              </el-select>
             </el-form-item>
-          </el-col> -->
+          </el-col>
         </el-row>
         <el-form-item label="閫傜敤绉戝" prop="region">
-                <el-cascader
-                style="width: 478px"
-                  v-model="form.leaveldeptcodes"
-                  :options="deptOptions"
-                  :props="props"
-                  :show-all-levels="false"
-                  clearable
-                >
-                  <template slot-scope="{ node, data }">
-                    <span>{{ data.label }}</span>
-                    <span v-if="!node.isLeaf">
-                      ({{ data.children.length }})
-                    </span>
-                  </template>
-                </el-cascader>
-              </el-form-item>
-              <el-form-item label="閫傜敤闄㈠尯" prop="region">
-                <el-cascader
-                style="width: 478px"
-                  v-model="form.leavehospitaldistrictcodes"
-                  :options="deptOptions"
-                  :props="props"
-                  :show-all-levels="false"
-                  clearable
-                >
-                  <template slot-scope="{ node, data }">
-                    <span>{{ data.label }}</span>
-                    <span v-if="!node.isLeaf">
-                      ({{ data.children.length }})
-                    </span>
-                  </template>
-                </el-cascader>
-              </el-form-item>
+            <el-cascader
+              style="width: 478px"
+              v-model="form.deptCodes"
+              @remove-tag="removehpsp"
+              :options="deptOptionsks"
+              :props="props"
+              filterable
+              clearable
+            >
+              <template slot-scope="{ node, data }">
+                <span>{{ data.label }}</span>
+                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
+              </template>
+            </el-cascader>
+        </el-form-item>
+        <el-form-item label="閫傜敤鐥呭尯" prop="region">
+            <el-cascader
+              style="width: 478px"
+              @remove-tag="removehpsp"
+              v-model="form.wardCodes"
+              :options="deptOptionsbq"
+              :props="props"
+              filterable
+              clearable
+            >
+              <template slot-scope="{ node, data }">
+                <span>{{ data.label }}</span>
+                <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
+              </template>
+            </el-cascader>
+        </el-form-item>
         <el-row>
           <el-col :span="12">
             <el-form-item label="鎵嬫満鍙风爜" prop="phonenumber">
@@ -374,12 +412,12 @@
           <el-col :span="12">
             <el-form-item
               v-if="form.userId == undefined"
-              label="鐢ㄦ埛鍚嶇О"
+              label="鐢ㄦ埛宸ュ彿"
               prop="userName"
             >
               <el-input
                 v-model="form.userName"
-                placeholder="璇疯緭鍏ョ敤鎴峰悕绉�"
+                placeholder="璇疯緭鍏ョ敤鎴峰伐鍙�"
                 maxlength="30"
               />
             </el-form-item>
@@ -426,6 +464,7 @@
             </el-form-item>
           </el-col>
         </el-row>
+
         <el-row>
           <el-col :span="12">
             <el-form-item label="宀椾綅">
@@ -532,12 +571,16 @@
   addUser,
   updateUser,
   resetUserPwd,
+  adduserdept,
+  removeusertd,
   changeUserStatus,
   deptTreeSelect,
 } from "@/api/system/user";
 import { getToken } from "@/utils/auth";
+import { getorganization } from "@/api/AiCentre/index";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { type } from "jquery";
 
 export default {
   name: "User",
@@ -555,6 +598,8 @@
       multiple: true,
       // 鏄剧ず鎼滅储鏉′欢
       showSearch: true,
+      // 褰撳墠鏈烘瀯鍚嶇О
+      orgname: localStorage.getItem("orgname") || "",
       // 鎬绘潯鏁�
       total: 0,
       // 鐢ㄦ埛琛ㄦ牸鏁版嵁
@@ -562,7 +607,14 @@
       // 寮瑰嚭灞傛爣棰�
       title: "",
       // 閮ㄩ棬鏍戦�夐」
-      deptOptions: undefined,
+      deptOptionsks: undefined,
+      deptOptionsbq: undefined,
+      // 绉戝缂栫爜 -> 鍚嶇О鏄犲皠
+      deptNameMap: {},
+      // 鐥呭尯缂栫爜 -> 鍚嶇О鏄犲皠
+      wardNameMap: {},
+      // 闄㈠尯缂栫爜 -> 鍚嶇О鏄犲皠
+      campusNameMap: {},
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
       // 閮ㄩ棬鍚嶇О
@@ -582,7 +634,7 @@
         children: "children",
         label: "label",
       },
-      props: { multiple: true, value: "id", label: "label" },
+      props: { multiple: true, value: "deptCode", label: "label" },
       // 鐢ㄦ埛瀵煎叆鍙傛暟
       upload: {
         // 鏄惁鏄剧ず寮瑰嚭灞傦紙鐢ㄦ埛瀵煎叆锛�
@@ -607,24 +659,33 @@
         status: undefined,
         deptId: undefined,
       },
+      searchscopelist: [
+        { value: "1", label: "绉戝" },
+        { value: "2", label: "鐥呭尯" },
+        { value: "0", label: "鍏ㄩ儴" },
+        { value: "9", label: "鏃�" },
+      ],
       // 鍒椾俊鎭�
       columns: [
         { key: 0, label: `鐢ㄦ埛缂栧彿`, visible: true },
-        { key: 1, label: `鐢ㄦ埛鍚嶇О`, visible: true },
+        { key: 1, label: `鐢ㄦ埛宸ュ彿`, visible: true },
         { key: 2, label: `鐢ㄦ埛鏄电О`, visible: true },
-        { key: 3, label: `閮ㄩ棬`, visible: true },
+        { key: 3, label: `绉戝`, visible: true },
         { key: 4, label: `鎵嬫満鍙风爜`, visible: true },
         { key: 5, label: `鐘舵�乣, visible: true },
         { key: 6, label: `鍒涘缓鏃堕棿`, visible: true },
+        { key: 7, label: `鐥呭尯`, visible: true },
+        { key: 8, label: `闄㈠尯`, visible: true },
       ],
+
       // 琛ㄥ崟鏍¢獙
       rules: {
         userName: [
-          { required: true, message: "鐢ㄦ埛鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
+          { required: true, message: "鐢ㄦ埛宸ュ彿涓嶈兘涓虹┖", trigger: "blur" },
           {
             min: 2,
             max: 20,
-            message: "鐢ㄦ埛鍚嶇О闀垮害蹇呴』浠嬩簬 2 鍜� 20 涔嬮棿",
+            message: "鐢ㄦ埛宸ュ彿闀垮害蹇呴』浠嬩簬 2 鍜� 20 涔嬮棿",
             trigger: "blur",
           },
         ],
@@ -664,10 +725,17 @@
     },
   },
   created() {
-    this.getList();
     this.getDeptTree();
     this.getConfigKey("sys.user.initPassword").then((response) => {
       this.initPassword = response.msg;
+    });
+  },
+  mounted() {
+    this.$nextTick(() => {
+      const menuWrap = document.querySelector('.el-cascader-menu__wrap');
+      if (menuWrap) {
+        menuWrap.style.height = '404px';
+      }
     });
   },
   methods: {
@@ -679,15 +747,82 @@
         (response) => {
           this.userList = response.rows;
           this.total = response.total;
+          this.enrichUserDept();
           this.loading = false;
         }
       );
     },
     /** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */
     getDeptTree() {
-      deptTreeSelect().then((response) => {
-        this.deptOptions = response.data;
+      // 绉戝鍒楄〃
+      const ksPromise = deptTreeSelect(1).then((response) => {
+        this.deptOptionsks = response.data;
+        this.deptNameMap = this.flattenDeptTree(response.data);
       });
+      // 鐥呭尯鍒楄〃
+      const bqPromise = deptTreeSelect(2).then((response) => {
+        this.deptOptionsbq = response.data;
+        this.wardNameMap = this.flattenDeptTree(response.data);
+      });
+      // 闄㈠尯鍒楄〃
+      const campusPromise = getorganization({ pageSize: 100 }).then((res) => {
+        if (res.code == 200) {
+          (res.rows || []).forEach((item) => {
+            this.campusNameMap[String(item.organizationID)] =
+              item.organizationName;
+          });
+        }
+      });
+      // 绉戝/鐥呭尯/闄㈠尯鏄犲皠灏辩华鍚庡啀鍔犺浇鍒楄〃锛屼繚璇侀灞忚兘鏄剧ず鍚嶇О
+      Promise.all([ksPromise, bqPromise, campusPromise]).then(() => {
+        this.getList();
+      });
+    },
+    /** 灏嗙瀹�/鐥呭尯鏍戞媿骞充负 { deptCode: label } 鏄犲皠 */
+    flattenDeptTree(nodes) {
+      const map = {};
+      const walk = (list) => {
+        (list || []).forEach((node) => {
+          if (node.deptCode) {
+            map[node.deptCode] = node.label;
+          }
+          if (node.children && node.children.length) {
+            walk(node.children);
+          }
+        });
+      };
+      walk(nodes);
+      return map;
+    },
+    /** 鎶� hospInfo/deptInfo 涓殑缂栫爜杞垚鍚嶇О锛屽啓鍏ヨ鐨勫睍绀哄瓧娈� */
+    enrichUserDept() {
+      (this.userList || []).forEach((row) => {
+        row._deptNames = this.mapCodesToNames(row.hospInfo, this.deptNameMap);
+        row._wardNames = this.mapCodesToNames(row.deptInfo, this.wardNameMap);
+        row._campusName = this.campusNameMap[String(row.campusid)] || "-";
+      });
+    },
+    /** 瑙f瀽缂栫爜 JSON 骞舵槧灏勪负鍚嶇О锛氱骇鑱旇矾寰勫悇灞傜敤 "/" 杩炴帴锛屽鏉$敤 "銆�" 杩炴帴 */
+    mapCodesToNames(jsonStr, nameMap) {
+      if (!jsonStr || !nameMap) return "";
+      let data = [];
+      try {
+        data = JSON.parse(jsonStr);
+      } catch (e) {
+        return "";
+      }
+      if (!Array.isArray(data)) data = [data];
+      return data
+        .map((item) => {
+          // 绾ц仈澶氶�夌殑鍊兼槸鏁存潯璺緞锛堟暟缁勶級锛屾棫鏁版嵁鍙兘鏄崟涓紪鐮�
+          const path = Array.isArray(item) ? item : [item];
+          return path
+            .map((code) => nameMap[code] || code)
+            .filter(Boolean)
+            .join(" / ");
+        })
+        .filter(Boolean)
+        .join("銆�");
     },
     // 绛涢�夎妭鐐�
     filterNode(value, data) {
@@ -734,6 +869,8 @@
         remark: undefined,
         postIds: [],
         roleIds: [],
+        deptCodes: [],
+        wardCodes: [],
       };
       this.resetForm("form");
     },
@@ -773,9 +910,9 @@
     handleAdd() {
       this.reset();
       this.open = true;
-        this.title = "娣诲姞鐢ㄦ埛";
-        this.form.password = this.initPassword;
-        this.form.depts = [];
+      this.title = "娣诲姞鐢ㄦ埛";
+      this.form.password = this.initPassword;
+      this.form.depts = [];
       // getUser().then((response) => {
       //   this.postOptions = response.posts;
       //   this.roleOptions = response.roles;
@@ -789,8 +926,20 @@
       const userId = row.userId || this.ids;
       getUser(userId).then((response) => {
         this.form = response.data;
-        this.form.leaveldeptcodes = JSON.parse(this.form.hospInfo);
-        this.form.leavehospitaldistrictcodes = JSON.parse(this.form.deptInfo);
+        this.belongDepts = response.belongDepts;
+        this.belongWards = response.belongWards;
+        if (this.form.hospInfo) {
+          this.form.deptCodes = JSON.parse(this.form.hospInfo);
+        } else {
+          this.form.deptCodes = [];
+        }
+        if (this.form.deptInfo) {
+          this.form.wardCodes = JSON.parse(this.form.deptInfo);
+        } else {
+          this.form.wardCodes = [];
+        }
+        console.log(this.form.wardCodes, "wardCodes");
+        console.log(this.form.deptCodes, "deptCodes");
         this.postOptions = response.posts;
         this.roleOptions = response.roles;
         this.$set(this.form, "postIds", response.postIds);
@@ -798,6 +947,16 @@
         this.open = true;
         this.title = "淇敼鐢ㄦ埛";
         this.form.password = "";
+      });
+    },
+    // 鍒犻櫎绉戝
+    removehpsp(valueArray) {
+      console.log(valueArray, "鍒犻櫎绉戝");
+      console.log(this.form.userId, "鍒犻櫎");
+      let code = valueArray[valueArray.length - 1];
+      removeusertd(this.form.userId, code).then((res) => {
+        if (res.code) {
+        }
       });
     },
     /** 閲嶇疆瀵嗙爜鎸夐挳鎿嶄綔 */
@@ -823,14 +982,18 @@
     },
     /** 鎻愪氦鎸夐挳 */
     submitForm: function () {
-      this.form.hospInfo = JSON.stringify(this.form.leaveldeptcodes);
-      this.form.deptInfo = JSON.stringify(this.form.leavehospitaldistrictcodes);
-      this.form.leaveldeptcodes = this.form.leaveldeptcodes.map(
-        (subArr) => subArr[subArr.length - 1]
-      );
-      this.form.leavehospitaldistrictcodes = this.form.leavehospitaldistrictcodes.map(
-        (subArr) => subArr[subArr.length - 1]
-      );
+      this.form.hospInfo = JSON.stringify(this.form.deptCodes);
+      this.form.deptInfo = JSON.stringify(this.form.wardCodes);
+      if (this.form.deptCodes.length)
+        this.form.deptCodes = this.form.deptCodes.map(
+          (subArr) => subArr[subArr.length - 1]
+        );
+      if (this.form.wardCodes.length)
+        this.form.wardCodes = this.form.wardCodes.map(
+          (subArr) => subArr[subArr.length - 1]
+        );
+      console.log(this.form.wardCodes, "wardCodes");
+      console.log(this.form.deptCodes, "deptCodes");
 
       this.$refs["form"].validate((valid) => {
         if (valid) {
@@ -838,17 +1001,64 @@
             updateUser(this.form).then((response) => {
               this.$modal.msgSuccess("淇敼鎴愬姛");
               this.open = false;
-              this.getList();
+              // this.adduserdept();
             });
           } else {
             addUser(this.form).then((response) => {
               this.$modal.msgSuccess("鏂板鎴愬姛");
               this.open = false;
-              this.getList();
+              this.form.userId = response.data;
+              console.log("寮�濮嬪姞閮ㄩ棬");
+
+              // this.adduserdept();
             });
           }
         }
       });
+    },
+    // 鏂板鏁版嵁
+    adduserdept() {
+      if (this.form.wardCodes[0]) {
+        this.form.wardCodes.forEach((dept) => {
+          let containsId8 = null;
+          if (this.belongWards) {
+            containsId8 = this.belongWards.some(
+              (item) => item.deptCode == dept
+            );
+          }
+
+          if (!containsId8) {
+            adduserdept({
+              deptCode: dept,
+              deptType: 2,
+              userId: this.form.userId,
+            }).then((response) => {
+              this.open = false;
+              this.getList();
+            });
+          }
+        });
+      }
+      if (this.form.deptCodes[0]) {
+        this.form.deptCodes.forEach((dept) => {
+          let containsId8 = null;
+          if (this.belongDepts) {
+            containsId8 = this.belongDepts.some(
+              (item) => item.deptCode == dept
+            );
+          }
+          if (!containsId8) {
+            adduserdept({
+              deptCode: dept,
+              deptType: 1,
+              userId: this.form.userId,
+            }).then((response) => {
+              this.open = false;
+              this.getList();
+            });
+          }
+        });
+      }
     },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
@@ -882,7 +1092,7 @@
     /** 涓嬭浇妯℃澘鎿嶄綔 */
     importTemplate() {
       this.download(
-        "system/user/importTemplate",
+        "smartor/import/getImportPatTemplate",
         {},
         `user_template_${new Date().getTime()}.xlsx`
       );
@@ -912,3 +1122,12 @@
   },
 };
 </script>
+<style lang="scss" >
+// ::v-deep .el-cascader-menu__wrap{
+//   min-height: 404px ;
+// }
+// ::v-deep.el-cascader-panel .el-cascader-menu__wrap {
+//   height: 404px !important;
+// }
+
+</style>

--
Gitblit v1.9.3