From 35cf8d289a09a6a4a34cf3d73fb41d84969ae4ee Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期一, 18 八月 2025 17:30:26 +0800
Subject: [PATCH] '注册修改'

---
 src/views/system/dept/utils/hook.tsx |  198 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 164 insertions(+), 34 deletions(-)

diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx
index 1825877..51e812e 100644
--- a/src/views/system/dept/utils/hook.tsx
+++ b/src/views/system/dept/utils/hook.tsx
@@ -1,4 +1,4 @@
-import dayjs from "dayjs";
+// import dayjs from "dayjs";
 import editForm from "../form.vue";
 import { handleTree } from "@/utils/tree";
 import { message } from "@/utils/message";
@@ -12,15 +12,24 @@
   getDaimaleixingList,
   caigourenAdd,
   caigourenUpdate,
-  caigourenDelete
+  caigourenDelete,
+  caigourenBatchDelete
 } from "@/api/item/index";
-import { usePublicHooks } from "../../hooks";
+// import { usePublicHooks } from "../../hooks";
 import { addDialog } from "@/components/ReDialog";
-import { reactive, ref, onMounted, h } from "vue";
-import type { FormItemProps } from "../utils/types";
-import { cloneDeep, isAllEmpty, deviceDetection } from "@pureadmin/utils";
+import { type Ref, reactive, ref, onMounted, h } from "vue";
+import type { FormItemProps } from "./types";
+import { cloneDeep, deviceDetection, getKeyList } from "@pureadmin/utils";
+// import { useUserStoreHook } from "@/store/modules/user";
+import type { PaginationProps } from "@pureadmin/table";
 
-export function useDept() {
+import pdfPreview from "../../component/pdfPreview.vue";
+// const nowRole = computed(() => {
+//   return useUserStoreHook().nowRole;
+// });
+const selectedNum = ref(0);
+
+export function useDept(tableRef: Ref) {
   const form = reactive({
     // 鏂板鏃ユ湡鑼冨洿锛屽彲涓� null锛岀被鍨嬩负鏁扮粍
     createDateRange: null,
@@ -38,6 +47,7 @@
     projectName: null,
     // 浠g悊鏈烘瀯鍚嶇О锛屽彲涓� null锛岀被鍨嬩负瀛楃涓�
     dailijigoumingcheng: null,
+    caigourenmingcheng: null,
     // 涓爣渚涘簲鍟嗗鍚嶏紝鍙负 null锛岀被鍨嬩负瀛楃涓�
     zhongbiaoName: null,
     // 涓撳濮撳悕锛屽彲涓� null锛岀被鍨嬩负瀛楃涓�
@@ -88,7 +98,7 @@
   const formRef = ref();
   const dataList = ref([]);
   const loading = ref(true);
-  const { tagStyle } = usePublicHooks();
+  // const { tagStyle } = usePublicHooks();
   const getOrderStatus = row => {
     const res = state.orderStatusList.find(item => {
       return row.orderStatus == item.status;
@@ -97,21 +107,27 @@
   };
   const columns: TableColumnList = [
     {
+      label: "鍕鹃�夊垪", // 濡傛灉闇�瑕佽〃鏍煎閫夛紝姝ゅlabel蹇呴』璁剧疆
+      type: "selection",
+      fixed: "left",
+      reserveSelection: true // 鏁版嵁鍒锋柊鍚庝繚鐣欓�夐」
+    },
+    {
+      label: "閲囪喘浜�",
+      prop: "caigourenmingcheng",
+      minWidth: 70
+    },
+    {
       label: "椤圭洰鍚嶇О",
       prop: "projectName",
       width: 180,
       align: "left"
     },
     {
-      label: "浠g悊鏈烘瀯",
-      prop: "dailijigoumingcheng",
-      minWidth: 70
-    },
-    {
       label: "椤圭洰杩涘害",
       prop: "orderStatus",
       minWidth: 70,
-      cellRenderer: ({ row, props }) => getOrderStatus(row)
+      cellRenderer: ({ row }) => getOrderStatus(row)
     },
     {
       label: "鎶ュ悕璐�",
@@ -126,7 +142,7 @@
     {
       label: "涓爣渚涘簲鍟�",
       prop: "zhongbiaoName",
-      minWidth: 70
+      minWidth: 180
     },
     {
       label: "璇勫涓撳",
@@ -137,15 +153,13 @@
       label: "璐ㄧ枒",
       prop: "zhiyi",
       minWidth: 100,
-      cellRenderer: ({ row, props }) => (
-        <span>{row.status === 1 ? "鏈�" : "鏃�"}</span>
-      )
+      cellRenderer: ({ row }) => <span>{row.status === 1 ? "鏈�" : "鏃�"}</span>
     },
     {
       label: "鎶曡瘔",
       prop: "tousu",
       minWidth: 100,
-      cellRenderer: ({ row, props }) => (
+      cellRenderer: ({ row }) => (
         // <el-tag size={props.size} style={tagStyle.value(row.status)}>
         <span>{row.status === 1 ? "鏈�" : "鏃�"}</span>
         // </el-tag>
@@ -154,13 +168,115 @@
     {
       label: "鎿嶄綔",
       fixed: "right",
-      width: 210,
+      width: 80,
+      slot: "operation"
+    }
+  ];
+  const CGRcolumns: TableColumnList = [
+    {
+      label: "鍕鹃�夊垪", // 濡傛灉闇�瑕佽〃鏍煎閫夛紝姝ゅlabel蹇呴』璁剧疆
+      type: "selection",
+      fixed: "left",
+      reserveSelection: true // 鏁版嵁鍒锋柊鍚庝繚鐣欓�夐」
+    },
+    {
+      label: "浠g悊鏈烘瀯",
+      prop: "dailijigoumingcheng",
+      minWidth: 70
+    },
+    {
+      label: "椤圭洰鍚嶇О",
+      prop: "projectName",
+      width: 180,
+      align: "left"
+    },
+    {
+      label: "椤圭洰杩涘害",
+      prop: "orderStatus",
+      minWidth: 70,
+      cellRenderer: ({ row }) => getOrderStatus(row)
+    },
+    {
+      label: "鎶ュ悕璐�",
+      prop: "baomingfei",
+      minWidth: 70
+    },
+    {
+      label: "鎶曟爣淇濊瘉閲�",
+      prop: "toubiaobaozhengjin",
+      minWidth: 70
+    },
+    {
+      label: "涓爣渚涘簲鍟�",
+      prop: "zhongbiaoName",
+      minWidth: 180
+    },
+    {
+      label: "璇勫涓撳",
+      prop: "zhuanjiaName",
+      minWidth: 70
+    },
+    {
+      label: "璐ㄧ枒",
+      prop: "zhiyi",
+      minWidth: 100,
+      cellRenderer: ({ row }) => <span>{row.status === 1 ? "鏈�" : "鏃�"}</span>
+    },
+    {
+      label: "鎶曡瘔",
+      prop: "tousu",
+      minWidth: 100,
+      cellRenderer: ({ row }) => (
+        // <el-tag size={props.size} style={tagStyle.value(row.status)}>
+        <span>{row.status === 1 ? "鏈�" : "鏃�"}</span>
+        // </el-tag>
+      )
+    },
+    {
+      label: "鎿嶄綔",
+      fixed: "right",
+      width: 80,
       slot: "operation"
     }
   ];
 
+  /** 褰揅heckBox閫夋嫨椤瑰彂鐢熷彉鍖栨椂浼氳Е鍙戣浜嬩欢 */
   function handleSelectionChange(val) {
-    console.log("handleSelectionChange", val);
+    selectedNum.value = val.length;
+    // 閲嶇疆琛ㄦ牸楂樺害
+    tableRef.value.setAdaptive();
+  }
+  /** 鍙栨秷閫夋嫨 */
+  function onSelectionCancel() {
+    selectedNum.value = 0;
+    // 鐢ㄤ簬澶氶�夎〃鏍硷紝娓呯┖鐢ㄦ埛鐨勯�夋嫨
+    tableRef.value.getTableRef().clearSelection();
+  }
+  /** 鎵归噺鍒犻櫎 */
+  async function onbatchDel() {
+    // 杩斿洖褰撳墠閫変腑鐨勮
+    const curSelected = tableRef.value.getTableRef().getSelectionRows();
+    const data = [];
+    curSelected.forEach(item => {
+      data.push({ id: item.id });
+    });
+    const res = await caigourenBatchDelete(data);
+    if (res.code == "200") {
+      // 鎺ヤ笅鏉ユ牴鎹疄闄呬笟鍔★紝閫氳繃閫変腑琛岀殑鏌愰」鏁版嵁锛屾瘮濡備笅闈㈢殑id锛岃皟鐢ㄦ帴鍙h繘琛屾壒閲忓垹闄�
+      message(
+        `宸插垹闄ら」鐩悕绉颁负 ${getKeyList(curSelected, "projectName")} 鐨勬暟鎹甡,
+        {
+          type: "success"
+        }
+      );
+      onSearch();
+    } else {
+      message(res.message, {
+        type: "error"
+      });
+    }
+    tableRef.value.getTableRef().clearSelection();
+    onSearch();
   }
   function handleSizeChange(val: number) {
     console.log(`${val} items per page`);
@@ -170,10 +286,23 @@
     console.log(`current page: ${val}`);
   }
 
-  function resetForm(formEl) {
-    if (!formEl) return;
-    formEl.resetFields();
-    onSearch();
+  function resetForm() {
+    // if (!formEl) return;
+    // formEl.resetFields();
+    // onSearch();
+
+    addDialog({
+      title: `棰勮pdf`,
+      props: {},
+      width: "60%",
+      draggable: true,
+      fullscreen: deviceDetection(),
+      fullscreenIcon: true,
+      sureBtnLoading: true,
+      closeOnClickModal: false,
+      contentRenderer: () => h(pdfPreview, { ref: formRef, formInline: null })
+      // jsx 璇硶 锛堟敞鎰忓湪.vue鏂囦欢鍚敤jsx璇硶锛岄渶瑕佸湪script寮�鍚痩ang="tsx"锛�
+    });
   }
   const checkboxAsRadio = data => {
     if (data.length > 1) {
@@ -193,7 +322,7 @@
     pagination.pageSize = result.pageSize;
     pagination.currentPage = result.page;
     // if (!isAllEmpty(form.name)) {
-    //   // 鍓嶇鎼滅储閮ㄩ棬鍚嶇О
+    //   // 鍓嶇鎼滅储椤圭洰鍚嶇О
     //   newData = newData.filter(item => item.name.includes(form.name));
     // }
     // if (!isAllEmpty(form.status)) {
@@ -204,7 +333,7 @@
   }
 
   function formatHigherDeptOptions(treeList) {
-    // 鏍规嵁杩斿洖鏁版嵁鐨剆tatus瀛楁鍊煎垽鏂拷鍔犳槸鍚︾鐢╠isabled瀛楁锛岃繑鍥炲鐞嗗悗鐨勬爲缁撴瀯锛岀敤浜庝笂绾ч儴闂ㄧ骇鑱旈�夋嫨鍣ㄧ殑灞曠ず锛堝疄闄呭紑鍙戜腑涔熸槸濡傛锛屼笉鍙兘鍓嶇闇�瑕佺殑姣忎釜瀛楁鍚庣閮戒細杩斿洖锛岃繖鏃堕渶瑕佸墠绔嚜琛屾牴鎹悗绔繑鍥炵殑鏌愪簺瀛楁鍋氶�昏緫澶勭悊锛�
+    // 鏍规嵁杩斿洖鏁版嵁鐨剆tatus瀛楁鍊煎垽鏂拷鍔犳槸鍚︾鐢╠isabled瀛楁锛岃繑鍥炲鐞嗗悗鐨勬爲缁撴瀯锛岀敤浜庝笂绾ч」鐩骇鑱旈�夋嫨鍣ㄧ殑灞曠ず锛堝疄闄呭紑鍙戜腑涔熸槸濡傛锛屼笉鍙兘鍓嶇闇�瑕佺殑姣忎釜瀛楁鍚庣閮戒細杩斿洖锛岃繖鏃堕渶瑕佸墠绔嚜琛屾牴鎹悗绔繑鍥炵殑鏌愪簺瀛楁鍋氶�昏緫澶勭悊锛�
     if (!treeList || !treeList.length) return;
     const newTreeList = [];
     for (let i = 0; i < treeList.length; i++) {
@@ -216,13 +345,12 @@
   }
 
   function openDialog(title = "鏂板", row?: FormItemProps) {
-    console.log(row,'-');
-    
     addDialog({
       title: `${title}椤圭洰`,
       props: {
         formInline: {
           higherDeptOptions: formatHigherDeptOptions(cloneDeep(dataList.value)),
+          id: row?.id ?? "",
           projectCode: row?.projectCode ?? "", // 椤圭洰缂栧彿锛堝繀濉級
           projectName: row?.projectName ?? "", // 椤圭洰鍚嶇О锛堝繀濉級
           hangyepinmu: row?.hangyepinmu ?? null, // 琛屼笟鍝佺洰锛堝彲閫夛級
@@ -301,8 +429,6 @@
           } else {
             closeLoading();
             const fail = [];
-            console.log(obj);
-            
             for (const key in obj) {
               fail.push(obj[key][0].message);
             }
@@ -344,19 +470,23 @@
     state,
     loading,
     columns,
+    CGRcolumns,
     dataList,
+    selectedNum,
     /** 鎼滅储 */
     onSearch,
     /** 閲嶇疆 */
     resetForm,
-    /** 鏂板銆佷慨鏀归儴闂� */
+    /** 鏂板銆佷慨鏀归」鐩� */
     openDialog,
-    /** 鍒犻櫎閮ㄩ棬 */
+    /** 鍒犻櫎椤圭洰 */
     handleDelete,
     handleSelectionChange,
     handleSizeChange,
     handleCurrentChange,
     pagination,
-    checkboxAsRadio
+    checkboxAsRadio,
+    onSelectionCancel,
+    onbatchDel
   };
 }

--
Gitblit v1.9.1