2026-03-01 21:28:05 +08:00
|
|
|
<template>
|
2026-03-03 23:05:02 +08:00
|
|
|
<div class="data-manage-page">
|
|
|
|
|
<CSearch
|
|
|
|
|
@search="handleSearch"
|
|
|
|
|
@reset="handleReset"
|
|
|
|
|
>
|
|
|
|
|
<el-form-item label="用户名称:" class="search-item">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="searchForm.uname"
|
|
|
|
|
placeholder="请输入用户名称"
|
|
|
|
|
clearable
|
|
|
|
|
class="search-input"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="登录账户:" class="search-item">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="searchForm.userName"
|
|
|
|
|
placeholder="请输入登录账户"
|
|
|
|
|
clearable
|
|
|
|
|
class="search-input"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="用户状态:" class="search-item">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="searchForm.ustatus"
|
|
|
|
|
placeholder="请选择用户状态"
|
|
|
|
|
clearable
|
|
|
|
|
class="search-select"
|
|
|
|
|
>
|
|
|
|
|
<el-option label="停用" value="0" />
|
|
|
|
|
<el-option label="在用" value="1" />
|
|
|
|
|
<el-option label="锁定" value="2" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</CSearch>
|
|
|
|
|
|
|
|
|
|
<div class="main-wrapper">
|
|
|
|
|
<div class="main-section">
|
|
|
|
|
<div class="action-section">
|
|
|
|
|
<el-button type="primary" icon="Plus" @click="handleAdd">
|
|
|
|
|
新增
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button type="success" icon="Download" @click="handleExport">
|
|
|
|
|
导出
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<STable
|
|
|
|
|
:table-data="tableData"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
:pagination="pagination"
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
>
|
|
|
|
|
<template #columns>
|
2026-03-06 15:43:05 +08:00
|
|
|
<el-table-column prop="createTime" label="记录日期" width="180" sortable fixed="left" />
|
2026-03-03 23:05:02 +08:00
|
|
|
<el-table-column prop="userName" label="登录账户" />
|
|
|
|
|
<el-table-column prop="uname" label="用户名称" />
|
2026-03-04 23:42:19 +08:00
|
|
|
<el-table-column prop="sex" label="性别" sortable />
|
2026-03-06 17:25:46 +08:00
|
|
|
<el-table-column prop="email" label="电子邮箱" width="225" show-overflow-tooltip="true" />
|
2026-03-03 23:05:02 +08:00
|
|
|
<el-table-column prop="phone" label="联系电话" />
|
2026-03-04 23:42:19 +08:00
|
|
|
<el-table-column prop="ustatus" label="状态" min-width="100" align="center" sortable>
|
2026-03-03 23:05:02 +08:00
|
|
|
<template #default="scope">
|
|
|
|
|
<el-tag
|
|
|
|
|
:type="scope.row.ustatus === '1' ? 'success' : scope.row.ustatus === '2' ? 'warning' : 'danger'"
|
|
|
|
|
>
|
|
|
|
|
{{ getStatusText(scope.row.ustatus) }}
|
|
|
|
|
</el-tag>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
2026-03-04 23:42:19 +08:00
|
|
|
<el-table-column label="操作" width="260" align="center" fixed="right">
|
2026-03-03 23:05:02 +08:00
|
|
|
<template #default="scope">
|
2026-03-04 23:42:19 +08:00
|
|
|
<el-button size="small" type="primary" @click="handleEdit(scope.row)">
|
2026-03-03 23:47:22 +08:00
|
|
|
<el-icon><Edit /></el-icon>
|
2026-03-03 23:05:02 +08:00
|
|
|
编辑
|
|
|
|
|
</el-button>
|
2026-03-06 10:47:14 +08:00
|
|
|
<el-button size="small" type="warning" @click="handleResetPwd(scope.row)">
|
|
|
|
|
<el-icon><Key /></el-icon>
|
|
|
|
|
初始化
|
|
|
|
|
</el-button>
|
2026-03-04 23:42:19 +08:00
|
|
|
<el-button size="small" type="danger" @click="handleDelete(scope.row)">
|
2026-03-03 23:47:22 +08:00
|
|
|
<el-icon><Delete /></el-icon>
|
2026-03-03 23:05:02 +08:00
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</template>
|
|
|
|
|
</STable>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<PDialog
|
|
|
|
|
v-model="dialogVisible"
|
2026-03-06 17:25:46 +08:00
|
|
|
:loading="saveLoading"
|
2026-03-03 23:05:02 +08:00
|
|
|
:title="isEdit ? '编辑数据' : '新增数据'"
|
|
|
|
|
@close="handleDialogClose"
|
|
|
|
|
@reset="handleDialogReset"
|
|
|
|
|
@confirm="handleSave"
|
|
|
|
|
>
|
|
|
|
|
<VForm ref="formComponentRef" :form-data="formData" :is-edit="isEdit" />
|
|
|
|
|
</PDialog>
|
|
|
|
|
</div>
|
2026-03-01 21:28:05 +08:00
|
|
|
</template>
|
|
|
|
|
|
2026-03-03 23:05:02 +08:00
|
|
|
<script setup>
|
|
|
|
|
import { ref, reactive, onMounted } from 'vue'
|
2026-03-06 10:47:14 +08:00
|
|
|
import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'
|
2026-03-03 23:47:22 +08:00
|
|
|
import { Plus, Download, Edit, Delete } from '@element-plus/icons-vue'
|
2026-03-06 10:47:14 +08:00
|
|
|
import { initPasswd } from '@/api/user'
|
2026-03-05 22:32:39 +08:00
|
|
|
import { getHomeUserList, getHomeUserSave, getHomeUserDelete } from '@/api/bizUser'
|
2026-03-03 23:05:02 +08:00
|
|
|
|
|
|
|
|
import CSearch from '@/components/Search/proSearch.vue'
|
|
|
|
|
import STable from '@/components/Table/proTable.vue'
|
|
|
|
|
import PDialog from '@/components/Dialog/proDialog.vue'
|
|
|
|
|
import VForm from './form.vue'
|
|
|
|
|
|
|
|
|
|
const formComponentRef = ref(null)
|
2026-03-06 17:25:46 +08:00
|
|
|
const saveLoading = ref(false)
|
2026-03-03 23:05:02 +08:00
|
|
|
const loading = ref(false)
|
|
|
|
|
const searchForm = reactive({
|
|
|
|
|
uname: '',
|
|
|
|
|
ustatus: '',
|
|
|
|
|
userName: ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const pagination = reactive({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
total: 0
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const tableData = ref([])
|
|
|
|
|
|
|
|
|
|
const isEdit = ref(false)
|
|
|
|
|
const formData = ref({})
|
2026-03-05 22:32:39 +08:00
|
|
|
const currentRow = ref({})
|
|
|
|
|
const dialogVisible = ref(false)
|
2026-03-03 23:05:02 +08:00
|
|
|
|
|
|
|
|
async function getDataList() {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
2026-03-07 12:13:00 +08:00
|
|
|
const reqParams = {
|
2026-03-03 23:05:02 +08:00
|
|
|
... searchForm,
|
|
|
|
|
pageNum: pagination.pageNum,
|
|
|
|
|
pageSize: pagination.pageSize,
|
|
|
|
|
}
|
2026-03-07 12:13:00 +08:00
|
|
|
const res = await getHomeUserList(reqParams);
|
2026-03-03 23:05:02 +08:00
|
|
|
pagination.total = res.total;
|
|
|
|
|
tableData.value = res.list || [];
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取数据失败:', error);
|
|
|
|
|
tableData.value = []
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getStatusText = (status) => {
|
|
|
|
|
const statusMap = {
|
|
|
|
|
'0': '停用',
|
|
|
|
|
'1': '在用',
|
|
|
|
|
'2': '锁定'
|
|
|
|
|
}
|
|
|
|
|
return statusMap[status] || '未知'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
|
pagination.pageNum = 1
|
|
|
|
|
getDataList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleReset = () => {
|
|
|
|
|
Object.assign(searchForm, {
|
|
|
|
|
uname: '',
|
|
|
|
|
ustatus: '',
|
|
|
|
|
userName: ''
|
|
|
|
|
})
|
|
|
|
|
pagination.pageNum = 1
|
|
|
|
|
getDataList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
isEdit.value = false
|
|
|
|
|
formData.value = {}
|
2026-03-05 22:32:39 +08:00
|
|
|
currentRow.value = {}
|
2026-03-03 23:05:02 +08:00
|
|
|
dialogVisible.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleEdit = (row) => {
|
|
|
|
|
isEdit.value = true
|
|
|
|
|
formData.value = { ...row }
|
2026-03-05 22:32:39 +08:00
|
|
|
currentRow.value = { ...row }
|
2026-03-03 23:05:02 +08:00
|
|
|
dialogVisible.value = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleExport = () => {
|
|
|
|
|
ElMessage.success('开始导出数据...')
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 22:32:39 +08:00
|
|
|
const handleDelete = async (row) => {
|
2026-03-06 10:47:14 +08:00
|
|
|
ElMessageBox.confirm('确定要删除该条数据吗?', '删除确认', {
|
|
|
|
|
type: 'warning',
|
|
|
|
|
closeOnClickModal: false,
|
|
|
|
|
showClose: false
|
|
|
|
|
})
|
|
|
|
|
.then(async () => {
|
|
|
|
|
const reqParams = {
|
|
|
|
|
userId: row.userId
|
|
|
|
|
}
|
|
|
|
|
const res = await getHomeUserDelete(reqParams);
|
|
|
|
|
ElMessage.success(res.msg);
|
|
|
|
|
getDataList();
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
ElMessage.info('已取消删除数据操作');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleResetPwd = async (row) => {
|
|
|
|
|
ElMessageBox.confirm('确定要初始化该用户的密码吗?', '初始化确认', {
|
|
|
|
|
type: 'warning',
|
|
|
|
|
closeOnClickModal: false,
|
|
|
|
|
showClose: false
|
|
|
|
|
})
|
|
|
|
|
.then(async () => {
|
2026-03-05 22:32:39 +08:00
|
|
|
const reqParams = {
|
|
|
|
|
userId: row.userId
|
|
|
|
|
}
|
2026-03-06 10:47:14 +08:00
|
|
|
const res = await initPasswd(reqParams);
|
|
|
|
|
ElNotification({
|
|
|
|
|
title: '初始化密码',
|
|
|
|
|
message: res.msg,
|
|
|
|
|
type: 'success',
|
|
|
|
|
})
|
|
|
|
|
getDataList();
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
ElMessage.info('已取消密码初始化操作');
|
|
|
|
|
});
|
2026-03-03 23:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSizeChange = (val) => {
|
|
|
|
|
pagination.pageSize = val
|
|
|
|
|
getDataList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleCurrentChange = (val) => {
|
|
|
|
|
pagination.pageNum = val
|
|
|
|
|
getDataList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDialogClose = () => {
|
|
|
|
|
formData.value = {}
|
|
|
|
|
isEdit.value = false
|
2026-03-05 22:32:39 +08:00
|
|
|
currentRow.value = {}
|
2026-03-03 23:05:02 +08:00
|
|
|
dialogVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleDialogReset = () => {
|
|
|
|
|
if (formComponentRef.value) {
|
|
|
|
|
formComponentRef.value.resetForm()
|
|
|
|
|
ElMessage.info('表单已重置')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSave = async () => {
|
|
|
|
|
if (formComponentRef.value) {
|
|
|
|
|
const isValid = await formComponentRef.value.validate()
|
|
|
|
|
if (!isValid) {
|
|
|
|
|
ElMessage.warning('表单验证失败,请检查必填项')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-06 17:25:46 +08:00
|
|
|
saveLoading.value = true
|
2026-03-05 22:32:39 +08:00
|
|
|
try {
|
|
|
|
|
const reqParams = {
|
|
|
|
|
...formData.value,
|
|
|
|
|
isEdit: isEdit.value,
|
|
|
|
|
userId: currentRow.value?.userId
|
|
|
|
|
}
|
|
|
|
|
const res = await getHomeUserSave(reqParams);
|
2026-03-06 17:25:46 +08:00
|
|
|
saveLoading.value = false;
|
2026-03-05 22:32:39 +08:00
|
|
|
dialogVisible.value = false;
|
2026-03-06 17:25:46 +08:00
|
|
|
ElMessage.success(res.msg);
|
2026-03-05 22:32:39 +08:00
|
|
|
getDataList();
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
2026-03-03 23:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getDataList()
|
|
|
|
|
})
|
2026-03-01 21:28:05 +08:00
|
|
|
</script>
|
|
|
|
|
|
2026-03-03 23:05:02 +08:00
|
|
|
<style scoped>
|
|
|
|
|
.data-manage-page {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2026-03-03 23:47:22 +08:00
|
|
|
padding: 4px;
|
2026-03-03 23:05:02 +08:00
|
|
|
box-sizing: border-box;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
overflow: hidden !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.main-wrapper {
|
|
|
|
|
flex: 1;
|
|
|
|
|
width: 100%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
min-height: 0;
|
|
|
|
|
border: 1px solid #e5e7eb;
|
|
|
|
|
border-radius: 6px;
|
2026-03-03 23:47:22 +08:00
|
|
|
margin: 0 !important;
|
|
|
|
|
padding: 0;
|
|
|
|
|
box-sizing: border-box;
|
2026-03-03 23:05:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.main-section {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-section {
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
border-bottom: 1px solid #e5e7eb;
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-03 23:47:22 +08:00
|
|
|
:deep(.el-button .el-icon) {
|
|
|
|
|
margin-right: 4px;
|
2026-03-03 23:05:02 +08:00
|
|
|
}
|
2026-03-01 21:28:05 +08:00
|
|
|
</style>
|