refactor: 部门API路径同步修改

This commit is contained in:
horizon 2022-09-05 07:52:48 +08:00
parent 4e60ff0a8d
commit 815be0beaa
3 changed files with 29 additions and 29 deletions

View File

@ -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<Option[]> {
export function listDeptOptions(): AxiosPromise<Option[]> {
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<Option[]> {
*
* @param id
*/
export function getDeptForrmData(id: string): AxiosPromise<DeptFormData> {
export function getDeptDetail(id: string): AxiosPromise<DeptFormData> {
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'
});
}

View File

@ -1,6 +1,6 @@
<script lang="ts">
export default {
name: 'dept',
name: 'dept'
};
</script>
@ -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)

View File

@ -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;
});
}