From 2aa2da6ff94c0e88e7ba0638606881a3c04cf579 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期二, 29 七月 2025 16:25:06 +0800
Subject: [PATCH] '-'

---
 src/views/system/dept/utils/hook.tsx |   56 ++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx
index d11ee6f..70bc46e 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() {
     loading.value = true;
-    const { result } = await zhaobiaoPageOrder(form); // 杩欓噷鏄繑鍥炰竴缁存暟缁勭粨鏋勶紝鍓嶇鑷澶勭悊鎴愭爲缁撴瀯锛岃繑鍥炴牸寮忚姹傦細鍞竴id鍔犵埗鑺傜偣parentId锛宲arentId鍙栫埗鑺傜偣id
+    const obj = cloneDeep(form);
+    obj.tousu = obj.tousu.join("");
+    obj.zhiyi = obj.zhiyi.join("");
+    obj.xingzhengquyu = obj.xingzhengquyu.join("");
+    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));
@@ -209,7 +234,7 @@
           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爜绫诲瀷锛堝彲閫夛級
@@ -237,12 +262,19 @@
       contentRenderer: () => h(editForm, { ref: formRef, formInline: null }),
       beforeSure: (done, { options }) => {
         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(); // 鍒锋柊琛ㄦ牸鏁版嵁
@@ -306,6 +338,10 @@
     openDialog,
     /** 鍒犻櫎閮ㄩ棬 */
     handleDelete,
-    handleSelectionChange
+    handleSelectionChange,
+    handleSizeChange,
+    handleCurrentChange,
+    pagination,
+    checkboxAsRadio
   };
 }

--
Gitblit v1.9.1