oyq28 3 年 前
コミット
830165a2ec

+ 14 - 1
imcs-ui/src/api/resourceProductMgr/resourceBusiness.js

@@ -20,7 +20,7 @@ const apiList = {
   updateStatus: {
     method: 'POST',
     url: `/authority/resourceBusiness/status`
-  },
+  },  
   remove: {
     method: 'DELETE',
     url: `/authority/resourceBusiness`
@@ -66,6 +66,19 @@ export default {
       data
     })
   },
+  check (code) {
+    return axiosApi({
+      method: 'GET',
+      url: `/authority/resourceBusiness/check/${code}`
+    })
+  },
+  checkField (data) {
+    return axiosApi({
+      method: 'POST',
+      url: `/authority/resourceBusiness/check`,
+      data
+    })
+  },
   remove (data) {
     return axiosApi({
       ...apiList.remove,

+ 14 - 1
imcs-ui/src/views/zuihou/resourceProductMgr/resourcesMgr/components/TenantEdit.vue

@@ -51,6 +51,15 @@ export default {
     }
   },
   data () {
+    let validate = (rule, value, callback) => {
+      //后台方法
+      this.checkExist(value).then(res => {
+        res = res.data               
+        if (res && res.data) {         
+          callback('名称已存在')
+        }
+      })
+    }
     return {
       type: 'add',
       rowData:{},
@@ -64,7 +73,8 @@ export default {
       roles: [],
       rules: {
         name: [
-        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' }
+        	{ required: true, message: this.$t("rules.require"), trigger: 'blur' },
+          { validator: validate, trigger: 'blur'}
         ]
       }
     }
@@ -158,6 +168,9 @@ export default {
           this.confirmDisabled = false
           return true
         })
+    },    
+    checkExist(name){
+      return resourceBusinessApi.checkField({"name":name})
     },
     update () {  
       //this.tenant.isFinal = (this.tenant.isFinal) ? "1" : "0"