Parcourir la source

修改用户管理用户名重复问题

smallwei il y a 6 ans
Parent
commit
1ac853e4e1
4 fichiers modifiés avec 26 ajouts et 20 suppressions
  1. 9 10
      src/const/crud/user.js
  2. 4 3
      src/views/admin/user/index.vue
  3. 2 2
      vue.config.js
  4. 11 5
      yarn.lock

+ 9 - 10
src/const/crud/user.js

@@ -17,8 +17,9 @@
 import { getDetails } from "@/api/user";
 var validateUsername = (rule, value, callback) => {
     getDetails(value).then(response => {
+        if (window.boxType === 'edit') callback()
         let result = response.data.data
-        if (result !== null){
+        if (result !== null) {
             callback(new Error('用户名已经存在'))
         }
     });
@@ -67,14 +68,12 @@ export const tableOption = {
         value: '',
         hide: true,
         span: 24,
-        rules: [
-            {
-                min: 6,
-                max: 20,
-                message: "长度在 6 到 20 个字符",
-                trigger: "blur"
-            }
-        ]
+        rules: [{
+            min: 6,
+            max: 20,
+            message: "长度在 6 到 20 个字符",
+            trigger: "blur"
+        }]
     }, {
         label: '所属部门',
         prop: 'deptId',
@@ -130,4 +129,4 @@ export const tableOption = {
         addVisdiplay: false,
         span: 24,
     }]
-}
+}

+ 4 - 3
src/views/admin/user/index.vue

@@ -42,9 +42,9 @@
         <template slot="username"
                   slot-scope="scope">
           <img v-if="scope.row.avatar"
-                   class="user-avatar"
-                   style="width: 20px; height: 20px; border-radius: 50%;"
-                   :src="scope.row.avatar+'?imageView2/1/w/20/h/20'" />
+               class="user-avatar"
+               style="width: 20px; height: 20px; border-radius: 50%;"
+               :src="scope.row.avatar+'?imageView2/1/w/20/h/20'" />
           <span>{{scope.row.username}}</span>
         </template>
         <template slot="role"
@@ -199,6 +199,7 @@ export default {
       this.$refs.crud.rowAdd();
     },
     handleOpenBefore (show, type) {
+      window.boxType = type;
       this.handleDept();
       if (['edit', 'views'].includes(type)) {
         this.role = [];

+ 2 - 2
vue.config.js

@@ -1,4 +1,4 @@
-const url = 'http://zn.huaxiadaowei.com:9999'
+const url = 'http://zn.huaxiadaowei.com'
 module.exports = {
     lintOnSave: true,
     productionSourceMap: false,
@@ -66,4 +66,4 @@ module.exports = {
             },
         }
     }
-}
+}

+ 11 - 5
yarn.lock

@@ -1249,9 +1249,9 @@
   version "1.1.2"
   resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26"
 
-"@smallwei/avue@^1.1.21-beta1":
-  version "1.1.21-beta1"
-  resolved "https://registry.yarnpkg.com/@smallwei/avue/-/avue-1.1.21-beta1.tgz#f78a0710c02d32f53421e3406d49732d402b7220"
+"@smallwei/avue@^1.3.1-beta3":
+  version "1.3.2"
+  resolved "https://registry.yarnpkg.com/@smallwei/avue/-/avue-1.3.2.tgz#c96753664ca722a2d2c07cbf2e6899a501af064f"
   dependencies:
     async-validator "~1.8.1"
     axios "^0.16.2"
@@ -1263,7 +1263,7 @@
     resize-observer-polyfill "^1.5.0"
     throttle-debounce "^1.0.1"
     vue "^2.5.2"
-    vue-quill-editor "^3.0.6"
+    vue-json-editor "^1.2.3"
     vuedraggable "^2.16.0"
 
 "@types/blob-util@1.3.3":
@@ -8611,6 +8611,12 @@ vue-hot-reload-api@^2.3.0:
   version "2.3.1"
   resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.1.tgz#b2d3d95402a811602380783ea4f566eb875569a2"
 
+vue-json-editor@^1.2.3:
+  version "1.2.3"
+  resolved "https://registry.yarnpkg.com/vue-json-editor/-/vue-json-editor-1.2.3.tgz#b928415640af335490d41a4061136e25394f36f6"
+  dependencies:
+    vue "^2.2.6"
+
 vue-json-tree-view@^2.1.4:
   version "2.1.4"
   resolved "https://registry.yarnpkg.com/vue-json-tree-view/-/vue-json-tree-view-2.1.4.tgz#b6f8ae2ba2eec4eec5b6f53b90fa187054cad79b"
@@ -8657,7 +8663,7 @@ vue-template-es2015-compiler@^1.6.0:
   version "1.6.0"
   resolved "https://registry.yarnpkg.com/vue-template-es2015-compiler/-/vue-template-es2015-compiler-1.6.0.tgz#dc42697133302ce3017524356a6c61b7b69b4a18"
 
-vue@^2.5.16, vue@^2.5.17, vue@^2.5.2:
+vue@^2.2.6, vue@^2.5.16, vue@^2.5.17, vue@^2.5.2:
   version "2.5.17"
   resolved "https://registry.yarnpkg.com/vue/-/vue-2.5.17.tgz#0f8789ad718be68ca1872629832ed533589c6ada"