From 1e1e5f612f252d66b0d0386cf52873bb1f3f7d7b Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期五, 01 九月 2023 16:10:37 +0800
Subject: [PATCH] 系统维护+系统监控器+调试工具的app 增加

---
 src/pages/settings/components/AuthorityManagement.vue |  265 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 265 insertions(+), 0 deletions(-)

diff --git a/src/pages/settings/components/AuthorityManagement.vue b/src/pages/settings/components/AuthorityManagement.vue
new file mode 100644
index 0000000..d95a783
--- /dev/null
+++ b/src/pages/settings/components/AuthorityManagement.vue
@@ -0,0 +1,265 @@
+<template>
+  <div class="s-authority-management">
+    <div class="authority-table s-table" v-if="display">
+      <el-table
+        highlight-current-row
+        :data="userList"
+        style="width: 100%"
+        :header-cell-style="{background:'#f8f8f8',color:'#222222'}"
+      >
+        <el-table-column align="center" type="index" label="搴忓彿" width="100"></el-table-column>
+        <el-table-column :align="'center'" prop="username" label="鐢ㄦ埛鍚�"></el-table-column>
+        <el-table-column :align="'center'" prop="role" label="瑙掕壊">
+          <template slot-scope="scope">{{scope.row.sysRoles | roles}}</template>
+        </el-table-column>
+        <el-table-column label="鎿嶄綔" :align="'center'">
+          <template slot-scope="scope">
+            <el-tooltip content="缂栬緫" placement="top" popper-class="atooltip">
+              <i
+                class="el-icon-edit"
+                style="font-size: 18px;"
+                @click="handleEdit(scope.$index, scope.row)"
+              ></i>
+            </el-tooltip>
+            <el-tooltip content="鍒犻櫎" placement="top" popper-class="atooltip" v-show="false">
+              <!-- :disabled="scope.row.sysRoles | roles | isSuper" -->
+              <i
+                class="el-icon-delete"
+                style="font-size: 18px; color:red;"
+                @click="handleDelete(scope.$index, scope.row)"
+              ></i>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
+    <div class="authority-details" v-if="!display">
+      <el-form label-width="80px" :rules="rules" ref="editForm" :model="editForm">
+        <el-form-item label="鐢ㄦ埛鍚�" style="width:580px" prop="username">
+          <!-- <el-input v-model="editForm.username" placeholder="璇疯緭鍏�" size="small"></el-input> -->
+          <span class="m10" v-if="editForm.username == 'admin' || editForm.username == 'basic'">{{editForm.username}}</span>
+          <el-input v-model="editForm.username" size="small" v-else></el-input>
+        </el-form-item>
+
+        <el-form-item label="鏂板瘑鐮�" style="width:580px" v-show="loginUser != editForm.username">
+          <el-input show-password v-model="editForm.newPwd" placeholder="璇疯緭鍏ュ瘑鐮�" size="small"></el-input>
+        </el-form-item>
+
+        <el-form-item
+          label="纭瀵嗙爜"
+          style="width:580px"
+          prop="checkPass"
+          v-show="loginUser != editForm.username"
+        >
+          <el-input show-password v-model="editForm.checkPass" placeholder="璇疯緭鍏ュ啀娆¤緭鍏ュ瘑鐮�" size="small"></el-input>
+        </el-form-item>
+
+        <el-form-item label="鏉冮檺閰嶇疆" style="width:580px;">
+          <!-- <el-transfer
+            id="e-transfer"
+            :titles="['鍏ㄩ儴瑙掕壊', '褰撳墠瑙掕壊']"
+            v-model="editForm.roleIds"
+            :props="{key: 'id', label: 'name'}"
+            :data="roledata"
+          ></el-transfer>-->
+
+          <el-tree
+            ref="treeMenus"
+            :data="sysMenus"
+            :props="props"
+            node-key="id"
+            :default-checked-keys="userMenus"
+            show-checkbox
+            check-on-click-node
+            default-expand-all
+            style="margin-top: 10px;"
+          ></el-tree>
+        </el-form-item>
+
+        <el-form-item style="width:580px;">
+          <el-button type="primary" style="float: right" @click="save" size="small">淇濆瓨</el-button>
+          <el-button type="info" style="margin-right: 10px;float: right" @click="goback" size="small">杩斿洖</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+  </div>
+</template>
+
+<script>
+
+import { getUsers, getSysMenus, updataUser, getUserMenus } from "@/api/user"
+
+export default {
+  name: "AuthorityManage",
+  filters: {
+    roles(roles) {
+      return roles.map(r => {
+        return r.name
+      }).join(' ')
+    },
+    isSuper(roles) {
+      return roles.indexOf("瓒呯骇绠$悊鍛�") >= 0
+    }
+  },
+  data() {
+    const generateData = _ => {
+      const data = [];
+      for (let i = 1; i <= 15; i++) {
+        data.push({
+          key: i,
+          label: `澶囬�夐」 ${i}`,
+          disabled: i % 4 === 0
+        });
+      }
+      return data;
+    };
+    const validateCheckPass = (rule, value, callback) => {
+      if (value !== this.editForm.newPwd) {
+        callback(new Error('涓ゆ杈撳叆瀵嗙爜涓嶄竴鑷�!'));
+      } else {
+        callback()
+      }
+    };
+    var checkUserName = (rule, value, callback) => {
+    聽聽if (value && value !== ''){
+    聽聽聽聽let regEn = /^[A-Za-z_@.]{2,10}$/
+        console.log("鐢ㄦ埛鍚嶆牎楠岋紒",value)
+    聽聽聽聽if (!regEn.test(value)) {
+    聽聽聽聽聽聽callback(new Error('璇疯緭鍏�2浣嶅埌10浣嶅瓧姣嶇殑鐢ㄦ埛鍚嶏紝涓嶈兘浠ユ暟瀛楀紑澶达紝涓斾笉鑳藉寘鍚眽瀛�'))
+    聽聽聽聽} else {
+    聽聽聽聽聽聽callback()
+    聽聽聽聽}
+    聽聽} else {
+    聽聽聽聽callback()
+    聽聽}
+    }
+    return {
+      display: true,
+      loginUser: JSON.parse(sessionStorage.getItem('userInfo')).username,
+      acknewpwd: "",
+      sysMenus: [],
+      userMenus: [],
+      rolevalue: [],
+      userList: [],
+      editForm: {},
+      props: {
+        label: 'name'
+      },
+      rules: {
+        username: [
+          { validator: checkUserName, trigger: 'blur' }
+        ],
+        checkPass: [
+          { validator: validateCheckPass, trigger: 'change' }
+        ]
+      }
+    };
+  },
+  mounted() {
+    this.fetchUserList();
+    this.fetchSysMenus();
+    this.initEditForm();
+  },
+  methods: {
+    initEditForm() {
+      this.editForm = {
+        id: "",
+        username: "",
+        newPwd: "",
+        checkPass: "",
+        menuIds: []
+      }
+    },
+    handleEdit(index, row) {
+      this.initEditForm()
+      this.display = !this.display;
+      this.editForm.id = row.id;
+      this.editForm.username = row.username;
+      this.userMenus = []
+      getUserMenus({ userId: row.id }).then(rsp => {
+        if (rsp && rsp.success) {
+          this.userMenus = rsp.data.menus.map(menu => {
+            return menu.id
+          })
+        }
+      })
+
+    },
+    handleDelete(index, row) {
+      this.$notify({
+        type: "warning",
+        message: "鏃犳硶鍒犻櫎璇ョ敤鎴�"
+      })
+    },
+    goback() {
+      this.display = !this.display;
+    },
+    save() {
+      this.$refs.editForm.validate((valid) => {
+        if (valid) {
+          this.editForm.menuIds = this.$refs.treeMenus.getCheckedKeys()
+          updataUser(this.editForm).then(rsp => {
+            if (rsp && rsp.success) {
+              this.$notify({
+                type: "success",
+                message: "淇敼鎴愬姛"
+              })
+            }
+          })
+        }
+      });
+    },
+    fetchUserList() {
+      getUsers().then(rsp => {
+        if (rsp && rsp.success) {
+          this.userList = rsp.data;
+        }
+      })
+    },
+    fetchSysMenus() {
+      getSysMenus().then(rsp => {
+        if (rsp && rsp.success) {
+          this.sysMenus = rsp.data;
+        }
+      })
+    }
+  }
+};
+</script>
+<style lang="scss">
+.s-authority-management {
+  height: 100%;
+  width: 100%;
+  .authority-table,
+  .authority-details {
+    height: 100%;
+    width: 100%;
+    margin-top: 40px;
+  }
+  #e-transfer {
+    .el-button--primary {
+      color: #fff;
+      background-color: #bfbfbf;
+      border-color: #bfbfbf;
+    }
+    .el-button--primary:focus,
+    .el-button--primary:hover {
+      background: #4c4c4c;
+      border-color: #4c4c4c;
+      color: #fff;
+    }
+    .el-transfer-panel
+      .el-transfer-panel__header
+      .el-checkbox
+      .el-checkbox__label {
+      font-size: 14px;
+    }
+  }
+  .el-form-item__content {
+    text-align: left;
+    input {
+      max-width: 498px;
+    }
+  }
+}
+</style>

--
Gitblit v1.8.0