瀏覽代碼

添加业务节点权限配置

Renxy 2 年之前
父節點
當前提交
b7c21ca5d7

+ 1 - 1
src/components/Flow/node/fields/radio.tsx

@@ -29,7 +29,7 @@ const SelectField: React.FC<IProps> = props => {
         }}
       >
         {options.map(item => (
-          <Radio value={item.value}>{item.label}</Radio>
+          <Radio key={`${item.value}-${item.label}`} value={item.value}>{item.label}</Radio>
         ))}
       </Radio.Group>
     </div>

+ 32 - 3
src/components/Flow/node/rect/mapServe.tsx

@@ -1,6 +1,6 @@
 import React, { useState, useEffect } from 'react';
 import { FlowchartFormWrapper } from '@antv/xflow';
-import { Button, message } from 'antd';
+import { Button, message, Select } from 'antd';
 import LuckyExcel from 'luckyexcel';
 import {
   Position,
@@ -13,6 +13,7 @@ import {
 } from '../fields';
 import { PREFIX } from '../constants';
 import { UnityAction } from '@/utils/utils';
+import { connect } from 'dva';
 
 export interface IConfig {
   label?: string;
@@ -31,6 +32,7 @@ export interface IConfig {
   version_name?: string;
   data?: any;
   excel_info?: any;
+  role_list?:string;
 }
 
 const defaultConfig: IConfig = {
@@ -39,8 +41,9 @@ const defaultConfig: IConfig = {
 };
 
 const Component = (props: any) => {
-  const { config, plugin = {} } = props;
+  const { config, plugin = {}, roleList } = props;
   const { updateNode } = plugin;
+  const [options, setOptions] = useState([])
   const [nodeConfig, setNodeConfig] = useState<IConfig>({
     ...defaultConfig,
     ...config,
@@ -113,6 +116,16 @@ const Component = (props: any) => {
   }, [config]);
   // console.log(nodeConfig, config)
 
+  useEffect(() => {
+    if(!roleList || roleList.length <= 0) return;
+    let op = []
+    roleList.forEach(item => {
+      op.push({label:item.Name, value:item.ID})
+    })
+    setOptions(op);
+    console.log(op)
+  },[roleList])
+
   return (
     <div className={`${PREFIX}-panel-body`}>
       <div className={`${PREFIX}-panel-group`}>
@@ -166,6 +179,20 @@ const Component = (props: any) => {
             <div>{nodeConfig.excel_info?.file_name}</div>
           </>
         )}
+        <div className='group'>
+          <label>权限</label>
+          <Select
+            value= {nodeConfig.role_list ? nodeConfig.role_list.split(",").map(item=>Number(item)) : []}
+            mode="multiple"
+            allowClear
+            style={{ width: '100%' }}
+            placeholder="选择权限"
+            onChange={(v: number[]) => {
+              onNodeConfigChange('role_list', v.join(','))
+            }}
+            options={options}
+          />
+        </div>
       </div>
       <div className={`${PREFIX}-panel-group`}>
         <h5>样式</h5>
@@ -229,10 +256,12 @@ const Component = (props: any) => {
   );
 };
 
-export default function RecthServe(props: any) {
+function RecthServe(props: any) {
   return (
     <FlowchartFormWrapper {...props}>
       {(config, plugin) => <Component {...props} plugin={plugin} config={config} />}
     </FlowchartFormWrapper>
   );
 }
+
+export default connect(({ flow }) => ({ roleList: flow.roleList }))(RecthServe);

+ 2 - 0
src/pages/PurchaseAdmin/PurchaseList/Detail/FlowModal.js

@@ -46,6 +46,8 @@ function FlowModal(props) {
           data = [...data, ...arr];
         }
       });
+      //解决key报错问题
+      data.forEach((item, id)=>data[id].key=`${id}-${item.name}`)
       setData(data);
     } catch (error) {
       console.log(error);

+ 129 - 0
src/pages/PurchaseAdmin/PurchaseList/Detail/HistoryDrawer.js

@@ -0,0 +1,129 @@
+import React, { useEffect, useState, useRef, useMemo } from 'react';
+import { UserOutlined } from '@ant-design/icons';
+import { Form } from '@ant-design/compatible';
+import '@ant-design/compatible/assets/index.css';
+import { Drawer, Descriptions, Card, Table } from 'antd';
+import moment from 'moment';
+import { connect } from 'dva';
+import CommentContent from '@/components/CommentContent';
+
+// 评论
+function HistoryDrawer(props) {
+  const {
+    visible,
+    onClose,
+    comment,
+    bomComment,
+    addComment,
+    version,
+    loading,
+    dispatch,
+    userList,
+    cellPosition,
+  } = props;
+  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]);
+  // const [commentList, setCommentList] = useState([]);
+
+  // const handleSubmitBom = (value, callback) => {
+  //   if (!value) return;
+  //   dispatch({
+  //     type: 'detail/addBomComment',
+  //     payload: {
+  //       excel_id: version.id,
+  //       comment: value,
+  //     },
+  //     callback,
+  //   });
+  // };
+  // const handleSubmitCell = (value, callback) => {
+  //   if (!value) return;
+  //   dispatch({
+  //     type: 'detail/addComment',
+  //     payload: {
+  //       ...cellPosition.current,
+  //       comment: value,
+  //     },
+  //     callback,
+  //   });
+  // };
+
+  // useEffect(() => {
+  //   if (!version.id || !visible) return;
+  //   dispatch({
+  //     type: 'detail/queryBomComment',
+  //     payload: { excel_id: version.id },
+  //   });
+  // }, [version.id,visible]);
+
+  return (
+    <Drawer
+      width={600}
+      title="历史版本"
+      mask={false}
+      placement="right"
+      onClose={onClose}
+      visible={visible}
+    >
+      {/* <Table columns={columns} dataSource={data} loading={nodeLoading} bordered={false} /> */}
+    </Drawer>
+  );
+}
+export default connect(({ detail, user, loading }) => ({
+  comment: detail.comment,
+  userList: user.list,
+  bomComment: detail.bomComment,
+  loading: loading,
+}))(HistoryDrawer);

+ 27 - 5
src/pages/PurchaseAdmin/PurchaseList/Detail/Index.js

@@ -21,6 +21,7 @@ import CommentContent from '@/components/CommentContent';
 import MergeModal from './MergeModal';
 import { GetTokenFromUrl, getToken } from '@/utils/utils';
 import { queryDetail } from '@/services/boom';
+import HistoryDrawer from './HistoryDrawer';
 const LocalData = localStorage.luckysheet;
 
 const { Option } = Select;
@@ -40,6 +41,7 @@ function Detail(props) {
     flowDetail,
     match: { params },
   } = props;
+  const [historyVisible, setHistoryVisible] = useState(false);
   const [commentVisible, setCommentVisible] = useState(false);
   const [mergeVisible, setMergeVisible] = useState(false);
   const [compareVisible, setCompareVisible] = useState(false);
@@ -531,7 +533,19 @@ function Detail(props) {
     ];
     // version.audit_status:4 为副本。不可操作
     if (version.audit_status != 4) {
-      menuList.push(<Menu.Item key="commitAudit">提交流转</Menu.Item>);
+      //判断权限配置,如果配置了,就指定权限的人可提交,没配置就全部人都可提交
+      const getIsSubmit = () => {
+        const nodeId = version.template_node_id;
+        if (!flowDetail?.nodes || !nodeId) return;
+        const node = flowDetail.nodes.find(item => item.Id == nodeId);
+        if( node?.role_list && node?.role_list.length > 0){
+          return node.role_list.split(",").some(id=> currentUser.roleList?.find(role=>role.ID == id))
+        } 
+        return true;
+      }
+      console.log('是否有权限提交流转',getIsSubmit())
+      if(getIsSubmit()) menuList.push(<Menu.Item key="commitAudit">提交流转</Menu.Item>);
+      
 
       if (!isAuditor && canEdit() && !version.flow_id) {
         // menuList.push(<Menu.Item key="edit">编辑</Menu.Item>);
@@ -828,15 +842,17 @@ function Detail(props) {
           )}
           <span style={{ marginLeft: 20 }}>{renderNode()}</span>
         </div>
-        <div className={styles.btns}>
+        <div className={styles.btns}> 
+          <Button type="primary" style={{ marginRight: 20 }} onClick={() => setHistoryVisible(true)}>
+            历史版本
+          </Button>
           <Avatar.Group style={{ marginRight: 20 }}>
-            {user.map(item => (
-              <Avatar style={{ backgroundColor: '#008dff' }} size="large">
+            {user.map((item, id) => (
+              <Avatar key={`${id}-${item.name}`} style={{ backgroundColor: '#008dff' }} size="large">
                 {item.Name}
               </Avatar>
             ))}
           </Avatar.Group>
-
           {renderBtns()}
         </div>
         <input
@@ -874,6 +890,12 @@ function Detail(props) {
         </div>
       )}
 
+      <HistoryDrawer 
+         version={version}
+         visible={historyVisible}
+         onClose={() => setHistoryVisible(false)}
+      />
+
       <CommentContent
         title="单元格沟通记录"
         comment={comment}

+ 3 - 0
src/pages/PurchaseAdmin/PurchaseList/Flow/List.js

@@ -47,6 +47,9 @@ function List(props) {
     dispatch({
       type: 'flow/queryProject',
     });
+    dispatch({
+      type: 'flow/getRoleList',
+    });
   }, []);
 
   return (

+ 0 - 2
src/pages/PurchaseAdmin/PurchaseList/Index.js

@@ -92,11 +92,9 @@ function LayoutDetail(props) {
                 </SubMenu>
               )}
 
-              {/* {isAdmin && (
               <Menu.Item key="/home">
                 <Link to="/home">采购清单</Link>
               </Menu.Item>
-              )} */}
               <Menu.Item key="/home/flow-list">
                 <Link to="/home/flow-list">流程图</Link>
               </Menu.Item>