xiangpei
2024-10-30 31f7b390b44db12308943492891e7e0ef96f32e8
src/views/user/admin/list.vue
@@ -1,22 +1,29 @@
<template>
  <div class="app-container">
    <el-form :model="queryParam" ref="queryForm" :inline="true">
      <el-form-item label="用户名:">
        <el-input v-model="queryParam.userName"></el-input>
      <el-form-item label="真实姓名:">
        <el-input v-model="queryParam.realName" @input="search" size="small"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">查询</el-button>
        <el-button type="primary" @click="submitForm" size="small">查询</el-button>
        <router-link :to="{path:'/user/admin/edit'}" class="link-left">
          <el-button type="primary">添加</el-button>
          <el-button type="primary" size="small">添加</el-button>
        </router-link>
      </el-form-item>
    </el-form>
    <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
      <el-table-column prop="id" label="Id" />
      <el-table-column prop="userName" label="用户名"/>
      <el-table-column prop="realName" label="真实姓名" />
      <el-table-column prop="sex" label="性别" width="60px;" :formatter="sexFormatter"/>
      <el-table-column label="班级">
        <template slot-scope="scope">
        <span v-if="Array.isArray(scope.row.className) && scope.row.className.length > 0">
          {{ scope.row.className.join(', ') }}
        </span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column prop="phone" label="手机号"/>
      <el-table-column prop="createTime" label="创建时间" width="160px"/>
      <el-table-column label="状态" prop="status" width="70px">
@@ -35,6 +42,7 @@
            <el-button size="mini">编辑</el-button>
          </router-link>
          <el-button size="mini" type="danger"  @click="deleteUser(row)" class="link-left">删除</el-button>
          <el-button size="mini"  @click="resetPassword(row)" type="success" class="link-left">重置密码</el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -53,7 +61,7 @@
  data () {
    return {
      queryParam: {
        userName: '',
        realName: '',
        role: 3,
        pageIndex: 1,
        pageSize: 10
@@ -70,7 +78,7 @@
    search () {
      this.listLoading = true
      userApi.getUserPageList(this.queryParam).then(data => {
        const re = data.response
        const re = data.data
        this.tableData = re.list
        this.total = re.total
        this.queryParam.pageIndex = re.pageNum
@@ -81,7 +89,7 @@
      let _this = this
      userApi.changeStatus(row.id).then(re => {
        if (re.code === 1) {
          row.status = re.response
          row.status = re.data
          _this.$message.success(re.message)
        } else {
          _this.$message.error(re.message)
@@ -114,7 +122,22 @@
    },
    statusBtnFormatter (status) {
      return this.enumFormat(this.statusBtn, status)
    }
    },
    resetPassword(row) {
      this.$confirm('此操作将重置该成员的密码, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        userApi.resetUserPassword(row.id).then(re => {
          if (re.code === 1) {
            this.$message.success(re.message)
          } else {
            this.$message.error(re.message)
          }
        })
      })
    },
  },
  computed: {
    ...mapGetters('enumItem', [