Administrator.vue
8.18 KB
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<template>
<div>
<el-dialog
v-if="shouDialog"
v-model="shouDialog" class="dialog" title="重置密码" :close-on-click-modal="true" width="80%"
draggable
@close="close"
>
<el-form
ref="queryRef" size="small"
label-position="top"
:model="queryParams"
:inline="true"
style="width: 100%;padding-left: 20px"
>
<el-row style="width: 100%">
<el-col :span="4">
<el-form-item label="登录账号" prop="userName">
<el-input
v-model="queryParams.userName"
placeholder="请输入登录账号"
clearable
style="width: 100%"
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="手机号码" prop="phonenumber">
<el-input
v-model="queryParams.phonenumber"
placeholder="请输入手机号码"
clearable
style="width: 100%"
@keyup.enter="handleQuery"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="创建时间" style="width: 100%">
<el-date-picker
v-model="dateRange"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[
new Date(2000, 1, 1, 0, 0, 0),
new Date(2000, 1, 1, 23, 59, 59),
]"
/>
</el-form-item>
</el-col>
<el-col :span="4" style="margin-left: auto">
<el-form-item label=" " style="margin-left: auto">
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="table">
<el-table
v-loading="loading"
:data="userList"
border
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="index" label="序号" width="55" align="center" />
<!-- <el-table-column
v-if="columns[0].visible"
key="userId"
label="用户编号"
align="center"
prop="userId"
:show-overflow-tooltip="true"
/> -->
<el-table-column
v-if="columns[1].visible"
key="userName"
label="登录账号"
align="center"
prop="userName"
:show-overflow-tooltip="true"
/>
<el-table-column
v-if="columns[2].visible"
key="nickName"
label="用户昵称"
align="center"
prop="nickName"
:show-overflow-tooltip="true"
/>
<el-table-column
v-if="columns[3].visible"
key="deptName"
label="部门"
align="center"
prop="dept.deptName"
:show-overflow-tooltip="true"
/>
<el-table-column
v-if="columns[4].visible"
key="phonenumber"
label="手机号码"
align="center"
prop="phonenumber"
width="120"
/>
<el-table-column
label="角色"
align="center"
prop="roleNameStr"
width="140"
/>
<!-- <el-table-column-->
<!-- v-if="columns[5].visible"-->
<!-- key="status"-->
<!-- label="状态"-->
<!-- align="center"-->
<!-- width="90"-->
<!-- >-->
<!-- <template #default="scope">-->
<!-- <el-switch-->
<!-- v-model="scope.row.status"-->
<!-- active-value="0"-->
<!-- inactive-value="1"-->
<!-- @change="handleStatusChange(scope.row)"-->
<!-- />-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
v-if="columns[6].visible"
label="创建时间"
align="center"
prop="createTime"
width="160"
>
<template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column
label="操作"
fixed="right"
align="center"
width="120"
class-name="small-padding fixed-width"
>
<template #default="scope">
<el-button
v-if="scope.row.userId !== 1"
type="primary"
@click="handleResetPwd(scope.row)"
>重置密码
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:total="total"
@pagination="getList"
/>
</div>
</el-dialog>
</div>
</template>
<script setup >
import { ref, reactive, toRefs, getCurrentInstance } from 'vue'
import {
listUser,
resetUserPwd
} from '@/api/system/user'
import { validPassword } from '/@/utils/validate'
import { nextTick } from '@vue/runtime-core'
import { changeStatus } from '/@/api/groupMember'
const { proxy } = getCurrentInstance()
const loading = ref(false)
const userList = ref([])
const total = ref(0)
const shouDialog = ref(false)
const dateRange = ref([])
const columns = ref([
{ key: 0, label: `用户编号`, visible: true },
{ key: 1, label: `用户名称`, visible: true },
{ key: 2, label: `用户昵称`, visible: true },
{ key: 3, label: `部门`, visible: true },
{ key: 4, label: `手机号码`, visible: true },
{ key: 5, label: `状态`, visible: true },
{ key: 6, label: `创建时间`, visible: true }
])
const data = reactive({
queryParams: {
pageNum: 1,
pageSize: 10
}
})
const { queryParams } = toRefs(data)
function open(id) {
shouDialog.value = true
queryParams.value.deptId = id
getList()
}
async function getList() {
loading.value = true
const res = await listUser(queryParams.value, dateRange.value)
if (res.code == 200) {
loading.value = false
userList.value = res.rows
total.value = res.total
}
}
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
function resetQuery() {
dateRange.value = []
proxy.resetForm('queryRef')
handleQuery()
}
function close() {
queryParams.value = {}
}
function handleResetPwd(row, val) {
// proxy.$prompt(`请输入"${row.userName}"的新密码 <br> 请设置8位以上大小写字母、数字、特殊符号组合的密码`, '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// closeOnClickModal: false,
// dangerouslyUseHTMLString: true,
// inputValue: val
// }).then(({ value }) => {
// if (validPassword(value)) {
// resetUserPwd(row.userId, value).then((response) => {
// proxy.$modal.msgSuccess('修改成功,新密码是:' + value)
// })
// } else {
// handleResetPwd(row, value)
// nextTick(() => {
// proxy.$modal.msgError('请设置8位以上大小写字母、数字、特殊符号组合的密码')
// })
// }
// })
proxy.$modal.confirm('是否确认重置登录账号为' + row.userName + '的密码?').then(function() {
return resetUserPwd(row.userId)
}).then(() => {
loading.value = true
proxy.$modal.msgSuccess('操作成功')
}).catch(() => {
}).finally(() => {
loading.value = false
})
}
defineExpose({
open
})
</script>
<style scoped lang="scss">
</style>