浏览代码

feat(tenant): support AI audit configuration

Casper Dai 3 年之前
父节点
当前提交
98071153a6
共有 2 个文件被更改,包括 48 次插入9 次删除
  1. 11 4
      src/api/user.js
  2. 37 5
      src/views/realm/tenant/Tenant.vue

+ 11 - 4
src/api/user.js

@@ -113,6 +113,7 @@ function normalizeGroups (groups, parentGroup, onlyOnce) {
       path,
       name,
       remark,
+      aiAudit: parentGroup ? void 0 : attributes.aiAudit?.[0] || '0',
       label: remark || name
     }
     if (onlyOnce) {
@@ -154,13 +155,16 @@ export function getTenantTree () {
   })
 }
 
-export function addTenant ({ name, remark }) {
+export function addTenant ({ name, remark, aiAudit }) {
   return add({
     url: `/groups`,
     method: 'POST',
     data: {
       name,
-      attributes: { remark: [remark] }
+      attributes: {
+        remark: [remark],
+        aiAudit: aiAudit ? [aiAudit] : void 0
+      }
     }
   }, keycloakRequest)
 }
@@ -196,13 +200,16 @@ export function addSubGroup ({ id }, { name, remark }) {
   }, keycloakRequest)
 }
 
-export function updateGroup ({ id, name, remark }) {
+export function updateGroup ({ id, name, remark, aiAudit }) {
   return update({
     url: `/groups/${id}`,
     method: 'PUT',
     data: {
       name,
-      attributes: { remark: [remark] }
+      attributes: {
+        remark: [remark],
+        aiAudit: aiAudit ? [aiAudit] : void 0
+      }
     }
   }, null, keycloakRequest)
 }

+ 37 - 5
src/views/realm/tenant/Tenant.vue

@@ -39,6 +39,19 @@
           maxlength="50"
           show-word-limit
         />
+        <template v-if="isTenant">
+          <span class="c-grid-form__label">AI机审:</span>
+          <div class="l-flex--row c-grid-form__option">
+            <el-switch
+              v-model="group.aiAudit"
+              class="c-sibling-item"
+              active-value="1"
+              inactive-value="0"
+              active-color="#13ce66"
+              inactive-color="#ff4949"
+            />
+          </div>
+        </template>
       </div>
     </confirm-dialog>
   </wrapper>
@@ -59,6 +72,7 @@ export default {
   data () {
     return {
       isAdd: false,
+      isTenant: false,
       dialogTitle: '',
       schema: {
         condition: { name: '' },
@@ -72,6 +86,14 @@ export default {
         cols: [
           { prop: 'name', label: '标识' },
           { prop: 'remark', label: '名称' },
+          { label: 'AI机审', type: 'tag', render ({ parentGroup, aiAudit }) {
+            return parentGroup
+              ? null
+              : {
+                type: aiAudit === '1' ? 'success' : 'danger',
+                label: aiAudit === '1' ? '开启' : '关闭'
+              }
+          } },
           { type: 'invoke', width: 180, render: [
             { label: '编辑', on: this.onEdit },
             { label: '新增下级', render ({ parentGroup }) { return !parentGroup }, on: this.onAddSub },
@@ -88,20 +110,27 @@ export default {
     },
     onAdd () {
       this.isAdd = true
+      this.isTenant = true
       this.dialogTitle = '新增租户'
-      this.group = { name: '', remark: '' }
+      this.group = {
+        name: '',
+        remark: '',
+        aiAudit: '1'
+      }
       this.$refs.editDialog.show()
     },
     onEdit (group) {
       this.isAdd = false
+      this.isTenant = !group.parentGroup
       this.dialogTitle = group.parentGroup ? '编辑部门' : '编辑租户'
-      const { id, name, remark } = group
+      const { id, name, remark, aiAudit } = group
       this.$group = group
-      this.group = { id, name, remark }
+      this.group = { id, name, remark, aiAudit: this.isTenant ? aiAudit : void 0 }
       this.$refs.editDialog.show()
     },
     onAddSub (group) {
       this.isAdd = true
+      this.isTenant = false
       this.dialogTitle = '新增下级部门'
       this.group = { name: '', remark: '', parentGroup: group }
       this.$refs.editDialog.show()
@@ -136,10 +165,13 @@ export default {
         })
         return
       }
-      if (this.$group.remark !== this.group.remark) {
+      if (this.$group.remark !== this.group.remark
+        || this.isTenant && this.$group.aiAudit !== this.group.aiAudit
+      ) {
         updateGroup(this.group).then(() => {
           done()
           this.$group.remark = this.group.remark
+          this.$group.aiAudit = this.group.aiAudit
         })
       }
     },
@@ -156,7 +188,7 @@ export default {
         { type: 'warning' }
       ).then(() => {
         const loading = this.$showLoading()
-        unbindDevices(group.path)
+        unbindDevices({ org: group.path })
           .then(() => deleteGroup(group))
           .then(() => {
             this.$message({