Browse Source

添加授权账号

元子 5 months ago
parent
commit
8957b7c8f5

+ 1 - 1
public/config.js

@@ -1,4 +1,4 @@
 window.g = {
-  // ApiUrl: "https://test.hz-hanghui.com:18890/patrol-management",
+  // ApiUrl: "http://192.168.77.25:8019/patrol-management",
   ApiUrl: "https://hhsz.hz-hanghui.com:8088/patrol-management",
 };

+ 35 - 0
src/api/userAuth.js

@@ -0,0 +1,35 @@
+import request from "@/utils/request";
+
+// 添加-编辑授权账号
+export function getAuthAdd(data) {
+  return request({
+    url: "/manage/api/v1/account/auth/add",
+    method: "post",
+    data,
+  });
+}
+//账号列表
+export function getAuthPagelist(data) {
+  return request({
+    url: "/manage/api/v1/account/auth/page",
+    method: "post",
+    data,
+  });
+}
+
+// 查询授权账号列表
+export function getAuthList(data) {
+  return request({
+    url: "/manage/api/v1/account/auth/list",
+    method: "post",
+    data,
+  });
+}
+
+// 删除
+export function getAuthDelete(accountId) {
+  return request({
+    url: `/manage/api/v1/account/auth/del/${accountId}`,
+    method: "get",
+  });
+}

+ 16 - 16
src/router/index.js

@@ -48,22 +48,22 @@ export const constantRoutes = [
       },
     ],
   },
-  // {
-  //   path: "/userList",
-  //   component: Layout,
-  //   children: [
-  //     {
-  //       path: "index",
-  //       name: "userList",
-  //       component: () => import("@/views/userList/index"),
-  //       meta: {
-  //         title: "授权账号列表",
-  //         role: [0, 1],
-  //         icon: "el-icon-s-finance",
-  //       },
-  //     },
-  //   ],
-  // },
+  {
+    path: "/userList",
+    component: Layout,
+    children: [
+      {
+        path: "index",
+        name: "userList",
+        component: () => import("@/views/userList/index"),
+        meta: {
+          title: "授权账号列表",
+          role: [0, 1],
+          icon: "el-icon-s-finance",
+        },
+      },
+    ],
+  },
   {
     path: "/pointManagement",
     redirect: "/pointManagement/index",

+ 3 - 6
src/views/dashboard/index.vue

@@ -269,12 +269,9 @@ export default {
       page: {
         data: {
           username: "",
-          companyName: "",
-          contactsName: "",
-          contactsName: "",
-          contactsPhone: "",
-          startTime: "",
-          endTime: "",
+          nickname: "",
+          phone: "",
+          address: "",
         },
         pageNumber: 1,
         pageSize: 10,

+ 2 - 0
src/views/login/index.vue

@@ -152,6 +152,8 @@ export default {
             await this.$store.dispatch("user/getInfo");
             if (this.$store.getters.role === 0) {
               this.$router.push({ path: "/index" });
+            } else if (this.$store.getters.role === 2) {
+              this.$router.push({ path: "/recordList/index" });
             } else {
               this.$router.push({ path: "/pointManagement/index" });
             }

+ 40 - 27
src/views/userList/index.vue

@@ -11,9 +11,9 @@
           >添加授权账号</el-button
         >
       </el-form-item>
-      <el-form-item class="margin-left input">
+      <el-form-item class="margin-left input" v-if="checkRole([0])">
         <el-select
-          v-model="page.data.username"
+          v-model="page.data.parentId"
           placeholder="请选择所属账号"
           filterable
           clearable
@@ -34,7 +34,7 @@
           clearable
         >
           <el-option
-            v-for="item in option"
+            v-for="item in authList"
             :key="item.id"
             :label="item.username"
             :value="item.id"
@@ -55,7 +55,6 @@
           clearable
         ></el-input>
       </el-form-item>
-
       <el-form-item class="margin-left">
         <el-button type="primary" @click="fetchData" icon="el-icon-search"
           >搜索</el-button
@@ -76,7 +75,12 @@
           {{ indexMethod(scope.$index) }}
         </template>
       </el-table-column>
-      <el-table-column align="center" prop="username" label="所属账号">
+      <el-table-column
+        align="center"
+        prop="parentName"
+        label="所属账号"
+        v-if="checkRole([0])"
+      >
       </el-table-column>
       <el-table-column align="center" prop="username" label="账号名称">
       </el-table-column>
@@ -130,10 +134,11 @@
           <el-form-item
             style="margin-right: 20px; flex: 0.5"
             label="所属账号"
-            prop="username"
+            prop="parentId"
+            v-if="checkRole([0])"
           >
             <el-select
-              v-model="addOrUpdateForm.accountId"
+              v-model="addOrUpdateForm.parentId"
               filterable
               clearable
               placeholder="请选择所属账号"
@@ -196,12 +201,13 @@
 
 <script>
 import Pagination from "@/components/Pagination";
+import { getUserlist } from "@/api/user";
 import {
-  doGetAdmins,
-  doEditAdmin,
-  doDeleteAdmin,
-  getUserlist,
-} from "@/api/user";
+  getAuthAdd,
+  getAuthPagelist,
+  getAuthList,
+  getAuthDelete,
+} from "@/api/userAuth";
 import { checkRole } from "@/utils/checkRole";
 export default {
   components: { Pagination },
@@ -222,16 +228,14 @@ export default {
       dialogVisible: false,
       total: 0,
       option: [],
+      authList: [], //授权账号
       // 分页参数
       page: {
         data: {
+          parentId: "",
           username: "",
-          companyName: "",
-          contactsName: "",
-          contactsName: "",
-          contactsPhone: "",
-          startTime: "",
-          endTime: "",
+          nickname: "",
+          phone: "",
         },
         pageNumber: 1,
         pageSize: 10,
@@ -240,17 +244,17 @@ export default {
       isEdit: false, //判断是否是编辑
       // 添加编辑账号
       addOrUpdateForm: {
+        parentId: "",
         username: "", //账号名称
         password: "", //账号密码
         nickname: "", //管理员姓名
         phone: "", //手机号
       },
-      //省市县列表
-      province_list: [],
-      city_list: [],
-      area_list: [],
       // 规则
       rules: {
+        parentId: [
+          { required: true, message: "请输入账号名称", trigger: "blur" },
+        ],
         username: [
           { required: true, message: "请输入账号名称", trigger: "blur" },
         ],
@@ -268,7 +272,10 @@ export default {
   },
   created() {
     this.fetchData();
-    this.getUserList();
+    if (checkRole([0])) {
+      this._getUserList();
+    }
+    this._getAuthList();
   },
   methods: {
     // 查询权限
@@ -276,17 +283,23 @@ export default {
     // 获取列表数据
     fetchData() {
       this.listLoading = true;
-      doGetAdmins(this.page).then((res) => {
+      getAuthPagelist(this.page).then((res) => {
         this.tableData = res.data.records;
         this.total = res.data.total;
         this.listLoading = false;
       });
     },
-    getUserList() {
+    _getUserList() {
       getUserlist().then((res) => {
         this.option = res.data;
       });
     },
+    // 授权账号列表
+    _getAuthList() {
+      getAuthList().then((res) => {
+        this.authList = res.data;
+      });
+    },
     // 添加编辑账号
     addOrUpdate(dialogTitle, edit) {
       this.dialogVisible = true;
@@ -309,7 +322,7 @@ export default {
         if (!pass) {
           return false;
         }
-        await doEditAdmin({
+        await getAuthAdd({
           ...this.addOrUpdateForm,
           id: this.isEdit ? this.addOrUpdateForm.id : undefined,
         });
@@ -327,7 +340,7 @@ export default {
         type: "warning",
         center: true,
       }).then(() => {
-        doDeleteAdmin(id).then((res) => {
+        getAuthDelete(id).then((res) => {
           this.fetchData();
           this.$message({
             type: "success",