From 185cd4fd0805cda64a236bad2f1ddb61e4aa01e6 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期一, 08 一月 2024 14:04:27 +0800
Subject: [PATCH] 用户等级行点击事件修改

---
 src/views/unifiedManage/userLevel/index.vue |  130 +++++++++++++++++++++++++++++++------------
 1 files changed, 94 insertions(+), 36 deletions(-)

diff --git a/src/views/unifiedManage/userLevel/index.vue b/src/views/unifiedManage/userLevel/index.vue
index 9c0aebb..ce5d583 100644
--- a/src/views/unifiedManage/userLevel/index.vue
+++ b/src/views/unifiedManage/userLevel/index.vue
@@ -59,7 +59,7 @@
         </div>
       </div>
     </div>
-    <!-- 鏂板缓/缂栬緫 -->
+    <!-- 娣诲姞/缂栬緫 -->
     <AddUserLevel v-if="editConfig.visible" :edit-common-config="editConfig" />
   </div>
 </template>
@@ -67,6 +67,7 @@
 <script>
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
 import AddUserLevel from "@/views/unifiedManage/userLevel/components/AddUserLevel"
+import { getListRole, getUserList, roleChange, deleteRole, getTotal } from "@/api/unifiedManage/userLevel"
 export default {
   name: "UserLevel",
   props: {
@@ -138,19 +139,80 @@
   },
   created() {
     this.setTable()
+    this.getData()
   },
   methods: {
+    // 鏁伴噺缁熻
+    overview() {
+      getTotal({
+        useType: 1
+      }).then((reply) => {
+        console.log(reply)
+        if (reply.code == 200) {
+          this.totalObject.value = reply.data.total
+          this.otherOptions.map((item) => {
+            if (item.label === "鍚敤") {
+              item.value = reply.data.use
+            } else if (item.label === "鍋滅敤") {
+              item.value = reply.data.ban
+            }
+          })
+        }
+      })
+    },
+    // 瑙掕壊鍒楄〃
+    async getData(val) {
+      this.data.page = this.pagerOptions.currPage
+      this.data.pageSize = this.pagerOptions.pageSize
+      const res = await getListRole(this.data)
+      console.log(res)
+      this.tableList.tableInfomation = res.data.list
+      this.pagerOptions.totalCount = res.data.total
+
+      if (this.pagerOptions.totalCount > 0) {
+        let row = this.tableList.tableInfomation[0]
+        this.selectRow = this.tableList.tableInfomation.length > 0 ? this.tableList.tableInfomation[0] : {}
+        this.getUserList(row.id)
+      }
+      if (val !== "search") {
+        this.overview()
+      }
+    },
+    // 鐢ㄦ埛鍒楄〃
+    async getUserList(id) {
+      let params = {
+        page: 0,
+        pageSize: 0,
+        id: id
+      }
+      const res = await getUserList(params)
+      if (res.data.list && res.data.list.length > 0) {
+        const list = res.data.list.map((item) => {
+          let dutyList = []
+          item.dutyIDs.forEach((val) => {
+            dutyList.push(val.dutyName)
+          })
+          return {
+            ...item,
+            dutyNames: dutyList.join(", ")
+          }
+        })
+        this.bottomTableList.tableInfomation = list || []
+      } else {
+        this.bottomTableList.tableInfomation = []
+      }
+    },
     // 鏂板缓
     addBtnClick() {
       this.editConfig.title = "鏂板缓"
-      this.editConfig.infomation = { ...this.addConfig, currency: "浜烘皯甯�" }
       this.editConfig.visible = true
+      this.editConfig.infomation = {}
     },
     // 鎼滅储
     searchClick(val) {
       this.data.keyword = val
       this.pagerOptions.currPage = 1
-      // this.getData();
+      this.getData("search")
     },
     // 鍋滅敤
     changeStatusClick(row) {
@@ -167,24 +229,26 @@
     // 鍚敤 鍋滅敤璇锋眰
     async getRoleChange(row) {
       console.log(row)
-      // await roleChange({
-      //   id: row.id,
-      //   status: !row.status,
-      // }).then((reply) => {
-      //   if (reply && reply.code == 200) {
-      //     let tips = row.status ? "鍋滅敤鎴愬姛" : "鍚敤鎴愬姛";
-      //     this.getData();
-      //     this.$message({
-      //       type: "success",
-      //       message: tips,
-      //     });
-      //   }
-      // });
+      await roleChange({
+        id: row.id,
+        status: !row.status
+      }).then((reply) => {
+        if (reply && reply.code == 200) {
+          let tips = row.status ? "鍋滅敤鎴愬姛" : "鍚敤鎴愬姛"
+          this.getData()
+          this.$message({
+            type: "success",
+            message: tips
+          })
+        }
+      })
     },
     // 缂栬緫
     handleClick(val) {
-      this.editRow = val
-      this.isopen = true
+      console.log(val)
+      this.editConfig.title = "缂栬緫"
+      this.editConfig.infomation = { ...val }
+      this.editConfig.visible = true
     },
     // 鍒犻櫎绛夌骇
     delClick(row) {
@@ -195,15 +259,15 @@
         type: "warning"
       })
         .then(() => {
-          // deleteRole(row.id).then((reply) => {
-          //   if (reply && reply.code == 200) {
-          //     this.getData();
-          //     this.$message({
-          //       type: "success",
-          //       message: "鍒犻櫎鎴愬姛",
-          //     });
-          //   }
-          // });
+          deleteRole(row.id).then((reply) => {
+            if (reply && reply.code == 200) {
+              this.getData()
+              this.$message({
+                type: "success",
+                message: "鍒犻櫎鎴愬姛"
+              })
+            }
+          })
         })
         .catch(() => {})
     },
@@ -211,7 +275,7 @@
     tableRowClick(row) {
       console.log(row)
       this.selectRow = row
-      // this.getUserList(row.id);
+      this.getUserList(row.id)
     },
     // 绛夌骇鐘舵��
     getRoleStatus(val) {
@@ -244,15 +308,9 @@
       // bottom
       this.setBottomList()
     },
-    // 绛夌骇鍒楄〃
+    // 鍒楄〃
     setTableList(tableList) {
       tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
-      this.searchOptions = []
-      for (let i = 0; i < tableList.tableColumn.length; i++) {
-        const label = tableList.tableColumn[i].label
-        const value = tableList.tableColumn[i].prop
-        this.searchOptions.push({ value: value, label: label })
-      }
     },
     // bom 鍒楄〃
     setBottomList() {
@@ -350,7 +408,7 @@
       background-color: #fff;
       border-radius: 12px;
       min-height: 70px;
-      height: calc(52% - 60px);
+      height: calc(52% - 50px);
       margin-top: 10px;
       // padding: 10px 20px;
       .list-view {

--
Gitblit v1.8.0