Procházet zdrojové kódy

Merge branch 'develop' into checkout

XuZinan před 2 roky
rodič
revize
167ddd38b6

+ 1 - 1
src/components/Flow/config-toolbar.ts

@@ -231,7 +231,7 @@ namespace NSToolbarConfig {
                   id: item.id,
                   source: item.source,
                   target: item.target,
-                  attrs: item.attrs
+                  attr: JSON.stringify(item.attrs)
                 };
               });
               console.log(data);

+ 43 - 43
src/global.less

@@ -42,20 +42,20 @@ ol {
 }
 
 @media (max-width: @screen-xs) {
-  .ant-table {
-    width: 100%;
-    overflow-x: auto;
-    &-thead > tr,
-    &-tbody > tr {
-      > th,
-      > td {
-        white-space: pre;
-        > span {
-          display: block;
-        }
-      }
-    }
-  }
+  // .ant-table {
+  //   width: 100%;
+  //   overflow-x: auto;
+  //   &-thead > tr,
+  //   &-tbody > tr {
+  //     > th,
+  //     > td {
+  //       white-space: pre;
+  //       > span {
+  //         display: block;
+  //       }
+  //     }
+  //   }
+  // }
 }
 
 //.ant-table-wrapper {
@@ -109,35 +109,35 @@ ol {
   }
 }
 
-.ant-table {
-  table {
-    border: 1px solid #e8e8e8;
-    border-right: 0;
-    border-bottom: 0;
-
-    .ant-table-bordered .ant-table-thead > tr > th, .ant-table-bordered .ant-table-tbody > tr > td {
-      border-right: 1px solid #e8e8e8;
-    }
-    .ant-table-thead > tr > th {
-      color: rgba(0, 0, 0, 0.85);
-      font-weight: 500;
-      text-align: left;
-      background: #fafafa;
-      border-bottom: 1px solid #e8e8e8;
-      transition: background 0.3s ease;
-      border-right: 1px solid #e8e8e8;
-    }
-    .ant-table-tbody > tr > td {
-      border-bottom: 1px solid #e8e8e8;
-      border-right: 1px solid #e8e8e8;
-      background: white;
-    }
-
-    .ant-table-thead > tr:first-child > th:first-child {
-      border-top-left-radius: 4px;
-    }
-  }
-}
+// .ant-table {
+//   table {
+//     border: 1px solid #e8e8e8;
+//     border-right: 0;
+//     border-bottom: 0;
+
+//     .ant-table-bordered .ant-table-thead > tr > th, .ant-table-bordered .ant-table-tbody > tr > td {
+//       border-right: 1px solid #e8e8e8;
+//     }
+//     .ant-table-thead > tr > th {
+//       color: rgba(0, 0, 0, 0.85);
+//       font-weight: 500;
+//       text-align: left;
+//       background: #fafafa;
+//       border-bottom: 1px solid #e8e8e8;
+//       transition: background 0.3s ease;
+//       border-right: 1px solid #e8e8e8;
+//     }
+//     .ant-table-tbody > tr > td {
+//       border-bottom: 1px solid #e8e8e8;
+//       border-right: 1px solid #e8e8e8;
+//       background: white;
+//     }
+
+//     .ant-table-thead > tr:first-child > th:first-child {
+//       border-top-left-radius: 4px;
+//     }
+//   }
+// }
 
 /*滚动条整体样式*/
 ::-webkit-scrollbar {

+ 23 - 4
src/models/user.js

@@ -2,6 +2,7 @@ import {
   query as queryUsers,
   queryCurrent,
   queryCurrentV2,
+  queryUserRole,
   queryUnreadNotification,
   SetNotificationRead,
 } from '@/services/user';
@@ -10,6 +11,20 @@ import { queryDeviceItemRealtimeData } from '@/services/DeviceAdmin';
 import { queryUserList } from '@/services/plant';
 import { queryProjectMenu, queryUserDetail } from '@/services/SysAdmin';
 
+const getRoleList = data => {
+  let roleList = [];
+  (data || []).forEach(dep => {
+    (dep.Role || []).forEach(role => {
+      roleList.push(role);
+    });
+
+    if (dep.children) {
+      let res = getRoleList(dep.children, roleList);
+      roleList = res.concat(res);
+    }
+  });
+  return roleList;
+};
 export default {
   namespace: 'user',
 
@@ -48,25 +63,29 @@ export default {
         user.Permissions?.forEach(item => {
           permission = {
             ...permission,
-            ...item.Menus
-          }
-        })
+            ...item.Menus,
+          };
+        });
         try {
           localStorage.setItem('depId', user.DepId);
           if (payload?.ID) {
             const { data: resData } = yield call(queryProjectMenu, payload);
             // permission = resData[0] ? resData[0]?.Menus : {};
-            
           }
         } catch (error) {
           console.error(error);
         }
+        const resRole = yield call(queryUserRole, user.ID);
+        let roleList = getRoleList(resRole.data.Dep);
+        console.log(roleList);
+
         yield put({
           type: 'saveCurrentUser',
           payload: {
             ...user,
             // Permission: {},
             Permission: permission,
+            roleList: roleList,
           },
         });
       }

+ 57 - 36
src/pages/PurchaseAdmin/PurchaseList/Detail/FlowModal.js

@@ -1,5 +1,5 @@
 import React, { useEffect, useState, useRef, useMemo } from 'react';
-import { Modal, Input, Select, List, Row, Col } from 'antd';
+import { Modal, Input, Select, List, Row, Col, Table } from 'antd';
 import Flow from '@/components/Flow/index';
 import { connect } from 'dva';
 import { GetTokenFromUrl, getToken } from '@/utils/utils';
@@ -35,14 +35,13 @@ function FlowModal(props) {
     const id = args.nodeId || args.nodeIds[0];
     if (!id) return;
     let node = graphData.nodes.find(item => item.id == id);
-    // setData(node.version);
     setNodeLoading(true);
     try {
       res = await queryVserionByNode({ template_node_id: node.Id });
       let data = [];
       Object.values(res.data.excel_version).map(arr => {
         if (res.data.flow_id) {
-          data = [...data, arr[arr.length - 1]];
+          data = [...data, arr[0]];
         } else {
           data = [...data, ...arr];
         }
@@ -53,6 +52,60 @@ function FlowModal(props) {
     }
     setNodeLoading(false);
   };
+  const columns = useMemo(() => {
+    return [
+      {
+        title: '名称',
+        width: '33%',
+        render: item => (
+          <div style={{ color: item.audit_status != 0 ? '#9b9b9b' : '' }}>
+            {item.id == version.id && <CheckOutlined style={{ marginRight: 10 }} />}
+            {item.version_name}
+          </div>
+        ),
+      },
+      {
+        title: '状态',
+        width: '33%',
+        render: item => {
+          let style = { color: getColor(item) };
+          let txt = '';
+          switch (item.audit_status) {
+            case 0:
+              txt = '未提交';
+              break;
+            case 1:
+              txt = '待审批';
+              break;
+            case 2:
+              txt = '拒绝';
+              break;
+            case 3:
+              txt = '通过';
+              break;
+            case 4:
+              txt = '已提交';
+              break;
+          }
+          return <span style={style}>{txt}</span>;
+        },
+      },
+      {
+        title: '操作',
+        render: item =>
+          item.id != version.id && (
+            <a
+              onClick={() => {
+                onChangeVersion(item);
+                onClose();
+              }}
+            >
+              切换
+            </a>
+          ),
+      },
+    ];
+  }, [version]);
 
   return (
     <Modal
@@ -69,39 +122,7 @@ function FlowModal(props) {
           <Flow meta={{ type: 'view' }} flowDetail={graphData} onSelectNode={handleSelectNode} />
         </Col>
         <Col span={6}>
-          <List
-            size="small"
-            header={<div>清单列表</div>}
-            bordered
-            dataSource={data}
-            loading={nodeLoading}
-            renderItem={item => {
-              const isCurrent = item.id == version.id;
-              return (
-                <List.Item
-                  actions={
-                    isCurrent
-                      ? null
-                      : [
-                          <a
-                            onClick={() => {
-                              onChangeVersion(item);
-                              onClose();
-                            }}
-                          >
-                            切换
-                          </a>,
-                        ]
-                  }
-                >
-                  <div style={{ color: getColor(item) }}>
-                    {isCurrent && <CheckOutlined style={{marginRight: 10}}/>}
-                    {item.version_name}
-                  </div>
-                </List.Item>
-              );
-            }}
-          />
+          <Table columns={columns} dataSource={data} loading={nodeLoading} bordered={false} />
         </Col>
       </Row>
     </Modal>

+ 19 - 32
src/pages/PurchaseAdmin/PurchaseList/Detail/Index.js

@@ -102,7 +102,7 @@ function Detail(props) {
   const isAuditor = useMemo(() => {
     const getUserRole = () => {
       let roleID = flow.currentNode?.AuditRoleInfo?.ID;
-      let item = currentUser.Permissions.find(role => role.RoleId == roleID);
+      let item = currentUser.roleList.find(role => role.ID == roleID);
       if (item) return true;
       return false;
     };
@@ -225,7 +225,7 @@ function Detail(props) {
       );
       if (serviceVersion) {
         message.error(
-          `新建清单失败!业务节点【${currentNode.label}】为单清单节点。已存在清单【${serviceVersion.version_name}】。`
+          `新建清单失败!业务节点【${currentNode.label}】只能有一个清单!`
         );
         return;
       }
@@ -288,11 +288,11 @@ function Detail(props) {
   };
 
   const onAudit = ({ audit_comment }) => {
-    var flowNode = flow.currentNode;
+    const flowNode = flow.currentNode;
     dispatch({
       type: 'detail/approve',
       payload: {
-        id: version.id,
+        id: flow.active_id,
         project_id: projectId,
         audit_status: 2,
         flow_id: flowNode.flow_id,
@@ -318,27 +318,6 @@ function Detail(props) {
     });
   };
 
-  const onSubmitAudit = () => {
-    Modal.confirm({
-      title: '提示',
-      content: '是否确认提交审批。',
-      okText: '确定',
-      cancelText: '取消',
-      onOk() {
-        var flowNode = flow.currentNode;
-        dispatch({
-          type: 'detail/submitAudit',
-          payload: {
-            id: version.id,
-            flow_id: flowNode.flow_id,
-            node_id: flowNode.id,
-            projectId,
-          },
-        });
-      },
-    });
-  };
-
   const onApprove = flag => {
     if (!flag) {
       setAuditVisible(true);
@@ -383,6 +362,17 @@ function Detail(props) {
                 id: templateId,
               },
             });
+            
+            // 更新审批流
+            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.version_id,
+              },
+            });
             if (flow.current == flow.list.FlowNodes.length - 1) {
               // 最后一个审核节点通过后  需要更新version id
               localStorage.excelId = newVersion.id;
@@ -442,6 +432,7 @@ function Detail(props) {
     //   sheetRef3.current.mergeExcl(sheet.data);
     // }, 400);
   };
+
   const handleClickFile = () => {
     fileRef.current.click();
   };
@@ -504,10 +495,6 @@ function Detail(props) {
         setCommitVisible(true);
         setCommentVisible(false);
         break;
-      case 'approval':
-        // 申请审批
-        onSubmitAudit();
-        break;
       case 'attachment':
         // 附件
         setFileVisible(true);
@@ -743,10 +730,10 @@ function Detail(props) {
         setCommitAuditVisible(false);
         // 更新version
         localStorage.excelId = newVersion.id;
-        setVersion({
+        changeVersion({
           ...version,
-          flow_id: newVersion.flow_id,
-          id: newVersion.id,
+          ...newVersion,
+          version_id: version.id
         });
         // 更新flow流程图
         dispatch({

+ 2 - 2
src/pages/PurchaseAdmin/PurchaseList/Detail/LuckySheet.js

@@ -121,10 +121,10 @@ class LuckySheet extends React.Component {
           sheet: true,
           hintText: '当前处于审批节点,禁止编辑!'
         }
-      } else if(version.audit_status == 4) {
+      } else if(version.audit_status != 0) {
         option.authority = {
           sheet: true,
-          hintText: '当前清单为历史清单,不可编辑!'
+          hintText: '当前清单不可编辑!'
         }
       }
     } else if (data && data.length > 0) {

+ 15 - 120
src/pages/PurchaseAdmin/PurchaseList/Flow/FlowDetail.json

@@ -301,196 +301,91 @@
       "id": "41561012:92334433-975bf288:15d1b217",
       "source": { "cell": "41561012", "port": "92334433" },
       "target": { "cell": "975bf288", "port": "15d1b217" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "975bf288:821f59c0-5764f3ce:c29d7b43",
       "source": { "cell": "975bf288", "port": "821f59c0" },
       "target": { "cell": "5764f3ce", "port": "c29d7b43" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "975bf288:a61170c3-8c1f18d0:89c0bc16",
       "source": { "cell": "975bf288", "port": "a61170c3" },
       "target": { "cell": "8c1f18d0", "port": "89c0bc16" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "8c1f18d0:a3adcac9-41561012:293a90b5",
       "source": { "cell": "8c1f18d0", "port": "a3adcac9" },
       "target": { "cell": "41561012", "port": "293a90b5" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "5764f3ce:4b4d9fa6-1aed14d1:d348b56a",
       "source": { "cell": "5764f3ce", "port": "4b4d9fa6" },
       "target": { "cell": "1aed14d1", "port": "d348b56a" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": "5 5",
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":\"5 5\",\"strokeWidth\":1}}"
     },
     {
       "id": "1aed14d1:9a699e3f-4651130e:94f485b5",
       "source": { "cell": "1aed14d1", "port": "9a699e3f" },
       "target": { "cell": "4651130e", "port": "94f485b5" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "5764f3ce:ce88d7e2-3fb8d302:22d16375",
       "source": { "cell": "5764f3ce", "port": "ce88d7e2" },
       "target": { "cell": "3fb8d302", "port": "22d16375" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "3fb8d302:205f1437-a48131e0:bac7962b",
       "source": { "cell": "3fb8d302", "port": "205f1437" },
       "target": { "cell": "a48131e0", "port": "bac7962b" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "a48131e0:4dee75d9-b57b57c8:73307680",
       "source": { "cell": "a48131e0", "port": "4dee75d9" },
       "target": { "cell": "b57b57c8", "port": "73307680" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": "5 5",
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":\"5 5\",\"strokeWidth\":1}}"
     },
     {
       "id": "a48131e0:0f72f2ba-3631eae9:2aae2a71",
       "source": { "cell": "a48131e0", "port": "0f72f2ba" },
       "target": { "cell": "3631eae9", "port": "2aae2a71" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "3631eae9:8e0bff55-399bddb7:0bccd839",
       "source": { "cell": "3631eae9", "port": "8e0bff55" },
       "target": { "cell": "399bddb7", "port": "0bccd839" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "399bddb7:58f52f2c-c28a18d3:e67dc19c",
       "source": { "cell": "399bddb7", "port": "58f52f2c" },
       "target": { "cell": "c28a18d3", "port": "e67dc19c" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "c28a18d3:b578cc26-5359e23c:ff6724ee",
       "source": { "cell": "c28a18d3", "port": "b578cc26" },
       "target": { "cell": "5359e23c", "port": "ff6724ee" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "5359e23c:34c9dbc6-5216c5dc:d2030f1b",
       "source": { "cell": "5359e23c", "port": "34c9dbc6" },
       "target": { "cell": "5216c5dc", "port": "d2030f1b" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     },
     {
       "id": "b57b57c8:04c81e99-4651130e:1eb352b0",
       "source": { "cell": "b57b57c8", "port": "04c81e99" },
       "target": { "cell": "4651130e", "port": "1eb352b0" },
-      "attrs": {
-        "line": {
-          "stroke": "#A2B1C3",
-          "targetMarker": { "name": "block", "width": 12, "height": 8 },
-          "strokeDasharray": [0, 0],
-          "strokeWidth": 1
-        }
-      }
+      "attr": "{\"line\":{\"stroke\":\"#A2B1C3\",\"targetMarker\":{\"name\":\"block\",\"width\":12,\"height\":8},\"strokeDasharray\":[0,0],\"strokeWidth\":1}}"
     }
   ]
 }

+ 5 - 1
src/services/boom.js

@@ -200,7 +200,11 @@ export async function queryBoomFlowDetail(params) {
         port: item.target_port,
       },
     };
-    edge.attrs = attrs;
+    try {
+      edge.attrs = item.attr ? JSON.parse(item.attr) : attrs;
+    } catch (error) {
+      edge.attrs = attrs;
+    }
     return edge;
   });
   return {

+ 3 - 0
src/services/user.js

@@ -11,6 +11,9 @@ export async function queryCurrent() {
 export async function queryCurrentV2() {
   return request('/api/v2/user/current-user', {method: 'GET'});
 }
+export async function queryUserRole(userId) {
+  return request('/api/v2/user/detail/'+userId, {method: 'GET'});
+}
 
 export async function queryUnreadNotification() {
   return request('/notification/unread/', {method: 'GET'});