Renxy преди 2 години
родител
ревизия
d87fe7e012

+ 14 - 10
src/components/Flow/node/circle/mapServe.tsx

@@ -23,7 +23,7 @@ export interface IConfig {
 }
 
 const Component = (props: any) => {
-  // const templateList = [
+  // const auditList = [
   //   {
   //     icon_url: 'https://gw.alicdn.com/tfs/TB13f_aCQzoK1RjSZFlXXai4VXa-102-102.png',
   //     is_new_process: false,
@@ -52,8 +52,8 @@ const Component = (props: any) => {
   //     attendance_type: 0,
   //   },
   // ];
-  const { config, plugin = {}, templateList } = props; //, auditList
-  console.log(templateList);
+  const { config, plugin = {}, auditList } = props; //, auditList
+  console.log(auditList);
   const { updateNode } = plugin;
   const [nodeConfig, setNodeConfig] = useState<IConfig>({
     ...config,
@@ -103,17 +103,21 @@ const Component = (props: any) => {
         <h5>数据</h5>
         <SelectField
           label="审批流程"
-          value={nodeConfig.process_code}
+          value={nodeConfig.flow_id}
           onChange={value => {
+            let audit = auditList.find(item => item.list.id == value);
+
             onNodeConfigChange(null, {
-              flow_node_id: 0,
-              process_code: value,
+              flow_node_id: audit.list.FlowNodes[0]?.id,
+              flow_id: value,
+              process_code: audit.list.process_code,
             });
           }}
-          options={templateList.map(item => {
+          options={auditList.map(item => {
+            const list = item.list;
             return {
-              label: item.flow_title,
-              value: item.process_code,
+              label: list.name || list.id,
+              value: list.id,
             };
           })}
         />
@@ -188,4 +192,4 @@ function RecthServe(props: any) {
   );
 }
 
-export default connect(({ flow }) => ({ templateList: flow.templateList }))(RecthServe);
+export default connect(({ xflow }) => ({ auditList: xflow.auditList }))(RecthServe);

+ 26 - 16
src/pages/PurchaseAdmin/PurchaseList/Detail/CommitAuditModal.js

@@ -6,6 +6,7 @@ import { isArray, result } from 'lodash';
 import { useForm } from 'rc-field-form';
 import { async } from '@antv/x6/lib/registry/marker/async';
 import AuditDetailed from './AuditDetailed';
+import { queryDingSchema } from '@/services/boom';
 
 const { TextArea } = Input;
 const { Option } = Select;
@@ -143,7 +144,6 @@ function CommitAuditModal(props) {
     },
   };
   const [schemaContent, setSchemaContent] = useState(res.result.schemaContent);
-  console.log(schemaContent);
 
   useEffect(() => {
     const { edges, nodes } = flowDetail;
@@ -151,8 +151,9 @@ function CommitAuditModal(props) {
     const currentId = flowDetail.nodes.find?.(item => item.Id == Id)?.node_id;
     const data = treeData(currentId);
     if (data.length <= 0) setAuditId(currentId);
+    console.log('================data', data, currentId, version);
     setData(data);
-  }, [auditId, version.template_node_id]);
+  }, [auditId, version]);
 
   useEffect(() => {
     form.resetFields();
@@ -246,20 +247,32 @@ function CommitAuditModal(props) {
   //处理tabs页
   const setAuditListFun = async () => {
     var fieldsValue = await form.validateFields();
+    let addAuditList = [];
     let result = Object.values(fieldsValue)
       .map(item => {
         if (item && Array.isArray(item)) return item;
       })
       .filter(item => item)
       .flat(Infinity);
-    let addAuditList = [...new Set(result)]
+    let codeList = [...new Set(result)]
       .map(Id => {
-        return flowDetail.nodes.find?.(item => item.Id == Id);
+        return flowDetail.nodes.find?.(item => item.Id == Id).process_code;
       })
-      .filter(item => item);
+      .filter(item => item); // && !auditList.find(node => node.formCode == item)
+    console.log('=========================auditfvsfs', codeList, auditList);
+    codeList.map(async process_code => {
+      let res = await queryDingSchema({ process_code });
+      if (res) {
+        addAuditList.push(res.data.result);
+      }
+    });
     setAuditList(addAuditList);
   };
 
+  useEffect(() => {
+    console.log(auditList);
+  }, [auditList]);
+
   const onFinish = async () => {
     var fieldsValue = await form.validateFields();
     let hasFlowId = true; //是否都绑定审批节点
@@ -334,11 +347,11 @@ function CommitAuditModal(props) {
       params.template_node_id = result[0][0]; // 将要流转的节点审批节点
       params.flow_path = result.map(item => getFlowPath(item));
     }
-    if (!hasFlowId) {
-      message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
-      return;
-    }
-    // onOk(params);
+    // if (!hasFlowId) {
+    //   message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
+    //   return;
+    // }
+    onOk(params);
   };
 
   const onTabChange = key => {
@@ -390,12 +403,9 @@ function CommitAuditModal(props) {
         </Form.Item>
       </Form>
       <Tabs defaultActiveKey="1" onChange={onTabChange}>
-        {auditList.map(item => (
-          // <TabPane tab={item.label} key={`${item.Id}_${item.label}`}>
-          //   <AuditDetailed />
-          // </TabPane>
-          <TabPane tab={schemaContent.title} key={`${item.Id}_${item.label}`}>
-            <AuditDetailed items={schemaContent.items} />
+        {auditList.map((item, idx) => (
+          <TabPane tab={item.name} key={`${idx}_${item.name}`}>
+            <AuditDetailed items={item.schemaContent.items} />
           </TabPane>
         ))}
       </Tabs>

+ 0 - 143
src/pages/PurchaseAdmin/PurchaseList/Detail/CommitAuditModalNew.js

@@ -1,143 +0,0 @@
-import React, { useEffect, useState, useRef, useMemo } from 'react';
-import { Form } from '@ant-design/compatible';
-import '@ant-design/compatible/assets/index.css';
-import { Modal, Input, Select, message } from 'antd';
-import { connect } from 'dva';
-
-const { TextArea } = Input;
-const { Option } = Select;
-
-// 提交
-function CommitAuditModal(props) {
-  const { visible, onClose, onOk, form, loading, version, versionList, flowDetail } = props;
-  const [auditId, setAuditId] = useState();
-  const handleOk = () => {
-    form.validateFields((err, fieldsValue) => {
-      console.log("-------",fieldsValue )
-      if (err) return;
-      let approvalNode = flowDetail.nodes.find?.(item => item.Id == fieldsValue.node_id);
-      let serviceNode = flowDetail.nodes.find?.(
-        item => item.Id == fieldsValue.next_template_node_id
-      );
-      let params = {
-        desc: fieldsValue.desc,
-        // 审核流程id
-        flow_id: approvalNode?.flow_id || 0,
-        node_level_id: approvalNode?.flow_id ? 1 : 0,
-
-        id: version.id,
-        project_id: version.project_id,
-        cur_template_node_id: version.template_node_id * 1, // 当前节点
-        template_node_id: approvalNode?.Id, // 将要流转的节点审批节点
-        next_template_node_id: serviceNode.Id * 1, // 审核完成后的业务节点
-
-        // 模板id.一致就行
-        template_id: version.template_id,
-        cur_template_id: version.template_id,
-        next_template_id: version.template_id,
-      };
-      if (approvalNode?.Id) {
-        if (!approvalNode?.flow_id) {
-          message.error('审批节点未绑定审批流程!请联系管理员。');
-          return;
-        }
-      }
-      // // 判断业务节点是否允许多清单
-      // if (!serviceNode.muti_version) {
-      //   //audit_status=4 表示为清单推进后留存的副本.不计入多清单计算
-      //   let serviceVersion = versionList.find(
-      //     item => item.audit_status != 4 && item.template_node_id == serviceNode.Id
-      //   );
-      //   if (serviceVersion) {
-      //     message.error(
-      //       `流转失败!业务节点【${serviceNode.label}】为单清单节点。已存在清单【${serviceVersion.version_name}】。`
-      //     );
-      //     return;
-      //   }
-      // }
-
-
-      setAuditId();
-      // onOk(params);
-    });
-  };
-  const currentNodeId = useMemo(() => {
-    let Id = version.template_node_id;
-    return flowDetail.nodes.find?.(item => item.Id == Id)?.node_id;
-  }, [flowDetail, version]);
-  /**
-   *
-   * @param {*} currentId 当前节点
-   * @param {*} type 下一个节点的类型  custom-circle: 审批节点   custom-rect: 业务节点
-   * @returns
-   */
-  const getNextNodes = (currentId, type) => {
-    const { edges, nodes } = flowDetail;
-    if (!currentId) return [];
-    let targetIds = edges
-      .filter(edge => edge.source.cell == currentId)
-      .map(item => item.target.cell);
-    let auditNodes = nodes.filter(node => {
-      if (type && node.name != type) {
-        return false;
-      }
-      return targetIds.indexOf(node.id) != -1;
-    });
-    return auditNodes || [];
-  };
-
-  const changeAudit = id => {
-    let node = flowDetail.nodes.find?.(item => item.Id == id);
-    setAuditId(node.node_id);
-  };
-
-  return (
-    <Modal
-      confirmLoading={loading}
-      destroyOnClose
-      title="提交流转目标"
-      visible={visible}
-      onCancel={() => {
-        setAuditId();
-        onClose();
-      }}
-      onOk={handleOk}
-    >
-      <Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label="审批节点">
-        {form.getFieldDecorator('node_id')(
-          <Select style={{ width: '100%' }} onChange={changeAudit}>
-            {getNextNodes(currentNodeId, 'custom-circle').map(item => (
-              <Option key={item.Id}>{item.label}</Option>
-            ))}
-          </Select>
-        )}
-      </Form.Item>
-      {/* <Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label="审批节点2">
-        {form.getFieldDecorator('nod_id')(
-          <Select style={{ width: '100%' }} onChange={changeAudit}>
-            {getNextNodes(auditId || currentNodeId, 'custom-circle').map(item => (
-              <Option key={item.Id}>{item.label}</Option>
-            ))}
-          </Select>
-        )}
-      </Form.Item> */}
-      <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' : '').map(item => (
-              <Option key={item.Id}>{item.label}</Option>
-            ))}
-          </Select>
-        )}
-      </Form.Item>
-      <Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label="备注信息">
-        {form.getFieldDecorator('desc')(<Input.TextArea />)}
-      </Form.Item>
-    </Modal>
-  );
-}
-
-export default connect(({ xflow, detail }) => ({
-  flowDetail: xflow.flowDetail,
-  versionList: detail.versionList,
-}))(Form.create()(CommitAuditModal));

+ 7 - 0
src/pages/PurchaseAdmin/PurchaseList/Detail/models/detail.js

@@ -31,6 +31,7 @@ import {
   queryVersionsTree,
   queryAuditExcel,
   queryAuditRecord,
+  queryDingSchema,
 } from '@/services/boom';
 import { queryRole } from '@/services/SysAdmin';
 import { setCurrentUser } from '@/utils/authority';
@@ -513,6 +514,12 @@ export default {
         callback && callback(response.data?.all);
       }
     },
+    *queryDingSchema({ payload, callback }, { call, put }) {
+      const response = yield call(queryDingSchema, payload);
+      if (response) {
+        callback && callback(response.data?.all);
+      }
+    },
   },
 
   reducers: {

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

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

+ 4 - 0
src/services/boom.js

@@ -103,6 +103,10 @@ export async function queryAuditExcel(params) {
 export async function queryAuditRecord(params) {
   return request(`/api/v1/purchase/audit/record?${stringify(params)}`);
 }
+//查询表单数据接口
+export async function queryDingSchema(params) {
+  return request(`/api/v1/purchase/bom/ding/schema?${stringify(params)}`);
+}
 /**
  * 查看项目流程列表
  * project_id