refactor(jnh): 优化账号管理相关代码结构
- 移除页面中的模拟数据,使用空数组初始化 - 统一API请求参数命名,将params改为data - 重构表单处理逻辑,使用reactive替代ref - 简化表单提交时的参数处理
This commit is contained in:
parent
5fda4e4df8
commit
849aa507f8
|
|
@ -1,38 +1,40 @@
|
||||||
import request from '/@/utils/request';
|
import request from '/@/utils/request';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 获取账号列表
|
// 获取账号列表
|
||||||
export const getAccounts = (params: any) => {
|
export const getAccounts = (data: any) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/jnh/accounts/page',
|
url: '/jnh/accounts/page',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加账号
|
// 添加账号
|
||||||
export const addOrUpdate = (params: any) => {
|
export const addOrUpdate = (data: any) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/jnh/accounts/addOrUpdate',
|
url: '/jnh/accounts/addOrUpdate',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除账号
|
// 删除账号
|
||||||
export const deleteAccount = (params: any) => {
|
export const deleteAccount = (data: any) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/jnh/accounts/remove',
|
url: '/jnh/accounts/remove',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 账号启用/禁用
|
// 账号启用/禁用
|
||||||
export const updateStatus = (params: any) => {
|
export const updateStatus = (data: any) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/jnh/accounts/status',
|
url: '/jnh/accounts/status',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,10 +47,10 @@ export const getUploadUrl = (data: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重置密码
|
// 重置密码
|
||||||
export const resetPassword = (params: any) => {
|
export const resetPassword = (data: any) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/user/password/reset',
|
url: '/user/password/reset',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<el-dialog v-model="dialogTableVisible" :title="form.id ? '账号编辑' : '账号创建'" width="600" @closed="closeDialog">
|
<el-dialog v-model="dialogTableVisible" :title="form.id ? '账号编辑' : '账号创建'" width="600" @closed="closeDialog">
|
||||||
<el-form :model="form" label-width="auto" :rules="rules" ref="ruleFormRef">
|
<el-form :model="form" label-width="auto" :rules="rules" ref="ruleFormRef">
|
||||||
<el-form-item label="姓名" prop="name">
|
<el-form-item label="姓名" prop="name">
|
||||||
<el-input v-model="form.name" placeholder="请输入姓名" />
|
<el-input v-model="form.name" placeholder="请输入姓名"> </el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="部门名称" prop="department">
|
<el-form-item label="部门名称" prop="department">
|
||||||
|
|
@ -37,14 +37,14 @@ const rules = reactive({
|
||||||
mobile: [{ required: true, message: '必须填写手机号码', trigger: 'blur' }],
|
mobile: [{ required: true, message: '必须填写手机号码', trigger: 'blur' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
const form = ref({});
|
const form = reactive({});
|
||||||
const dialogTableVisible = ref(false);
|
const dialogTableVisible = ref(false);
|
||||||
|
|
||||||
function open(data) {
|
function open(data) {
|
||||||
console.log('🚀 ~ open ~ data:', data);
|
console.log('🚀 ~ open ~ data:', data);
|
||||||
dialogTableVisible.value = true;
|
dialogTableVisible.value = true;
|
||||||
if (data) {
|
if (data) {
|
||||||
form.value = data;
|
Object.assign(form, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function close() {
|
function close() {
|
||||||
|
|
@ -55,7 +55,9 @@ const ruleFormRef = ref(null);
|
||||||
async function submit() {
|
async function submit() {
|
||||||
await ruleFormRef.value.validate();
|
await ruleFormRef.value.validate();
|
||||||
|
|
||||||
addOrUpdate(form.value).then((res) => {
|
addOrUpdate({
|
||||||
|
...form,
|
||||||
|
}).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
ElMessage.success('操作成功');
|
ElMessage.success('操作成功');
|
||||||
close();
|
close();
|
||||||
|
|
|
||||||
|
|
@ -62,29 +62,10 @@ import { ElMessage, ElMessageBox } from 'element-plus';
|
||||||
import addDialog from '/@/views/pages/jnh/add.vue';
|
import addDialog from '/@/views/pages/jnh/add.vue';
|
||||||
import importDialog from '/@/views/pages/jnh/import.vue';
|
import importDialog from '/@/views/pages/jnh/import.vue';
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({});
|
||||||
keyword: '',
|
|
||||||
});
|
|
||||||
|
|
||||||
const tableData = reactive({
|
const tableData = reactive({
|
||||||
data: [
|
data: [],
|
||||||
{
|
|
||||||
name: 'string',
|
|
||||||
mobile: 'string',
|
|
||||||
createTime: 'string',
|
|
||||||
updateTime: 'string',
|
|
||||||
status: '0',
|
|
||||||
department: 'sdfa',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'string',
|
|
||||||
mobile: 'string',
|
|
||||||
createTime: 'string',
|
|
||||||
updateTime: 'string',
|
|
||||||
status: '1',
|
|
||||||
department: 'sdfa',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
total: 0,
|
total: 0,
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 20,
|
size: 20,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue