Browse Source

修改请求无code直接用axios

Renxy 1 năm trước cách đây
mục cha
commit
707a5a9b0d
1 tập tin đã thay đổi với 31 bổ sung12 xóa
  1. 31 12
      src/pages/PSRManage/detail.js

+ 31 - 12
src/pages/PSRManage/detail.js

@@ -22,11 +22,14 @@ import SaveModal from './components/saveOtherModal';
 import CompareModal from './components/compareModal';
 import CompareCom from './components/compareCom';
 import dayjs from 'dayjs';
+import { getToken } from '@/utils/utils';
 import { exportExcel, getUUID } from '../../utils/exportExcl';
+import { stringify } from 'qs';
 const PSRDetail = () => {
   const navigate = useNavigate();
   const params = useParams();
   const location = useLocation();
+  const token = getToken();
   const { id: projectId } = params;
   const {
     state: { project_name, flow_id, node_id },
@@ -78,15 +81,15 @@ const PSRDetail = () => {
   };
 
   //请求投标版、签字版psr excel
-  const { run: runExcel } = useRequest(queryPsrExcel, {
-    manual: true,
-    formatResult: (res) => {
-      if (res) {
-        const jsonData = JSON.parse(res);
-        renderSheet(jsonData);
-      }
-    },
-  });
+  // 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 {
@@ -145,15 +148,31 @@ const PSRDetail = () => {
     if (key) {
       onChange(key);
     } else {
-      runExcel({ gridKey: node_id });
+      queryPsrExcel({ gridKey: node_id });
     }
   }, [key]);
+  //请求投标版、签字版psr excel
+  const queryPsrExcel = (data) => {
+    axios({
+      url: `/api/v1/purchase/record/sheet?${stringify(data)}`,
+      method: 'POST',
+      data,
+      headers: {
+        'JWT-TOKEN': token,
+      },
+    }).then((req) => {
+      if (req.status == 200) {
+        const jsonData = JSON.parse(req.data);
+        renderSheet(jsonData);
+      }
+    });
+  };
 
   const onChange = (key) => {
     if (key == '1') {
-      runExcel({ gridKey: node_id });
+      queryPsrExcel({ gridKey: node_id });
     } else if (key == '2') {
-      runExcel({ gridKey: flow_id });
+      queryPsrExcel({ gridKey: flow_id });
     } else {
       initPsrActrual(key);
     }