Renxy 1 år sedan
förälder
incheckning
7f3e16222e
4 ändrade filer med 75 tillägg och 24 borttagningar
  1. 7 7
      src/app.tsx
  2. 48 14
      src/pages/PSRManage/detail.js
  3. 5 1
      src/pages/PSRManage/index.js
  4. 15 2
      src/services/psr.js

+ 7 - 7
src/app.tsx

@@ -113,13 +113,13 @@ export const request: RequestConfig = {
     (res: any) => {
       const resData = res.data;
       const { code, msg, data } = resData;
-      if (code !== 200) {
-        let error: any = {};
-        error.name = 'AjaxError';
-        error.info = { code, msg, data };
-        // throw error;
-        return Promise.reject(error);
-      }
+      // if (code !== 200) {
+      //   let error: any = {};
+      //   error.name = 'AjaxError';
+      //   error.info = { code, msg, data };
+      //   // throw error;
+      //   return Promise.reject(error);
+      // }
       return res;
     },
   ],

+ 48 - 14
src/pages/PSRManage/detail.js

@@ -3,8 +3,14 @@ import { Button, Tabs, Space, Drawer, Timeline, message } from 'antd';
 import styles from './index.less';
 import { useEffect, useRef, useState } from 'react';
 import axios from 'axios';
-import { useRequest } from '@umijs/max';
 import {
+  useLocation,
+  useParams,
+  useRequest,
+  useSearchParams,
+} from '@umijs/max';
+import {
+  queryPsrExcel,
   queryPsrMonthDetail,
   queryPsrMonthList,
   queryPsrWorkLoad,
@@ -12,13 +18,15 @@ import {
 } from '../../services/psr';
 import SaveModal from './components/saveOtherModal';
 import dayjs from 'dayjs';
-const PSRDetail = (props) => {
+const PSRDetail = () => {
+  const params = useParams();
+  const location = useLocation();
+  const { id: projectId } = params;
   const {
-    projectId = 643,
-    project_name = '测试2',
-    flow_id = '1',
-    node_id = '2',
-  } = props;
+    state: { project_name, flow_id, node_id },
+  } = location;
+  console.log('========================', location, luckysheet);
+
   const [excelData, setExcelData] = useState();
   const [historyOpen, setHistoryOpen] = useState();
   const [open, setOpen] = useState();
@@ -61,6 +69,17 @@ const PSRDetail = (props) => {
     };
   };
 
+  //请求投标版、签字版psr excel
+  const { run: runExcel } = useRequest(queryPsrExcel, {
+    manual: true,
+    formatResult: (res) => {
+      if (res) {
+        const jsonData = JSON.parse(res);
+        renderSheet(jsonData);
+      }
+    },
+  });
+
   //请求月度psr和现金流列表 data_type 1 psr 2 现金流
   const {
     data,
@@ -121,16 +140,29 @@ const PSRDetail = (props) => {
       const data_type = key == '3' ? 1 : 2;
       setDataType(data_type);
       runList({ data_type });
+      axios.get('/excelData.json').then((res) => {
+        if (res.status == 200) {
+          renderSheet(res.data);
+        }
+      });
+    } else if (key == '1') {
+      runExcel({ gridKey: node_id });
+    } else {
+      runExcel({ gridKey: flow_id });
     }
   };
 
-  // useEffect(() => {
-  //   axios.get('/excelData.json').then((res) => {
-  //     if (res.status == 200) {
-  //       renderSheet(res.data);
-  //     }
-  //   });
-  // }, []);
+  useEffect(() => {
+    runExcel({ gridKey: node_id });
+    // axios.get('/excelData.json').then((res) => {
+    //   if (res.status == 200) {
+    //     renderSheet(res.data);
+    //   }
+    // });
+    // setTimeout(() => {
+    //   luckysheetRef.current.setCellValue(1, 1, 33333);
+    // }, 5000);
+  }, []);
 
   const handlerSaveOther = (date) => {
     const luckyData = luckysheetRef.current?.toJson();
@@ -180,6 +212,7 @@ const PSRDetail = (props) => {
         cellUpdated: () => {
           luckysheetRef.current.refreshFormula();
         },
+        workbookCreateAfter: () => {},
       },
     };
     //设置不可编辑
@@ -229,6 +262,7 @@ const PSRDetail = (props) => {
     const contentWindow = iframeRef.current.contentWindow;
     luckysheetRef.current = contentWindow.luckysheet;
   };
+
   const items = [
     {
       key: '1',

+ 5 - 1
src/pages/PSRManage/index.js

@@ -44,7 +44,11 @@ const PSRManage = () => {
               style={{ color: '#4096ff' }}
               onClick={() => {
                 navigate(`/psrManage/detail/${record.id}`, {
-                  project_name: record.project_name,
+                  state: {
+                    project_name: record.project_name,
+                    flow_id: record.flow_id,
+                    node_id: record.node_id,
+                  },
                 });
               }}
             >

+ 15 - 2
src/services/psr.js

@@ -1,4 +1,5 @@
 import { request } from 'umi';
+import { stringify } from 'qs';
 
 /**
  * 请求月度psr或现金流列表
@@ -62,8 +63,20 @@ export const queryPsrWorkLoad = async (data) => {
  * @param {*} code
  */
 export const queryPsrList = async (data) => {
-  return await request('api/v1/psr/project/list', {
-    method: 'GET',
+  return await request('/api/v1/psr/project/list', {
     params: data,
   });
 };
+
+/**
+ * 获取psr excel
+ * @param {*} gridKey
+ * NodeID = 投标版
+ * FlowID = 签字版
+ */
+export const queryPsrExcel = async (data) => {
+  return await request(`/api/v1/purchase/record/sheet?${stringify(data)}`, {
+    method: 'POST',
+    data,
+  });
+};