refactor: 部门API路径同步修改
Former-commit-id: 815be0beaa6aa1c043d91582f7c7ed7fa45c1466
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
DeptFormData,
|
DeptFormData,
|
||||||
DeptItem,
|
DeptItem,
|
||||||
DeptQueryParam,
|
DeptQueryParam
|
||||||
} from '@/types/api/system/dept';
|
} from '@/types/api/system/dept';
|
||||||
import { Option } from '@/types/common';
|
import { Option } from '@/types/common';
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
@@ -18,17 +18,17 @@ export function listDepartments(
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts',
|
url: '/youlai-admin/api/v1/depts',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: queryParams,
|
params: queryParams
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门下拉列表
|
* 部门下拉列表
|
||||||
*/
|
*/
|
||||||
export function listSelectDepartments(): AxiosPromise<Option[]> {
|
export function listDeptOptions(): AxiosPromise<Option[]> {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts/select_list',
|
url: '/youlai-admin/api/v1/depts/options',
|
||||||
method: 'get',
|
method: 'get'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,10 +37,10 @@ export function listSelectDepartments(): AxiosPromise<Option[]> {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
export function getDeptForrmData(id: string): AxiosPromise<DeptFormData> {
|
export function getDeptDetail(id: string): AxiosPromise<DeptFormData> {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts/' + id + '/form_data',
|
url: '/youlai-admin/api/v1/depts/' + id,
|
||||||
method: 'get',
|
method: 'get'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ export function addDept(data: DeptFormData) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts',
|
url: '/youlai-admin/api/v1/depts',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ export function updateDept(id: string, data: DeptFormData) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts/' + id,
|
url: '/youlai-admin/api/v1/depts/' + id,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data,
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +79,6 @@ export function updateDept(id: string, data: DeptFormData) {
|
|||||||
export function deleteDept(ids: string) {
|
export function deleteDept(ids: string) {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts/' + ids,
|
url: '/youlai-admin/api/v1/depts/' + ids,
|
||||||
method: 'delete',
|
method: 'delete'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
name: 'dept',
|
name: 'dept'
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -10,12 +10,12 @@ import { onMounted, reactive, ref, toRefs } from 'vue';
|
|||||||
|
|
||||||
// API依赖
|
// API依赖
|
||||||
import {
|
import {
|
||||||
getDeptForrmData,
|
getDeptDetail,
|
||||||
deleteDept,
|
deleteDept,
|
||||||
updateDept,
|
updateDept,
|
||||||
addDept,
|
addDept,
|
||||||
listSelectDepartments,
|
listDeptOptions,
|
||||||
listDepartments,
|
listDepartments
|
||||||
} from '@/api/system/dept';
|
} from '@/api/system/dept';
|
||||||
|
|
||||||
// 组件依赖
|
// 组件依赖
|
||||||
@@ -24,7 +24,7 @@ import { ElForm, ElMessage, ElMessageBox } from 'element-plus';
|
|||||||
import {
|
import {
|
||||||
DeptFormData,
|
DeptFormData,
|
||||||
DeptItem,
|
DeptItem,
|
||||||
DeptQueryParam,
|
DeptQueryParam
|
||||||
} from '@/types/api/system/dept';
|
} from '@/types/api/system/dept';
|
||||||
import { Dialog, Option } from '@/types/common';
|
import { Dialog, Option } from '@/types/common';
|
||||||
|
|
||||||
@@ -49,16 +49,16 @@ const state = reactive({
|
|||||||
// 表单数据
|
// 表单数据
|
||||||
formData: {
|
formData: {
|
||||||
sort: 1,
|
sort: 1,
|
||||||
status: 1,
|
status: 1
|
||||||
} as DeptFormData,
|
} as DeptFormData,
|
||||||
// 表单参数校验
|
// 表单参数校验
|
||||||
rules: {
|
rules: {
|
||||||
parentId: [
|
parentId: [
|
||||||
{ required: true, message: '上级部门不能为空', trigger: 'blur' },
|
{ required: true, message: '上级部门不能为空', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
name: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
|
name: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
|
||||||
sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }],
|
sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }]
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -69,7 +69,7 @@ const {
|
|||||||
queryParams,
|
queryParams,
|
||||||
formData,
|
formData,
|
||||||
rules,
|
rules,
|
||||||
dialog,
|
dialog
|
||||||
} = toRefs(state);
|
} = toRefs(state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,11 +101,11 @@ function handleSelectionChange(selection: any) {
|
|||||||
*/
|
*/
|
||||||
async function loadDeptData() {
|
async function loadDeptData() {
|
||||||
const deptOptions: any[] = [];
|
const deptOptions: any[] = [];
|
||||||
listSelectDepartments().then((response) => {
|
listDeptOptions().then(response => {
|
||||||
const rootDeptOption = {
|
const rootDeptOption = {
|
||||||
value: '0',
|
value: '0',
|
||||||
label: '顶级部门',
|
label: '顶级部门',
|
||||||
children: response.data,
|
children: response.data
|
||||||
};
|
};
|
||||||
deptOptions.push(rootDeptOption);
|
deptOptions.push(rootDeptOption);
|
||||||
state.deptOptions = deptOptions;
|
state.deptOptions = deptOptions;
|
||||||
@@ -121,7 +121,7 @@ function handleAdd(row: any) {
|
|||||||
state.formData.parentId = row.id;
|
state.formData.parentId = row.id;
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: '添加部门',
|
title: '添加部门',
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,9 +133,9 @@ async function handleUpdate(row: any) {
|
|||||||
const deptId = row.id || state.ids;
|
const deptId = row.id || state.ids;
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: '修改部门',
|
title: '修改部门',
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
getDeptForrmData(deptId).then((response: any) => {
|
getDeptDetail(deptId).then((response: any) => {
|
||||||
state.formData = response.data;
|
state.formData = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ function handleDelete(row: any) {
|
|||||||
ElMessageBox.confirm(`确认删除已选中的数据项?`, '警告', {
|
ElMessageBox.confirm(`确认删除已选中的数据项?`, '警告', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning'
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
deleteDept(ids)
|
deleteDept(ids)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
exportUser,
|
exportUser,
|
||||||
importUser
|
importUser
|
||||||
} from '@/api/system/user';
|
} from '@/api/system/user';
|
||||||
import { listSelectDepartments } from '@/api/system/dept';
|
import { listDeptOptions } from '@/api/system/dept';
|
||||||
import { listRoleOptions } from '@/api/system/role';
|
import { listRoleOptions } from '@/api/system/role';
|
||||||
|
|
||||||
// 组件依赖
|
// 组件依赖
|
||||||
@@ -358,7 +358,7 @@ function cancel() {
|
|||||||
* 加载部门
|
* 加载部门
|
||||||
*/
|
*/
|
||||||
async function loadDeptOptions() {
|
async function loadDeptOptions() {
|
||||||
listSelectDepartments().then(response => {
|
listDeptOptions().then(response => {
|
||||||
state.deptOptions = response.data;
|
state.deptOptions = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user