Prechádzať zdrojové kódy

:sparkles: 添加新特性. 客户端维护去重判断

冷冷 5 rokov pred
rodič
commit
89da89e8a4

+ 16 - 2
src/const/crud/admin/client.js

@@ -14,6 +14,7 @@
  * this software without specific prior written permission.
  * Author: lengleng (wangiegie@gmail.com)
  */
+import {getObj} from '@/api/admin/client'
 
 const DIC = {
   vaild: [{
@@ -24,6 +25,19 @@ const DIC = {
     value: 'true'
   }]
 }
+
+var validateClient = (rule, value, callback) => {
+  getObj(value).then(response => {
+    if (window.boxType === 'edit') callback()
+    const result = response.data.data
+    if (result.length !==0) {
+      callback(new Error('客户端已存在'))
+    } else {
+      callback()
+    }
+  })
+}
+
 export const tableOption = {
   border: true,
   index: true,
@@ -44,7 +58,7 @@ export const tableOption = {
       required: true,
       message: '请输入clientId',
       trigger: 'blur'
-    }]
+    }, {validator: validateClient, trigger: 'blur'}]
   }, {
     label: '密钥',
     prop: 'clientSecret',
@@ -71,7 +85,7 @@ export const tableOption = {
     prop: 'autoapprove',
     align: 'center',
     type: 'radio',
-    border:true,
+    border: true,
     dicData: DIC.vaild,
     rules: [{
       required: true,

+ 1 - 2
src/views/admin/client/index.vue

@@ -82,7 +82,6 @@
         })
       },
       handleDelete: function (row, index) {
-        var _this = this
         this.$confirm('是否确认删除ID为' + row.clientId, '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
@@ -90,7 +89,7 @@
         }).then(function () {
           return delObj(row.clientId)
         }).then(() => {
-          _this.$message.success('删除成功')
+          this.$message.success('删除成功')
           this.refreshChange()
         })
       },

+ 0 - 1
src/views/admin/role/index.vue

@@ -259,7 +259,6 @@ export default {
       done()
     },
     handleDelete(row, index) {
-      var _this = this
       this.$confirm('是否确认删除名称为"' + row.roleName + '"' + '"的数据项?', '警告', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',