From 2c4c416bf7950c72ffa2543a218e4fd993ee2af2 Mon Sep 17 00:00:00 2001
From: WXL <1785969728@qq.com>
Date: 星期四, 12 九月 2024 12:04:32 +0800
Subject: [PATCH] 测试完成

---
 src/views/system/user/index.vue |  106 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 95 insertions(+), 11 deletions(-)

diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 6f1d6d2..70a1b6d 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -189,14 +189,14 @@
             v-if="columns[2].visible"
             :show-overflow-tooltip="true"
           />
-          <el-table-column
+          <!-- <el-table-column
             label="閮ㄩ棬"
             align="center"
             key="deptName"
             prop="dept.deptName"
             v-if="columns[3].visible"
             :show-overflow-tooltip="true"
-          />
+          /> -->
           <el-table-column
             label="鎵嬫満鍙风爜"
             align="center"
@@ -228,7 +228,7 @@
             width="160"
           >
             <template slot-scope="scope">
-              <span>{{ parseTime(scope.row.createTime) }}</span>
+              <span>{{ formatTime(scope.row.createTime) }}</span>
             </template>
           </el-table-column>
           <el-table-column
@@ -304,17 +304,52 @@
               />
             </el-form-item>
           </el-col>
-          <el-col :span="12">
+          <!-- <el-col :span="12">
             <el-form-item label="褰掑睘閮ㄩ棬" prop="deptId">
               <treeselect
-                v-model="form.deptId"
+                v-model="form.depts"
                 :options="deptOptions"
+                :multiple="true"
                 :show-count="true"
                 placeholder="璇烽�夋嫨褰掑睘閮ㄩ棬"
               />
             </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-row>
           <el-col :span="12">
             <el-form-item label="鎵嬫満鍙风爜" prop="phonenumber">
@@ -497,6 +532,7 @@
   addUser,
   updateUser,
   resetUserPwd,
+  adduserdept,
   changeUserStatus,
   deptTreeSelect,
 } from "@/api/system/user";
@@ -536,6 +572,7 @@
       initPassword: undefined,
       // 鏃ユ湡鑼冨洿
       dateRange: [],
+      deptIds: [],
       // 宀椾綅閫夐」
       postOptions: [],
       // 瑙掕壊閫夐」
@@ -546,6 +583,7 @@
         children: "children",
         label: "label",
       },
+      props: { multiple: true, value: "deptCode", label: "label" },
       // 鐢ㄦ埛瀵煎叆鍙傛暟
       upload: {
         // 鏄惁鏄剧ず寮瑰嚭灞傦紙鐢ㄦ埛瀵煎叆锛�
@@ -735,20 +773,29 @@
     /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd() {
       this.reset();
-      getUser().then((response) => {
-        this.postOptions = response.posts;
-        this.roleOptions = response.roles;
-        this.open = true;
+      this.open = true;
         this.title = "娣诲姞鐢ㄦ埛";
         this.form.password = this.initPassword;
-      });
+        this.form.depts = [];
+      // getUser().then((response) => {
+      //   this.postOptions = response.posts;
+      //   this.roleOptions = response.roles;
+
+      // });
     },
     /** 淇敼鎸夐挳鎿嶄綔 */
     handleUpdate(row) {
       this.reset();
+      this.deptIds = [];
       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);
+        console.log(this.form.leavehospitaldistrictcodes,'leavehospitaldistrictcodes');
+        console.log(this.form.leaveldeptcodes,'leaveldeptcodes');
+
         this.postOptions = response.posts;
         this.roleOptions = response.roles;
         this.$set(this.form, "postIds", response.postIds);
@@ -781,6 +828,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]
+      );
+      console.log(this.form.leavehospitaldistrictcodes,'leavehospitaldistrictcodes');
+      console.log(this.form.leaveldeptcodes,'leaveldeptcodes');
+
+
       this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.form.userId != undefined) {
@@ -799,6 +858,31 @@
         }
       });
     },
+    // 鏂板鏁版嵁
+    adduserdept(){
+      if (this.form.leavehospitaldistrictcodes[0]) {
+        this.form.leavehospitaldistrictcodes.forEach((dept) => {
+          adduserdept({deptCode:dept,deptType:2,userId:this.form.userId}).then((response) => {
+            this.open = false;
+            this.getList();
+          });
+        })
+      }
+      if (this.form.leaveldeptcodes[0]) {
+        this.form.leaveldeptcodes.forEach((dept) => {
+          adduserdept({deptCode:dept,deptType:1,userId:this.form.userId}).then((response) => {
+            this.open = false;
+            this.getList();
+          });
+        })
+      }
+
+      adduserdept(this.form).then((response) => {
+        this.$modal.msgSuccess("娣诲姞鎴愬姛");
+        this.open = false;
+        this.getList();
+      });
+    },
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const userIds = row.userId || this.ids;

--
Gitblit v1.9.3