瀏覽代碼

新增用户修改

zhaoke 1 年之前
父節點
當前提交
783400545a
共有 2 個文件被更改,包括 23 次插入7 次删除
  1. 5 2
      src/layout/mixin/publicFunc.js
  2. 18 5
      src/views/newUserManagement/index.vue

+ 5 - 2
src/layout/mixin/publicFunc.js

@@ -214,11 +214,14 @@ export default {
         return { code, message }
       } catch (error) {
         console.log(error)
-        return 0
+        return {
+          code: -1,
+          message: error
+        }
       }
     },
     tipMsg (code, msg) {
-      if (code == 0 || code) {
+      if (code == 0 || code != -1) {
         this.$message.success(msg ?? '操作成功')
       } else {
         this.$message.error(msg ?? '操作失败')

+ 18 - 5
src/views/newUserManagement/index.vue

@@ -299,10 +299,10 @@ export default {
     dataList () {
       return this.arrs
     },
-    editGroupDisabled() {
+    editGroupDisabled () {
       return !this.type
     },
-    addUserDisabled() {
+    addUserDisabled () {
       return !this.treeCheckId
     }
   },
@@ -409,6 +409,7 @@ export default {
         const { user_name } = this.dataObj
         const { user_group_id } = this.treeCheckObj
         const { code } = await this.getChangeList(SERVICE_ID.getUserTableId, { user_name, up_user_group_id: user_group_id }, 3)
+        this.tipMsg(code)
         if (code == 0) {
           const { returnData } = await this.getQueryList(SERVICE_ID.getUserTableId, {
             up_user_group_id: this.dataObj.up_user_group_id
@@ -424,6 +425,7 @@ export default {
       this.$refs['form'].validate(async (valid) => {
         if (valid) {
           let code = null
+          let mesResult = null
           this.formInline.user_group_id = this.treeCheckId
           const data = _.cloneDeep(this.formInline)
           // console.log(this.type)
@@ -441,6 +443,7 @@ export default {
                 result = await this.getChangeList(this.queryId, data, 1)
               }
               code = result.code
+              mesResult = result
             }
           }
           if (code == 0) {
@@ -448,8 +451,14 @@ export default {
               this.clearForm()
             }
             this.getTreeData()
+            this.tipMsg(code)
+          } else {
+            if (mesResult.code == -1 && mesResult.message.toString().includes('for key')) {
+              this.tipMsg(code, '账号组名称重复,请重新输入')
+            } else {
+              this.tipMsg(code)
+            }
           }
-          this.tipMsg(code)
         }
         else {
           return false
@@ -571,8 +580,12 @@ export default {
             this.ruleForm.up_user_group_id = this.ruleForm.user_group_id
             delete this.ruleForm.user_group_id
             const data = this.ruleForm
-            const { code } = await this.getChangeList(SERVICE_ID.getUserTableId, data, 1)
-            this.tipMsg(code)
+            const { code, message } = await this.getChangeList(SERVICE_ID.getUserTableId, data, 1)
+            if (code == -1 && message.toString().includes('for key')) {
+              this.tipMsg(code, '账号名称重复,请重新输入')
+            } else {
+              this.tipMsg(code)
+            }
           } else {
             const id = this.ruleForm.user_group_id || this.ruleForm.user_id
             if (id) {