king
2023-08-08 ab003fccad96beb96d18f8018980e6c75ed03edc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, InputNumber } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
 
import MemberForm from './memberform'
const { TextArea } = Input
 
class NodeForm extends Component {
  static propTpyes = {
    node: PropTypes.any,
    data: PropTypes.any,
    orgs: PropTypes.array
  }
 
  state = {}
 
  handleConfirm = () => {
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          resolve(values)
        } else {
          reject(err)
        }
      })
    })
  }
 
  render() {
    const { node, orgs } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
    let data = this.props.data || {}
    let nodetype = node.shape !== 'edge' ? 'node' : 'edge'
    if (node.mknode === 'start') {
      nodetype = 'start'
    } else if (node.mknode === 'end') {
      nodetype = 'end'
    }
 
    return (
      <Form {...formItemLayout} className="normal-node-form">
        <Row gutter={24}>
          <Col span={12}>
            <Form.Item label="状态值">
              {getFieldDecorator('status', {
                initialValue: data.status === undefined ? 0 : data.status,
                rules: [
                  {
                    required: true,
                    message: '请输入状态值!'
                  }
                ]
              })(
                <InputNumber precision={0}/>
              )}
            </Form.Item>
          </Col>
          <Col span={12}>
            <Form.Item label="状态名">
              {getFieldDecorator('statusName', {
                initialValue: data.statusName || ''
              })(
                <Input placeholder="" autoComplete="off"/>
              )}
            </Form.Item>
          </Col>
          {nodetype === 'node' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="标记将作为节点ID">
                <QuestionCircleOutlined className="mk-form-tip" />
                标记
              </Tooltip>
            }>
              {getFieldDecorator('sign', {
                initialValue: data.sign || ''
              })(
                <Input placeholder="" autoComplete="off"/>
              )}
            </Form.Item>
          </Col> : null}
          {nodetype === 'node' ? <Col span={12}>
            <Form.Item label="设置审批人">
              {getFieldDecorator('approver', {
                initialValue: data.approver || 'member'
              })(
                <Radio.Group>
                  <Radio value="member">指定成员</Radio>
                  <Radio value="departmentManager">部门主管</Radio>
                  <Radio value="directManager">直属主管</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {nodetype === 'node' ? <Col span={12}>
            <Form.Item label="审批方式">
              {getFieldDecorator('approvalMethod', {
                initialValue: data.approvalMethod || 'countersign'
              })(
                <Radio.Group>
                  <Radio value="countersign">会签</Radio>
                  <Radio value="orsign">或签</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={12}>
            <Form.Item label="审批人">
              {getFieldDecorator('members', {
                initialValue: data.members || [],
                rules: [{
                  required: true,
                  message: '请添加审批人!'
                }]
              })(
                <MemberForm orgs={orgs} title="审批人"/>
              )}
            </Form.Item>
          </Col>
          <Col span={12}>
            <Form.Item label="抄送人">
              {getFieldDecorator('copys', {
                initialValue: data.copys || []
              })(
                <MemberForm orgs={orgs} title="抄送人"/>
              )}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="备注">
              {getFieldDecorator('remark', {
                initialValue: data.remark || ''
              })(
                <TextArea rows={2}/>
              )}
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )
  }
}
 
export default Form.create()(NodeForm)