Procházet zdrojové kódy

fix: 用户绑定回显

zhengnaiwen_citu před 4 měsíci
rodič
revize
ca467fa005
1 změnil soubory, kde provedl 20 přidání a 17 odebrání
  1. 20 17
      src/views/system/user/userEdit.vue

+ 20 - 17
src/views/system/user/userEdit.vue

@@ -1,6 +1,6 @@
 <template>
   <MDialog ref="dialog" :title="userFormValue.id ? '编辑用户' : '新增用户'" @sure="handleSave">
-    <MForm ref="userForm" :items="userFormItems" v-model="userFormValue"></MForm>
+    <MForm ref="userForm" :items="userFormItems" v-model="userFormValue" v-loading="loading"></MForm>
   </MDialog>
 </template>
 
@@ -19,6 +19,7 @@ export default {
         type: 1
       },
       loading: false,
+      searchLoading: false,
       items: []
     }
   },
@@ -100,7 +101,7 @@ export default {
             remoteMethod: this.remoteMethod,
             valueKey: 'personnelCode',
             defaultFirstOption: true,
-            loading: this.loading,
+            loading: this.searchLoading,
             items: this.items
           },
           rules: [
@@ -112,39 +113,41 @@ export default {
   },
   methods: {
     async open (item) {
+      this.$refs.dialog.open()
       if (!item) {
         this.items = []
         this.userFormValue = {
-          id: undefined,
-          tenantCode: undefined,
           type: 1,
           username: null,
           name: null,
           email: null,
           employeeCode: null
         }
-        this.$refs.dialog.open()
         return
       }
+      this.items = []
+      this.loading = true
+
+      this.userFormValue = {
+        id: item.id,
+        tenantCode: item.tenantCode,
+        type: item.password ? 2 : 1,
+        username: item.username,
+        name: item.name,
+        email: item.email,
+        employeeCode: item.employeeCode
+      }
       try {
         const { data } = await getRosterList({ entity: { personnelCode: item.employeeCode } })
         this.items = data.records
-        this.userFormValue = {
-          id: item.id,
-          tenantCode: item.tenantCode,
-          type: item.password ? 2 : 1,
-          username: item.username,
-          name: item.name,
-          email: item.email,
-          employeeCode: item.employeeCode
-        }
-        this.$refs.dialog.open()
       } catch (error) {
         this.$message.error(error)
+      } finally {
+        this.loading = false
       }
     },
     async remoteMethod (str) {
-      this.loading = true
+      this.searchLoading = true
       try {
         const { data } = await getRosterList({
           entity: {
@@ -160,7 +163,7 @@ export default {
         this.items = []
         this.$message.error(error)
       } finally {
-        this.loading = false
+        this.searchLoading = false
       }
     },
     handleType (v) {