litian
2025-03-18 4a8d8a5f49321d9597251e7ba69bf39f78baa51b
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<template>
  <div class="user-manage">
    <div class="flex jc-sb ai-c">
      <div class="addBox">
        <el-icon><Plus /></el-icon>
        <span>新建</span>
      </div>
      <div class="search">
        <el-input
          v-model="searchValue"
          style="width: 400px"
          placeholder="请输入搜索关键字"
        >
          <template #suffix>
            <el-icon class="el-input__icon"><search /></el-icon>
          </template>
        </el-input>
      </div>
    </div>
    <div class="list">
      <el-table
        :data="tableData"
        row-key="id"
        border
        style="width: 100%"
        class="roverTable"
      >
        <el-table-column prop="index" label="序号" width="60" />
        <el-table-column prop="userName" label="用户姓名" />
        <el-table-column prop="name" label="用户名" />
        <el-table-column prop="state" label="状态" />
        <el-table-column prop="role" label="类型" />
        <el-table-column prop="creatTime" label="创建时间" />
        <el-table-column label="操作"  width="220" >
          <template #default="scope">
            <el-button size="small" @click="update(scope.row)">
              编辑
            </el-button>
            <el-button size="small" @click="goDisable(scope.row)">
              禁用
            </el-button>
            <el-button size="small" @click="goDelete(scope.row)">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="rover-pagination-block">
      <el-pagination
        v-model:current-page="currentPage"
        :page-size="pageSize"
        :background="background"
        layout="total, prev, pager, next"
        :total="100"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { ElMessage, ElMessageBox } from 'element-plus'
 
const searchValue = ref();
const tableData = ref([]);
// 分页
const currentPage = ref(4);
const pageSize = ref(100);
const background = ref(true);
 
onMounted(() => {
  getUserData();
});
 
const getUserData =() =>{
  let list=[
    {
      index: 1,
      userName:'',
      name:'',
      state:'',
      role:'',
      creatTime:'',
    },
    {
      index: 2,
      userName:'',
      name:'',
      state:'',
      role:'',
      creatTime:'',
    },
    {
      index: 3,
      userName:'',
      name:'',
      state:'',
      role:'',
      creatTime:'',
    },
  ]
  tableData.value = list
 
}
 
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`);
};
 
// 编辑
const update = (row) =>{
 
}
//禁用
const goDisable = (row) =>{
  ElMessageBox.confirm(
    '确定要禁用该用户?',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      console.log(row)
     
    })
    .catch(() => {
      
    })
  
}
//删除
const goDelete = () =>{
  ElMessageBox.confirm(
    '确定要删除该用户?',
    'Warning',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      console.log(row)
    })
    .catch(() => {
      
    })
}
</script>
 
<style lang="less" scoped>
.user-manage {
  padding: 20px;
}
.addBox {
  display: flex;
  align-items: center;
  color: #409eff;
}
.list{
  margin-top:20px;
}
.rover-pagination-block {
    height: 60px;
    display: flex;
    justify-content: flex-end;
    background-color: #fff;
    padding: 0 10px;
    box-sizing: border-box;
  }
</style>