Files
admin-govern/src/views/auth/userList/index.vue

227 lines
8.1 KiB
Vue
Raw Normal View History

2024-01-19 15:24:21 +08:00
<template>
2024-01-29 14:57:49 +08:00
<div class="default-main">
2024-01-19 15:24:21 +08:00
<TableHeader>
<template v-slot:select>
2024-01-29 14:57:49 +08:00
<el-form-item label="用户状态">
<el-select v-model="tableStore.table.params.searchState" placeholder="选择用户状态">
2024-01-19 15:24:21 +08:00
<el-option
2024-01-29 14:57:49 +08:00
v-for="(item, index) in userState"
:label="item.label"
:key="index"
:value="item.value"
2024-01-19 15:24:21 +08:00
></el-option>
</el-select>
</el-form-item>
2024-01-29 14:57:49 +08:00
<el-form-item label="用户类型:">
<el-select v-model="tableStore.table.params.casualUser" placeholder="选择用户类型">
2024-01-19 15:24:21 +08:00
<el-option
2024-01-29 14:57:49 +08:00
v-for="(item, index) in casualUser"
:label="item.label"
:key="index"
:value="item.value"
2024-01-19 15:24:21 +08:00
></el-option>
</el-select>
</el-form-item>
2024-01-29 14:57:49 +08:00
<el-form-item label="关键词:">
2024-01-19 15:24:21 +08:00
<el-input
2024-01-29 14:57:49 +08:00
style="width: 240px"
v-model="tableStore.table.params.searchValue"
2024-01-19 15:24:21 +08:00
clearable
2024-01-29 14:57:49 +08:00
placeholder="仅根据用户名/登录名"
2024-01-19 15:24:21 +08:00
/>
</el-form-item>
</template>
<template v-slot:operation>
2024-01-29 14:57:49 +08:00
<el-button :icon="Plus" type="primary" @click="addUser">添加</el-button>
2024-01-19 15:24:21 +08:00
</template>
</TableHeader>
2024-01-29 14:57:49 +08:00
<Table ref="tableRef" />
<PopupEdit ref="popupEditRef"></PopupEdit>
<PopupPwd ref="popupPwdRef"></PopupPwd>
2024-01-19 15:24:21 +08:00
</div>
</template>
2024-01-29 14:57:49 +08:00
<script setup lang="ts">
2024-01-19 15:24:21 +08:00
import { Plus } from '@element-plus/icons-vue'
import { ref, onMounted, provide } from 'vue'
2024-01-22 14:21:31 +08:00
import { ElMessageBox, ElMessage } from 'element-plus'
import { activateUser, deluser, passwordConfirm } from '@/api/user-boot/user'
2024-01-19 15:24:21 +08:00
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
2024-01-19 16:30:46 +08:00
import PopupEdit from './popupEdit.vue'
import PopupPwd from './popupPwd.vue'
2024-01-19 15:24:21 +08:00
defineOptions({
name: 'auth/userlist'
})
2024-01-19 16:30:46 +08:00
const popupEditRef = ref()
const popupPwdRef = ref()
2024-01-19 15:24:21 +08:00
const tableStore = new TableStore({
url: '/user-boot/user/list',
method: 'POST',
column: [
{ title: '用户名称', field: 'name', minWidth: '130' },
{ title: '登录名', field: 'loginName', minWidth: '130' },
2024-01-22 14:21:31 +08:00
{ title: '角色', field: 'roleName', minWidth: '130' },
2024-01-19 15:24:21 +08:00
{ title: '部门', field: 'deptName', minWidth: '200' },
2024-01-22 14:21:31 +08:00
{ title: '电话', field: 'phoneShow', minWidth: '100' },
2024-01-19 15:24:21 +08:00
{ title: '注册时间', field: 'registerTime', minWidth: '130' },
{ title: '登录时间', field: 'loginTime', minWidth: '130' },
{ title: '类型', field: 'casualUserName', minWidth: '80' },
2024-01-26 09:08:20 +08:00
{
title: '状态',
field: 'state',
width: '80',
render: 'tag',
custom: {
0: 'danger',
1: 'success',
2: 'warning',
3: 'warning',
4: 'info',
5: 'danger'
},
replaceValue: {
0: '注销',
1: '正常',
2: '锁定',
3: '待审核',
4: '休眠',
5: '密码过期'
}
},
2024-01-19 15:24:21 +08:00
{
title: '操作',
width: '180',
render: 'buttons',
fixed: 'right',
buttons: [
{
name: 'edit',
title: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
2024-01-30 14:11:29 +08:00
render: 'basicButton',
2024-01-19 15:24:21 +08:00
disabled: row => {
return row.state !== 1
},
2024-01-19 16:30:46 +08:00
click: row => {
popupEditRef.value.open('编辑用户', row)
}
2024-01-19 15:24:21 +08:00
},
{
name: 'edit',
title: '修改密码',
type: 'primary',
icon: 'el-icon-Lock',
2024-01-30 14:11:29 +08:00
render: 'basicButton',
2024-01-19 15:24:21 +08:00
disabled: row => {
return row.state !== 1
},
2024-01-19 16:30:46 +08:00
click: row => {
2024-01-29 14:57:49 +08:00
ElMessageBox.prompt('二次校验密码确认', '注销用户', {
confirmButtonText: '确认',
cancelButtonText: '取消',
inputType: 'password'
}).then(({ value }) => {
passwordConfirm(value).then(res => {
popupPwdRef.value.open(row.id)
})
})
2024-01-19 16:30:46 +08:00
}
2024-01-19 15:24:21 +08:00
},
{
name: 'edit',
title: '激活',
type: 'success',
icon: 'el-icon-Open',
2024-01-30 14:11:29 +08:00
render: 'basicButton',
2024-01-19 15:24:21 +08:00
disabled: row => {
return row.state !== 2 && row.state !== 5 && row.state !== 0 && row.state !== 4
},
2024-01-22 14:21:31 +08:00
click: row => {
activateUser({
id: row.id
}).then(() => {
ElMessage.success('激活成功')
tableStore.index()
})
}
2024-01-19 15:24:21 +08:00
},
{
name: 'edit',
title: '注销',
type: 'danger',
icon: 'el-icon-SwitchButton',
2024-01-30 14:11:29 +08:00
render: 'basicButton',
2024-01-19 15:24:21 +08:00
disabled: row => {
return row.state !== 1 && row.state !== 3
},
2024-01-22 14:21:31 +08:00
click: row => {
ElMessageBox.prompt('二次校验密码确认', '注销用户', {
confirmButtonText: '确认',
cancelButtonText: '取消',
inputType: 'password'
2024-01-29 14:57:49 +08:00
}).then(({ value }) => {
passwordConfirm(value).then(res => {
deluser({
id: row.id
}).then(() => {
ElMessage.success('注销成功')
tableStore.index()
2024-01-22 14:21:31 +08:00
})
})
2024-01-29 14:57:49 +08:00
})
2024-01-22 14:21:31 +08:00
}
2024-01-19 15:24:21 +08:00
}
]
}
],
loadCallback: () => {
tableStore.table.data.forEach((item: any) => {
item.deptName = item.deptName || '/'
2024-01-22 14:21:31 +08:00
item.phoneShow = item.phone || '/'
item.roleName = item.role.length ? item.role : '/'
2024-01-19 15:24:21 +08:00
switch (item.casualUser) {
case 0:
item.casualUserName = '临时用户'
break
case 1:
item.casualUserName = '长期用户'
break
default:
item.casualUserName = '/'
break
}
})
}
})
provide('tableStore', tableStore)
tableStore.table.params.searchState = 1
tableStore.table.params.casualUser = -1
tableStore.table.params.orderBy = ''
const userState = [
{ label: '全部', value: -1 },
{ label: '注销', value: 0 },
{ label: '正常', value: 1 },
{ label: '锁定', value: 2 },
{ label: '待审核', value: 3 },
{ label: '休眠', value: 4 },
{ label: '密码过期', value: 5 }
]
const casualUser = [
{ label: '全部', value: -1 },
{ label: '临时用户', value: 0 },
{ label: '长期用户', value: 1 }
]
onMounted(() => {
tableStore.index()
})
2024-01-19 16:30:46 +08:00
const addUser = () => {
popupEditRef.value.open('新增用户')
}
2024-01-19 15:24:21 +08:00
</script>