mirror of
http://112.124.100.131/ebiz-ai/ebiz-ai-knowledge-manage.git
synced 2025-12-23 01:36:53 +08:00
feat(system): 添加系统管理功能模块
- 新增用户管理、部门管理和角色管理页面 - 实现用户列表查询、用户新增、编辑和删除功能 - 添加部门列表查询功能 - 实现角色列表查询功能 - 新增用户对话框组件用于用户信息录入 - 添加重置密码对话框组件用于修改用户密码 - 新增系统管理相关API接口
This commit is contained in:
298
src/api/generatedApi/system.js
Normal file
298
src/api/generatedApi/system.js
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
import request from '@/assets/js/utils/request'
|
||||||
|
import getUrl from '@/assets/js/utils/get-url'
|
||||||
|
|
||||||
|
// 用户新增
|
||||||
|
export function addUser(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/sysUser/create'),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//用户编辑
|
||||||
|
export function updateUser(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/sysUser/update'),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 用户删除
|
||||||
|
export function deleteUser(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/sysUser/delete'),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 查询用户详情
|
||||||
|
export function queryUserDetail(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/sysUser/query'),
|
||||||
|
method: 'get',
|
||||||
|
params: params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 用户分页查询
|
||||||
|
export function getUserPage(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/sysUser/page'),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改用户状态
|
||||||
|
export function changeUserStatus(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/sysUserEx/changeUserStatus'),
|
||||||
|
method: 'get',
|
||||||
|
params: params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 重置密码
|
||||||
|
export function updatePassword(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/sysUser/updatePassword`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function datasetsExTaskPages(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/taskPage`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//minerU 获取bbox
|
||||||
|
export function minerUBbox(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/document/mineru/bbox_json'),
|
||||||
|
method: 'get',
|
||||||
|
params: params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//minerU 重试
|
||||||
|
export function minerURetry(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/document/mineru/retry'),
|
||||||
|
method: 'get',
|
||||||
|
params: params,
|
||||||
|
noLoading: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//minerU 获取文档处理状态
|
||||||
|
export function minerUQuery(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl('/dataset/document/query'),
|
||||||
|
method: 'get',
|
||||||
|
params: params,
|
||||||
|
noLoading: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//minerU 获取markdown
|
||||||
|
export function minerUMarkDown(params) {
|
||||||
|
return getUrl(`/document/mineru/md?documentId=${params.documentId}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// minerU 获取pdf
|
||||||
|
export function getPdfUrl(params) {
|
||||||
|
return getUrl(`/datasetDocumentEx/preview?id=${params.documentId}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function minerUMarkDownUpdate(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/document/mineru/md/update`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 规则分页
|
||||||
|
export function getRulesPage(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/rules/page`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function getRulesList(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/rules/list`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 拆分规则-新增
|
||||||
|
export function addRuleSplit(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/ruleDocSplitEx/create`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 拆分规则-详情
|
||||||
|
export function getRuleDetail(id) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/rulesEx/query?id=${id}`),
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 拆分规则-编辑
|
||||||
|
export function updateRuleSplit(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/ruleDocSplitEx/update`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 拆分规则-下一步校验
|
||||||
|
export function execSplit(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/execSplit`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 拆分结果预览
|
||||||
|
export function splitResultPreview(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/split/preview`),
|
||||||
|
method: 'get',
|
||||||
|
params: params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 题词-新增
|
||||||
|
export function addRuleExtract(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/ruleAttributeExtractEx/create`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 题词-编辑
|
||||||
|
export function updateRuleExtractSplit(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/ruleAttributeExtractEx/update`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 题词-下一步校验
|
||||||
|
export function execExtract(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/execExtract`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 题词-查询题词结果详情
|
||||||
|
export function getExtractResultList(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/document/attribute/extract/result/list`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 题词-保存
|
||||||
|
export function saveContentToDocument(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/saveContentToDocument`),
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//知识库文件上传-自定义
|
||||||
|
export function uploadFileByCustom(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/uploadFileByCustom`),
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//知识库文件上传-通用
|
||||||
|
export function uploadFileByTemplate(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/uploadFileByTemplate`),
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 知识库文件详情
|
||||||
|
export function datasetQuerySegments(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/querySegments`),
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 知识文档详情查询(包含json的题词和拆分规则)
|
||||||
|
export function datasetDocumentEx(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/query`),
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 任务轨迹查看详情
|
||||||
|
export function getTaskDetail(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/query`),
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 知识库文件删除
|
||||||
|
export function datasetQueryDelete(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/delete?documentId=${data.id}`),
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryTask(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/datasetDocumentEx/queryTask`),
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 识别页面表格
|
||||||
|
|
||||||
|
export function imageRetry(data) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/document/mineru/img/retry`),
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
noLoading: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMd_info(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/document/mineru/md_info`),
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
noLoading: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function mdIndex(params) {
|
||||||
|
return request({
|
||||||
|
url: getUrl(`/document/mineru/md`),
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
noLoading: true,
|
||||||
|
back: true
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -137,5 +137,45 @@ export default [
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system',
|
||||||
|
name: 'system',
|
||||||
|
component: layout,
|
||||||
|
redirect: '/system/user',
|
||||||
|
meta: {
|
||||||
|
title: '系统管理',
|
||||||
|
icon: 'el-icon-setting',
|
||||||
|
affix: true
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '/system/user',
|
||||||
|
name: 'system-user',
|
||||||
|
component: () => import('@/views/system/user/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '用户管理',
|
||||||
|
icon: 'el-icon-user'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/department',
|
||||||
|
name: 'system-department',
|
||||||
|
component: () => import('@/views/system/department/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '部门管理',
|
||||||
|
icon: 'el-icon-office-building'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/role',
|
||||||
|
name: 'system-role',
|
||||||
|
component: () => import('@/views/system/role/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '角色管理',
|
||||||
|
icon: 'el-icon-s-custom'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
115
src/views/system/department/index.vue
Normal file
115
src/views/system/department/index.vue
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
<template>
|
||||||
|
<div class="department-manage">
|
||||||
|
<el-card>
|
||||||
|
<div class="filter-container">
|
||||||
|
<el-form :model="queryParams" label-width="100px" class="demo-form-inline">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="部门类型">
|
||||||
|
<el-select v-model="queryParams.deptType" placeholder="全部规则" clearable style="width: 100%" size="small">
|
||||||
|
<el-option label="总部" value="headquarters" />
|
||||||
|
<el-option label="分部" value="branch" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="部门名称">
|
||||||
|
<el-input v-model="queryParams.name" placeholder="请输入部门名称" clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.dateRange"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
style="width: 100%"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" size="medium" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button type="primary" plain size="medium" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="departmentList" row-key="id" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
|
||||||
|
<el-table-column prop="name" label="部门名称" />
|
||||||
|
<el-table-column prop="leader" label="负责人" />
|
||||||
|
<el-table-column prop="phone" label="联系电话" />
|
||||||
|
<el-table-column prop="email" label="邮箱" />
|
||||||
|
<el-table-column prop="status" label="状态">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">
|
||||||
|
{{ scope.row.status === 1 ? '启用' : '禁用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="orderNum" label="排序" />
|
||||||
|
<el-table-column label="操作" width="200">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'DepartmentManage',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
departmentList: [],
|
||||||
|
queryParams: {
|
||||||
|
deptType: '',
|
||||||
|
name: '',
|
||||||
|
dateRange: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleQuery() {
|
||||||
|
// TODO: 实现查询逻辑
|
||||||
|
},
|
||||||
|
resetQuery() {
|
||||||
|
this.queryParams.deptType = ''
|
||||||
|
this.queryParams.name = ''
|
||||||
|
this.queryParams.dateRange = []
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
// TODO: 实现编辑逻辑
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.department-manage {
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.el-form-item {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
.el-form-item__label {
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
140
src/views/system/role/index.vue
Normal file
140
src/views/system/role/index.vue
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<template>
|
||||||
|
<div class="role-manage">
|
||||||
|
<el-card>
|
||||||
|
<div class="filter-container">
|
||||||
|
<el-form :model="queryParams" label-width="100px" class="demo-form-inline">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="规则类型">
|
||||||
|
<el-select v-model="queryParams.type" placeholder="全部规则" clearable style="width: 100%" size="small">
|
||||||
|
<el-option label="全部规则" value="" />
|
||||||
|
<el-option label="规则一" value="1" />
|
||||||
|
<el-option label="规则二" value="2" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="规则名称">
|
||||||
|
<el-input v-model="queryParams.name" placeholder="请输入规则名称" clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.dateRange"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
style="width: 100%"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" size="medium" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button type="primary" plain size="medium" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="roleList">
|
||||||
|
<el-table-column type="index" label="序号" width="50" />
|
||||||
|
<el-table-column prop="name" label="角色名称" />
|
||||||
|
<el-table-column prop="code" label="角色编码" />
|
||||||
|
<el-table-column prop="description" label="角色描述" />
|
||||||
|
<el-table-column prop="status" label="状态">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">
|
||||||
|
{{ scope.row.status === 1 ? '启用' : '禁用' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="250">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="text" @click="handlePermission(scope.row)">权限设置</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
:current-page.sync="queryParams.pageNum"
|
||||||
|
:page-size.sync="queryParams.pageSize"
|
||||||
|
:total="total"
|
||||||
|
:page-sizes="[10, 20, 30, 50]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'RoleManage',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
total: 0,
|
||||||
|
roleList: [],
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
type: '',
|
||||||
|
name: '',
|
||||||
|
dateRange: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleQuery() {
|
||||||
|
// TODO: 实现查询逻辑
|
||||||
|
},
|
||||||
|
resetQuery() {
|
||||||
|
this.queryParams.type = ''
|
||||||
|
this.queryParams.name = ''
|
||||||
|
this.queryParams.dateRange = []
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
// TODO: 实现编辑逻辑
|
||||||
|
},
|
||||||
|
handlePermission(row) {
|
||||||
|
// TODO: 实现权限设置逻辑
|
||||||
|
},
|
||||||
|
handleSizeChange(val) {
|
||||||
|
this.queryParams.pageSize = val
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
handleCurrentChange(val) {
|
||||||
|
this.queryParams.pageNum = val
|
||||||
|
this.handleQuery()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.role-manage {
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.el-form-item {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
.el-form-item__label {
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
102
src/views/system/user/components/ResetPasswordDialog.vue
Normal file
102
src/views/system/user/components/ResetPasswordDialog.vue
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog title="重置密码" :visible.sync="visible" width="500px" append-to-body @close="handleClose">
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px" status-icon>
|
||||||
|
<el-form-item label="旧密码" prop="userPassword">
|
||||||
|
<el-input v-model="form.userPassword" placeholder="请输入旧密码" type="password" show-password clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新密码" prop="newPassword">
|
||||||
|
<el-input v-model="form.newPassword" placeholder="请输入新密码" type="password" show-password clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="确认新密码" prop="confirmPassword">
|
||||||
|
<el-input v-model="form.confirmPassword" placeholder="请再次输入新密码" type="password" show-password clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" size="small" :loading="loading" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button size="small" @click="handleClose">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { updatePassword } from '@/api/generatedApi/system'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ResetPasswordDialog',
|
||||||
|
props: {
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
// 确认密码验证
|
||||||
|
const validateConfirmPassword = (rule, value, callback) => {
|
||||||
|
if (value !== this.form.newPassword) {
|
||||||
|
callback(new Error('两次输入的密码不一致'))
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
form: {
|
||||||
|
userPassword: '',
|
||||||
|
newPassword: '',
|
||||||
|
confirmPassword: ''
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
userPassword: [{ required: true, message: '请输入旧密码', trigger: 'blur' }],
|
||||||
|
newPassword: [{ required: true, message: '请输入新密码', trigger: 'blur' }, { min: 6, message: '密码长度不能少于6个字符', trigger: 'blur' }],
|
||||||
|
confirmPassword: [{ required: true, message: '请再次输入新密码', trigger: 'blur' }, { validator: validateConfirmPassword, trigger: 'blur' }]
|
||||||
|
},
|
||||||
|
loading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleClose() {
|
||||||
|
this.$refs.form.resetFields()
|
||||||
|
this.$emit('update:visible', false)
|
||||||
|
},
|
||||||
|
submitForm() {
|
||||||
|
this.$refs.form.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true
|
||||||
|
const data = {
|
||||||
|
userId: this.userId,
|
||||||
|
userPassword: this.form.userPassword,
|
||||||
|
newPassword: this.form.newPassword
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePassword(data)
|
||||||
|
.then(response => {
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.$message.success('密码重置成功')
|
||||||
|
this.handleClose()
|
||||||
|
this.$emit('success')
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || '密码重置失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('密码重置出错:', error)
|
||||||
|
this.$message.error('密码重置出错')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.dialog-footer {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
203
src/views/system/user/components/UserDialog.vue
Normal file
203
src/views/system/user/components/UserDialog.vue
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :title="title" :visible.sync="visible" width="800px" append-to-body @close="handleClose">
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户编码" prop="userCode">
|
||||||
|
<el-input v-model="form.userCode" placeholder="请输入用户编码" clearable size="small" :disabled="isView || isEdit" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input v-model="form.userName" placeholder="请输入用户名称" clearable size="small" :disabled="isView" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="20" v-if="!isView">
|
||||||
|
<el-col :span="12" v-if="!isEdit">
|
||||||
|
<el-form-item label="密码" prop="password">
|
||||||
|
<el-input v-model="form.password" placeholder="请输入密码" clearable type="password" size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="form.status" :disabled="isView">
|
||||||
|
<el-radio :label="0">启用</el-radio>
|
||||||
|
<el-radio :label="1">停用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="20" v-else>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-radio-group v-model="form.status" :disabled="isView">
|
||||||
|
<el-radio :label="0">启用</el-radio>
|
||||||
|
<el-radio :label="1">停用</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="真实姓名" prop="realName">
|
||||||
|
<el-input v-model="form.realName" placeholder="请输入真实姓名" clearable size="small" :disabled="isView" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="工号" prop="jobNo">
|
||||||
|
<el-input v-model="form.jobNo" placeholder="请输入工号" clearable size="small" :disabled="isView" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="手机号" prop="mobile">
|
||||||
|
<el-input v-model="form.mobile" placeholder="请输入手机号" clearable size="small" :disabled="isView" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input v-model="form.email" placeholder="请输入邮箱" clearable size="small" :disabled="isView" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="钉钉ID" prop="dingtalkId">
|
||||||
|
<el-input v-model="form.dingtalkId" placeholder="请输入钉钉ID" clearable size="small" :disabled="isView" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户角色" prop="userRoles">
|
||||||
|
<el-select v-model="form.userRoles" placeholder="请选择用户角色" clearable size="small" :disabled="isView">
|
||||||
|
<el-option v-for="item in roleOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer" v-if="!isView">
|
||||||
|
<el-button type="primary" size="small" :loading="loading" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button size="small" @click="handleClose">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
<div slot="footer" class="dialog-footer" v-else>
|
||||||
|
<el-button size="small" @click="handleClose">关 闭</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { addUser, updateUser } from '@/api/generatedApi/system'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'UserDialog',
|
||||||
|
props: {
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '添加用户'
|
||||||
|
},
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
userData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
isEdit: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
isView: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
form: {
|
||||||
|
userRoles: '',
|
||||||
|
userCode: '',
|
||||||
|
userName: '',
|
||||||
|
status: 0,
|
||||||
|
dingtalkId: '',
|
||||||
|
password: '',
|
||||||
|
realName: '',
|
||||||
|
jobNo: '',
|
||||||
|
mobile: '',
|
||||||
|
email: '',
|
||||||
|
sysUserRoleDTOs: []
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
userCode: [{ required: true, message: '请输入用户编码', trigger: 'blur' }],
|
||||||
|
userName: [{ required: true, message: '请输入用户名称', trigger: 'blur' }],
|
||||||
|
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
|
||||||
|
},
|
||||||
|
roleOptions: [{ value: 'admin', label: '管理员' }, { value: 'user', label: '普通用户' }],
|
||||||
|
loading: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
userData: {
|
||||||
|
handler(val) {
|
||||||
|
if (val && Object.keys(val).length > 0) {
|
||||||
|
this.form = { ...val }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleClose() {
|
||||||
|
this.$refs.form.resetFields()
|
||||||
|
this.$emit('update:visible', false)
|
||||||
|
},
|
||||||
|
submitForm() {
|
||||||
|
// 查看模式下不允许提交
|
||||||
|
if (this.isView) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$refs.form.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true
|
||||||
|
const submitData = { ...this.form }
|
||||||
|
|
||||||
|
// 根据是否是编辑模式调用不同的API
|
||||||
|
const apiRequest = this.isEdit ? updateUser(submitData) : addUser(submitData)
|
||||||
|
|
||||||
|
apiRequest
|
||||||
|
.then(response => {
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.$message.success(this.isEdit ? '修改成功' : '添加成功')
|
||||||
|
this.$emit('submit', submitData)
|
||||||
|
this.handleClose()
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || (this.isEdit ? '修改失败' : '添加失败'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(this.isEdit ? '修改用户出错:' : '添加用户出错:', error)
|
||||||
|
this.$message.error(this.isEdit ? '修改用户出错' : '添加用户出错')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.dialog-footer {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
380
src/views/system/user/index.vue
Normal file
380
src/views/system/user/index.vue
Normal file
@@ -0,0 +1,380 @@
|
|||||||
|
<template>
|
||||||
|
<div class="user-manage">
|
||||||
|
<el-card>
|
||||||
|
<div class="filter-container">
|
||||||
|
<el-form :model="queryParams" label-width="100px" class="demo-form-inline">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="用户类型">
|
||||||
|
<el-select v-model="queryParams.userRoles" placeholder="请选择用户类型" clearable size="small">
|
||||||
|
<el-option label="管理员" value="admin" />
|
||||||
|
<el-option label="普通用户" value="user" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="用户编码">
|
||||||
|
<el-input v-model="queryParams.userCodeLike" placeholder="请输入用户编码" clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="用户名称">
|
||||||
|
<el-input v-model="queryParams.userNameLike" placeholder="请输入用户名称" clearable size="small" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="创建时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.dateRange"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
size="small"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" size="medium" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button type="primary" plain size="medium" @click="resetQuery">重置</el-button>
|
||||||
|
<el-button type="primary" size="medium" @click="handleAdd">新增</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
<r-table
|
||||||
|
:columns="tableConfig.columns"
|
||||||
|
:data="tableData"
|
||||||
|
:deletion="false"
|
||||||
|
:total="tableConfig.total"
|
||||||
|
@currentChange="handleCurrentChange"
|
||||||
|
@sizeChange="handleSizeChange"
|
||||||
|
:currentPage="tableConfig.currentPage"
|
||||||
|
:pageSize="tableConfig.pageSize"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 用户新增弹窗 -->
|
||||||
|
<user-dialog :visible.sync="dialogVisible" :title="dialogTitle" :is-edit="isEdit" :is-view="isView" :user-data="currentUserData" @submit="handleSubmit" />
|
||||||
|
|
||||||
|
<!-- 重置密码弹窗 -->
|
||||||
|
<reset-password-dialog :visible.sync="resetPasswordVisible" :user-id="currentUserId" @success="getUserList" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import UserDialog from './components/UserDialog.vue'
|
||||||
|
import ResetPasswordDialog from './components/ResetPasswordDialog.vue'
|
||||||
|
import { getUserPage, queryUserDetail, deleteUser, changeUserStatus, updatePassword } from '@/api/generatedApi/system'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'UserManage',
|
||||||
|
components: {
|
||||||
|
UserDialog,
|
||||||
|
ResetPasswordDialog
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
dialogVisible: false,
|
||||||
|
resetPasswordVisible: false,
|
||||||
|
dialogTitle: '添加用户',
|
||||||
|
isEdit: false,
|
||||||
|
isView: false,
|
||||||
|
currentUserData: {},
|
||||||
|
currentUserId: '',
|
||||||
|
queryParams: {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
userRoles: '',
|
||||||
|
userCodeLike: '',
|
||||||
|
userNameLike: '',
|
||||||
|
status: '',
|
||||||
|
dateRange: []
|
||||||
|
},
|
||||||
|
// 表格配置项
|
||||||
|
tableConfig: {
|
||||||
|
total: 0,
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
columns: [
|
||||||
|
{ prop: 'userCode', key: '用户编码' },
|
||||||
|
{ prop: 'userName', key: '用户名称' },
|
||||||
|
{ prop: 'realName', key: '真实姓名' },
|
||||||
|
{ prop: 'jobNo', key: '工号' },
|
||||||
|
{ prop: 'mobile', key: '手机号' },
|
||||||
|
{ prop: 'email', key: '邮箱' },
|
||||||
|
{ prop: 'userRoles', key: '用户角色' },
|
||||||
|
{
|
||||||
|
prop: 'status',
|
||||||
|
key: '状态',
|
||||||
|
render: (h, params) => {
|
||||||
|
return h(
|
||||||
|
'el-tag',
|
||||||
|
{
|
||||||
|
props: {
|
||||||
|
type: params.row.status === 0 ? 'success' : 'danger',
|
||||||
|
size: 'small'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
params.row.status === 0 ? '启用' : '停用'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: '操作',
|
||||||
|
render: (h, params) => {
|
||||||
|
return h('div', [
|
||||||
|
h(
|
||||||
|
'el-button',
|
||||||
|
{
|
||||||
|
props: { type: 'text', size: 'mini' },
|
||||||
|
on: { click: () => this.handleEdit(params.row) }
|
||||||
|
},
|
||||||
|
'编辑'
|
||||||
|
),
|
||||||
|
// h(
|
||||||
|
// 'el-button',
|
||||||
|
// {
|
||||||
|
// props: { type: 'text', size: 'mini' },
|
||||||
|
// on: { click: () => this.handleInfoVisible(params.row) }
|
||||||
|
// },
|
||||||
|
// '查看详情'
|
||||||
|
// ),
|
||||||
|
h(
|
||||||
|
'el-button',
|
||||||
|
{
|
||||||
|
props: {
|
||||||
|
type: 'text',
|
||||||
|
size: 'mini',
|
||||||
|
style: params.row.status === 0 ? 'color: #F56C6C' : 'color: #67C23A'
|
||||||
|
},
|
||||||
|
on: { click: () => this.handleToggleStatus(params.row) }
|
||||||
|
},
|
||||||
|
params.row.status === 0 ? '停用' : '启用'
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
'el-button',
|
||||||
|
{
|
||||||
|
props: { type: 'text', size: 'mini', style: 'color: #409EFF' },
|
||||||
|
on: { click: () => this.handleResetPassword(params.row) }
|
||||||
|
},
|
||||||
|
'重置密码'
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
'el-button',
|
||||||
|
{
|
||||||
|
props: { type: 'text', size: 'mini', style: 'color: #F56C6C' },
|
||||||
|
on: { click: () => this.handleDelete(params.row) }
|
||||||
|
},
|
||||||
|
'删除'
|
||||||
|
)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
tableData: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getUserList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 获取用户列表
|
||||||
|
getUserList() {
|
||||||
|
this.loading = true
|
||||||
|
const params = { ...this.queryParams }
|
||||||
|
|
||||||
|
// 处理日期范围
|
||||||
|
if (params.dateRange && params.dateRange.length === 2) {
|
||||||
|
params.startDate = params.dateRange[0]
|
||||||
|
params.endDate = params.dateRange[1]
|
||||||
|
}
|
||||||
|
delete params.dateRange
|
||||||
|
|
||||||
|
getUserPage(params)
|
||||||
|
.then(response => {
|
||||||
|
console.log(response)
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.tableData = response.content.content.list || []
|
||||||
|
this.tableConfig.total = response.content.content.total || 0
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || '获取用户列表失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('获取用户列表出错:', error)
|
||||||
|
this.$message.error('获取用户列表出错')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.page = 1
|
||||||
|
this.getUserList()
|
||||||
|
},
|
||||||
|
resetQuery() {
|
||||||
|
this.queryParams.userRoles = ''
|
||||||
|
this.queryParams.userCodeLike = ''
|
||||||
|
this.queryParams.userNameLike = ''
|
||||||
|
this.queryParams.dateRange = []
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
handleAdd() {
|
||||||
|
this.isEdit = false
|
||||||
|
this.isView = false
|
||||||
|
this.currentUserData = {}
|
||||||
|
this.dialogVisible = true
|
||||||
|
this.dialogTitle = '添加用户'
|
||||||
|
},
|
||||||
|
handleEdit(row) {
|
||||||
|
this.isEdit = true
|
||||||
|
this.isView = false
|
||||||
|
this.dialogTitle = '编辑用户'
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
// 获取用户详情
|
||||||
|
queryUserDetail({ id: row.id })
|
||||||
|
.then(response => {
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.currentUserData = response.content.content || {}
|
||||||
|
this.dialogVisible = true
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || '获取用户详情失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('获取用户详情出错:', error)
|
||||||
|
this.$message.error('获取用户详情出错')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleInfoVisible(row) {
|
||||||
|
// 查看详情逻辑
|
||||||
|
this.isView = true
|
||||||
|
this.isEdit = false
|
||||||
|
this.dialogTitle = '查看用户详情'
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
// 获取用户详情
|
||||||
|
queryUserDetail({ id: row.id })
|
||||||
|
.then(response => {
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.currentUserData = response.content.content || {}
|
||||||
|
this.dialogVisible = true
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || '获取用户详情失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('获取用户详情出错:', error)
|
||||||
|
this.$message.error('获取用户详情出错')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleSubmit(formData) {
|
||||||
|
this.getUserList() // 提交后刷新列表
|
||||||
|
},
|
||||||
|
handleSizeChange(val) {
|
||||||
|
this.queryParams.pageSize = val
|
||||||
|
this.getUserList()
|
||||||
|
},
|
||||||
|
handleCurrentChange(val) {
|
||||||
|
this.queryParams.page = val
|
||||||
|
this.getUserList()
|
||||||
|
},
|
||||||
|
handleDelete(row) {
|
||||||
|
this.$confirm('确认删除该用户吗?', '警告', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.loading = true
|
||||||
|
// 将id放入数组中传递
|
||||||
|
deleteUser([row.id])
|
||||||
|
.then(response => {
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.$message.success('删除成功')
|
||||||
|
this.getUserList()
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || '删除失败')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('删除用户出错:', error)
|
||||||
|
this.$message.error('删除用户出错')
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message.info('已取消删除')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleToggleStatus(row) {
|
||||||
|
const statusText = row.status === 0 ? '停用' : '启用'
|
||||||
|
this.$confirm(`确认${statusText}该用户吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
// 调用changeUserStatus接口
|
||||||
|
const newStatus = row.status === 0 ? 1 : 0 // 切换状态
|
||||||
|
changeUserStatus({
|
||||||
|
userId: row.id,
|
||||||
|
status: newStatus
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.code === '0') {
|
||||||
|
this.$message.success(`${statusText}成功`)
|
||||||
|
this.getUserList() // 刷新列表
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.msg || `${statusText}失败`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(`${statusText}用户出错:`, error)
|
||||||
|
this.$message.error(`${statusText}用户出错`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleResetPassword(row) {
|
||||||
|
this.currentUserId = row.id
|
||||||
|
this.resetPasswordVisible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.user-manage {
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.el-form-item {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
.el-form-item__label {
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user