yangfeng
2024-01-08 185cd4fd0805cda64a236bad2f1ddb61e4aa01e6
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,22 +229,23 @@
    // 启用 停用请求
    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) {
      console.log(val)
      this.editConfig.title = "编辑"
      this.editConfig.infomation = { ...val }
      this.editConfig.visible = true
@@ -196,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(() => {})
    },
@@ -212,7 +275,7 @@
    tableRowClick(row) {
      console.log(row)
      this.selectRow = row
      // this.getUserList(row.id);
      this.getUserList(row.id)
    },
    // 等级状态
    getRoleStatus(val) {
@@ -245,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() {
@@ -351,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 {