From 16ebb4eb229f1466207cba34b46b4c6c137137d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Tue, 18 Jan 2022 23:30:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(dept/index.vue):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=86=99=E6=B3=95=E5=92=8C=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/dept.ts | 58 ++++-- src/components/TreeSelect/index.vue | 25 +-- src/views/dashboard/index.vue | 2 +- src/views/oms/order/index.vue | 103 ++--------- src/views/system/dept/index.vue | 274 +++++++++++++--------------- src/views/system/user/index.vue | 58 +++--- tsconfig.json | 2 +- 7 files changed, 229 insertions(+), 293 deletions(-) diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts index 43123e0..e676cba 100644 --- a/src/api/system/dept.ts +++ b/src/api/system/dept.ts @@ -1,6 +1,11 @@ import request from '@/utils/request' -export const listDept = (queryParams?: object) => { +/** + * 部门树形表格 + * + * @param queryParams + */ +export function listDeptTable(queryParams?: object) { return request({ url: '/youlai-admin/api/v1/depts/table', method: 'get', @@ -8,22 +13,35 @@ export const listDept = (queryParams?: object) => { }) } -export const getDept = (id: any) => { +/** + * 部门下拉列表 + */ +export function listDeptSelect() { return request({ - url: '/youlai-admin/api/v1/depts/'+id, + url: '/youlai-admin/api/v1/depts/select', method: 'get' }) } -export const delDept = (id: any) => { +/** + * 获取部门详情 + * + * @param id + */ +export function getDeptDetail(id: any) { return request({ - url: '/youlai-admin/api/v1/depts/'+id, - method: 'delete', + url: '/youlai-admin/api/v1/depts/' + id, + method: 'get' }) } -// 新增部门 -export const addDept = (data: any) => { + +/** + * 新增部门 + * + * @param data + */ +export function addDept(data: any) { return request({ url: '/youlai-admin/api/v1/depts', method: 'post', @@ -31,19 +49,29 @@ export const addDept = (data: any) => { }) } -// 修改部门 -export const updateDept = (id:number,data: any) => { +/** + * 修改部门 + * + * @param id + * @param data + */ +export function updateDept(id: number, data: any) { return request({ - url: '/youlai-admin/api/v1/depts/'+id, + url: '/youlai-admin/api/v1/depts/' + id, method: 'put', data: data }) } - -export const listDeptsForSelect = ()=> { +/** + * 删除部门 + * + * @param id + */ +export function deleteDept(id: any) { return request({ - url: '/youlai-admin/api/v1/depts/select', - method: 'get' + url: '/youlai-admin/api/v1/depts/' + id, + method: 'delete', }) } + diff --git a/src/components/TreeSelect/index.vue b/src/components/TreeSelect/index.vue index c909093..51161ff 100644 --- a/src/components/TreeSelect/index.vue +++ b/src/components/TreeSelect/index.vue @@ -29,8 +29,9 @@ diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 963cd53..fd13a10 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -334,7 +334,7 @@ placeholder="请选择" > { + listDeptSelect().then(response => { state.deptOptions = response.data }) } @@ -577,7 +577,7 @@ function resetPassword(row: { [key: string]: any }) { } /** - * 用户查询 + * 用户查询 **/ function handleQuery() { state.loading = true @@ -628,7 +628,7 @@ async function handleUpdate(row: { [key: string]: any }) { await loadDeptOptions() await loadRoleOptions() state.dialog = { - title: '添加用户', + title: '修改用户', visible: true } getUserFormDetail(userId).then((response: any) => { @@ -636,25 +636,6 @@ async function handleUpdate(row: { [key: string]: any }) { }) } -/** - * 表单重置 - **/ -function resetForm() { - state.formData = { - id: undefined, - deptId: undefined, - username: undefined, - nickname: undefined, - password: '', - mobile: undefined, - email: undefined, - gender: undefined, - status: 1, - remark: undefined, - roleIds: [] - } -} - /** * 表单提交 @@ -681,7 +662,30 @@ function submitForm() { }) } -/** 删除按钮操作 */ + +/** + * 表单重置 + **/ +function resetForm() { + state.formData = { + id: undefined, + deptId: undefined, + username: undefined, + nickname: undefined, + password: '', + mobile: undefined, + email: undefined, + gender: undefined, + status: 1, + remark: undefined, + roleIds: [] + } +} + + +/** + * 删除用户 + **/ function handleDelete(row: { [key: string]: any }) { const userIds = row.id || state.ids.join(',') ElMessageBox.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?', '警告', { diff --git a/tsconfig.json b/tsconfig.json index fe79317..aee776d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "baseUrl": "./", "paths": { - "@*": ["src/*"], + "@*": ["src/*"] }, "extends": "./tsconfig.extends.json", "skipLibCheck": true, // element-plus 生产打包报错,通过此配置修改 TS 不对第三方依赖类型检查