yangfeng
2024-01-05 b195c95d3a37995f6ff2aaa8038173660ec49d76
src/views/unifiedManage/userManage/index.vue
@@ -21,7 +21,23 @@
              <el-table-column label="操作" width="120">
                <template slot-scope="scope">
                  <el-button @click="viewClick(scope.row)" type="text" size="small">查看</el-button>
                  <el-button @click="approveClick(scope.row)" type="text" size="small">审核</el-button>
                  <el-button
                    v-if="scope.row.status == 0 || scope.row.status == 3"
                    @click="changeStatusClick(scope.row, 1)"
                    type="text"
                    size="small"
                    >启用</el-button
                  >
                  <el-button
                    v-else-if="scope.row.status == 1"
                    @click="changeStatusClick(scope.row, 0)"
                    type="text"
                    size="small"
                    >禁用</el-button
                  >
                  <el-button v-else-if="scope.row.status == 2" @click="approveClick(scope.row)" type="text" size="small"
                    >审核</el-button
                  >
                  <el-button @click="editClick(scope.row)" type="text" size="small">编辑</el-button>
                </template>
              </el-table-column>
@@ -44,6 +60,8 @@
import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
import EditUserInfo from "@/views/unifiedManage/userManage/components/EditUserInfo"
import ReviewDialog from "@/views/unifiedManage/userManage/components/ReviewDialog"
import { listUser, changeStatus } from "@/api/unifiedManage/userManage"
export default {
  name: "UserManage",
  props: {},
@@ -56,12 +74,12 @@
      tableColumn: [
        { label: "用户名", prop: "username", default: true },
        { label: "手机号", prop: "phone" },
        { label: "公司名称", prop: "company" },
        { label: "联系人姓名", prop: "contact" },
        { label: "邮箱", prop: "email" },
        { label: "公司名称", prop: "companyName" },
        { label: "联系人姓名", prop: "nickName" },
        { label: "邮箱", prop: "companyEmail" },
        { label: "行业", prop: "industry" },
        { label: "地区", prop: "region" },
        { label: "状态", prop: "status" }
        { label: "状态", prop: "status", isCallMethod: true, getCallMethod: this.getStatus }
      ],
      showCol: ["用户名", "手机号", "公司名称", "联系人姓名", "邮箱", "行业", "地区", "状态"],
      editConfig: {
@@ -72,37 +90,84 @@
      reviewConfig: {
        visible: false,
        infomation: {}
      },
      obj: {
        page: 1,
        pageSize: 15,
        keyword: "",
        useType: 1
      }
    }
  },
  created() {
    this.setTable()
    this.getData()
  },
  methods: {
    // 获取列表值
    getData() {
      this.obj.pageSize = this.pagerOptions.pageSize
      this.obj.page = this.pagerOptions.currPage
      listUser(this.obj).then((res) => {
        console.log(res)
        this.tableList.tableInfomation = res.data.list || []
        this.pagerOptions.totalCount = res.data.total
      })
    },
    // 搜索
    onFilterSearch(val) {
      console.log(val)
      this.obj.keyword = val
      this.pagerOptions.currPage = 1
      this.getData()
    },
    // 查看
    viewClick(row) {
      console.log(row)
      this.editConfig.visible = true
      this.editConfig.title = "查看"
      this.editConfig.tableInfomation = { ...row }
      this.editConfig.form = row
    },
    // 审核
    approveClick(row) {
      console.log(row)
      this.reviewConfig.visible = true
      this.reviewConfig.title = "用户审核"
      this.reviewConfig.tableInfomation = { ...row }
      this.reviewConfig.infomation = { ...row }
    },
    // 停用
    changeStatusClick(row, status) {
      if (status === 0) {
        this.$confirm("是否禁用此用户?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.changeStatus(row, status)
          })
          .catch(() => {})
      } else {
        this.changeStatus(row, status)
      }
    },
    // 启用/禁用
    changeStatus(row, status) {
      changeStatus({
        status: status,
        userId: row.id
      }).then((res) => {
        console.log(res)
        let messageStr = status === 0 ? "禁用成功" : "启用成功"
        this.$message.success(messageStr)
        this.getData()
      })
    },
    // 编辑
    editClick(row) {
      console.log(row)
      this.editConfig.visible = true
      this.editConfig.title = "编辑"
      this.editConfig.tableInfomation = { ...row }
      this.editConfig.form = { ...row }
    },
    // 列表初始化
    setTable() {
@@ -110,7 +175,7 @@
        selectIndex: true,
        tableInfomation: [
          {
            usename: "测试",
            username: "测试",
            status: 1
          }
        ],
@@ -119,12 +184,6 @@
        tableColumn: this.setColumnVisible(this.showCol)
      }
      this.tableList.allcol = this.tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
      this.searchOptions = []
      for (let i = 0; i < this.tableList.tableColumn.length; i++) {
        const label = this.tableList.tableColumn[i].label
        const value = this.tableList.tableColumn[i].prop
        this.searchOptions.push({ value: value, label: label })
      }
    },
    setColumnVisible(showCol) {
      return this.tableColumn.map((ele) => {
@@ -137,6 +196,20 @@
    selTableCol(val) {
      this.showcol = val
      this.tableList.tableColumn = this.setColumnVisible(val)
    },
    // 状态
    getStatus(val) {
      return val === 0
        ? "禁用"
        : val === 1
        ? "启用中"
        : val === 2
        ? "待审核"
        : val === 3
        ? "待启用"
        : val === 4
        ? "已拒绝"
        : ""
    }
  }
}
@@ -163,7 +236,7 @@
    .body-card {
      background-color: #fff;
      border-radius: 12px;
      height: 100%;
      height: calc(100% - 10px);
      overflow: hidden;
    }
    .list-view {