Procházet zdrojové kódy

Squashed commit of the following:

commit 59535b86b480beba035eb7cb84d2febe06eb1727
Author: Renxy <18510891294@163.com>
Date:   Fri Feb 3 17:16:38 2023 +0800

    【BOM】采购合同改动中
Renxy před 2 roky
rodič
revize
4552929ce0
2 změnil soubory, kde provedl 49 přidání a 82 odebrání
  1. 41 82
      src/pages/Detail/FlowModal.js
  2. 8 0
      src/services/boom.js

+ 41 - 82
src/pages/Detail/FlowModal.js

@@ -25,6 +25,7 @@ import {
   queryDelPurchaseExcel,
   queryDingInstanceDetail,
   queryRecordSheet,
+  queryTrySeal,
   queryVserionByNode,
 } from '@/services/boom';
 import { async } from '@antv/x6/lib/registry/marker/async';
@@ -72,6 +73,11 @@ function FlowModal(props) {
   const [selectType, setSelectType] = useState(SELECT_TYPE.NAME);
   const [inputValue, setInputValue] = useState('');
 
+  const [sealLoading, setSealLoading] = useState(false);
+  // const [currentTempNodeId, setCurrentTempNodeId] = useState();
+  const currentTempNodeId = useRef();
+  console.log('=======', currentTempNodeId);
+
   const graphData = useMemo(() => {
     if (!flowDetail) return;
     let nodes = flowDetail.nodes?.map(item => ({
@@ -96,14 +102,19 @@ function FlowModal(props) {
     }
   }, [stepsData]);
 
-  const handleSelectNode = async args => {
-    let res;
+  const handleSelectNode = args => {
     const id = args.nodeId || args.nodeIds[0];
     if (!id) return;
     let node = graphData.nodes.find(item => item.id == id);
+    initData(node.Id);
+  };
+
+  const initData = async template_node_id => {
     setNodeLoading(true);
     try {
-      res = await queryVserionByNode({ template_node_id: node.Id });
+      const res = await queryVserionByNode({
+        template_node_id: template_node_id,
+      });
       let data = [];
       if (!res.data.excel_version_tree) setData([]);
       res.data.excel_version_tree?.map(arr => {
@@ -120,6 +131,7 @@ function FlowModal(props) {
         item.isParent = true;
       });
       console.log(data);
+      currentTempNodeId.current = template_node_id;
       setData(data);
     } catch (error) {
       console.log(error);
@@ -180,7 +192,7 @@ function FlowModal(props) {
     return [
       {
         title: '名称',
-        width: '25%',
+        width: '20%',
         render: item => (
           <span style={{ color: item.audit_status != 0 ? '#9b9b9b' : '' }}>
             {item.id == version.id && !item.isParent && (
@@ -259,99 +271,34 @@ function FlowModal(props) {
         },
       },
       {
-        title: '操作',
-        width: '20%',
-        render: item =>
-          (item.flow_id || !item.isParent) &&
-          item.id != version.id && (
-            <Space>
-              <a
-                onClick={() => {
-                  console.log(item);
-                  onChangeVersion(item);
-                  onClose();
-                }}
-              >
-                加载
-              </a>
-              {item.audit_status == 0 &&
-              item.author == currentUser.ID && ( //自己创建的&&未提交的清单自己可以删除
-                  <a
-                    onClick={() => {
-                      onDelVersion({ excel_id: item.id });
-                    }}
-                  >
-                    删除
-                  </a>
-                )}
-            </Space>
-          ),
-      },
-    ];
-  }, [version]);
-
-  const childColumns = useMemo(() => {
-    return [
-      {
-        title: '名称',
-        width: '50%',
-        render: item => (
-          <span style={{ color: item.audit_status != 0 ? '#9b9b9b' : '' }}>
-            {item.id == version.id && !item.isParent && (
-              <CheckOutlined style={{ marginRight: 10 }} />
-            )}
-            {item.version_no && !item.children?.length
-              ? `${item.version_name}.${item.version_no}`
-              : item.version_name}
-          </span>
-        ),
-      },
-      {
-        title: '状态',
+        title: '印章申请',
+        width: '15%',
         render: item => {
           if (!item.flow_id && item.isParent) return;
-          let style = { color: getColor(item) };
           let txt = '';
-          let dom = '';
-          switch (item.audit_status) {
+          //申请印章成功 1  默认0 失败2
+          switch (item.is_seal_succeed) {
             case 0:
-              txt = '未提交';
+              txt = '-';
               break;
             case 1:
-              txt = '待审批';
+              txt = '成功';
               break;
             case 2:
-              txt = '已拒绝';
-              break;
-            case 3:
-              txt = '已通过';
-              break;
-            case 4:
-              txt = '已提交';
+              txt = '失败';
               break;
           }
-          if (item.status == 1) txt = '已失效';
-
-          // 显示拒绝原因
-          if (item.audit_comment) {
-            dom = (
-              <Popover content={item.audit_comment} title="原因">
-                {txt}
-              </Popover>
-            );
-          } else {
-            dom = txt;
-          }
-          return item.audit_status != 0 ? (
-            <Button onClick={() => handleChangeClick(item)}>{dom}</Button>
-          ) : (
-            <span style={style}>{dom}</span>
+          return (
+            <Space>
+              <span>{txt}</span>
+              {item.is_seal_succeed == 2 && <a onClick={() => handleRetryClick(item.id)}>重试</a>}
+            </Space>
           );
         },
       },
       {
         title: '操作',
-        width: '30%',
+        width: '20%',
         render: item =>
           (item.flow_id || !item.isParent) &&
           item.id != version.id && (
@@ -381,6 +328,18 @@ function FlowModal(props) {
     ];
   }, [version]);
 
+  const handleRetryClick = async id => {
+    setNodeLoading(true);
+    const res = await queryTrySeal({ excel_id: id });
+    setNodeLoading(false);
+    if (res.data?.errcode != 0) {
+      message.error(res.data?.errmsg);
+    } else {
+      message.success('用印成功');
+      if (currentTempNodeId.current) initData(currentTempNodeId.current);
+    }
+  };
+
   const onChange = value => {
     updateSteps([]);
   };

+ 8 - 0
src/services/boom.js

@@ -454,3 +454,11 @@ export async function queryGetBomForm(params) {
   });
   return res;
 }
+
+//章管家失败,重新申请用印
+export async function queryTrySeal(params) {
+  let res = await request(`/purchase/bom/try-seal?${stringify(params)}`, {
+    method: 'GET',
+  });
+  return res;
+}