yangfeng
2024-01-05 b195c95d3a37995f6ff2aaa8038173660ec49d76
src/views/unifiedManage/userLevel/index.vue
@@ -59,28 +59,19 @@
        </div>
      </div>
    </div>
    <!-- 新建/编辑 -->
    <AddUserLevel v-if="editConfig.visible" :edit-common-config="editConfig" />
    <div class="overSpread" v-show="isopen"></div>
    <!-- 添加/编辑 -->
    <AddUserLevel :isopen="isopen" @shutdown="shutdown" :editRow="editRow" />
  </div>
</template>
<script>
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import AddUserLevel from "@/views/unifiedManage/userLevel/components/AddUserLevel"
import { getListRole, getUserList, roleChange, deleteRole } from "@/api/unifiedManage/userLevel"
export default {
  name: "UserLevel",
  props: {
    isDetail: {
      type: Boolean,
      default: false
    },
    addConfig: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  props: {},
  mixins: [pageMixin],
  components: { AddUserLevel },
  computed: {},
@@ -123,6 +114,7 @@
      ],
      showBottomCol: ["用户名", "姓名", "手机号", "岗位职务", "状态"],
      isopen: false,
      editRow: {},
      editConfig: {
        visible: false,
        title: "新建",
@@ -138,13 +130,58 @@
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    // 角色列表
    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.title = "新建"
      // this.editConfig.visible = true
      // this.editConfig.infomation = {}
      this.isopen = true
      this.editRow = {}
    },
    // 搜索
    searchClick(val) {
@@ -167,25 +204,28 @@
    // 启用 停用请求
    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.editConfig.title = "编辑"
      this.editConfig.infomation = { ...val }
      this.editConfig.visible = true
      console.log(val)
      // this.editConfig.title = "编辑"
      // this.editConfig.infomation = { ...val }
      // this.editConfig.visible = true
      this.editRow = val
      this.isopen = true
    },
    // 删除等级
    delClick(row) {
@@ -196,17 +236,23 @@
        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(() => {})
    },
    shutdown() {
      this.isopen = false
      setTimeout(() => {
        this.getData()
      }, 200)
    },
    // 行点击
    tableRowClick(row) {
@@ -245,15 +291,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 +391,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 {