|
@@ -22,7 +22,12 @@ 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';
|
|
import AuditFlow from './AuditFlow';
|
|
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 { 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';
|
|
@@ -63,32 +68,67 @@ function CommitAuditModal(props) {
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (!visible) return;
|
|
if (!visible) return;
|
|
const { edges, nodes } = flowDetail;
|
|
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(() => {
|
|
useEffect(() => {
|
|
form.resetFields();
|
|
form.resetFields();
|
|
setAuditList([]);
|
|
setAuditList([]);
|
|
}, [visible]);
|
|
}, [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 treeData = currentId => {
|
|
const list = getNextNodes(currentId, 'custom-circle');
|
|
const list = getNextNodes(currentId, 'custom-circle');
|
|
const fun = nodes => {
|
|
const fun = nodes => {
|
|
@@ -171,9 +211,10 @@ function CommitAuditModal(props) {
|
|
setAuditId(node.node_id);
|
|
setAuditId(node.node_id);
|
|
};
|
|
};
|
|
|
|
|
|
- const onChange = value => {
|
|
|
|
|
|
+ const onChange = (value, approvalProcess) => {
|
|
|
|
+ if (!value) return;
|
|
changeAudit(value[value.length - 1]);
|
|
changeAudit(value[value.length - 1]);
|
|
- setAuditListFun();
|
|
|
|
|
|
+ setAuditListFun(approvalProcess);
|
|
};
|
|
};
|
|
|
|
|
|
const getReComputeAudit = (items, changedValues) => {
|
|
const getReComputeAudit = (items, changedValues) => {
|
|
@@ -219,13 +260,12 @@ function CommitAuditModal(props) {
|
|
if (data) {
|
|
if (data) {
|
|
setApprovalProcess(data);
|
|
setApprovalProcess(data);
|
|
}
|
|
}
|
|
- console.log('=======================================', data);
|
|
|
|
},
|
|
},
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
//处理tabs页
|
|
//处理tabs页
|
|
- const setAuditListFun = async () => {
|
|
|
|
|
|
+ const setAuditListFun = async (approvalProcess = {}) => {
|
|
var fieldsValue = await form.validateFields();
|
|
var fieldsValue = await form.validateFields();
|
|
let addAuditList = [];
|
|
let addAuditList = [];
|
|
let result = Object.values(fieldsValue)
|
|
let result = Object.values(fieldsValue)
|
|
@@ -249,7 +289,7 @@ function CommitAuditModal(props) {
|
|
nodeId: node.Id,
|
|
nodeId: node.Id,
|
|
items: JSON.parse(curData.form_json || '[]'),
|
|
items: JSON.parse(curData.form_json || '[]'),
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
return newItem;
|
|
return newItem;
|
|
});
|
|
});
|
|
addAuditList = [...addAuditList, ...newlist];
|
|
addAuditList = [...addAuditList, ...newlist];
|
|
@@ -279,14 +319,13 @@ function CommitAuditModal(props) {
|
|
})
|
|
})
|
|
.filter(item => item);
|
|
.filter(item => item);
|
|
if (getReComputeAudit(items, changedValues)) advanceSubmit();
|
|
if (getReComputeAudit(items, changedValues)) advanceSubmit();
|
|
- // console.log('==================================', { ...formComponentValues });
|
|
|
|
setFormComponentValues({ ...formComponentValues });
|
|
setFormComponentValues({ ...formComponentValues });
|
|
},
|
|
},
|
|
})(AuditDetailed);
|
|
})(AuditDetailed);
|
|
item.FormComponents = <Components items={item.items} />;
|
|
item.FormComponents = <Components items={item.items} />;
|
|
});
|
|
});
|
|
setAuditList(addAuditList);
|
|
setAuditList(addAuditList);
|
|
- advanceSubmit();
|
|
|
|
|
|
+ if (Object.keys(approvalProcess).length == 0) advanceSubmit();
|
|
};
|
|
};
|
|
|
|
|
|
const getFromData = async idList => {
|
|
const getFromData = async idList => {
|
|
@@ -446,6 +485,11 @@ function CommitAuditModal(props) {
|
|
message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
|
|
message.error('当前存在审批节点未绑定审批流程!请联系管理员。');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ await querySaveBomForm({
|
|
|
|
+ project_id: version.project_id,
|
|
|
|
+ node_id: version.template_node_id,
|
|
|
|
+ json: JSON.stringify({approvalProcess}),
|
|
|
|
+ });
|
|
onOk(params);
|
|
onOk(params);
|
|
};
|
|
};
|
|
const CascaderNode = index => {
|
|
const CascaderNode = index => {
|
|
@@ -507,7 +551,7 @@ function CommitAuditModal(props) {
|
|
// rules={[{ required: true, message: '请选择业务节点' }]}
|
|
// rules={[{ required: true, message: '请选择业务节点' }]}
|
|
>
|
|
>
|
|
<Select style={{ width: '100%' }}>
|
|
<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>
|
|
<Option key={item.value}>{item.label}</Option>
|
|
))}
|
|
))}
|
|
</Select>
|
|
</Select>
|
|
@@ -545,13 +589,13 @@ function CommitAuditModal(props) {
|
|
}
|
|
}
|
|
|
|
|
|
function getDataValue(item) {
|
|
function getDataValue(item) {
|
|
- let arr = []
|
|
|
|
- arr.push(item.value)
|
|
|
|
|
|
+ let arr = [];
|
|
|
|
+ arr.push(item.value);
|
|
if (item.children?.length > 0) {
|
|
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 }) => ({
|
|
export default connect(({ xflow, detail, user }) => ({
|