From b61d3353ae963c0430258230649951e423fbdbee Mon Sep 17 00:00:00 2001
From: children117cl <278950112@qq.com>
Date: 星期五, 25 六月 2021 15:27:26 +0800
Subject: [PATCH] 管理员页,获取角色需要判断isUse===1才能使用

---
 src/pages/system/admin.vue |   47 +++++++++++++++++++++++++++--------------------
 1 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/src/pages/system/admin.vue b/src/pages/system/admin.vue
index 7d3f28f..65f8492 100644
--- a/src/pages/system/admin.vue
+++ b/src/pages/system/admin.vue
@@ -9,6 +9,7 @@
           clearable
           size="small"
           style="width: 240px"
+          maxlength="50"
           @keyup.enter.native="reGetList"
         />
       </el-form-item>
@@ -40,7 +41,7 @@
       <el-table-column label="璐﹀彿" prop="account" align="center" min-width="120" />
       <el-table-column label="璐﹀彿绫诲瀷" prop="account" align="center" min-width="120">
         <template slot-scope="scope">
-          <span v-if="scope.row.type">{{ accountTypeOptions[scope.row.type].name }}</span>
+          {{ accountTypeOptions.find(item=>item.id == scope.row.type) ? accountTypeOptions.find(item=>item.id == scope.row.type).name : '' }}
         </template>
       </el-table-column>
       <el-table-column label="瑙掕壊" prop="roleName" align="center" min-width="120" />
@@ -48,6 +49,7 @@
       <el-table-column label="鐘舵��" align="center" min-width="100">
         <template slot-scope="scope">
           <el-switch
+            v-if="scope.row.type!=0"
             v-model="scope.row.isUse"
             :active-value="1"
             :inactive-value="0"
@@ -66,7 +68,7 @@
             @click="showEditAdminDialog(scope.row)"
           >缂栬緫</el-button>
           <el-button
-            v-if="getAuthValueFN('sys_admin_del')"
+            v-if="getAuthValueFN('sys_admin_del') && scope.row.type!=0"
             size="mini"
             type="text warn"
             icon="el-icon-delete"
@@ -85,19 +87,19 @@
     />
 
     <!-- 鏂板&缂栬緫 -->
-    <el-dialog :title="adminDialogData.type=='add'?'鏂板绠$悊鍛�':'缂栬緫绠$悊鍛�'" width="500px" :visible.sync="adminDialogVisible" append-to-body :before-close="hideDialog">
+    <el-dialog v-el-drag-dialog :title="adminDialogData.type==='add'?'鏂板绠$悊鍛�':'缂栬緫绠$悊鍛�'" width="500px" :visible.sync="adminDialogVisible" append-to-body :close-on-click-modal="false">
       <el-form ref="adminDialog" :model="adminDialogData" label-width="80px" :rules="rules" size="small">
         <el-form-item label="鍚嶇О" prop="name">
-          <el-input v-model="adminDialogData.name" placeholder="璇疯緭鍏ュ悕绉�" />
+          <el-input v-model="adminDialogData.name" placeholder="璇疯緭鍏ュ悕绉�" maxlength="50" />
         </el-form-item>
         <el-form-item label="璐﹀彿" prop="account">
-          <el-input v-model="adminDialogData.account" placeholder="璇疯緭鍏ュ笎鍙�" :disabled="adminDialogData.type!='add'" />
+          <el-input v-model="adminDialogData.account" placeholder="璇疯緭鍏ュ笎鍙�" maxlength="20" :disabled="adminDialogData.type!='add'" />
         </el-form-item>
-        <el-form-item label="瀵嗙爜" :prop="adminDialogData.type=='add'?'password':''">
-          <el-input v-model="adminDialogData.password" type="password" placeholder="璇疯緭鍏ュ瘑鐮�" />
+        <el-form-item label="瀵嗙爜" :prop="adminDialogData.type==='add'||adminDialogData.password||adminDialogData.passwordSure?'password':'none'">
+          <el-input v-model="adminDialogData.password" type="password" placeholder="璇疯緭鍏ュ瘑鐮�" maxlength="20" />
         </el-form-item>
-        <el-form-item label="纭瀵嗙爜" :prop="adminDialogData.type=='add'?'passwordSure':''">
-          <el-input v-model="adminDialogData.passwordSure" type="password" placeholder="璇疯緭鍏ョ‘璁ゅ瘑鐮�" />
+        <el-form-item label="纭瀵嗙爜" :prop="adminDialogData.type==='add'||adminDialogData.password||adminDialogData.passwordSure?'passwordSure':'none'">
+          <el-input v-model="adminDialogData.passwordSure" type="password" placeholder="璇疯緭鍏ョ‘璁ゅ瘑鐮�" maxlength="20" />
         </el-form-item>
         <!-- 璐﹀彿绫诲瀷 -->
         <el-form-item label="璐﹀彿绫诲瀷" prop="accountType">
@@ -122,7 +124,7 @@
           </el-select>
         </el-form-item>
 
-        <el-form-item label="鏄惁鍚敤" prop="sysRoleId">
+        <el-form-item label="鏄惁鍚敤" prop="isUse">
           <el-switch
             v-model="adminDialogData.isUse"
             :active-value="1"
@@ -140,7 +142,6 @@
 </template>
 
 <script>
-
 export default {
   name: 'Admin',
   data() {
@@ -183,7 +184,8 @@
           { required: true, message: '璐﹀彿涓嶈兘涓虹┖', trigger: 'change' }
         ],
         password: [
-          { required: true, message: '瀵嗙爜涓嶈兘涓虹┖', trigger: 'change' }
+          { required: true, message: '瀵嗙爜涓嶈兘涓虹┖', trigger: 'change' },
+          { min: 5, max: 20, message: '瀵嗙爜鍦�5~20涓瓧涔嬮棿'}
         ],
         passwordSure: [
           { required: true, message: '纭瀵嗙爜涓嶈兘涓虹┖', trigger: 'change' },
@@ -194,6 +196,9 @@
         ],
         accountType: [
           { required: true, message: '璐﹀彿绫诲瀷涓嶈兘涓虹┖', trigger: 'change' }
+        ],
+        isUse: [
+          { required: true, message: '鏄惁鍚敤涓嶈兘涓虹┖', trigger: 'change' }
         ]
       }
     }
@@ -219,13 +224,15 @@
         mockData: {
           code: 100,
           msg: '',
-          data: [{
-            id: 'xxx',
-            name: '閲庨┈鍙�'
-          }]
+          data: {
+            list: [{
+              id: 'xxx',
+              name: '閲庨┈鍙�'
+            }]
+          }
         }
       }, (inf) => {
-        this.roleArr = inf.list || []
+        this.roleArr = inf.list && inf.list.filter(item => item.isUse === 1) || []
       })
     },
 
@@ -349,9 +356,9 @@
         passwordSure: '',
         sysRoleId: item.roId,
         id: item.id,
-        isUse: item.isUse
+        isUse: item.isUse,
+        accountType: item.type
       }
-      if (!item.type + '') adminDialogData.accountType = item.type
       this.adminDialogVisible = true
       this.$nextTick(() => {
         this.adminDialogData = adminDialogData
@@ -392,7 +399,7 @@
           }, () => {
             this.$messageSuc('淇濆瓨鎴愬姛')
             this.hideAdminDialog()
-            this.getList()
+            isAdd ? this.reGetList() : this.getList()
           })
         }
       })

--
Gitblit v1.8.0