|
@@ -9,13 +9,12 @@ import router from 'umi/router';
|
|
|
const { Option } = Select;
|
|
|
|
|
|
function Audit(props) {
|
|
|
- const { userList, list = [], dispatch } = props;
|
|
|
- const [form] = Form.useForm();
|
|
|
+ const { userList, currentItem, dispatch } = props;
|
|
|
const [visible, setVisible] = useState({
|
|
|
audit: false,
|
|
|
auditNode: false,
|
|
|
});
|
|
|
- const [current, setCurrent] = useState({});
|
|
|
+ const [current, setCurrent] = useState({ ...currentItem });
|
|
|
const [currentNode, setCurrentNode] = useState({});
|
|
|
const columns = [
|
|
|
{
|
|
@@ -28,7 +27,8 @@ function Audit(props) {
|
|
|
},
|
|
|
{
|
|
|
title: '审批人',
|
|
|
- dataIndex: ['AuditorUser', 'CName'],
|
|
|
+ dataIndex: 'auditor',
|
|
|
+ render: auditor => userList.find(item => item.ID == auditor)?.CName,
|
|
|
},
|
|
|
{
|
|
|
title: '审批关系',
|
|
@@ -68,16 +68,16 @@ function Audit(props) {
|
|
|
),
|
|
|
},
|
|
|
];
|
|
|
- const handleAuditOk = values => {
|
|
|
- console.log(values);
|
|
|
- dispatch({
|
|
|
- type: 'flow/addAudit',
|
|
|
- payload: values,
|
|
|
- callback: () => {
|
|
|
- changeVisible('audit', false);
|
|
|
- },
|
|
|
- });
|
|
|
- };
|
|
|
+ // const handleAuditOk = values => {
|
|
|
+ // console.log(values);
|
|
|
+ // dispatch({
|
|
|
+ // type: 'flow/addAudit',
|
|
|
+ // payload: values,
|
|
|
+ // callback: () => {
|
|
|
+ // changeVisible('audit', false);
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // };
|
|
|
const handleAuditNodeOk = values => {
|
|
|
console.log(values);
|
|
|
let FlowNodes = current.FlowNodes;
|
|
@@ -87,6 +87,14 @@ function Audit(props) {
|
|
|
let index = FlowNodes.findIndex(item => item.id == currentNode.id);
|
|
|
let newNodes = [...FlowNodes];
|
|
|
newNodes[index] = values;
|
|
|
+ // 将同审批级别的审批关系设置为相同
|
|
|
+ newNodes.forEach(item => {
|
|
|
+ if (item.seq == values.seq) {
|
|
|
+ item.seq_relate = values.seq_relate;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 排序
|
|
|
+ newNodes.sort((a, b) => a.seq - b.seq);
|
|
|
setCurrent({
|
|
|
...current,
|
|
|
FlowNodes: newNodes,
|
|
@@ -106,10 +114,10 @@ function Audit(props) {
|
|
|
FlowNodes: newNodes,
|
|
|
});
|
|
|
};
|
|
|
- const onCancel = () => {
|
|
|
- form.resetFields();
|
|
|
- setCurrent({});
|
|
|
- };
|
|
|
+ // const onCancel = () => {
|
|
|
+ // form.resetFields();
|
|
|
+ // setCurrent({});
|
|
|
+ // };
|
|
|
const onSave = () => {
|
|
|
const nodes = current.FlowNodes.map(item => ({
|
|
|
flow_id: current.id,
|
|
@@ -126,15 +134,18 @@ function Audit(props) {
|
|
|
flowId: current.id,
|
|
|
nodes: nodes,
|
|
|
},
|
|
|
+ callback: () => {
|
|
|
+ router.go(-1);
|
|
|
+ },
|
|
|
});
|
|
|
};
|
|
|
- const handleSelect = id => {
|
|
|
- const item = list.find(item => item.list?.id == id);
|
|
|
- console.log(item);
|
|
|
- setCurrent({
|
|
|
- ...item.list,
|
|
|
- });
|
|
|
- };
|
|
|
+ // const handleSelect = id => {
|
|
|
+ // const item = list.find(item => item.list?.id == id);
|
|
|
+ // console.log(item);
|
|
|
+ // setCurrent({
|
|
|
+ // ...item.list,
|
|
|
+ // });
|
|
|
+ // };
|
|
|
const changeVisible = (type, visible) => {
|
|
|
setVisible({
|
|
|
...visible,
|
|
@@ -157,7 +168,7 @@ function Audit(props) {
|
|
|
<span>审批详情</span>
|
|
|
{current?.id && (
|
|
|
<div className={styles.btns}>
|
|
|
- <Button onClick={onCancel}>取消</Button>
|
|
|
+ {/* <Button onClick={onCancel}>取消</Button> */}
|
|
|
<Button onClick={onSave} type="primary">
|
|
|
保存
|
|
|
</Button>
|
|
@@ -175,38 +186,32 @@ function Audit(props) {
|
|
|
</div>
|
|
|
);
|
|
|
};
|
|
|
-
|
|
|
+ console.log(current);
|
|
|
return (
|
|
|
<div>
|
|
|
- <div className={styles.box}>
|
|
|
+ <div className={styles.btns}>
|
|
|
<Button onClick={() => router.go(-1)}>返回</Button>
|
|
|
- <Form layout="inline" name="basic" autoComplete="off" form={form}>
|
|
|
- <Form.Item label="审批流程" name="flowId">
|
|
|
- <Select onChange={handleSelect} style={{ minWidth: 180 }}>
|
|
|
- {list.map(item => (
|
|
|
- <Option key={item.list.id}>{item.list.name || item.list.id}</Option>
|
|
|
- ))}
|
|
|
- </Select>
|
|
|
- </Form.Item>
|
|
|
- <Form.Item>
|
|
|
- <Button onClick={() => changeVisible('audit', true)} type="primary">
|
|
|
- 新建流程
|
|
|
- </Button>
|
|
|
- </Form.Item>
|
|
|
- </Form>
|
|
|
+ {/* <Button onClick={onCancel}>取消</Button> */}
|
|
|
+ <Button onClick={onSave} type="primary">
|
|
|
+ 保存
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ onClick={() => {
|
|
|
+ setCurrentNode({});
|
|
|
+ changeVisible('auditNode', true);
|
|
|
+ }}
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
+ 添加节点
|
|
|
+ </Button>
|
|
|
</div>
|
|
|
|
|
|
- <Table
|
|
|
- rowKey="id"
|
|
|
- title={renderTitle}
|
|
|
- dataSource={current?.FlowNodes || []}
|
|
|
- columns={columns}
|
|
|
- />
|
|
|
- <AuditModal
|
|
|
+ <Table rowKey="id" dataSource={current?.FlowNodes || []} columns={columns} />
|
|
|
+ {/* <AuditModal
|
|
|
visible={visible.audit}
|
|
|
onOk={handleAuditOk}
|
|
|
onCancel={() => changeVisible('audit', false)}
|
|
|
- />
|
|
|
+ /> */}
|
|
|
<AuditNodeModal
|
|
|
userList={userList}
|
|
|
data={currentNode}
|
|
@@ -219,6 +224,6 @@ function Audit(props) {
|
|
|
}
|
|
|
export default connect(({ user, flow, loading }) => ({
|
|
|
userList: user.list,
|
|
|
- list: flow.auditList,
|
|
|
+ currentItem: flow.current,
|
|
|
loading: loading.models.purchaseList2,
|
|
|
}))(Audit);
|