Przeglądaj źródła

Merge branch 'master' into develop

xujunjie 2 lat temu
rodzic
commit
b173439474

Plik diff jest za duży
+ 0 - 0
public/Luckysheet/luckysheet.umd.js


Plik diff jest za duży
+ 0 - 0
public/Luckysheet/luckysheet.umd.js.map


+ 19 - 20
src/pages/Detail/ApprovalProcess.tsx

@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useMemo, useState } from 'react';
 
 import { queryUserListByRoleID } from '@/services/boom';
 import { connect } from 'dva';
@@ -18,21 +18,23 @@ const ApprovalProcess = props => {
   const [curNodeIdx, setCurNodeIdx] = useState(-1);
   const [loading, setLoading] = useState(false);
 
-  const list = approvalProcess[id];
-  list?.forEach(item => {
-    if (item.length > 1 && item[0].type == TYPR.USER) {
-      item.forEach(curUser => {
-        curUser.name = userList.find(user => user.ID == curUser.value)?.CName || '-';
-      });
-    } else if (item.length == 1 && item[0].type == TYPR.USER) {
-      item[0].name = userList.find(user => user.ID == item[0].value)?.CName || '-';
-    } else if (item.length == 1 && item[0].nowType == TYPR.USER) {
-      item[0].name = userList.find(user => user.ID == item[0].nowValue)?.CName || '-';
-    } else {
-      item[0].name = null;
-    }
-  });
-  console.log(list);
+  const list = useMemo(() => {
+    const newList = approvalProcess[id];
+    newList?.forEach(item => {
+      if (item.length > 1 && item[0].type == TYPR.USER) {
+        item.forEach(curUser => {
+          curUser.name = userList.find(user => user.ID == curUser.value)?.CName || '-';
+        });
+      } else if (item.length == 1 && item[0].type == TYPR.USER) {
+        item[0].name = userList.find(user => user.ID == item[0].value)?.CName || '-';
+      } else if (item.length == 1 && item[0].nowType == TYPR.USER) {
+        item[0].name = userList.find(user => user.ID == item[0].nowValue)?.CName || '-';
+      } else {
+        item[0].name = null;
+      }
+    });
+    return newList;
+  }, [approvalProcess]);
 
   const onStepsChange = async (current, list) => {
     setLoading(true);
@@ -71,8 +73,7 @@ const ApprovalProcess = props => {
           <Step
             key={item[0]?.value}
             icon={
-              item[0].type != TYPR.USER || item[0].nowType == TYPR.USER ? (
-                <Popover
+              <Popover
                   placement="bottomLeft"
                   title={'选择审批人'}
                   content={content}
@@ -81,8 +82,6 @@ const ApprovalProcess = props => {
                 >
                   <PlusOutlined />
                 </Popover>
-              ) : null
-              // <PlusOutlined />
             }
             title={
               item[0]?.name || `从${roleList?.find(cur => cur.ID == item[0]?.value)?.Name}选择`

+ 78 - 34
src/pages/Detail/CommitAuditModal.js

@@ -22,7 +22,12 @@ import { useForm } from 'rc-field-form';
 import { async } from '@antv/x6/lib/registry/marker/async';
 import AuditDetailed from './AuditDetailed';
 import AuditFlow from './AuditFlow';
-import { queryDingSchema, queryProcessFlows } from '@/services/boom';
+import {
+  queryDingSchema,
+  queryGetBomForm,
+  queryProcessFlows,
+  querySaveBomForm,
+} from '@/services/boom';
 import { Form as Form3x } from '@ant-design/compatible';
 import { getCurrentUser } from '@/utils/authority';
 import DDCode from '@/components/DDComponents/DDCode';
@@ -63,32 +68,67 @@ function CommitAuditModal(props) {
   useEffect(() => {
     if (!visible) return;
     const { edges, nodes } = flowDetail;
-    let Id = version.template_node_id;
-    const currentId = flowDetail.nodes.find?.(item => item.Id == Id)?.node_id;
-    const data = treeData(currentId);
-    if (data.length <= 0) {
-      setAuditId(currentId)
-    }
-    else {
-      let defaultValues = {}
-      data.forEach((item, index) => {
-        let value = getDataValue(item)
-        defaultValues[`circle${index}`] = value
-      })
-      // 设置延迟,等待组件渲染
-      setTimeout(() => {
-        form.setFieldsValue(defaultValues)
-        Object.values(defaultValues).forEach(value => onChange(value))
-      }, 200)
-    }
-    setData(data);
-  }, [auditId, version.template_node_id, visible]);
+    initFormList().then(approvalProcess => {
+      let Id = version.template_node_id;
+      const currentId = flowDetail.nodes.find?.(item => item.Id == Id)?.node_id;
+      const data = treeData(currentId);
+      if (data.length <= 0) {
+        setAuditId(currentId);
+      } else {
+        let defaultValues = {};
+        if (data.length == 1) {
+          let value = getDataValue(data[0]);
+          defaultValues[`circle`] = value;
+        } else {
+          data.forEach((item, index) => {
+            let value = getDataValue(item);
+            defaultValues[`circle${index}`] = value;
+          });
+        }
+        // 设置延迟,等待组件渲染
+        setTimeout(() => {
+          form.setFieldsValue(defaultValues);
+          Object.values(defaultValues).forEach(value => onChange(value, approvalProcess || {}));
+        }, 200);
+      }
+      setData(data);
+    });
+  }, [version.template_node_id, visible]);
 
   useEffect(() => {
     form.resetFields();
     setAuditList([]);
   }, [visible]);
 
+  const initFormList = async () => {
+    const res = await queryGetBomForm({
+      project_id: version.project_id,
+      node_id: version.template_node_id,
+    });
+    if (res.data) {
+      const formList = JSON.parse(res.data.json);
+
+      // const defaultApproval = {};
+      // formList.forEach(item => {
+      //   const curItem = JSON.parse(item);
+      //   const audit_list = curItem.audit_list.map(audit => {
+      //     return [{ type: 'user', value: audit, name: null }];
+      //   });
+      //   defaultApproval[curItem.template_node_id] = audit_list;
+      // });
+      // const defaultFormData = {};
+      // formList.forEach(item => {
+      //   const curItem = JSON.parse(item);
+      //   defaultFormData[curItem.template_node_id] = curItem.formComponentValues;
+      // });
+      // console.log('========defaultApproval==============', defaultApproval);
+      // console.log('========defaultFormData==============', defaultFormData);
+      setApprovalProcess(formList.approvalProcess || {});
+      return formList.approvalProcess;
+      // setFormComponentValues(defaultFormData);
+    }
+  };
+
   const treeData = currentId => {
     const list = getNextNodes(currentId, 'custom-circle');
     const fun = nodes => {
@@ -171,9 +211,10 @@ function CommitAuditModal(props) {
     setAuditId(node.node_id);
   };
 
-  const onChange = value => {
+  const onChange = (value, approvalProcess) => {
+    if (!value) return;
     changeAudit(value[value.length - 1]);
-    setAuditListFun();
+    setAuditListFun(approvalProcess);
   };
 
   const getReComputeAudit = (items, changedValues) => {
@@ -219,13 +260,12 @@ function CommitAuditModal(props) {
         if (data) {
           setApprovalProcess(data);
         }
-        console.log('=======================================', data);
       },
     });
   };
 
   //处理tabs页
-  const setAuditListFun = async () => {
+  const setAuditListFun = async (approvalProcess = {}) => {
     var fieldsValue = await form.validateFields();
     let addAuditList = [];
     let result = Object.values(fieldsValue)
@@ -249,7 +289,7 @@ function CommitAuditModal(props) {
           nodeId: node.Id,
           items: JSON.parse(curData.form_json || '[]'),
         };
-        
+
         return newItem;
       });
       addAuditList = [...addAuditList, ...newlist];
@@ -279,14 +319,13 @@ function CommitAuditModal(props) {
             })
             .filter(item => item);
           if (getReComputeAudit(items, changedValues)) advanceSubmit();
-          // console.log('==================================', { ...formComponentValues });
           setFormComponentValues({ ...formComponentValues });
         },
       })(AuditDetailed);
       item.FormComponents = <Components items={item.items} />;
     });
     setAuditList(addAuditList);
-    advanceSubmit();
+    if (Object.keys(approvalProcess).length == 0) advanceSubmit();
   };
 
   const getFromData = async idList => {
@@ -446,6 +485,11 @@ function CommitAuditModal(props) {
       message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
       return;
     }
+    await querySaveBomForm({
+      project_id: version.project_id,
+      node_id: version.template_node_id,
+      json: JSON.stringify({approvalProcess}),
+    });
     onOk(params);
   };
   const CascaderNode = index => {
@@ -507,7 +551,7 @@ function CommitAuditModal(props) {
           // rules={[{ required: true, message: '请选择业务节点' }]}
         >
           <Select style={{ width: '100%' }}>
-            {getNextNodes(data.length < 0 ? currentNodeId : auditId, 'custom-rect').map(item => (
+            {getNextNodes(auditId || currentNodeId, 'custom-rect').map(item => (
               <Option key={item.value}>{item.label}</Option>
             ))}
           </Select>
@@ -545,13 +589,13 @@ function CommitAuditModal(props) {
 }
 
 function getDataValue(item) {
-  let arr = []
-  arr.push(item.value)
+  let arr = [];
+  arr.push(item.value);
   if (item.children?.length > 0) {
-    let res = getDataValue(item.children[0])
-    arr = arr.concat(res)
+    let res = getDataValue(item.children[0]);
+    arr = arr.concat(res);
   }
-  return arr
+  return arr;
 }
 
 export default connect(({ xflow, detail, user }) => ({

+ 43 - 75
src/pages/Detail/FlowModal.js

@@ -154,57 +154,13 @@ function FlowModal(props) {
         list: seqList,
         name: curNode?.label || itemDataList[0].FlowInfo.name,
       };
-      // itemDataList.forEach((itemData, idx) => {
-      //   if (idx >= obj.list.length) return;
-      //   obj.list[idx].auditor = itemData.AuthorInfo.CName;
-      // });
       return obj;
     });
     setStepsData(dataList);
   };
 
-  // const updateSteps = async (data, curNodeId) => {
-  //   const dataList = [];
-  //   for (let i = 0; i < data.length; i++) {
-  //     let curNode = flowDetail.nodes.find(item => item.Id == data[i].template_node_id);
-  //     console.log(curNode);
-  //     const response = await queryDingInstanceDetail({
-  //       process_instance_id: data[i].ding_instance_id, //创建表单成功返回的id
-  //     });
-  //     if (response) {
-  //       const processInstance = response.data?.process_instance;
-  //       let data = {
-  //         processCode: '',
-  //         deptId: '14169890',
-  //         tasks: [],
-  //         // userId: '16569001414345099',
-  //         // deptId: currentUser.DingDepId || getCurrentUser()?.DingDepId,
-  //         userId: currentUser.DingUserId || getCurrentUser()?.DingUserId,
-  //         formComponentValues: [],
-  //         activityId: '',
-  //         cc_userids: [],
-  //         status: 'undefined',
-  //         name: curNode?.label || '未知节点',
-  //       };
-  //       if (processInstance?.tasks && processInstance.tasks?.length > 0) {
-  //         // let item = flowDetail.nodes.find(item => item.Id == version.template_node_id);
-  //         // if (!item) return data;
-  //         const { tasks, form_component_values, cc_userids } = processInstance;
-  //         data.processCode = curNode.process_code;
-  //         data.activityId = tasks[tasks.length - 1]?.activity_id;
-  //         data.tasks = tasks || [];
-  //         data.cc_userids = cc_userids;
-  //         data.formComponentValues = form_component_values?.filter(curNode => curNode.name);
-  //       }
-  //       dataList.push(data);
-  //     }
-  //   }
-  //   console.log(dataList);
-  //   setStepsData(dataList);
-  // };
-
   const handleChangeClick = item => {
-    let file = isOut ? 'newList' : 'detail';
+    let file = isOut ? 'list' : 'detail';
     let type = item.flow_id ? '/queryAuditRecord' : '/queryAuditExcel';
     console.log(`${file}${type}`, item);
     dispatch({
@@ -295,7 +251,7 @@ function FlowModal(props) {
             dom = txt;
           }
           return item.audit_status != 0 ? (
-            <Button onClick={() => onDelVersion(item)}>{dom}</Button>
+            <Button onClick={() => handleChangeClick(item)}>{dom}</Button>
           ) : (
             <span style={style}>{dom}</span>
           );
@@ -386,7 +342,7 @@ function FlowModal(props) {
             dom = txt;
           }
           return item.audit_status != 0 ? (
-            <Button onClick={() => onDelVersion(item)}>{dom}</Button>
+            <Button onClick={() => handleChangeClick(item)}>{dom}</Button>
           ) : (
             <span style={style}>{dom}</span>
           );
@@ -439,10 +395,7 @@ function FlowModal(props) {
         resultData = data.filter(item => item.version_name.includes(inputValue));
         break;
       case SELECT_TYPE.TYPE:
-        const classify = typeOptions.find(item => item.name.includes(inputValue));
-        if (classify) {
-          resultData = data.filter(item => item.classify_id == classify.id);
-        }
+        resultData = data.filter(item => item.classify_id == inputValue);
         break;
       case SELECT_TYPE.CREATOR:
         resultData = data.filter(item => item.AuthorInfo?.CName.includes(inputValue));
@@ -469,38 +422,53 @@ function FlowModal(props) {
           </Col>
           <Col span={10}>
             <div style={{ fontSize: '16px', marginBottom: '10px' }}>清单列表</div>
-            <div style={{ display: 'flex' }}>
-              <Select
-                defaultValue={selectType}
-                style={{ width: '20%' }}
-                onChange={value => {
-                  setSelectType(value);
-                  setInputValue('');
-                }}
-              >
-                <Option value={SELECT_TYPE.NAME}>名称:</Option>
-                <Option value={SELECT_TYPE.TYPE}>分类:</Option>
-                <Option value={SELECT_TYPE.CREATOR}>创建人:</Option>
-              </Select>
-              <Input
-                placeholder="请输入"
-                value={inputValue}
-                onChange={e => setInputValue(e.target.value)}
-              />
-              {isOut && (
-                <Button
-                  type="primary"
-                  style={{ marginLeft: '20%' }}
-                  onClick={() => setVersionVisible(true)}
+            <div style={{ display: 'flex', justifyContent: 'space-between' }}>
+              <div style={{ width: '60%' }}>
+                <Select
+                  defaultValue={selectType}
+                  style={{ width: '30%' }}
+                  onChange={value => {
+                    setSelectType(value);
+                    setInputValue('');
+                  }}
                 >
+                  <Option value={SELECT_TYPE.NAME}>名称:</Option>
+                  <Option value={SELECT_TYPE.TYPE}>分类:</Option>
+                  <Option value={SELECT_TYPE.CREATOR}>创建人:</Option>
+                </Select>
+                {selectType != SELECT_TYPE.TYPE && (
+                  <Input
+                    style={{ width: '70%' }}
+                    placeholder="请输入"
+                    value={inputValue}
+                    onChange={e => setInputValue(e.target.value)}
+                  />
+                )}
+                {selectType == SELECT_TYPE.TYPE && (
+                  <Select
+                    showSearch
+                    allowClear
+                    style={{ width: '70%' }}
+                    placeholder="请选择分类"
+                    options={typeOptions}
+                    onChange={id => setInputValue(id)}
+                    filterOption={(input, option) =>
+                      (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
+                    }
+                  />
+                )}
+              </div>
+              {isOut && (
+                <Button type="primary" onClick={() => setVersionVisible(true)}>
                   新建清单
                 </Button>
               )}
             </div>
+
             <div style={{ width: '100%', marginTop: '10px' }}>
               <Table
                 columns={columns}
-                dataSource={showData} //data
+                dataSource={showData}
                 loading={nodeLoading}
                 bordered={false}
                 pagination={{ position: ['none', 'none'], pageSize: 999, onChange }}

+ 3 - 3
src/pages/Detail/Index.js

@@ -1011,9 +1011,9 @@ function Detail(props) {
     dispatch({
       type: 'user/getRoleList',
     });
-    // dispatch({
-    //   type: 'user/fetch',
-    // });
+    dispatch({
+      type: 'user/fetch',
+    });
     dispatch({
       type: 'user/fetchDepV2',
     });

+ 3 - 3
src/pages/Detail/LuckySheet.js

@@ -94,13 +94,13 @@ class LuckySheet extends React.Component {
         },
         updated(operate) {
           if (operate.type == 'datachange') {
-            if(_this.currentSheetIndex != operate.sheetIndex) {
-              _this.currentSheetIndex = operate.sheetIndex
+            if (_this.currentSheetIndex != operate.sheetIndex) {
+              _this.currentSheetIndex = operate.sheetIndex;
               return;
             }
             clearTimeout(_this.updateTimer);
             _this.updateTimer = setTimeout(() => {
-              onUpdate.bind(_this)
+              onUpdate.bind(_this);
               onUpdate();
             }, 1000);
           }

+ 5 - 5
src/pages/Flow/List.js

@@ -72,11 +72,11 @@ function List(props) {
         <Button type="primary" style={{ marginRight: 20 }} onClick={() => setVisible(true)}>
           新增工作流
         </Button>
-        {(permission['func-01-point-bom-flow'] || currentUser.IsSuper) && (
-          <Link to="/home/audit-list">
-            <Button type="primary">审批流管理</Button>
-          </Link>
-        )}
+        {/* {(permission['func-01-point-bom-flow'] || currentUser.IsSuper) && ( */}
+        <Link to="/home/audit-list">
+          <Button type="primary">审批流管理</Button>
+        </Link>
+        {/* )} */}
       </div>
 
       <Table rowKey="Id" dataSource={list} columns={columns} />

+ 4 - 0
src/pages/List/ClassifyModal.js

@@ -32,6 +32,7 @@ const ClassifyModal = ({ data, visible, userList, onClose, handleChange }) => {
       render: item => {
         return (
           <Select
+            showSearch
             mode="multiple"
             allowClear
             style={{ width: '100%' }}
@@ -39,6 +40,9 @@ const ClassifyModal = ({ data, visible, userList, onClose, handleChange }) => {
             defaultValue={item.uid ? item.uid.split(',').map(item => Number(item)) : []}
             onChange={e => onChange(e, item)}
             options={list}
+            filterOption={(input, option) =>
+              (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
+            }
           />
         );
       },

+ 1 - 1
src/pages/List/List.js

@@ -139,6 +139,7 @@ function List(props) {
 
   const onCommit = async (values, id, callback) => {
     let currentNode = flowDetail.nodes.find?.(item => item.Id == version.template_node_id);
+    setCommitLoading(true);
     let sheets = await queryRecordSheet({ gridKey: version.id, 'JWT-TOKEN': token });
     // if (!currentNode.muti_version) {
     //   // audit_status=4 表示为清单推进后留存的副本.不计入多清单计算
@@ -165,7 +166,6 @@ function List(props) {
       data: sheets,
       base_id: version.id,
     };
-    setCommitLoading(true);
     dispatch({
       type: 'list/commitSheet',
       payload: params,

+ 14 - 1
src/services/boom.js

@@ -17,7 +17,7 @@ export async function queryRecord(params) {
 export async function queryDelSheetRecord(params) {
   const response = await request(`/purchase/bom/del-purchase-excel-sheet?${stringify(params)}`);
   if (response.code == 200) {
-    message.success('删除成功');
+    // message.success('删除成功');
   }
 }
 
@@ -441,3 +441,16 @@ export async function queryDelPurchaseExcel(params) {
   });
   return res;
 }
+//提交流转存储表单审批人历史记录
+export async function querySaveBomForm(data) {
+  return request(`/purchase/bom/save-bom-form`, {
+    method: 'POST',
+    body: data,
+  });
+}
+export async function queryGetBomForm(params) {
+  let res = await request(`/purchase/bom/get-bom-form?${stringify(params)}`, {
+    method: 'GET',
+  });
+  return res;
+}

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików