From b94b71d44d62802bb8093f64a202d0176fdade50 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期二, 05 八月 2025 17:00:46 +0800 Subject: [PATCH] '一些更改' --- src/views/system/dept/utils/hook.tsx | 81 +++++++++++++++++++++++++++++++++------- 1 files changed, 66 insertions(+), 15 deletions(-) diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx index d11ee6f..1825877 100644 --- a/src/views/system/dept/utils/hook.tsx +++ b/src/views/system/dept/utils/hook.tsx @@ -11,6 +11,7 @@ getRegionList, getDaimaleixingList, caigourenAdd, + caigourenUpdate, caigourenDelete } from "@/api/item/index"; import { usePublicHooks } from "../../hooks"; @@ -24,15 +25,15 @@ // 鏂板鏃ユ湡鑼冨洿锛屽彲涓� null锛岀被鍨嬩负鏁扮粍 createDateRange: null, // 琛屾斂鍖哄煙锛屽彲涓� null锛岀被鍨嬩负瀛楃涓� - xingzhengquyu: "", + xingzhengquyu: [], // 琛屼笟鍝佺洰锛屽彲涓� null锛岀被鍨嬩负瀛楃涓� hangyepinmu: "", // 璁㈠崟鐘舵�侊紝鍙负 null锛岀被鍨嬩负 32 浣嶆暣鏁� orderStatus: "", // 璐ㄧ枒鏈夋棤锛屽彲涓� null锛岀被鍨嬩负甯冨皵鍊� - zhiyi: null, + zhiyi: [], // 鎶曡瘔鏈夋棤锛屽彲涓� null锛岀被鍨嬩负甯冨皵鍊� - tousu: null, + tousu: [], // 椤圭洰鍚嶇О锛屽彲涓� null锛岀被鍨嬩负瀛楃涓� projectName: null, // 浠g悊鏈烘瀯鍚嶇О锛屽彲涓� null锛岀被鍨嬩负瀛楃涓� @@ -48,6 +49,12 @@ orderStatusList: [], regionList: [], daimaleixingList: [] + }); + const pagination = reactive<PaginationProps>({ + total: 0, + pageSize: 10, + currentPage: 1, + background: true }); //鑾峰彇閲囪喘鏂瑰紡 const getCaigoufangshiListFun = async () => { @@ -86,7 +93,7 @@ const res = state.orderStatusList.find(item => { return row.orderStatus == item.status; }); - return res.label; + return res?.label; }; const columns: TableColumnList = [ { @@ -155,18 +162,36 @@ function handleSelectionChange(val) { console.log("handleSelectionChange", val); } + function handleSizeChange(val: number) { + console.log(`${val} items per page`); + } + + function handleCurrentChange(val: number) { + console.log(`current page: ${val}`); + } function resetForm(formEl) { if (!formEl) return; formEl.resetFields(); onSearch(); } - + const checkboxAsRadio = data => { + if (data.length > 1) { + data.shift(); + } + }; async function onSearch() { + const obj = cloneDeep(form); + obj.tousu = obj.tousu.join(""); + obj.zhiyi = obj.zhiyi.join(""); + obj.xingzhengquyu = obj.xingzhengquyu ? obj.xingzhengquyu.join("") : ""; loading.value = true; - const { result } = await zhaobiaoPageOrder(form); // 杩欓噷鏄繑鍥炰竴缁存暟缁勭粨鏋勶紝鍓嶇鑷澶勭悊鎴愭爲缁撴瀯锛岃繑鍥炴牸寮忚姹傦細鍞竴id鍔犵埗鑺傜偣parentId锛宲arentId鍙栫埗鑺傜偣id + const { result } = await zhaobiaoPageOrder(obj); // 杩欓噷鏄繑鍥炰竴缁存暟缁勭粨鏋勶紝鍓嶇鑷澶勭悊鎴愭爲缁撴瀯锛岃繑鍥炴牸寮忚姹傦細鍞竴id鍔犵埗鑺傜偣parentId锛宲arentId鍙栫埗鑺傜偣id const newData = result.items; loading.value = false; + pagination.total = result.total; + pagination.pageSize = result.pageSize; + pagination.currentPage = result.page; // if (!isAllEmpty(form.name)) { // // 鍓嶇鎼滅储閮ㄩ棬鍚嶇О // newData = newData.filter(item => item.name.includes(form.name)); @@ -191,6 +216,8 @@ } function openDialog(title = "鏂板", row?: FormItemProps) { + console.log(row,'-'); + addDialog({ title: `${title}椤圭洰`, props: { @@ -206,10 +233,10 @@ toubiaobaozhengjin: row?.toubiaobaozhengjin ?? null, // 鎶曟爣淇濊瘉閲戯紙鍙�夛級 lianhetitoubiao: row?.lianhetitoubiao ?? null, // 鑱斿悎浣撴姇鏍囷紙鍙�夛級 kaibiaofangshi: row?.kaibiaofangshi ?? null, // 寮�鏍囨柟寮忥紙鍙�夛級 - shifoufenbao: row?.shifoufenbao ?? false, // 鏄惁鍒嗗寘锛堝彲閫夛級 - shifoutuisongxuanchuan: row?.shifoutuisongxuanchuan ?? true, // 鏄惁鎺ㄩ�佸浼狅紙鍙�夛級 + shifoufenbao: row?.shifoufenbao ?? "false", // 鏄惁鍒嗗寘锛堝彲閫夛級 + shifoutuisongxuanchuan: row?.shifoutuisongxuanchuan ?? "true", // 鏄惁鎺ㄩ�佸浼狅紙鍙�夛級 caigourenmingcheng: row?.caigourenmingcheng ?? null, // 閲囪喘浜哄悕绉帮紙鍙�夛級 - xingzhengquyu: row?.xingzhengquyu ?? null, // 琛屾斂鍖哄煙锛堝彲閫夛級 + xingzhengquyu: row?.xingzhengquyu.split(",") ?? [], // 琛屾斂鍖哄煙锛堝彲閫夛級 xingzhengquyuName: row?.xingzhengquyuName ?? null, // 琛屾斂鍖哄煙鍚嶇О锛堝彲閫夛級 jigoudaima: row?.jigoudaima ?? null, // 鏈烘瀯浠g爜锛堝彲閫夛級 daimaleixing: row?.daimaleixing ?? null, // 浠g爜绫诲瀷锛堝彲閫夛級 @@ -233,28 +260,36 @@ draggable: true, fullscreen: deviceDetection(), fullscreenIcon: true, + sureBtnLoading: true, closeOnClickModal: false, contentRenderer: () => h(editForm, { ref: formRef, formInline: null }), - beforeSure: (done, { options }) => { + beforeSure: (done, { options, closeLoading }) => { const FormRef = formRef.value.getRef(); - const curData = options.props.formInline as FormItemProps; + const curData = cloneDeep(options.props.formInline as FormItemProps); async function chores() { message(`鎮�${title}浜嗛」鐩悕绉颁负${curData.projectName}鐨勮繖鏉℃暟鎹甡, { type: "success" }); - const res = await caigourenAdd(curData); + // curData.dingbiaoguize = curData.dingbiaoguize.join(""); + curData.xingzhengquyu = curData.xingzhengquyu.join(","); + let res; + if (title == "鏂板") { + res = await caigourenAdd(curData); + } else { + res = await caigourenUpdate(curData); + } if (res.code == "200") { done(); // 鍏抽棴寮规 onSearch(); // 鍒锋柊琛ㄦ牸鏁版嵁 } else { + closeLoading(); message(res.message, { type: "error" }); } } - FormRef.validate(valid => { + FormRef.validate((valid, obj) => { if (valid) { - console.log("curData", curData); // 琛ㄥ崟瑙勫垯鏍¢獙閫氳繃 if (title === "鏂板") { // 瀹為檯寮�鍙戝厛璋冪敤鏂板鎺ュ彛锛屽啀杩涜涓嬮潰鎿嶄綔 @@ -263,6 +298,18 @@ // 瀹為檯寮�鍙戝厛璋冪敤淇敼鎺ュ彛锛屽啀杩涜涓嬮潰鎿嶄綔 chores(); } + } else { + closeLoading(); + const fail = []; + console.log(obj); + + for (const key in obj) { + fail.push(obj[key][0].message); + } + message(fail[0], { + type: "warning" + }); + return false; } }); } @@ -306,6 +353,10 @@ openDialog, /** 鍒犻櫎閮ㄩ棬 */ handleDelete, - handleSelectionChange + handleSelectionChange, + handleSizeChange, + handleCurrentChange, + pagination, + checkboxAsRadio }; } -- Gitblit v1.9.1