Explorar o código

修改请求人日数据时间

Renxy hai 1 ano
pai
achega
2a62009d7e
Modificáronse 2 ficheiros con 15 adicións e 26 borrados
  1. 15 24
      src/pages/PSRManage/detail.js
  2. 0 2
      src/utils/exportExcl.js

+ 15 - 24
src/pages/PSRManage/detail.js

@@ -372,7 +372,7 @@ const PSRDetail = () => {
         //   if (data.celldata) data.celldata = JSON.parse(data.celldata);
         //   if (data.config) data.config = JSON.parse(data.config);
         // }
-        renderSheet(jsonData, data.is_edit);
+        renderSheet(jsonData, data.is_edit, data.day);
 
         // if (jsonData[0].celldata && typeof jsonData[0].celldata == 'string')
         //   jsonData[0].celldata = JSON.parse(jsonData[0].celldata);
@@ -491,11 +491,11 @@ const PSRDetail = () => {
           if (item.config && typeof item.config == 'string')
             item.config = JSON.parse(item.config);
         });
-        renderSheet(data, canEdit);
+        renderSheet(data, canEdit, res.data[0].day);
       } else {
         if (data.celldata) data.celldata = JSON.parse(data.celldata);
         if (data.config) data.config = JSON.parse(data.config);
-        renderSheet([data], canEdit);
+        renderSheet([data], canEdit, res.data[0].day);
       }
     } else {
       setIsOriginVer(false);
@@ -537,9 +537,9 @@ const PSRDetail = () => {
   const handlerSave = () => {
     // 手动触发单元格的完成编辑事件
     const $ = iframeRef.current.contentWindow.$;
-    const e = $.Event("keydown")
-    e.keyCode = 13
-    $(".luckysheet-cell-input").trigger(e)
+    const e = $.Event('keydown');
+    e.keyCode = 13;
+    $('.luckysheet-cell-input').trigger(e);
 
     const luckyData = luckysheetRef.current?.toJson();
     let allData;
@@ -619,7 +619,7 @@ const PSRDetail = () => {
     const contentWindow = iframeRef.current.contentWindow;
     luckysheetRef.current = contentWindow.luckysheet;
   };
-  const renderSheet = (currentData, is_edit = false) => {
+  const renderSheet = (currentData, is_edit = false, day = '') => {
     if (!currentData || !currentData[0]?.celldata) {
       setNoData(true);
       return;
@@ -627,7 +627,7 @@ const PSRDetail = () => {
     setNoData(false);
     if (!luckysheetRef.current) {
       setTimeout(() => {
-        renderSheet(currentData, is_edit);
+        renderSheet(currentData, is_edit, day);
       }, 500);
       return;
     }
@@ -667,7 +667,6 @@ const PSRDetail = () => {
           console.log(cell, sheet);
         },
         cellUpdated: () => {
-          console.log(123123123)
           luckysheetRef.current.refreshFormula();
         },
         workbookCreateAfter: async () => {
@@ -676,13 +675,7 @@ const PSRDetail = () => {
           }, 800);
           //当前为为终版psr标签并且可编辑状态时填充人日数据
           if (key == '3' && is_edit) {
-            fillWorkLoadData();
-            // const res = await queryPsrWorkLoad({ project_id: projectId });
-            // if (res?.data) {
-            //   console.log('--------------------', res.data);
-            //   luckysheetRef.current.setCellValue(8, 4, res.data.Total);
-            //   luckysheetRef.current.setCellValue(8, 8, res.data.Month);
-            // }
+            fillWorkLoadData(day);
           }
         },
       },
@@ -701,29 +694,27 @@ const PSRDetail = () => {
 
     //设置不可编辑
     if (!is_edit) unableEdit(option);
-
     luckysheetRef.current.destroy();
     luckysheetRef.current.create(option);
   };
 
-  const fillWorkLoadData = async () => {
+  const fillWorkLoadData = async (day) => {
     const param = { project_id: projectId };
     param.code = workConfig.map((item) => item.code).join(',');
-    param.s_time = dayjs('2023-01').startOf('month').format('YYYY-MM-DD');
-    param.e_time = dayjs('2023-07').endOf('month').format('YYYY-MM-DD');
+    param.s_time = dayjs(day).add(-1, 'month').format('YYYY-MM') + '-26';
+    param.e_time = dayjs(day).format('YYYY-MM') + '-25';
     const res = await queryPsrWorkLoad(param);
     if (res?.data) {
       const data = res?.data; //{ '02-010': [800, 100] };
       Object.keys(data).forEach((code) => {
         const list = data[code]; //第一个是当月的,第二个是累计的
         const fill = workConfig.find((item) => item.code == code)?.fill;
-        if (list?.length > 0 && fill)
+        if (list?.length > 0 && fill) {
           luckysheetRef.current.setCellValue(fill.r, fill.curC, list[0]);
-        luckysheetRef.current.setCellValue(fill.r, fill.actC, list[1]);
+          luckysheetRef.current.setCellValue(fill.r, fill.actC, list[1]);
+        }
       });
       console.log('--------------------', res.data);
-      // luckysheetRef.current.setCellValue(8, 4, res.data.Total);
-      // luckysheetRef.current.setCellValue(8, 8, res.data.Month);
     }
   };
   const renderTitle = (data_type, name) => {

+ 0 - 2
src/utils/exportExcl.js

@@ -155,8 +155,6 @@ var setStyleAndValue = function (cellArr, worksheet) {
 var setColumnlen = function (luckyColumnlen, worksheet) {
   const columnlen = Object.values(luckyColumnlen);
   const result = columnlen.map(function (elem, idx) {
-    // elem格式:{r: 0, c: 0, rs: 1, cs: 2}
-    // 按开始行,开始列,结束行,结束列合并(相当于 K10:M12)
     return {
       // header: idx,
       key: idx,