From 74f40059f57f73ed75518a277b83beac4dee9e23 Mon Sep 17 00:00:00 2001 From: adiao <1819192616@qq.com> Date: Fri, 26 May 2023 10:51:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=9A=84=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=9A=84=E5=BC=B9=E7=AA=97=E6=95=88=E6=9E=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/common.js | 39 +++++++------ src/views/admin1/work/index.vue | 97 ++++++++++++++++++++------------- 2 files changed, 81 insertions(+), 55 deletions(-) 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 () => { />