ludc
2024-06-26 809dab4c259ea465efafe302c4a4a4b2ff555c7f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
  <basic-container>
    <avue-crud
      :data="tableData"
      :option="option"
      :page.sync="page"
      :table-loading="tableLoading"
      @on-load="getTableList"
      @refresh-change="handleRefresh"
      @search-change="handleSearch"
      @search-reset="handleReset"
      @size-change="sizeChange"
      @current-change="currentChange"
    >
      <template slot="status" slot-scope="{row}">
        <el-tag v-if="row.status === 0" type="success">启用</el-tag>
        <el-tag v-if="row.status === 1" type="danger">停用</el-tag>
      </template>
 
      <template slot="lockFlag" slot-scope="{row}">
        <el-tag v-if="!row.lockFlag" type="success">未锁定</el-tag>
        <el-tag v-if="row.lockFlag" type="danger">锁定</el-tag>
      </template>
 
      <template #menu="{row,index,size}">
        <el-button size="small" type="text" @click="stopUserHandler(row)">
          <span style="color: #fa3434" v-if="row.status === 0"><i class="el-icon-video-pause"></i> 停用</span>
          <span style="color: #55b61d" v-if="row.status === 1"><i class="el-icon-video-pause"></i> 启用</span>
        </el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
 
<script>
import basicOption from '@/util/basic-option'
import {getDataUsers, stopUser} from '@/api/user/userManageApi'
import {column} from "./userManage"
import func from '@/util/func'
 
export default {
  name: "userManage",
  data() {
    return {
      tableLoading: false,
      tableData: [],
      option: {
        ...basicOption,
        calcHeight: -60,
        column: column
      },
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      searchParams: {},
    }
  },
  created() {
  },
  methods: {
    // 表格请求
    getTableList() {
      getDataUsers(this.page.currentPage, this.page.pageSize, this.searchParams).then(res => {
        const data = res.data.data;
        this.tableData = data;
        this.page.total = res.data.total;
      });
    },
 
    // 表格右侧刷新图标
    handleRefresh() {
      this.getTableList();
    },
 
    // 搜索查询
    handleSearch(params, done) {
      if (!func.isEmptyObject(params)) {
        for (let key in params) {
          if (params.hasOwnProperty(key)) {
            // 判断如果 key 是 'pkPersonName',则改为 'pkPerson' 分别为显示值和保存值
            let newKey = key === 'pkPersonName' ? 'pkPerson' : key;
            this.searchParams[`conditionMap["${newKey}"]`] = params[key];
          }
        }
      } else {
        this.searchParams = {};
      }
      this.getTableList();
      done();
    },
 
    // 重置搜索条件
    handleReset() {
      this.searchParams = {};
      this.getTableList();
    },
 
    // 条数
    sizeChange(val) {
      this.page.pageSize = val;
    },
 
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
    },
 
    // 停用启用
    stopUserHandler(row){
      let params = {};
      params = {
        idList:row.oid,
        flag: row.status === 0 ? true : false
      }
      stopUser(params).then(res => {
        console.log(res)
      })
    }
  }
 
}
</script>
 
<style scoped>
 
</style>