From e73d6759ed6dd4c0e6d05604a829445dedd90cef Mon Sep 17 00:00:00 2001 From: horizon <1490493387@qq.com> Date: Mon, 5 Sep 2022 07:52:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=83=A8=E9=97=A8API=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 815be0beaa6aa1c043d91582f7c7ed7fa45c1466 --- src/api/system/dept.ts | 22 +++++++++++----------- src/views/system/dept/index.vue | 32 ++++++++++++++++---------------- src/views/system/user/index.vue | 4 ++-- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts index b1b859f8..cb801fb2 100644 --- a/src/api/system/dept.ts +++ b/src/api/system/dept.ts @@ -1,7 +1,7 @@ import { DeptFormData, DeptItem, - DeptQueryParam, + DeptQueryParam } from '@/types/api/system/dept'; import { Option } from '@/types/common'; import request from '@/utils/request'; @@ -18,17 +18,17 @@ export function listDepartments( return request({ url: '/youlai-admin/api/v1/depts', method: 'get', - params: queryParams, + params: queryParams }); } /** * 部门下拉列表 */ -export function listSelectDepartments(): AxiosPromise { +export function listDeptOptions(): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/depts/select_list', - method: 'get', + url: '/youlai-admin/api/v1/depts/options', + method: 'get' }); } @@ -37,10 +37,10 @@ export function listSelectDepartments(): AxiosPromise { * * @param id */ -export function getDeptForrmData(id: string): AxiosPromise { +export function getDeptDetail(id: string): AxiosPromise { return request({ - url: '/youlai-admin/api/v1/depts/' + id + '/form_data', - method: 'get', + url: '/youlai-admin/api/v1/depts/' + id, + method: 'get' }); } @@ -53,7 +53,7 @@ export function addDept(data: DeptFormData) { return request({ url: '/youlai-admin/api/v1/depts', method: 'post', - data: data, + data: data }); } @@ -67,7 +67,7 @@ export function updateDept(id: string, data: DeptFormData) { return request({ url: '/youlai-admin/api/v1/depts/' + id, method: 'put', - data: data, + data: data }); } @@ -79,6 +79,6 @@ export function updateDept(id: string, data: DeptFormData) { export function deleteDept(ids: string) { return request({ url: '/youlai-admin/api/v1/depts/' + ids, - method: 'delete', + method: 'delete' }); } diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index d669fce0..cccd6d11 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -1,6 +1,6 @@ @@ -10,12 +10,12 @@ import { onMounted, reactive, ref, toRefs } from 'vue'; // API依赖 import { - getDeptForrmData, + getDeptDetail, deleteDept, updateDept, addDept, - listSelectDepartments, - listDepartments, + listDeptOptions, + listDepartments } from '@/api/system/dept'; // 组件依赖 @@ -24,7 +24,7 @@ import { ElForm, ElMessage, ElMessageBox } from 'element-plus'; import { DeptFormData, DeptItem, - DeptQueryParam, + DeptQueryParam } from '@/types/api/system/dept'; import { Dialog, Option } from '@/types/common'; @@ -49,16 +49,16 @@ const state = reactive({ // 表单数据 formData: { sort: 1, - status: 1, + status: 1 } as DeptFormData, // 表单参数校验 rules: { parentId: [ - { required: true, message: '上级部门不能为空', trigger: 'blur' }, + { required: true, message: '上级部门不能为空', trigger: 'blur' } ], name: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }], - sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }], - }, + sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }] + } }); const { @@ -69,7 +69,7 @@ const { queryParams, formData, rules, - dialog, + dialog } = toRefs(state); /** @@ -101,11 +101,11 @@ function handleSelectionChange(selection: any) { */ async function loadDeptData() { const deptOptions: any[] = []; - listSelectDepartments().then((response) => { + listDeptOptions().then(response => { const rootDeptOption = { value: '0', label: '顶级部门', - children: response.data, + children: response.data }; deptOptions.push(rootDeptOption); state.deptOptions = deptOptions; @@ -121,7 +121,7 @@ function handleAdd(row: any) { state.formData.parentId = row.id; state.dialog = { title: '添加部门', - visible: true, + visible: true }; } @@ -133,9 +133,9 @@ async function handleUpdate(row: any) { const deptId = row.id || state.ids; state.dialog = { title: '修改部门', - visible: true, + visible: true }; - getDeptForrmData(deptId).then((response: any) => { + getDeptDetail(deptId).then((response: any) => { state.formData = response.data; }); } @@ -173,7 +173,7 @@ function handleDelete(row: any) { ElMessageBox.confirm(`确认删除已选中的数据项?`, '警告', { confirmButtonText: '确定', cancelButtonText: '取消', - type: 'warning', + type: 'warning' }) .then(() => { deleteDept(ids) diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index f54348a0..9b3f6f34 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -28,7 +28,7 @@ import { exportUser, importUser } from '@/api/system/user'; -import { listSelectDepartments } from '@/api/system/dept'; +import { listDeptOptions } from '@/api/system/dept'; import { listRoleOptions } from '@/api/system/role'; // 组件依赖 @@ -358,7 +358,7 @@ function cancel() { * 加载部门 */ async function loadDeptOptions() { - listSelectDepartments().then(response => { + listDeptOptions().then(response => { state.deptOptions = response.data; }); }