|
@@ -1,8 +1,23 @@
|
|
-import React, { useEffect, useState, useRef, useMemo } from 'react';
|
|
|
|
|
|
+import React, { useEffect, useState, useRef, useMemo, useCallback } from 'react';
|
|
import '@ant-design/compatible/assets/index.css';
|
|
import '@ant-design/compatible/assets/index.css';
|
|
-import { Modal, Input, Select, message, Cascader, Form, Tabs, Row, Col, Empty, Button } from 'antd';
|
|
|
|
|
|
+import {
|
|
|
|
+ Modal,
|
|
|
|
+ Input,
|
|
|
|
+ Select,
|
|
|
|
+ message,
|
|
|
|
+ Cascader,
|
|
|
|
+ Form,
|
|
|
|
+ Tabs,
|
|
|
|
+ Row,
|
|
|
|
+ Col,
|
|
|
|
+ Empty,
|
|
|
|
+ Button,
|
|
|
|
+ Steps,
|
|
|
|
+ Popover,
|
|
|
|
+} from 'antd';
|
|
|
|
+import { PlusOutlined } from '@ant-design/icons';
|
|
import { connect } from 'dva';
|
|
import { connect } from 'dva';
|
|
-import { isArray, result } from 'lodash';
|
|
|
|
|
|
+import { isArray, result, set } from 'lodash';
|
|
import { useForm } from 'rc-field-form';
|
|
import { useForm } from 'rc-field-form';
|
|
import { async } from '@antv/x6/lib/registry/marker/async';
|
|
import { async } from '@antv/x6/lib/registry/marker/async';
|
|
import AuditDetailed from './AuditDetailed';
|
|
import AuditDetailed from './AuditDetailed';
|
|
@@ -11,15 +26,17 @@ import { queryDingSchema, queryProcessFlows } from '@/services/boom';
|
|
import { Form as Form3x } from '@ant-design/compatible';
|
|
import { Form as Form3x } from '@ant-design/compatible';
|
|
import { getCurrentUser } from '@/utils/authority';
|
|
import { getCurrentUser } from '@/utils/authority';
|
|
import DDCode from '@/components/DDComponents/DDCode';
|
|
import DDCode from '@/components/DDComponents/DDCode';
|
|
-import { uploadFile } from '@/services/boom';
|
|
|
|
|
|
+import { uploadFile, queryUserListByRoleID } from '@/services/boom';
|
|
|
|
|
|
const { TextArea } = Input;
|
|
const { TextArea } = Input;
|
|
const { Option } = Select;
|
|
const { Option } = Select;
|
|
const { TabPane } = Tabs;
|
|
const { TabPane } = Tabs;
|
|
|
|
+const { Step } = Steps;
|
|
|
|
|
|
// 提交
|
|
// 提交
|
|
function CommitAuditModal(props) {
|
|
function CommitAuditModal(props) {
|
|
const {
|
|
const {
|
|
|
|
+ dispatch,
|
|
visible,
|
|
visible,
|
|
onClose,
|
|
onClose,
|
|
onOk,
|
|
onOk,
|
|
@@ -29,6 +46,7 @@ function CommitAuditModal(props) {
|
|
flowDetail,
|
|
flowDetail,
|
|
currentUser,
|
|
currentUser,
|
|
luckysheet,
|
|
luckysheet,
|
|
|
|
+ userList,
|
|
} = props;
|
|
} = props;
|
|
const [auditId, setAuditId] = useState();
|
|
const [auditId, setAuditId] = useState();
|
|
const [data, setData] = useState([]);
|
|
const [data, setData] = useState([]);
|
|
@@ -37,6 +55,9 @@ function CommitAuditModal(props) {
|
|
const [auditList, setAuditList] = useState([]); //用于创建Tabs表单
|
|
const [auditList, setAuditList] = useState([]); //用于创建Tabs表单
|
|
const [formComponentValues, setFormComponentValues] = useState({}); //用于创建Tabs表单
|
|
const [formComponentValues, setFormComponentValues] = useState({}); //用于创建Tabs表单
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
|
|
+ const [approvalProcess, setApprovalProcess] = useState({});
|
|
|
|
+ const [selectUserList, setSelectUserList] = useState([]);
|
|
|
|
+ const [curNodeIdx, setCurNodeIdx] = useState(-1);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (!visible) return;
|
|
if (!visible) return;
|
|
@@ -137,9 +158,76 @@ function CommitAuditModal(props) {
|
|
|
|
|
|
const onChange = value => {
|
|
const onChange = value => {
|
|
changeAudit(value[value.length - 1]);
|
|
changeAudit(value[value.length - 1]);
|
|
-
|
|
|
|
setAuditListFun();
|
|
setAuditListFun();
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+ const getReComputeAudit = (items, changedValues) => {
|
|
|
|
+ const id = Object.keys(changedValues)[0];
|
|
|
|
+ const formItem = items?.find(item => item.props.id == id);
|
|
|
|
+ if (formItem && formItem.props?.required) return true;
|
|
|
|
+ return false;
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ //填写表单实时计算审批流程
|
|
|
|
+ const advanceSubmit = async () => {
|
|
|
|
+ console.log('重重新计算审批流程');
|
|
|
|
+ var fieldsValue = await form.validateFields();
|
|
|
|
+ let hasFlowId = true; //是否都绑定审批节点
|
|
|
|
+
|
|
|
|
+ let result = Object.values(fieldsValue)
|
|
|
|
+ .map(item => {
|
|
|
|
+ if (item && Array.isArray(item)) return item;
|
|
|
|
+ })
|
|
|
|
+ .filter(item => item);
|
|
|
|
+ const formList = await getFromData(result);
|
|
|
|
+ let params = {
|
|
|
|
+ desc: fieldsValue.desc,
|
|
|
|
+ // 审核流程id
|
|
|
|
+ flow_id: 0,
|
|
|
|
+ node_level_id: 0,
|
|
|
|
+ id: version.id,
|
|
|
|
+ project_id: version.project_id,
|
|
|
|
+ cur_template_node_id: version.template_node_id * 1, // 当前节点
|
|
|
|
+ next_template_node_id: 0, // 审核完成后的业务节点
|
|
|
|
+ template_node_id: null, // 将要流转的节点审批节点
|
|
|
|
+ flow_path: null, //审批节点数组
|
|
|
|
+ // 模板id.一致就行
|
|
|
|
+ template_id: version.template_id,
|
|
|
|
+ cur_template_id: version.template_id,
|
|
|
|
+ next_template_id: version.template_id,
|
|
|
|
+ form_list: formList,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const ddd = {
|
|
|
|
+ '778': [
|
|
|
|
+ { type: 'user', value: 448, origin: 0 },
|
|
|
|
+ { type: 'role', value: 82, origin: 0 },
|
|
|
|
+ { type: 'role', value: 61, origin: 0 },
|
|
|
|
+ ],
|
|
|
|
+ '791': [
|
|
|
|
+ { type: 'user', value: 448, origin: 0 },
|
|
|
|
+ { type: 'role', value: 82, origin: 0 },
|
|
|
|
+ { type: 'role', value: 61, origin: 0 },
|
|
|
|
+ ],
|
|
|
|
+ '792': [
|
|
|
|
+ { type: 'user', value: 448, origin: 0 },
|
|
|
|
+ { type: 'role', value: 82, origin: 0 },
|
|
|
|
+ { type: 'role', value: 29, origin: 0 },
|
|
|
|
+ ],
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'detail/advanceSubmitNextNode',
|
|
|
|
+ payload: params, //values,
|
|
|
|
+ callback: data => {
|
|
|
|
+ if (data) {
|
|
|
|
+ setApprovalProcess(data);
|
|
|
|
+ }
|
|
|
|
+ console.log('=======================================', data);
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
//处理tabs页
|
|
//处理tabs页
|
|
const setAuditListFun = async () => {
|
|
const setAuditListFun = async () => {
|
|
var fieldsValue = await form.validateFields();
|
|
var fieldsValue = await form.validateFields();
|
|
@@ -193,6 +281,7 @@ function CommitAuditModal(props) {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.filter(item => item);
|
|
.filter(item => item);
|
|
|
|
+ if (getReComputeAudit(items, changedValues)) advanceSubmit();
|
|
console.log('==================================', { ...formComponentValues });
|
|
console.log('==================================', { ...formComponentValues });
|
|
setFormComponentValues({ ...formComponentValues });
|
|
setFormComponentValues({ ...formComponentValues });
|
|
},
|
|
},
|
|
@@ -225,14 +314,43 @@ function CommitAuditModal(props) {
|
|
flow_id: approvalNode.flow_id,
|
|
flow_id: approvalNode.flow_id,
|
|
template_node_id: approvalNode.Id,
|
|
template_node_id: approvalNode.Id,
|
|
formComponentValues: [...values], //{ name: '附件', value: JSON.stringify(attachment) }
|
|
formComponentValues: [...values], //{ name: '附件', value: JSON.stringify(attachment) }
|
|
|
|
+ audit_list: approvalProcess[approvalNode.Id]?.map(item => item[0].value) || [],
|
|
};
|
|
};
|
|
result.push(JSON.stringify(formItem));
|
|
result.push(JSON.stringify(formItem));
|
|
});
|
|
});
|
|
return result;
|
|
return result;
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+ const getFlowPath = node => {
|
|
|
|
+ //[134, 135]
|
|
|
|
+ let itemData = {};
|
|
|
|
+ const Function = (curId, index) => {
|
|
|
|
+ if (!curId) return;
|
|
|
|
+ let data = {};
|
|
|
|
+ let approvalNode = flowDetail.nodes.find?.(item => item.Id == curId);
|
|
|
|
+ data.template_id = version.template_id;
|
|
|
|
+ data.flow_id = approvalNode?.flow_id || 0;
|
|
|
|
+ data.node_level_id = approvalNode?.flow_id ? 1 : 0;
|
|
|
|
+ data.template_node_id = approvalNode?.Id;
|
|
|
|
+ index++;
|
|
|
|
+ if (approvalNode?.Id) {
|
|
|
|
+ if (!approvalNode?.flow_id) {
|
|
|
|
+ hasFlowId = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const res = Function(node[index], index);
|
|
|
|
+ if (res) {
|
|
|
|
+ data.flow_path = [res];
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+ };
|
|
|
|
+ itemData = Function(node[0], 0);
|
|
|
|
+ return itemData;
|
|
|
|
+ };
|
|
|
|
+
|
|
const onFinish = async () => {
|
|
const onFinish = async () => {
|
|
|
|
+ console.log(approvalProcess);
|
|
var fieldsValue = await form.validateFields();
|
|
var fieldsValue = await form.validateFields();
|
|
- console.log();
|
|
|
|
let hasFlowId = true; //是否都绑定审批节点
|
|
let hasFlowId = true; //是否都绑定审批节点
|
|
const getFlowPath = node => {
|
|
const getFlowPath = node => {
|
|
//[134, 135]
|
|
//[134, 135]
|
|
@@ -315,6 +433,7 @@ function CommitAuditModal(props) {
|
|
message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
|
|
message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ console.log(params);
|
|
onOk(params);
|
|
onOk(params);
|
|
};
|
|
};
|
|
const CascaderNode = index => {
|
|
const CascaderNode = index => {
|
|
@@ -353,6 +472,74 @@ function CommitAuditModal(props) {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const renderSteps = id => {
|
|
|
|
+ const list = approvalProcess[id];
|
|
|
|
+ list?.forEach(item => {
|
|
|
|
+ if (item.length > 1 && item[0].type == 'user') {
|
|
|
|
+ item.forEach(curUser => {
|
|
|
|
+ curUser.name = userList.find(user => user.ID == curUser.value)?.CName || '-';
|
|
|
|
+ });
|
|
|
|
+ } else if (item.length == 1 && item[0].type == 'user') {
|
|
|
|
+ item[0].name = userList.find(user => user.ID == item[0].value)?.CName || '-';
|
|
|
|
+ } else {
|
|
|
|
+ item[0].name = null;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ console.log(list);
|
|
|
|
+
|
|
|
|
+ const onStepsChange = async (current, list) => {
|
|
|
|
+ const itemNode = list[current][0];
|
|
|
|
+ if (itemNode.type !== 'role') return;
|
|
|
|
+ const data = await queryUserListByRoleID({ role_id: itemNode.value });
|
|
|
|
+ console.log(data);
|
|
|
|
+ setCurNodeIdx(current);
|
|
|
|
+ setSelectUserList(data);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const selectedUserId = userId => {
|
|
|
|
+ const name = userList.find(user => user.ID == userId)?.CName || '-';
|
|
|
|
+ const data = { type: 'user', value: Number(userId), name };
|
|
|
|
+ list[curNodeIdx][0] = data;
|
|
|
|
+ console.log(list);
|
|
|
|
+ setApprovalProcess({ ...approvalProcess, [id]: list });
|
|
|
|
+ // const newData = userIdData[id] || [];
|
|
|
|
+ // newData[curNodeIdx] = userId;
|
|
|
|
+ // setUserIdData({ ...userIdData, [id]: newData });
|
|
|
|
+ // console.log(userId, curNodeIdx, { ...userIdData, [id]: newData });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return (
|
|
|
|
+ <>
|
|
|
|
+ <Steps current={-1} direction="vertical" onChange={value => onStepsChange(value, list)}>
|
|
|
|
+ {list?.map(item => (
|
|
|
|
+ <Step
|
|
|
|
+ key={item[0]?.value}
|
|
|
|
+ icon={
|
|
|
|
+ item[0]?.name ? null : (
|
|
|
|
+ // <Popover
|
|
|
|
+ // placement="rightTop"
|
|
|
|
+ // title={'选择审批人'}
|
|
|
|
+ // content={selectUserList.map(item => {
|
|
|
|
+ // <div>{item.c_name}</div>;
|
|
|
|
+ // })}
|
|
|
|
+ // trigger="click"
|
|
|
|
+ // >
|
|
|
|
+ // <PlusOutlined />
|
|
|
|
+ // </Popover>
|
|
|
|
+ <PlusOutlined />
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ title={item[0]?.name}
|
|
|
|
+ />
|
|
|
|
+ ))}
|
|
|
|
+ </Steps>
|
|
|
|
+ {selectUserList.map(item => (
|
|
|
|
+ <Button onClick={() => selectedUserId(item.user_id)}>{item.c_name}</Button>
|
|
|
|
+ ))}
|
|
|
|
+ </>
|
|
|
|
+ );
|
|
|
|
+ };
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<Modal
|
|
<Modal
|
|
confirmLoading={loading}
|
|
confirmLoading={loading}
|
|
@@ -394,17 +581,20 @@ function CommitAuditModal(props) {
|
|
<Row>
|
|
<Row>
|
|
<Col span={17}>{item.FormComponents}</Col>
|
|
<Col span={17}>{item.FormComponents}</Col>
|
|
<Col offset={1} span={4}>
|
|
<Col offset={1} span={4}>
|
|
- {!formComponentValues[item.nodeId] ? (
|
|
|
|
|
|
+ {!formComponentValues[item.nodeId] || !approvalProcess[item.nodeId] ? (
|
|
<Empty description="请先填写表单" />
|
|
<Empty description="请先填写表单" />
|
|
) : (
|
|
) : (
|
|
- <AuditFlow
|
|
|
|
- processCode={item.formCode}
|
|
|
|
- formComponentValues={formComponentValues[item.nodeId]}
|
|
|
|
- direction={'vertical'}
|
|
|
|
- deptId={'14237557'}
|
|
|
|
- userId={currentUser.DingUserId || getCurrentUser()?.DingUserId}
|
|
|
|
- />
|
|
|
|
- )}
|
|
|
|
|
|
+ renderSteps(item.nodeId)
|
|
|
|
+ )
|
|
|
|
+ // ({renderSteps(item.nodeId)})
|
|
|
|
+ // <AuditFlow
|
|
|
|
+ // processCode={item.formCode}
|
|
|
|
+ // formComponentValues={formComponentValues[item.nodeId]}
|
|
|
|
+ // direction={'vertical'}
|
|
|
|
+ // deptId={'14237557'}
|
|
|
|
+ // userId={currentUser.DingUserId || getCurrentUser()?.DingUserId}
|
|
|
|
+ // />
|
|
|
|
+ }
|
|
</Col>
|
|
</Col>
|
|
</Row>
|
|
</Row>
|
|
</TabPane>
|
|
</TabPane>
|
|
@@ -418,4 +608,5 @@ export default connect(({ xflow, detail, user }) => ({
|
|
flowDetail: xflow.flowDetail,
|
|
flowDetail: xflow.flowDetail,
|
|
versionList: detail.versionList,
|
|
versionList: detail.versionList,
|
|
currentUser: user.currentUser,
|
|
currentUser: user.currentUser,
|
|
|
|
+ userList: user.list,
|
|
}))(CommitAuditModal);
|
|
}))(CommitAuditModal);
|