liujq 2 年之前
父節點
當前提交
5c715d01d5
共有 2 個文件被更改,包括 30 次插入1 次删除
  1. 3 0
      src/api/user.js
  2. 27 1
      src/views/user/index.vue

+ 3 - 0
src/api/user.js

@@ -25,4 +25,7 @@ export default {
   admuserauthedit: params => { // 认证审核
     return getRequestNoSort('/adm/user/auth/edit', params, 'loading')
   },
+  admuseradmin: params => { // admin
+    return getRequestNoSort('/adm/user/admin', params, 'loading')
+  },
 }

+ 27 - 1
src/views/user/index.vue

@@ -15,6 +15,7 @@
       @sizeChange="sizeChange"
       :isAdd="true"
       @add="openPopup"
+      :operationsDefaultLength="6"
     />
     <popup-edit
       :isShow="isDtlShow"
@@ -73,16 +74,41 @@ export default {
         { label: '更新时间', prop: 'update_at' },
         // { label: '系统', prop: 'is_admin', type: 'tag', tags: arrToObj(this.$dictData.sys_yesno), tagTypeObj: {'1': 'success', '2': 'danger'} },
         { label: '系统', prop: 'is_admin' },
-        { label: '操作', width: 120, type: 'handle2', operations:
+        { label: '操作', width: 180, type: 'handle2', operations:
           [
             { label: '编辑', func: this.openPopup, btnType: 'primary' },
             { label: '删除', func: this.delHandle, btnType: 'danger' },
+            { labelFor: 'is_admin', func: this.adminHandle,
+              labelConfig: {
+                texts: {
+                  1: 'NO',
+                  2: 'YES'
+                },
+                btnTypes: {
+                  1: 'danger',
+                  2: 'success'
+                }
+              }
+            },
           ]
         }
       ]
     }
   },
   methods: {
+    adminHandle (row) {
+      const is_admin = Number(row.is_admin) === 1 ? 2 : 1
+      const msgText = Number(row.is_admin) === 1 ? '禁用' : '设置'
+      this.$msg(`确定把${row.nickname}${msgText}为超级管理员吗?`, 'confirm', ()=> {
+        this.$api.user.admuseradmin({
+          id: row.id,
+          is_admin
+        }).then(data => {
+          this.$msgs(`${msgText}成功!`)
+          this.fetchData()
+        })
+      }, null, true)
+    },
     delHandle(row) {
       this.$msg(`您确定要删除该用户吗?`, 'confirm', () => {
         this.$api.user.admuserdel({