diff --git a/src/api/common.js b/src/api/common.js index ff5d4a8..c79fef9 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -1,36 +1,39 @@ // 公共API -import request from '@/utils/request' +import request from "@/utils/request"; export const animationRoute = (url, username) => { return request({ - url:url, - method: 'GET', + url: url, + method: "GET", params: username, headers: { - "Content-Type": "application/json" - } - }) -} + "Content-Type": "application/json", + }, + }); +}; export const getData = (url) => { return request({ url: url, method: "GET", - }) -} + }); +}; -export const initWork =(url,data)=>{ +export const initWork = (url, data) => { return request({ url: url, method: "GET", - params: data - }) -} + params: data, + }); +}; -export const addWork = (url,data) =>{ +export const addWork = (url, data) => { return request({ url: url, - method:"POST", - data: data - }) -} \ No newline at end of file + method: "POST", + data: data, + headers: { + "Content-Type": "application/json", + }, + }); +}; diff --git a/src/views/admin1/work/index.vue b/src/views/admin1/work/index.vue index c852481..36f0e7c 100644 --- a/src/views/admin1/work/index.vue +++ b/src/views/admin1/work/index.vue @@ -9,6 +9,7 @@ import { ElMessage } from "element-plus"; const Router = useRoute(); const tableData = ref([]); const addDialogVisible = ref(false); +const background = ref(null); const addForm = reactive({ workId: "", @@ -57,7 +58,6 @@ const tableColumn = ref([ ]); // TODO 添加 添加操作弹窗 -const handleEdite = () => {}; const handleSelectionChange = (val) => { if (!val) return getWorkListData("/work/page", queryInfo.info); if (val.data != null && val.data != "") { @@ -73,34 +73,38 @@ const handleSelectionChange = (val) => { const handleAdd = () => { console.log("被调用了"); addDialogVisible.value = true; + console.log(addDialogVisible.value); }; // 添加部门的逻辑(这里只是一个示例,你需要根据实际需求实现添加部门的功能) -const addWork = async () => { +// const addWork = async () => { +// console.log(addForm.workId); +// if (!addForm.workId || !addForm.workName) { +// ElMessage.warning("请填写部门编号和部门名称"); +// return; +// } + +// // 在这里调用后端接口添加部门,然后刷新部门列表 +// // 例如:await addWorkAPI(addForm); +// const reslt = await addWork("/work/add", addForm); +// console.log(reslt); +// ElMessage.success("添加成功"); +// addDialogVisible.value = false; +// addForm.workId = ""; +// addForm.workName = ""; +// addForm.workDescription = ""; + +// // 刷新部门列表 +// getWorkListData("/work/page", queryInfo.info); +// }; +const addWork = () => { if (!addForm.workId || !addForm.workName) { ElMessage.warning("请填写部门编号和部门名称"); return; + } else { + const reslt = addWork("/work/add", addForm); + console.log(reslt); } - - // 在这里调用后端接口添加部门,然后刷新部门列表 - // 例如:await addWorkAPI(addForm); -<<<<<<< HEAD - const reslt = await addWork("/work/add", addForm); - console.log(reslt); - -======= - const rsl = await initWork('/work/add', addForm) - console.log(rsl); - ->>>>>>> 04aa138 (弹窗的请求) - ElMessage.success("添加成功"); - addDialogVisible.value = false; - addForm.workId = ""; - addForm.workName = ""; - addForm.workDescription = ""; - - // 刷新部门列表 - getWorkListData("/work/page", queryInfo.info); }; // TODO 返回操作状态 @@ -148,13 +152,7 @@ const addWork = async () => { />