ProcessConfig.jsx 3.47 KB
Newer Older
1
import React, { useEffect, useState } from 'react';
邓超's avatar
邓超 committed
2
import { CMFlowGet, CMFlowPost } from '@/services/flow/flow';
邓超's avatar
邓超 committed
3 4 5 6 7
import { Form, Modal, Input, Radio, Select, notification } from 'antd';
const { Option } = Select;
const { TextArea } = Input;

const ProcessConfig = props => {
8
  const { onSubumit, handleCancel, visible, processMsg, allDisabled } = props;
邓超's avatar
邓超 committed
9
  const [form] = Form.useForm();
10
  const [flag, setFlag] = useState(0);
邓超's avatar
邓超 committed
11
  useEffect(() => {
邓超's avatar
邓超 committed
12
    form.resetFields();
邓超's avatar
邓超 committed
13 14 15 16 17 18 19 20 21
    if (visible) {
      getFormData();
    }
  }, [visible]);
  // 获取表单回显
  const getFormData = () => {
    CMFlowGet({ flowId: processMsg.ID }).then(res => {
      if (res.code === 0) {
        form.setFieldsValue(res.data);
22
        setFlag(flag + 1);
邓超's avatar
邓超 committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
      }
    });
  };
  // 提交表单
  const onFinish = () => {
    form.validateFields().then(validate => {
      if (validate) {
        console.log(validate);
        CMFlowPost({ ...validate, flowId: processMsg.ID })
          .then(res => {
            if (res.code === 0) {
              notification.success({
                message: '提示',
                duration: 3,
                description: '编辑成功',
              });
              onSubumit();
            } else {
              notification.error({
                message: '提示',
                duration: 3,
                description: res.msg,
              });
            }
          })
          .catch(() => {
            notification.error({
              message: '提示',
              duration: 3,
              description: '网络异常',
            });
          });
      }
    });
  };
  return (
    <Modal
60
      title={allDisabled ? '流程配置查看' : '流程配置'}
邓超's avatar
邓超 committed
61 62 63 64
      visible={visible}
      onOk={onFinish}
      onCancel={handleCancel}
      maskClosable={false}
65
      footer={allDisabled ? null : true}
邓超's avatar
邓超 committed
66 67 68 69 70 71 72 73 74 75 76
    >
      <Form
        form={form}
        labelCol={{ span: 5 }}
        wrapperCol={{ span: 18 }}
        initialValues={{ remember: true }}
      >
        <Form.Item label="流程名称" name="name">
          <Input disabled />
        </Form.Item>
        <Form.Item label="流程结束" name="flowEndBehavior">
77
          <Radio.Group>
邓超's avatar
邓超 committed
78 79 80 81 82 83
            <Radio value={0}>不做任何事情</Radio>
            <Radio value={1}>直接关闭事件</Radio>
            <Radio value={2}>事件转为待审核</Radio>
            <Radio value={3}>重新处理事件</Radio>
          </Radio.Group>
        </Form.Item>
84
        <Form.Item
85
          label="办理样式"
86 87
          name="webPage"
          initialValue="多表显示"
88
          rules={[{ required: true, message: '请选择办理样式' }]}
89
        >
90
          <Select placeholder="请选择办理样式">
邓超's avatar
邓超 committed
91
            <Option value="多表在办显示">多表在办显示</Option>
92
            <Option value="多表显示">多表显示</Option>
邓超's avatar
邓超 committed
93
            <Option value="表堆叠显示">表堆叠显示</Option>
94
            {/* <Option value="分派节点显示">分派节点显示</Option> */}
邓超's avatar
邓超 committed
95 96
          </Select>
        </Form.Item>
97
        <Form.Item label="编码样式" name="useFixedCodingRule">
98
          <Radio.Group>
99 100
            <Radio value={false}>{form.getFieldValue('codingDefaultText')}</Radio>
            <Radio value>{form.getFieldValue('coding12Text')}</Radio>
邓超's avatar
邓超 committed
101 102 103
          </Radio.Group>
        </Form.Item>
        <Form.Item label="接口配置" name="interfaceConfig">
104
          <TextArea placeholder="请填写接口配置" />
邓超's avatar
邓超 committed
105 106 107 108 109 110
        </Form.Item>
      </Form>
    </Modal>
  );
};
export default ProcessConfig;