xujunjie 3 anni fa
parent
commit
f3e6e7a920

+ 3 - 3
config/config.js

@@ -65,8 +65,8 @@ if (APP_TYPE === 'site') {
 export default {
   // add for transfer to umi
   plugins,
-  base: '/purchase/',
-  publicPath: NODE_ENV == 'development' ? '/' : '/purchase/',
+  base: '/bom/',
+  publicPath: NODE_ENV == 'development' ? '/' : '/bom/',
   // base: '/',
   // publicPath: '/',
   history: 'hash',
@@ -139,7 +139,7 @@ export default {
   chainWebpack: webpackPlugin,
   proxy: {
     '/api': {
-      target: 'http://47.96.12.136:8888/',
+      target: 'http://47.96.12.136:8896/',
       // target: 'http://oraysmart.com:8889/',
       // target: 'http://oraysmart.com:8888/api',
       // changeOrigin: true,

+ 1 - 1
config/router.config.js

@@ -17,7 +17,7 @@ export default [
             // component: './PurchaseAdmin/PurchaseList/List/List',
           },
           {
-            path: '/home/detail/:excelId/:projectId',
+            path: '/home/detail/:projectId',
             component: './PurchaseAdmin/PurchaseList/Detail/Index',
           },
           {

File diff suppressed because it is too large
+ 0 - 0
public/Luckysheet/luckysheet.umd.js


File diff suppressed because it is too large
+ 0 - 0
public/Luckysheet/luckysheet.umd.js.map


+ 17 - 8
public/luckysheet.html

@@ -6,19 +6,28 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>Document</title>
 
-    <link rel="stylesheet" href="/Luckysheet/plugins/css/pluginsCss.css" />
+    <!-- 本地开发使用路径 -->
+    <!-- <link rel="stylesheet" href="/Luckysheet/plugins/css/pluginsCss.css" />
     <link rel="stylesheet" href="/Luckysheet/plugins/plugins.css" />
     <link rel="stylesheet" href="/Luckysheet/css/luckysheet.css" />
     <link rel="stylesheet" href="/Luckysheet/assets/iconfont/iconfont.css" />
     <script src="/Luckysheet/plugins/js/plugin.js"></script>
-    <script src="/Luckysheet/luckysheet.umd.js"></script>
+    <script src="/Luckysheet/luckysheet.umd.js"></script> -->
 
-    <!-- <link rel="stylesheet" href="/purchase/Luckysheet/plugins/css/pluginsCss.css" />
-    <link rel="stylesheet" href="/purchase/Luckysheet/plugins/plugins.css" />
-    <link rel="stylesheet" href="/purchase/Luckysheet/css/luckysheet.css" />
-    <link rel="stylesheet" href="/purchase/Luckysheet/assets/iconfont/iconfont.css" />
-    <script src="/purchase/Luckysheet/plugins/js/plugin.js"></script>
-    <script src="/purchase/Luckysheet/luckysheet.umd.js"></script> -->
+    <!-- 线上发布使用路径 -->
+    <!-- <link rel="stylesheet" href="/bom/Luckysheet/plugins/css/pluginsCss.css" />
+    <link rel="stylesheet" href="/bom/Luckysheet/plugins/plugins.css" />
+    <link rel="stylesheet" href="/bom/Luckysheet/css/luckysheet.css" />
+    <link rel="stylesheet" href="/bom/Luckysheet/assets/iconfont/iconfont.css" />
+    <script src="/bom/Luckysheet/plugins/js/plugin.js"></script>
+    <script src="/bom/Luckysheet/luckysheet.umd.js"></script> -->
+
+    <link rel='stylesheet' href='http://localhost:3000/plugins/css/pluginsCss.css' />
+    <link rel='stylesheet' href='http://localhost:3000/plugins/plugins.css' />
+    <link rel='stylesheet' href='http://localhost:3000/css/luckysheet.css' />
+    <link rel='stylesheet' href='http://localhost:3000/assets/iconfont/iconfont.css' />
+    <script src="http://localhost:3000/plugins/js/plugin.js"></script>
+    <script src="http://localhost:3000/luckysheet.umd.js"></script>
   </head>
   <body>
     <div

+ 1 - 4
src/components/Flow/config-cmd.ts

@@ -41,10 +41,7 @@ export const useCmdConfig = props => {
           name: 'selectNode',
           handler: async args => {
             console.log('select node:', args);
-            setTimeout(async () => {
-              let node = await MODELS.SELECTED_NODE.useValue(args.modelService);
-              props.onSelectNode?.(node.getData?.());
-            }, 100);
+            props.onSelectNode?.(args);
           },
         }),
         // hooks.updateNode.registerHook({

+ 12 - 0
src/components/Flow/index.tsx

@@ -25,6 +25,7 @@ import {
   /** 通用组件:节点连接桩 */
   CanvasNodePortTooltip,
   IApplication,
+  XFlowNodeCommands,
 } from '@antv/xflow';
 import { Graph } from '@antv/x6';
 /** 配置Command*/
@@ -73,6 +74,17 @@ export const Demo: React.FC<IProps> = props => {
   const renderGraph = () => {
     if (flowDetail.nodes.length == 0 || !appRef.current) return;
     initGraphCmds(appRef.current, flowDetail);
+    // 设置选中状态
+    const node = flowDetail.nodes.find(item => item.isCheck);
+    if (node) {
+      const args = {
+        nodeIds: [node.id],
+        resetSelection: true,
+      };
+      setTimeout(() => {
+        appRef.current.commandService.executeCommand(XFlowNodeCommands.SELECT_NODE.id, args);
+      }, 100);
+    }
   };
   const getConfig = () => {
     const defaultOption = {

+ 9 - 1
src/components/Flow/node/rect/mapServe.tsx

@@ -77,7 +77,15 @@ const Component = (props: any) => {
       }
       console.log(exportJson);
       const sheet = exportJson.sheets[0];
-      const titleCell = sheet.celldata.filter(item => item.r == 0);
+      let titleCell = [];
+      sheet.celldata.forEach(item => {
+        if(item.r == 0) {
+          // 标题头
+          titleCell.push(item)
+        }
+        // 生成cid
+        item.v.cid = `${item.r}-${item.c}`
+      })
       let cell = titleCell.map(item => {
         let value = '';
         if (item.v?.v) {

+ 20 - 15
src/pages/PurchaseAdmin/PurchaseList/Detail/CommitAuditModal.js

@@ -8,23 +8,22 @@ const { TextArea } = Input;
 const { Option } = Select;
 
 // 提交
-function CommitModal(props) {
-  const { visible, onClose, onOk, form, loading, version, flowDetail, auditList } = props;
+function CommitAuditModal(props) {
+  const { visible, onClose, onOk, form, loading, version, flowDetail } = props;
   const [auditId, setAuditId] = useState();
   const handleOk = () => {
     form.validateFields((err, fieldsValue) => {
       if (err) return;
       let nextNode = flowDetail.nodes.find?.(item => item.Id == fieldsValue.node_id);
-      let { list: flow } = auditList.find(item => item.list.id == nextNode?.flow_id);
       let params = {
         desc: fieldsValue.desc,
         // 审核流程id
-        flow_id: flow?.id || 0,
-        node_level_id: flow?.FlowNodes[0]?.seq || 0,
+        flow_id: nextNode?.flow_id || 0,
+        node_level_id: nextNode?.flow_id ? 1 : 0,
 
         id: version.id,
         project_id: version.project_id,
-        template_node_id: nextNode.Id, // 将要流转的节点
+        template_node_id: nextNode?.Id, // 将要流转的节点
         cur_template_node_id: version.template_node_id * 1, // 当前节点
         next_template_node_id: fieldsValue.next_template_node_id * 1, // 审核完成后的业务节点
 
@@ -34,6 +33,7 @@ function CommitModal(props) {
         next_template_id: version.template_id,
       };
       console.log(params);
+      setAuditId();
       onOk(params);
     });
   };
@@ -53,7 +53,12 @@ function CommitModal(props) {
     let targetIds = edges
       .filter(edge => edge.source.cell == currentId)
       .map(item => item.target.cell);
-    let auditNodes = nodes.filter(node => node.name == type && targetIds.indexOf(node.id) != -1);
+    let auditNodes = nodes.filter(node => {
+      if (type && node.name != type) {
+        return false;
+      }
+      return targetIds.indexOf(node.id) != -1;
+    });
     return auditNodes || [];
   };
 
@@ -68,7 +73,10 @@ function CommitModal(props) {
       destroyOnClose
       title="提交流转目标"
       visible={visible}
-      onCancel={onClose}
+      onCancel={() => {
+        setAuditId();
+        onClose();
+      }}
       onOk={handleOk}
     >
       <Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label="审批节点">
@@ -83,11 +91,9 @@ function CommitModal(props) {
       <Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label="业务节点">
         {form.getFieldDecorator('next_template_node_id')(
           <Select style={{ width: '100%' }}>
-            {getNextNodes(auditId || currentNodeId, auditId ? 'custom-rect' : 'custom-circle').map(
-              item => (
-                <Option key={item.Id}>{item.label}</Option>
-              )
-            )}
+            {getNextNodes(auditId || currentNodeId, auditId ? 'custom-rect' : '').map(item => (
+              <Option key={item.Id}>{item.label}</Option>
+            ))}
           </Select>
         )}
       </Form.Item>
@@ -99,6 +105,5 @@ function CommitModal(props) {
 }
 
 export default connect(({ xflow, detail }) => ({
-  auditList: detail.auditList,
   flowDetail: xflow.flowDetail,
-}))(Form.create()(CommitModal));
+}))(Form.create()(CommitAuditModal));

+ 10 - 58
src/pages/PurchaseAdmin/PurchaseList/Detail/CompareModal.js

@@ -8,11 +8,9 @@ const { TabPane } = Tabs;
 
 // 选择比对版本
 function CompareModal(props) {
-  const { visible, versionList, onClose, onOk, historyList, dispatch, version } = props;
+  const { visible, versionList, onClose, onOk, dispatch, version } = props;
 
   const [checkValue, setCheckValue] = useState([]);
-  const [tabList, setTabList] = useState([]);
-  const [active, setActive] = useState();
 
   const onChange = check => {
     if (check.length <= 2) {
@@ -22,60 +20,23 @@ function CompareModal(props) {
     }
   };
 
-  const changeAcitve = versionId => {
-    setActive(versionId);
-    if (!versionId || historyList[versionId]) return;
-    // 查询历史提交
-    dispatch({
-      type: 'detail/queryHistoryList',
-      payload: {
-        version_id: versionId,
-      },
-    });
-  };
-
   const handleOk = () => {
     if (checkValue.length != 2) {
       message.error('请选择要比对的两个文件');
     } else {
       let checkSheet = [];
 
-      Object.values(historyList).forEach(verList => {
-        if(checkSheet.length >= 2) return;
-        verList.forEach(item => {
-          if(checkValue.indexOf(item.id) != -1) {
-            checkSheet.push(item)
-          }
-        })
-        
+      versionList.forEach(item => {
+        if (checkValue.indexOf(item.id) != -1) {
+          checkSheet.push(item);
+        }
       });
-      // console.log(checkSheet);
       onOk(checkSheet);
       onClose();
       setCheckValue([]);
     }
   };
 
-  useEffect(() => {
-    changeAcitve(version.id);
-  }, [version.id]);
-
-  // useEffect(() => {
-  //   let obj = {};
-  //   list.forEach(item => {
-  //     let nodeId = item.NodeInfo.id;
-  //     if (!obj[nodeId])
-  //       obj[nodeId] = {
-  //         list: [],
-  //         id: nodeId + '',
-  //         name: item.NodeInfo.node,
-  //       };
-  //     obj[nodeId].list.push(item);
-  //   });
-  //   let arr = Object.values(obj).map(item => item);
-  //   setTabList(arr);
-  //   setActive(arr[0]?.id);
-  // }, [list]);
 
   return (
     <Modal
@@ -83,29 +44,20 @@ function CompareModal(props) {
       visible={visible}
       onCancel={onClose}
       onOk={handleOk}
-      bodyStyle={{ paddingTop: 0 }}
     >
       <Checkbox.Group value={checkValue} style={{ width: '100%' }} onChange={onChange}>
-        <Tabs activeKey={active} onChange={changeAcitve}>
-          {/* {tabList.map(tab => ( */}
+        <Row gutter={16}>
           {versionList.map(version => (
-            <TabPane tab={version.version_name} key={version.id}>
-              <Row>
-                {(historyList[version.id] || []).map(item => (
-                  <Col span={8} key={item.id}>
-                    <Checkbox value={item.id}>{item.version_name}</Checkbox>
-                  </Col>
-                ))}
-              </Row>
-            </TabPane>
+            <Col span={8} key={version.id}>
+              <Checkbox value={version.id}>{version.version_name}</Checkbox>
+            </Col>
           ))}
-        </Tabs>
+        </Row>
       </Checkbox.Group>
     </Modal>
   );
 }
 
 export default connect(({ detail }) => ({
-  historyList: detail.historyList,
   versionList: detail.versionList,
 }))(CompareModal);

+ 45 - 20
src/pages/PurchaseAdmin/PurchaseList/Detail/FlowModal.js

@@ -4,28 +4,43 @@ import Flow from '@/components/Flow/index';
 import { connect } from 'dva';
 import { GetTokenFromUrl, getToken } from '@/utils/utils';
 import { MODELS, useXFlowApp, useModelAsync } from '@antv/xflow';
+import { StarOutlined } from '@ant-design/icons';
 
 const { TextArea } = Input;
 const localData = JSON.parse(localStorage.ggDetaiData || '{}');
 
 // 提交
 function FlowModal(props) {
-  const { visible, onClose, onChangeVersion, form, loading, flowDetail, versionList } = props;
+  const {
+    visible,
+    version,
+    onClose,
+    onChangeVersion,
+    form,
+    loading,
+    flowDetail,
+    versionList,
+  } = props;
   const [data, setData] = useState([]);
+  // const app = useXFlowApp();
+  // const appRef = userRef()
 
   const graphData = useMemo(() => {
     let nodes = flowDetail.nodes.map(item => ({
       ...item,
+      isCheck: item.Id == version.template_node_id,
       version: versionList.filter(version => version.template_node_id == item.Id) || [],
     }));
     return {
       nodes,
       edges: flowDetail.edges,
     };
-  }, [flowDetail, versionList]);
+  }, [flowDetail, versionList, version.template_node_id]);
 
-  const handleSelectNode = node => {
-    console.log(node);
+  const handleSelectNode = args => {
+    const id = args.nodeId || args.nodeIds[0];
+    if (!id) return;
+    let node = graphData.nodes.find(item => item.id == id);
     setData(node.version);
   };
 
@@ -46,22 +61,32 @@ function FlowModal(props) {
         bordered
         dataSource={data}
         style={{ marginTop: 20 }}
-        renderItem={item => (
-          <List.Item
-            actions={[
-              <a
-                onClick={() => {
-                  onChangeVersion(item);
-                  onClose();
-                }}
-              >
-                切换
-              </a>,
-            ]}
-          >
-            {item.version_name}
-          </List.Item>
-        )}
+        renderItem={item => {
+          const isCurrent = item.id == version.id;
+          return (
+            <List.Item
+              actions={
+                isCurrent
+                  ? null
+                  : [
+                      <a
+                        onClick={() => {
+                          onChangeVersion(item);
+                          onClose();
+                        }}
+                      >
+                        切换
+                      </a>,
+                    ]
+              }
+            >
+              <div style={{ color: isCurrent ? '#1890ff' : '' }}>
+                {isCurrent && <StarOutlined />}
+                {item.version_name}
+              </div>
+            </List.Item>
+          );
+        }}
       />
     </Modal>
   );

+ 207 - 148
src/pages/PurchaseAdmin/PurchaseList/Detail/Index.js

@@ -1,6 +1,6 @@
 import React, { useEffect, useState, useRef, useMemo } from 'react';
-import { DownOutlined } from '@ant-design/icons';
-import { Button, Modal, message, Alert, Spin, Select, Menu, Dropdown } from 'antd';
+import { UnorderedListOutlined } from '@ant-design/icons';
+import { Button, Modal, message, Alert, Avatar, Spin, Select, Menu, Dropdown } from 'antd';
 import { connect } from 'dva';
 import styles from './Index.less';
 import LuckySheet from './LuckySheet';
@@ -18,11 +18,10 @@ import FilesModal from './FilesModal';
 import VersionModal from './VersionModal';
 import CommitAuditModal from './CommitAuditModal';
 import { GetTokenFromUrl, getToken } from '@/utils/utils';
-
+import { queryDetail } from '@/services/boom';
 const LocalData = localStorage.luckysheet;
 
 const { Option } = Select;
-let cell_position = {};
 
 function Detail(props) {
   const {
@@ -41,7 +40,6 @@ function Detail(props) {
   } = props;
   // const audit_status = 0
   const [commentVisible, setCommentVisible] = useState(false);
-  const [historyVisible, setHistoryVisible] = useState(false);
   const [compareVisible, setCompareVisible] = useState(false);
   const [exportVisible, setExportVisible] = useState(false);
   const [commitVisible, setCommitVisible] = useState(false);
@@ -54,6 +52,7 @@ function Detail(props) {
   const [edit, setEdit] = useState(false);
   const [isMerge, setIsMerge] = useState(false);
   const [version, setVersion] = useState({});
+  const [user, setUser] = useState([]);
   const [updateCount, setUpdateCount] = useState({
     diff: 0,
     add: 0,
@@ -64,19 +63,22 @@ function Detail(props) {
   // const [lastCommit, setLastCommit] = useState({ data: [] });
   const sheetRef = useRef();
   const sheetRef2 = useRef();
+  const sheetRef3 = useRef();
   const fileRef = useRef();
   const statusRef = useRef({
     edit: false,
     compare: false,
   });
-  const audit_status = version.audit_status;
+  const cellPosition = useRef({});
 
-  const excelId = parseInt(params.excelId);
+  // const [excelId, setExcelId] = useState(parseInt(params.excelId));
+  // const excelId = parseInt(params.excelId);
   const projectId = parseInt(params.projectId);
 
   const flow = useMemo(() => {
     let data = {
       active: 0,
+      active_id: null,
       current: 0,
       currentNode: {},
       list: {
@@ -86,14 +88,25 @@ function Detail(props) {
     if (version?.flow_id && auditList?.length > 0) {
       let item = auditList.find(item => item.list.id == version.flow_id);
       if (!item) return data;
-      item.current = item.list.FlowNodes.findIndex(node => node.id == item.active);
-      item.current = item.current == -1 ? 0 : item.current;
+      // 合并同审批级别项
+      let nodes = {};
+      item.list.FlowNodes.map(item => {
+        if (!nodes[item.seq]) nodes[item.seq] = { ...item, user: [] };
+        nodes[item.seq].user.push(item.AuditorUser);
+      });
+      item.list.FlowNodes = Object.values(nodes);
+      // 查询当前节点
+      let current = item.list.FlowNodes.findIndex(node => node.seq == item.active);
+      item.current = current == -1 ? 0 : current;
+      // 保存当前所处节点
       item.currentNode = item.list.FlowNodes[item.current];
       data = item;
     }
 
     return data;
   }, [auditList, version]);
+  const audit_status = flow.active_audit;
+  // const audit_status = 1;
 
   const onSave = () => {
     setEdit(false);
@@ -103,7 +116,7 @@ function Detail(props) {
     console.log(jsonData);
     let newExcl = {
       ...sheet,
-      excel_id: excelId,
+      excel_id: version.id,
       title: '',
       data: jsonData.data,
     };
@@ -113,11 +126,20 @@ function Detail(props) {
 
   const onCompare = async checkSheets => {
     if (checkSheets) {
-      if (!checkSheets[0].data) {
-        checkSheets[0].data = await queryHistoryDetail(checkSheets[0]);
+      const [sheet1, sheet2] = checkSheets;
+      if (!sheet1.data) {
+        sheet1.data = (
+          await queryDetail({
+            excel_id: sheet1.id,
+          })
+        ).data;
       }
-      if (!checkSheets[1].data) {
-        checkSheets[1].data = await queryHistoryDetail(checkSheets[1]);
+      if (!sheet2.data) {
+        sheet2.data = (
+          await queryDetail({
+            excel_id: sheet2.id,
+          })
+        ).data;
       }
 
       setCompareList(checkSheets);
@@ -126,7 +148,7 @@ function Detail(props) {
       let index = compareList.findIndex(item => item.id == sheet.id);
       // 退出比对模式
       if (index == 0) {
-        sheetRef.current.toggleCompare(false);
+        sheetRef3.current.toggleCompare(false);
       } else if (index == 1) {
         sheetRef2.current.toggleCompare(false);
       }
@@ -145,16 +167,16 @@ function Detail(props) {
     setCommentVisible(false);
   };
 
-  const exportSheet = async item => {
-    console.log(item);
-    var sheets = await queryHistoryDetail(item);
-    sheets.id = sheets.sheet_id;
-    setSheet({
-      ...item,
-      name: item.version_name,
-      data: sheets,
-    });
-  };
+  // const exportSheet = async item => {
+  //   console.log(item);
+  //   var sheets = await queryHistoryDetail(item);
+  //   sheets.id = sheets.sheet_id;
+  //   setSheet({
+  //     ...item,
+  //     name: item.version_name,
+  //     data: sheets,
+  //   });
+  // };
 
   const renderSheetDom = (item, index) => {
     return (
@@ -165,14 +187,9 @@ function Detail(props) {
         </h3>
         <LuckySheet
           className={styles.sheet}
-          ref={!index ? sheetRef : sheetRef2}
+          ref={!index ? sheetRef3 : sheetRef2}
           data={item.data || null}
           onClickCell={onClickCell}
-          onLoad={() => {
-            if (compareList.length == 0) {
-              sheetRef.current.renderSheet(item.data);
-            }
-          }}
         />
       </div>
     );
@@ -183,31 +200,36 @@ function Detail(props) {
     if (cell?.cid && !statusRef.current.edit) {
       let payload = {
         sheet_id: s.order || '0',
-        excel_id: excelId,
+        excel_id: version.id,
         cid: cell.cid,
       };
       dispatch({
         type: 'detail/queryComment',
         payload,
       });
-      cell_position = {
+      cellPosition.current = {
         ...payload,
         sheet_index: (s.seq || 0) + '',
       };
       setCommentVisible(true);
     }
     // 比对模式下双excl同步选中
-    if (statusRef.current.compare) {
-      sheetRef.current.selectCell(position.r, position.c, s.order);
-      sheetRef2.current.selectCell(position.r, position.c, s.order);
-    }
+    // if (statusRef.current.compare) {
+    //   sheetRef3.current.selectCell(position.r, position.c, s.order);
+    //   sheetRef2.current.selectCell(position.r, position.c, s.order);
+    // }
   };
 
-  const onCommit = (values, new_version) => {
+  const onCommit = (values, id) => {
     let currentData = sheetRef.current.getSheetJson().data;
+    let sheets = JSON.parse(JSON.stringify(currentData));
+    sheets.forEach(item => {
+      delete item.data;
+    });
+    console.log(sheets);
     let params = {
       ...values,
-      // id: version.id,
+      id: id,
       project_id: version.project_id,
       name: version.name,
       guid: version.guid,
@@ -216,8 +238,8 @@ function Detail(props) {
       template_node_id: version.template_node_id,
       flow_id: version.flow_id,
       node_id: version.node_id,
-      new_version: String(new_version),
-      data: JSON.stringify(currentData),
+      new_version: '0',
+      data: JSON.stringify(sheets),
     };
     dispatch({
       type: 'detail/commitSheet',
@@ -278,11 +300,11 @@ function Detail(props) {
     dispatch({
       type: 'detail/approve',
       payload: {
-        id: excelId,
+        id: version.id,
         project_id: projectId,
         audit_status: 2,
         flow_id: flowNode.flow_id,
-        node_id: flowNode.id,
+        node_id: flowNode.seq,
         audit_comment,
       },
       callback: () => {
@@ -302,7 +324,7 @@ function Detail(props) {
         dispatch({
           type: 'detail/submitAudit',
           payload: {
-            id: excelId,
+            id: version.id,
             flow_id: flowNode.flow_id,
             node_id: flowNode.id,
             projectId,
@@ -327,11 +349,21 @@ function Detail(props) {
         dispatch({
           type: 'detail/approve',
           payload: {
-            id: excelId,
+            id: flow.active_id,
             project_id: projectId,
             audit_status: flag ? 3 : 2,
             flow_id: flowNode.flow_id,
-            node_id: flowNode.id,
+            node_id: flowNode.seq,
+          },
+          callback: newVersion => {
+            if (flow.current == flow.list.FlowNodes.length - 1) {
+              // 最后一个审核节点通过后  需要更新version id
+              localStorage.excelId = newVersion.id;
+              setVersion({
+                ...version,
+                id: newVersion.id,
+              });
+            }
           },
         });
       },
@@ -411,15 +443,17 @@ function Detail(props) {
   };
 
   const getUserRole = () => {
-    if (currentUser.ID == flow.currentNode?.auditor) return true;
-    let roleId = Number(flow.currentNode?.audit_role);
-    console.log(roleId);
-    if (roleId) {
-      let role = roleList.find(item => item.ID == roleId);
-      if (role) {
-        return role.User.find(item => item.ID == currentUser.ID);
-      }
-    }
+    // if (currentUser.ID == flow.currentNode?.auditor) return true;
+    let item = flow.currentNode?.user?.find?.(item => item.ID == currentUser.ID);
+    if (item) return true;
+    // let roleId = Number(flow.currentNode?.audit_role);
+    // console.log(roleId);
+    // if (roleId) {
+    //   let role = roleList.find(item => item.ID == roleId);
+    //   if (role) {
+    //     return role.User.find(item => item.ID == currentUser.ID);
+    //   }
+    // }
     return false;
   };
 
@@ -430,16 +464,24 @@ function Detail(props) {
         // 返回
         router.push(`/home`);
         break;
-      case 'version':
-        // 版本
-        queryHistory();
-        setCommentVisible(false);
-        setHistoryVisible(true);
-        break;
+      // case 'version':
+      //   // 版本
+      //   queryHistory();
+      //   setCommentVisible(false);
+      //   setHistoryVisible(true);
+      //   break;
       case 'export':
         // 导出
         handleExportClick();
         break;
+      case 'commitAudit':
+        // 提交流转
+        setCommitAuditVisible(true);
+        break;
+      case 'flow':
+        // 查看流程
+        setFlowVisible(true);
+        break;
       case 'compare':
         // 比对
         setCompareVisible(true);
@@ -456,9 +498,9 @@ function Detail(props) {
       //   // 审核拒绝
       //   onApprove(false);
       //   break;
-      case 'edit':
-        // 编辑
-        handleEdit(true);
+      // case 'edit':
+      //   // 编辑
+      //   handleEdit(true);
       case 'merge':
         // 同步版本
 
@@ -501,7 +543,7 @@ function Detail(props) {
             {/* <Button type="success" onClick={() => onMerge()}>
               同步新增内容
             </Button>*/}
-            <Button onClick={() => handleEdit(true)}>编辑</Button>
+            {/* <Button onClick={() => handleEdit(true)}>编辑</Button> */}
             <Button onClick={() => setCommitVisible(true)}>确认提交</Button>
             <Button onClick={() => onCompare(false)}>取消比对</Button>
           </>
@@ -515,13 +557,15 @@ function Detail(props) {
     const menuList = [
       <Menu.Item key="back">返回</Menu.Item>,
       <Menu.Item key="export">导出</Menu.Item>,
+      <Menu.Item key="commitAudit">提交流转</Menu.Item>,
+      <Menu.Item key="flow">查看流程</Menu.Item>,
       <Menu.Item key="compare">比对</Menu.Item>,
       <Menu.Item key="attachment">附件</Menu.Item>,
     ];
-    if (audit_status != 1) {
-      menuList.push(<Menu.Item key="version">历史提交</Menu.Item>);
-      // menuList.push(<Menu.Item key="template">模板</Menu.Item>);
-    }
+    // if (audit_status != 1) {
+    //   menuList.push(<Menu.Item key="version">历史提交</Menu.Item>);
+    //   // menuList.push(<Menu.Item key="template">模板</Menu.Item>);
+    // }
     if (!isAuditor && canEdit()) {
       menuList.push(<Menu.Item key="edit">编辑</Menu.Item>);
       menuList.push(<Menu.Item key="merge">合并</Menu.Item>);
@@ -543,9 +587,10 @@ function Detail(props) {
           </>
         )}
         <Dropdown overlay={<Menu onClick={handleMenuClick}>{menuList}</Menu>}>
-          <Button type="primary">
+          {/* <Button type="primary">
             其他操作 <DownOutlined />
-          </Button>
+          </Button> */}
+          <UnorderedListOutlined style={{ fontSize: 30, cursor: 'pointer' }} />
         </Dropdown>
       </>
     );
@@ -558,13 +603,15 @@ function Detail(props) {
 
   const renderAlert = () => {
     const audit_comment = history.list[0]?.audit_comment;
+    let item = '';
     switch (audit_status) {
       case 0:
         return;
       case 1:
-        return <Alert message="等待审核中" type="info" />;
+        item = <Alert message="等待审核中" type="info" />;
+        break;
       case 2:
-        return (
+        item = (
           <Alert
             message={`审批被拒绝${
               audit_comment ? `,拒绝原因:${audit_comment}` : ''
@@ -572,9 +619,13 @@ function Detail(props) {
             type="error"
           />
         );
+        break;
       case 3:
-        return <Alert message="审批通过" type="success" />;
+        item = <Alert message="审批通过" type="success" />;
+        break;
     }
+
+    return <div style={{ marginTop: 20 }}>{item}</div>;
   };
 
   const exportExcl = files => {
@@ -604,17 +655,6 @@ function Detail(props) {
     setExportVisible(false);
   };
 
-  const addComment = (data, callback) => {
-    dispatch({
-      type: 'detail/addComment',
-      payload: {
-        ...cell_position,
-        comment: data,
-      },
-      callback,
-    });
-  };
-
   const queryHistory = id => {
     return new Promise(reslove => {
       dispatch({
@@ -633,7 +673,7 @@ function Detail(props) {
       type: 'detail/queryFiles',
       payload: {
         // excel_id: id || excelId,
-        excel_id: excelId,
+        excel_id: version.id,
       },
     });
   };
@@ -642,7 +682,7 @@ function Detail(props) {
     const uploadProps = {
       name: 'file',
       showUploadList: false,
-      action: `/api/v1/purchase/attachment/${excelId}`,
+      action: `/api/v1/purchase/attachment/${version.id}`,
       headers: {
         'JWT-TOKEN': token,
       },
@@ -702,41 +742,45 @@ function Detail(props) {
 
   const changeVersion = id => {
     let version = versionList.find(item => item.id == id);
-    if (!version) return message.error('版本不存在!');
+    if (!version) return;
+    localStorage.excelId = id;
     setVersion(version);
 
     // 查询excel内容
-    dispatch({
-      type: 'detail/queryRecord',
-      payload: {
-        project_id: projectId,
-        template_id: version.template_id,
-        template_node_id: version.template_node_id,
-        version_id: version.id,
-      },
-      callback: sheets => {
-        console.log(sheets);
-        setSheet(sheets);
-        sheetRef.current.renderSheet(sheets.data);
-      },
-    });
+    // dispatch({
+    //   type: 'detail/queryRecord',
+    //   payload: {
+    //     project_id: projectId,
+    //     template_id: version.template_id,
+    //     template_node_id: version.template_node_id,
+    //     version_id: version.id,
+    //   },
+    //   callback: sheets => {
+    //     console.log(sheets);
+    //     setSheet(sheets);
+    //     // sheetRef.current.renderSheet(sheets.data);
+    //   },
+    // });
 
-    // 查询历史修改
-    dispatch({
-      type: 'detail/queryHistoryList',
-      payload: {
-        version_id: version.id,
-      },
-    });
-    // 判断是否审批节点
+    // // 查询历史修改
     // dispatch({
-    //   type: 'detail/queryAuditList',
+    //   type: 'detail/queryHistoryList',
     //   payload: {
-    //     template_id: version.template_id ,
-    //     template_node_id: version.template_node_id ,
-    //      flow_id: version.flow_id
-    //   }
-    // })
+    //     version_id: version.id,
+    //   },
+    // });
+    // 判断是否审批节点
+    if (version.flow_id) {
+      dispatch({
+        type: 'detail/queryAuditList',
+        payload: {
+          template_id: version.template_id,
+          template_node_id: version.template_node_id,
+          flow_id: version.flow_id,
+          version_id: version.id,
+        },
+      });
+    }
   };
 
   const onSubmitNextNode = values => {
@@ -749,6 +793,10 @@ function Detail(props) {
     });
   };
 
+  const getUser = user => {
+    setUser(user);
+  };
+
   useEffect(() => {
     dispatch({
       type: 'detail/queryProjectRecord',
@@ -763,9 +811,9 @@ function Detail(props) {
       },
     });
     // 审批流程
-    dispatch({
-      type: 'detail/queryAuditList',
-    });
+    // dispatch({
+    //   type: 'detail/queryAuditList',
+    // });
     // 查询节点
     // dispatch({
     //   type: 'detail/queryFlowInfo',
@@ -814,7 +862,7 @@ function Detail(props) {
           };
         });
       };
-      var update1 = sheetRef.current.toggleCompare(true, compareList[1].data, callback);
+      var update1 = sheetRef3.current.toggleCompare(true, compareList[1].data, callback);
       var update2 = sheetRef2.current.toggleCompare(true, compareList[0].data, callback);
     }
   }, [compareList]);
@@ -822,45 +870,47 @@ function Detail(props) {
   useEffect(() => {
     if (versionList.length == 0) return;
     if (!version.id) {
+      const excelId = localStorage.excelId;
       changeVersion(excelId);
     } else {
       changeVersion(version.id);
     }
+    // else if (version.id != params.excelId) {
+    //   changeVersion(version.id);
+    // }
   }, [versionList]);
 
   return (
     <Spin spinning={false}>
       {/* <Spin spinning={getLoading()}> */}
-      <Button type="primary" onClick={() => setFlowVisible(true)}>
-        查看流程
-      </Button>
+
       <div className={styles.top}>
-        <div>
+        <div style={{ minWidth: 700, marginTop: 20 }}>
           {/* 当前节点: {version.template_node_id}
           <br />
           当前状态:{version.audit_status} */}
-          {flow.active !== 0 && <TimeNode flow={flow}></TimeNode>}
-        </div>
-        <div className={styles.btns}>
-          {renderBtns()}
-          <Button type="primary" onClick={() => setCommitAuditVisible(true)}>
-            提交流转
-          </Button>
-          <Button type="primary" onClick={() => setVersionVisible(true)}>
-            创建版本
-          </Button>
-          <Select style={{ width: 140 }} value={version.id} onChange={changeVersion}>
+          <TimeNode nodeId={version.template_node_id} flow={flow}></TimeNode>
+          <Select
+            style={{ width: 140, marginLeft: 10 }}
+            value={version.id}
+            onChange={changeVersion}
+          >
             {versionList.map(item => (
               <Option value={item.id} key={item.id}>
                 {item.version_name}
               </Option>
             ))}
           </Select>
+          <Button type="primary" onClick={() => setVersionVisible(true)}>
+            创建版本
+          </Button>
+        </div>
+        <div className={styles.btns}>
+          {user.map(item => (
+            <Avatar size="large">{item.Name}</Avatar>
+          ))}
+          {renderBtns()}
         </div>
-        {/* 
-       
-        <div className={styles.btns}>{renderBtns()}</div>
-         */}
         <input
           type="file"
           ref={fileRef}
@@ -868,7 +918,7 @@ function Detail(props) {
           onChange={e => exportExcl(e.target.files)}
         />
       </div>
-      <div style={{ marginTop: 20 }}>{renderAlert()}</div>
+      {renderAlert()}
       {/* 判断是否为比对模式 */}
       {compareList.length == 2 ? (
         <>
@@ -879,23 +929,32 @@ function Detail(props) {
           <div className={styles.sheetBox}>{compareList.map(renderSheetDom)}</div>
         </>
       ) : (
-        <div className={styles.sheetBox}>{renderSheetDom(sheet)}</div>
+        <div className={styles.sheetBox}>
+          {version.id && (
+            <LuckySheet
+              className={styles.sheet}
+              ref={sheetRef}
+              onClickCell={onClickCell}
+              version={version}
+              getUser={getUser}
+            />
+          )}
+        </div>
       )}
 
       <RightDrawer
-        list={comment?.list || []}
+        version={version}
         visible={commentVisible}
-        addComment={addComment}
-        loading={loading.effects['detail/queryComment'] || loading.effects['detail/addComment']}
         onClose={() => setCommentVisible(false)}
+        cellPosition={cellPosition}
       />
-      <HistoryModal
+      {/* <HistoryModal
         visible={historyVisible}
         version={version}
         // onChange={queryHistory}
         onClose={() => setHistoryVisible(false)}
         onSelect={item => exportSheet(item)}
-      />
+      /> */}
       <CompareModal
         visible={compareVisible}
         version={version}
@@ -918,6 +977,7 @@ function Detail(props) {
       <FlowModal
         visible={flowVisible}
         onClose={() => setFlowVisible(false)}
+        version={version}
         // onOk={onCommit}
         onChangeVersion={version => changeVersion(version.id)}
       />
@@ -940,7 +1000,7 @@ function Detail(props) {
         loading={getLoading()}
         visible={versionVisible}
         onClose={() => setVersionVisible(false)}
-        onOk={values => onCommit(values, 0)}
+        onOk={values => onCommit(values)}
       />
       <CommitAuditModal
         loading={getLoading()}
@@ -961,7 +1021,6 @@ export default connect(({ detail, user, loading }) => ({
   comment: detail.comment,
   currentUser: user.currentUser,
   roleList: detail.roleList,
-  version: detail.version,
   versionList: detail.versionList,
   loading,
 }))(Detail);

+ 3 - 1
src/pages/PurchaseAdmin/PurchaseList/Detail/Index.less

@@ -30,8 +30,10 @@
 .btns {
   margin: 20px 0;
   position: relative;
+  display: flex;
+  align-items: center;
   :global {
-    .ant-btn {
+    .ant-avatar {
       margin-right: 10px;
     }
   }

+ 50 - 39
src/pages/PurchaseAdmin/PurchaseList/Detail/LuckySheet.js

@@ -2,6 +2,7 @@ import React from 'react';
 import { message } from 'antd';
 import exportExcel from '@/utils/exportExcl';
 import LuckyExcel from 'luckyexcel';
+import { getToken } from '@/utils/utils';
 
 const hintText = '禁止编辑!请先点击编辑按钮。';
 const DIFF_COLOR = '#ff0000';
@@ -49,8 +50,8 @@ class LuckySheet extends React.Component {
     return uuid.join('');
   }
   renderSheet(sheets) {
-    if (!sheets) return;
-    const { onClickCell } = this.props;
+    // if (!sheets) return;
+    const { onClickCell, version, getUser, data } = this.props;
     if (!this.luckysheet) {
       clearTimeout(this.renderTimer);
       this.renderTimer = setTimeout(() => {
@@ -58,7 +59,8 @@ class LuckySheet extends React.Component {
       }, 300);
       return;
     }
-    let data = {
+    let token = getToken();
+    let option = {
       lang: 'zh',
       showinfobar: false,
       showstatisticBar: false,
@@ -76,10 +78,19 @@ class LuckySheet extends React.Component {
         },
       },
     };
-    if (sheets && sheets.length > 0) {
-      data.data = JSON.parse(JSON.stringify(sheets));
+    if (version) {
+      option = {
+        ...option,
+        allowUpdate: true,
+        gridKey: version.id,
+        loadUrl: `/api/v1/purchase/record/sheet?gridKey=${version.id}&JWT-TOKEN=${token}`,
+        updateUrl: `ws://47.96.12.136:8896/api/v1/ws?id=${version.id}&sid=1&JWT-TOKEN=${token}`,
+        getUser,
+      };
+    } else if (data && data.length > 0) {
+      option.data = JSON.parse(JSON.stringify(data));
 
-      data.data.forEach(item => {
+      option.data.forEach(item => {
         if (item.celldata) {
           item.celldata.forEach(cell => {
             // 生成uuid
@@ -87,21 +98,21 @@ class LuckySheet extends React.Component {
           });
         }
         // 默认禁止编辑
-        item.config.authority = { sheet: true, hintText };
+        // item.config.authority = { sheet: true, hintText };
       });
     } else {
       // 默认sheet页数据
       data.data = [
         {
           name: 'sheet1',
-          config: {
-            authority: { sheet: true, hintText },
-          },
+          // config: {
+          //   authority: { sheet: true, hintText },
+          // },
         },
       ];
     }
     // this.luckysheet.destroy();
-    this.luckysheet.create(data);
+    this.luckysheet.create(option);
   }
 
   // componentDidUpdate(prevProps) {
@@ -112,12 +123,12 @@ class LuckySheet extends React.Component {
   // }
 
   handleLoad() {
-    const { onLoad, data } = this.props;
+    const { onLoad } = this.props;
     let contentWindow = this.sheetRef.current.contentWindow;
     this.luckysheet = contentWindow.luckysheet;
-    this.luckysheet = this.luckysheet;
-    // this.renderSheet(data);
-    onLoad && onLoad();
+    // this.luckysheet = this.luckysheet;
+    this.renderSheet();
+    // onLoad && onLoad();
   }
 
   selectCell(row, col, order) {
@@ -180,7 +191,7 @@ class LuckySheet extends React.Component {
         celldata1.forEach(item => {
           // 不判断空字符串
           if (this.isEmpty(item)) return;
-          var d2Item = celldata2.find(item2 => item2.c == item.c && item2.r == item.r);
+          var d2Item = celldata2.find(item2 => item2.v.cid == item.v.cid);
           if (d2Item && !this.isEmpty(d2Item)) {
             // v.ct.s相同,不做处理
             if (item.v.ct?.s && JSON.stringify(item.v.ct?.s) == JSON.stringify(d2Item.v.ct?.s))
@@ -229,7 +240,7 @@ class LuckySheet extends React.Component {
       let celldata1 = sheet.celldata;
       let celldata2 = mergeData[index].celldata;
       celldata2.forEach(item => {
-        var d2Item = celldata1.find(item2 => item2.r == item.r && item2.c == item2.c);
+        var d2Item = celldata1.find(item2 => item2.v.cid == item.v.cid);
         if (!d2Item) {
           delete item.v.v.bg;
           // 将新增项添加至当前文档
@@ -283,14 +294,14 @@ class LuckySheet extends React.Component {
           if (this.isEmpty(dCell)) return;
           // 判断v.ct是否相同
           // if (cell?.v?.ct?.s && dCell.v.ct?.s && cell.v.ct?.s.join('') != dCell.v.ct?.s.join('')) return;
-          if (cell?.v?.ct?.s && dCell.v.ct?.s){
-            if( cell.v.ct?.s.join('') != dCell.v.ct?.s.join('')) return
+          if (cell?.v?.ct?.s && dCell.v.ct?.s) {
+            if (cell.v.ct?.s.join('') != dCell.v.ct?.s.join('')) return;
             let cellS = cell.v.ct.s;
             let dCellS = dCell.v.ct.s;
             let isEqul = cellS.every((cur, idx) => {
-                return JSON.stringify(cur) === JSON.stringify(dCellS[idx])
-            })
-            if(!isEqul) return
+              return JSON.stringify(cur) === JSON.stringify(dCellS[idx]);
+            });
+            if (!isEqul) return;
           }
           // 判断v.v是否相同
           if (cell?.v?.v && dCell.v.v != cell.v.v) return;
@@ -331,50 +342,50 @@ class LuckySheet extends React.Component {
 
   downloadExcel(checkValue) {
     let resultList = [];
-    console.log(this.luckysheet.getAllSheets())
+    console.log(this.luckysheet.getAllSheets());
 
     let currentData = this.luckysheet.getAllSheets();
-    currentData.forEach( sheet => {
+    currentData.forEach(sheet => {
       let data = sheet.data;
       let celldata = sheet.celldata;
       //获取当前导出列的数组
-      let colList = []
+      let colList = [];
       data[0]?.forEach((rowOneItem, colIdx) => {
-        if(rowOneItem && checkValue.indexOf(rowOneItem.v) !== -1){
+        if (rowOneItem && checkValue.indexOf(rowOneItem.v) !== -1) {
           colList.indexOf(colIdx) == -1 ? colList.push(colIdx) : true;
         }
-      })
+      });
 
       //处理data
-      const newData = []
+      const newData = [];
       data.forEach(item => {
-        if(item !== null){
+        if (item !== null) {
           let arr = item.filter((cur, idx) => {
-            return  item && colList.includes(idx)
-          })
+            return item && colList.includes(idx);
+          });
           // let len = item.length - arr.length
           // let nullList = new Array(len).fill(null);
           // let rowList =  arr.concat(nullList);
-          newData.push(arr)
+          newData.push(arr);
         }
-      })
+      });
       sheet.data = newData;
 
       //消除空列后都列下标
       let newColIdxList = colList.map((cur, idx) => {
         return idx;
-      })
+      });
       //处理celldata
-      const newCellData = []
+      const newCellData = [];
       celldata.forEach(item => {
         let idx = colList.indexOf(item.c);
-        if(idx !== -1){
+        if (idx !== -1) {
           item.c = newColIdxList[idx];
-          newCellData.push(item)
+          newCellData.push(item);
         }
-      })
+      });
       sheet.celldata = newCellData;
-    })
+    });
     exportExcel(currentData, '下载');
   }
 

+ 112 - 0
src/pages/PurchaseAdmin/PurchaseList/Detail/MergeModal.js

@@ -0,0 +1,112 @@
+import React, { useEffect, useState, useRef } from 'react';
+import { Form } from '@ant-design/compatible';
+import '@ant-design/compatible/assets/index.css';
+import { Modal, Checkbox, Row, Col, message, Tabs } from 'antd';
+import { connect } from 'dva';
+
+const { TabPane } = Tabs;
+
+// 选择比对版本
+function CompareModal(props) {
+  const { visible, versionList, onClose, onOk, historyList, dispatch, version } = props;
+
+  const [checkValue, setCheckValue] = useState([]);
+  const [tabList, setTabList] = useState([]);
+  const [active, setActive] = useState(version.id);
+
+  const onChange = check => {
+    if (check.length <= 2) {
+      setCheckValue(check);
+    } else {
+      message.error('只能比对两个文件');
+    }
+  };
+
+  const changeAcitve = versionId => {
+    setActive(versionId);
+    if (!versionId || historyList[versionId]) return;
+    // 查询历史提交
+    dispatch({
+      type: 'detail/queryHistoryList',
+      payload: {
+        version_id: versionId,
+      },
+    });
+  };
+
+  const handleOk = () => {
+    if (checkValue.length != 2) {
+      message.error('请选择要比对的两个文件');
+    } else {
+      let checkSheet = [];
+
+      Object.values(historyList).forEach(verList => {
+        if (checkSheet.length >= 2) return;
+        verList.forEach(item => {
+          if (checkValue.indexOf(item.id) != -1) {
+            checkSheet.push(item);
+          }
+        });
+      });
+      // console.log(checkSheet);
+      onOk(checkSheet);
+      onClose();
+      setCheckValue([]);
+    }
+  };
+
+  useEffect(() => {
+    if (version.id) {
+      setActive(version.id + '');
+    }
+  }, [version.id]);
+
+  // useEffect(() => {
+  //   let obj = {};
+  //   list.forEach(item => {
+  //     let nodeId = item.NodeInfo.id;
+  //     if (!obj[nodeId])
+  //       obj[nodeId] = {
+  //         list: [],
+  //         id: nodeId + '',
+  //         name: item.NodeInfo.node,
+  //       };
+  //     obj[nodeId].list.push(item);
+  //   });
+  //   let arr = Object.values(obj).map(item => item);
+  //   setTabList(arr);
+  //   setActive(arr[0]?.id);
+  // }, [list]);
+
+  return (
+    <Modal
+      title="选择合并的版本"
+      visible={visible}
+      onCancel={onClose}
+      onOk={handleOk}
+      bodyStyle={{ paddingTop: 0 }}
+    >
+      <Checkbox.Group value={checkValue} style={{ width: '100%' }} onChange={onChange}>
+        <Tabs activeKey={active} onChange={changeAcitve}>
+          {/* {tabList.map(tab => ( */}
+          {versionList.map(version => (
+            <TabPane tab={version.version_name} key={version.id}>
+              <Row>
+                {(historyList[version.id] || []).map(item => (
+                  <Col span={8} key={item.id}>
+                    <Checkbox value={item.id}>{item.version_name}</Checkbox>
+                  </Col>
+                ))}
+              </Row>
+            </TabPane>
+          ))}
+        </Tabs>
+      </Checkbox.Group>
+    </Modal>
+  );
+}
+
+export default connect(({ detail }) => ({
+  historyList: detail.historyList,
+  versionList: detail.versionList,
+}))(CompareModal);

+ 67 - 17
src/pages/PurchaseAdmin/PurchaseList/Detail/RightDrawer.js

@@ -4,39 +4,80 @@ import { Form } from '@ant-design/compatible';
 import '@ant-design/compatible/assets/index.css';
 import { Button, Drawer, Comment, Tooltip, Avatar, List, Card, Input, Descriptions } from 'antd';
 import moment from 'moment';
+import { connect } from 'dva';
 
 const { TextArea } = Input;
 
 // 评论
 function RightDrawer(props) {
-  const { visible, onClose, list, addComment, loading } = props;
+  const {
+    visible,
+    onClose,
+    comment,
+    bomComment,
+    addComment,
+    version,
+    loading,
+    dispatch,
+    cellPosition,
+  } = props;
   // const [commentList, setCommentList] = useState([]);
 
   const handleSubmitBom = (value, callback) => {
     if (!value) return;
-    addComment(value, callback);
+    dispatch({
+      type: 'detail/addBomComment',
+      payload: {
+        excel_id: version.id,
+        comment: value,
+      },
+      callback,
+    });
   };
   const handleSubmitCell = (value, callback) => {
     if (!value) return;
-    addComment(value, callback);
+    dispatch({
+      type: 'detail/addComment',
+      payload: {
+        ...cellPosition.current,
+        comment: value,
+      },
+      callback,
+    });
   };
+
+  useEffect(() => {
+    if (!version.id) return;
+    dispatch({
+      type: 'detail/queryBomComment',
+      payload: { excel_id: version.id },
+    });
+  }, [version.id]);
+
   return (
-    <Drawer width={600} title="评论列表" mask={false} placement="right" onClose={onClose} visible={visible}>
+    <Drawer
+      width={600}
+      title="评论列表"
+      mask={false}
+      placement="right"
+      onClose={onClose}
+      visible={visible}
+    >
       <BomContetn />
       <CommentContent
         title="BOM沟通记录"
-        list={list}
+        comment={bomComment}
         onSubmit={handleSubmitBom}
-        loading={loading}
+        loading={
+          loading.effects['detail/queryBomComment'] || loading.effects['detail/addBomComment']
+        }
+      />
+      <CommentContent
+        title="单元格沟通记录"
+        comment={comment}
+        onSubmit={handleSubmitCell}
+        loading={loading.effects['detail/queryComment'] || loading.effects['detail/addComment']}
       />
-      {list.length > 0 && (
-        <CommentContent
-          title="单元格沟通记录"
-          list={list}
-          onSubmit={handleSubmitCell}
-          loading={loading}
-        />
-      )}
     </Drawer>
   );
 }
@@ -54,11 +95,16 @@ function BomContetn(props) {
 }
 
 function CommentContent(props) {
-  const { list, loading, onSubmit, title } = props;
+  const {
+    comment: { list },
+    loading,
+    onSubmit,
+    title,
+  } = props;
   const [value, setValue] = useState('');
 
   return (
-    <Card title={title} type="inner" style={{marginTop: 20}}>
+    <Card title={title} type="inner" style={{ marginTop: 20 }}>
       <List
         className="comment-list"
         itemLayout="horizontal"
@@ -107,4 +153,8 @@ function CommentContent(props) {
   );
 }
 
-export default RightDrawer;
+export default connect(({ detail, loading }) => ({
+  comment: detail.comment,
+  bomComment: detail.bomComment,
+  loading: loading,
+}))(RightDrawer);

+ 26 - 35
src/pages/PurchaseAdmin/PurchaseList/Detail/TimeNode.js

@@ -1,46 +1,37 @@
 import React, { useEffect, useState, useRef } from 'react';
 import { Form } from '@ant-design/compatible';
 import '@ant-design/compatible/assets/index.css';
-import {
-  Steps,
-  Button,
-  Drawer,
-  Comment,
-  Tooltip,
-  Avatar,
-  List,
-  Card,
-  Modal,
-  Checkbox,
-  Row,
-  Col,
-  message,
-  Input,
-  Table,
-  Alert,
-  Spin,
-  Tabs,
-} from 'antd';
+import { connect } from 'dva';
+import { Steps } from 'antd';
 
 const { Step } = Steps;
-const { TextArea } = Input;
-const { TabPane } = Tabs;
 // 时间节点
 function TimeNode(props) {
   const {
-    flow: { current, list },
+    flow: { current, list, active },
+    flowDetail,
+    nodeId,
   } = props;
-  return (
-    <Steps current={current}>
-      {list.FlowNodes.map(item => (
-        <Step
-          key={item.id}
-          title={item.node}
-          description={`审批人:${item.AuditorUser?.CName || '-'}`}
-        />
-      ))}
-    </Steps>
-  );
+
+  if (active !== 0) {
+    return (
+      <Steps current={current}>
+        {list.FlowNodes.map(item => (
+          <Step
+            key={item.id}
+            title={item.node}
+            description={`审批人:${item?.user.map(item => item.CName).join('、') || '-'}`}
+          />
+        ))}
+      </Steps>
+    );
+  } else {
+    if (!flowDetail?.nodes) return;
+    const node = flowDetail.nodes.find(item => item.Id == nodeId);
+    return `当前节点:${node?.label || '-'}`;
+  }
 }
 
-export default TimeNode;
+export default connect(({ xflow }) => ({
+  flowDetail: xflow.flowDetail,
+}))(TimeNode);

+ 34 - 12
src/pages/PurchaseAdmin/PurchaseList/Detail/models/detail.js

@@ -24,7 +24,9 @@ import {
   queryHistoryList,
   queryHistoryDetail,
   submitNextNode,
-  approve
+  addBomComment,
+  queryBomComment,
+  approve,
 } from '@/services/boom';
 import { queryRole } from '@/services/SysAdmin';
 import { setCurrentUser } from '@/utils/authority';
@@ -37,7 +39,6 @@ export default {
   namespace: 'detail',
   state: {
     template: {},
-    version: {},
     versionList: [],
     historyList: [],
     auditList: [],
@@ -62,6 +63,7 @@ export default {
       pagination: false,
     },
     comment: { list: [] },
+    bomComment: { list: [] },
     fileList: [],
     roleList: [],
   },
@@ -154,6 +156,32 @@ export default {
         });
       }
     },
+    *queryBomComment({ payload }, { call, put }) {
+      const response = yield call(queryBomComment, payload);
+      if (response) {
+        yield put({
+          type: 'save',
+          payload: { bomComment: response.data },
+        });
+      }
+    },
+    *addBomComment({ payload, callback }, { call, put }) {
+      try {
+        const response = yield call(addBomComment, payload);
+        if (response) {
+          yield put({
+            type: 'queryBomComment',
+            payload: {
+              excel_id: payload.excel_id,
+            },
+          });
+          message.success('评论成功');
+          callback && callback();
+        }
+      } catch (error) {
+        console.log(error);
+      }
+    },
     // 提交流转
     *submitNextNode({ payload, callback }, { call, put }) {
       let response = yield call(submitNextNode, payload);
@@ -169,15 +197,8 @@ export default {
       }
     },
     *queryDetail({ payload, callback }, { call, put }) {
-      const response = yield call(queryDetail, payload);
-      if (response) {
-        let sheet = response.data;
-        sheet.data = JSON.parse(sheet.data || '[]');
-        sheet.data.forEach(item => {
-          item.config = JSON.parse(item.config || '{}');
-          item.celldata = JSON.parse(item.cell_data || '[]');
-          delete item.cell_data;
-        });
+      const sheet = yield call(queryDetail, payload);
+      if (sheet) {
         callback?.(sheet);
       }
     },
@@ -202,10 +223,11 @@ export default {
         const response = yield call(approve, payload);
         if (response) {
           message.success('操作成功');
+          callback(response.data);
           yield put({
             type: 'queryVersionsList',
             payload: {
-              projectId: payload.projectId,
+              project_id: payload.project_id,
             },
           });
         }

+ 7 - 3
src/pages/PurchaseAdmin/PurchaseList/Flow/Audit.js

@@ -4,6 +4,7 @@ import { connect } from 'dva';
 import AuditNodeModal from './AuditNodeModal';
 import AuditModal from './AuditModal';
 import styles from './Audit.less';
+import router from 'umi/router';
 
 const { Option } = Select;
 
@@ -178,6 +179,7 @@ function Audit(props) {
   return (
     <div>
       <div className={styles.box}>
+        <Button onClick={() => router.go(-1)}>返回</Button>
         <Form layout="inline" name="basic" autoComplete="off" form={form}>
           <Form.Item label="审批流程" name="flowId">
             <Select onChange={handleSelect} style={{ minWidth: 180 }}>
@@ -186,10 +188,12 @@ function Audit(props) {
               ))}
             </Select>
           </Form.Item>
+          <Form.Item>
+            <Button onClick={() => changeVisible('audit', true)} type="primary">
+              新建流程
+            </Button>
+          </Form.Item>
         </Form>
-        <Button onClick={() => changeVisible('audit', true)} type="primary">
-          新建流程
-        </Button>
       </div>
 
       <Table

+ 1 - 1
src/pages/PurchaseAdmin/PurchaseList/Flow/Flow.js

@@ -58,7 +58,7 @@ class FlowPage extends React.PureComponent {
       <div>
         {/* <Form></Form> */}
         <Link to="/home/audit" style={{ marginBottom: 20 }}>
-          <Button style={{ marginBottom: 20 }}>流管理</Button>
+          <Button style={{ marginBottom: 20 }}>审批流管理</Button>
         </Link>
 
         <Flow

+ 5 - 15
src/pages/PurchaseAdmin/PurchaseList/Index.js

@@ -36,7 +36,7 @@ function LayoutDetail(props) {
               defaultSelectedKeys={[props.location.pathname]}
               style={{ lineHeight: '64px', width: '100%' }}
             >
-              <SubMenu key="/home/work-hours" title="工时管理">
+              {/* <SubMenu key="/home/work-hours" title="工时管理">
                 <Menu.Item key="/home/work-hours">
                   <Link to="/home/work-hours">上报工时</Link>
                 </Menu.Item>
@@ -53,21 +53,12 @@ function LayoutDetail(props) {
                   <Link to="/home/approval/auth">审核列表</Link>
                 </Menu.Item>
               </SubMenu>
-              {/* <Menu.Item key="/home/work-hours">
-                <Link to="/home/work-hours">工时管理</Link>
-              </Menu.Item> */}
-
-              {/* <Menu.Item key="/home/work-hours-auth">
-                <Link to="/home/work-hours-auth">审批工时</Link>
-              </Menu.Item> */}
+      
               {(isAdmin ||
                 currentUser.is_leader ||
                 currentUser.is_accountant ||
                 permission['func-01-point-works-report']) && (
                 <SubMenu key="/home/report" title="工时报表">
-                  {/* <Menu.Item key="/home/report/resource">
-                  <Link to="/home/report/resource">资源报表</Link>
-                </Menu.Item> */}
                   {(isAdmin ||
                     currentUser.is_leader ||
                     currentUser.is_accountant ||
@@ -82,14 +73,13 @@ function LayoutDetail(props) {
                       <Link to="/home/report/department">部门报表</Link>
                     </Menu.Item>
                   )}
-                  {/* <Menu.Item key="/home/report/dep">部门报表</Menu.Item> */}
                 </SubMenu>
-              )}
-              {isAdmin && (
+              )} */}
+              {/* {isAdmin && ( */}
                 <Menu.Item key="/home">
                   <Link to="/home">采购清单</Link>
                 </Menu.Item>
-              )}
+              {/* )} */}
               <Menu.Item key="/home/flow">
                 <Link to="/home/flow">流程图</Link>
               </Menu.Item>

+ 8 - 1
src/pages/PurchaseAdmin/PurchaseList/List/NewList.js

@@ -26,7 +26,14 @@ function List(props) {
       title: '操作',
       render: record => (
         <>
-          <a onClick={() => router.push(`/home/detail/${record.id}/${record.project_id}`)}>查看</a>
+          <a
+            onClick={() => {
+              localStorage.excelId = record.id;
+              router.push(`/home/detail/${record.project_id}`);
+            }}
+          >
+            查看
+          </a>
         </>
       ),
     },

+ 1 - 1
src/pages/PurchaseAdmin/PurchaseList/Login/models/login.js

@@ -26,7 +26,7 @@ export default {
         payload: response,
       });
 
-      yield put(routerRedux.replace('/home/work-hours'));
+      yield put(routerRedux.replace('/home'));
     },
     *logout(_, { call, put }) {
       yield call(Logout);

+ 18 - 1
src/services/boom.js

@@ -24,6 +24,15 @@ export async function approve(params) {
     body: params
   });
 }
+export async function addBomComment(params) {
+  return request(`/purchase/comment`, {
+    method: 'POST',
+    body: params
+  });
+}
+export async function queryBomComment(params) {
+  return request(`/purchase/comment?${stringify(params)}`);
+}
 
 /**
  * 提交流转
@@ -45,7 +54,15 @@ export async function submitNextNode(params) {
 }
 
 export async function queryDetail(params) {
-  return request(`/purchase/record?${stringify(params)}`);
+  let response =await request(`/purchase/record?${stringify(params)}`);
+  let sheet = response.data;
+  sheet.data = JSON.parse(sheet.data || '[]');
+  sheet.data.forEach(item => {
+    item.config = JSON.parse(item.config || '{}');
+    item.celldata = JSON.parse(item.cell_data || '[]');
+    delete item.cell_data;
+  });
+  return sheet
 }
 export async function queryHistoryDetail(params) {
   return request(`/purchase/record/history/detail?${stringify(params)}`);

Some files were not shown because too many files changed in this diff