提交 5e5223dc authored 作者: 詹银鑫's avatar 詹银鑫

feat: 部门管理功能添加

上级 098e0e43
...@@ -44,19 +44,6 @@ export const getMenuList = (data?: object) => { ...@@ -44,19 +44,6 @@ export const getMenuList = (data?: object) => {
return http.request<Result>("post", "/menu", { data }); return http.request<Result>("post", "/menu", { data });
}; };
// {
// name: "杭州总公司",
// parentId: 0,
// id: 100,
// sort: 0,
// phone: "15888888888",
// principal: faker.person.firstName(),
// email: faker.internet.email(),
// status: 1, // 状态 1 启用 0 停用
// type: 1, // 1 公司 2 分公司 3 部门
// createTime: 1605456000000,
// remark: "这里是备注信息这里是备注信息这里是备注信息这里是备注信息"
// },
/** 获取系统管理-部门管理列表 */ /** 获取系统管理-部门管理列表 */
export const getDeptList = (data?: object) => { export const getDeptList = (data?: object) => {
return http.request<Result>("post", "/api/depart/get-depart-list-by-page", { return http.request<Result>("post", "/api/depart/get-depart-list-by-page", {
...@@ -64,6 +51,21 @@ export const getDeptList = (data?: object) => { ...@@ -64,6 +51,21 @@ export const getDeptList = (data?: object) => {
}); });
}; };
/** 新增部门-部门管理列表 */
export const addDept = (data?: object) => {
return http.request<Result>("post", "/api/depart/add-depart", { data });
};
/** 修改部门-部门管理列表 */
export const updateDept = (data?: object) => {
return http.request<Result>("post", `/api/depart/modify-depart`, { data });
};
/** 删除部门-部门管理列表 */
export const deleteDept = (data?: { id: number }) => {
return http.request<Result>("post", `/api/depart/delete-depart/${data.id}`);
};
/** 获取系统监控-在线用户列表 */ /** 获取系统监控-在线用户列表 */
export const getOnlineLogsList = (data?: object) => { export const getOnlineLogsList = (data?: object) => {
return http.request<ResultTable>("post", "/online-logs", { data }); return http.request<ResultTable>("post", "/online-logs", { data });
......
...@@ -2,7 +2,7 @@ import dayjs from "dayjs"; ...@@ -2,7 +2,7 @@ import dayjs from "dayjs";
import editForm from "../form.vue"; import editForm from "../form.vue";
import { handleTree } from "@/utils/tree"; import { handleTree } from "@/utils/tree";
import { message } from "@/utils/message"; import { message } from "@/utils/message";
import { getDeptList } from "@/api/system"; import { getDeptList, addDept, deleteDept, updateDept } from "@/api/system";
import { usePublicHooks } from "../hooks"; import { usePublicHooks } from "../hooks";
import { addDialog } from "@/components/ReDialog"; import { addDialog } from "@/components/ReDialog";
import { reactive, ref, onMounted, h } from "vue"; import { reactive, ref, onMounted, h } from "vue";
...@@ -50,11 +50,11 @@ export function useDept() { ...@@ -50,11 +50,11 @@ export function useDept() {
formatter: ({ createTime }) => formatter: ({ createTime }) =>
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss") dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
}, },
{ // {
label: "备注", // label: "备注",
prop: "remark", // prop: "remark",
minWidth: 320 // minWidth: 320
}, // },
{ {
label: "操作", label: "操作",
fixed: "right", fixed: "right",
...@@ -77,7 +77,7 @@ export function useDept() { ...@@ -77,7 +77,7 @@ export function useDept() {
// loading.value = true; // loading.value = true;
const params = { const params = {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 200
}; };
const { data } = await getDeptList(params); // 这里是返回一维数组结构,前端自行处理成树结构,返回格式要求:唯一id加父节点parentId,parentId取父节点id const { data } = await getDeptList(params); // 这里是返回一维数组结构,前端自行处理成树结构,返回格式要求:唯一id加父节点parentId,parentId取父节点id
console.log("data", data); console.log("data", data);
...@@ -134,6 +134,8 @@ export function useDept() { ...@@ -134,6 +134,8 @@ export function useDept() {
beforeSure: (done, { options }) => { beforeSure: (done, { options }) => {
const FormRef = formRef.value.getRef(); const FormRef = formRef.value.getRef();
const curData = options.props.formInline as FormItemProps; const curData = options.props.formInline as FormItemProps;
console.log("row.id", row.id);
function chores() { function chores() {
message(`您${title}了部门名称为${curData.name}的这条数据`, { message(`您${title}了部门名称为${curData.name}的这条数据`, {
type: "success" type: "success"
...@@ -146,11 +148,26 @@ export function useDept() { ...@@ -146,11 +148,26 @@ export function useDept() {
console.log("curData", curData); console.log("curData", curData);
// 表单规则校验通过 // 表单规则校验通过
if (title === "新增") { if (title === "新增") {
// 实际开发先调用新增接口,再进行下面操作 addDept(curData).then(res => {
if ((res as any).code === "0") {
chores(); chores();
} else { } else {
// 实际开发先调用修改接口,再进行下面操作 message((res as any).msg, { type: "error" });
}
});
} else {
if (!row.id) {
message("id不能为空", { type: "error" });
return;
}
curData.id = row.id; // 修改时需要传入id
updateDept(curData).then(res => {
if ((res as any).code === "0") {
chores(); chores();
} else {
message((res as any).msg, { type: "error" });
}
});
} }
} }
}); });
...@@ -159,9 +176,14 @@ export function useDept() { ...@@ -159,9 +176,14 @@ export function useDept() {
} }
function handleDelete(row) { function handleDelete(row) {
console.log("handleDelete", row.id);
deleteDept({ id: row.id }).then(res => {
if ((res as any).code === "0") {
message(`您删除了部门名称为${row.name}的这条数据`, { type: "success" }); message(`您删除了部门名称为${row.name}的这条数据`, { type: "success" });
onSearch(); onSearch();
} }
});
}
onMounted(() => { onMounted(() => {
onSearch(); onSearch();
......
...@@ -8,6 +8,7 @@ interface FormItemProps { ...@@ -8,6 +8,7 @@ interface FormItemProps {
sort: number; sort: number;
status: number; status: number;
remark: string; remark: string;
id?: number;
} }
interface FormProps { interface FormProps {
formInline: FormItemProps; formInline: FormItemProps;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论