king
2025-05-23 24842b40de5cd60700bf69dfd38a0332f5431e36
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, InputNumber, Switch, notification } 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,
    handleSubmit: PropTypes.func
  }
 
  state = {
    flowType: 'approval',
    execCondition: false,
    seniorCondition: false,
    approvalMethod: 'orsign',
    readOnly: false,
    options: []
  }
 
  UNSAFE_componentWillMount() {
    const { node, data } = this.props
 
    let options = []
    let readOnly = false
 
    if (node.mknode === 'start') {
      readOnly = true
    } else if (node.mknode === 'end') {
 
    } else if (node.mknode === 'throughEdge') {
      options = ['senior']
    } else if (node.mknode === 'endEdge') {
      options = ['approvalMethod', 'execCondition']
    } else if (node.mknode === 'startEdge') {
      readOnly = true
    } else if (node.mknode === 'firstEdge') {
      options = ['approver', 'members', 'copys']
    } else if (node.shape !== 'edge') { // node
      options = ['sign']
    } else {
      options = ['flowType', 'approvalMethod', 'approver', 'members', 'copys', 'execCondition', 'senior']
    }
 
    this.setState({
      flowType: data.flowType || 'approval',
      execCondition: options.includes('execCondition') ? data.execCondition === 'open' : false,
      seniorCondition: options.includes('senior') ? data.seniorCondition === 'open' : false,
      approvalMethod: data.approvalMethod || 'orsign',
      options,
      readOnly
    })
  }
 
  handleConfirm = () => {
    const { node } = this.props
 
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
 
          if (values.approvalMethod === 'countersign' && values.members.length > 5) {
            notification.warning({
              top: 92,
              message: '会签时审批人不可超过5人!',
              duration: 10
            })
            return
          } else if (node.mknode === 'throughEdge' && values.seniorCondition === false) {
            notification.warning({
              top: 92,
              message: '开始与结束直连的分支必须设置特殊审批人!',
              duration: 10
            })
            return
          }
 
          if (values.seniorCondition === true) {
            values.seniorCondition = 'open'
          } else if (values.seniorCondition === false) {
            values.seniorCondition = 'close'
          }
 
          if (values.execCondition === true) {
            values.execCondition = 'open'
          } else if (values.execCondition === false) {
            values.execCondition = 'close'
          }
 
          if (values.matchVal) {
            values.matchVal = values.matchVal.replace(/\t+|\v+|\s+/g, '')
          }
          resolve(values)
        } else {
          reject(err)
        }
      })
    })
  }
 
  render() {
    const { orgs } = this.props
    const { getFieldDecorator } = this.props.form
    const { flowType, execCondition, seniorCondition, approvalMethod, readOnly, options } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
    let data = this.props.data || {}
 
    return (
      <Form {...formItemLayout} className="normal-node-form">
        <Row gutter={24}>
          {options.includes('approver') || options.includes('execCondition') ? <Col span={24}>
            <p className="mk-split">按钮执行命令</p>
          </Col> : null}
          <Col span={12}>
            <Form.Item label="状态值">
              {getFieldDecorator('status', {
                initialValue: data.status,
                rules: [
                  { required: true, message: '请输入状态值!' }
                ]
              })(
                <InputNumber readOnly={readOnly} precision={0} onPressEnter={() => this.props.handleSubmit()}/>
              )}
            </Form.Item>
          </Col>
          <Col span={12}>
            <Form.Item label="状态名">
              {getFieldDecorator('statusName', {
                initialValue: data.statusName || ''
              })(
                <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/>
              )}
            </Form.Item>
          </Col>
          {options.includes('sign') ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="标记将作为节点ID">
                <QuestionCircleOutlined className="mk-form-tip" />
                标记
              </Tooltip>
            }>
              {getFieldDecorator('sign', {
                initialValue: data.sign || ''
              })(
                <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('flowType') ? <Col span={12}>
            <Form.Item label="操作类型">
              {getFieldDecorator('flowType', {
                initialValue: flowType
              })(
                <Radio.Group onChange={(e) => this.setState({flowType: e.target.value})}>
                  <Radio value="approval">审批</Radio>
                  <Radio value="reject">驳回</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('approvalMethod') && flowType !== 'reject' ? <Col span={12}>
            <Form.Item label="审批方式">
              {getFieldDecorator('approvalMethod', {
                initialValue: approvalMethod
              })(
                <Radio.Group onChange={(e) => this.setState({approvalMethod: e.target.value})}>
                  <Radio value="orsign">或签</Radio>
                  <Radio value="countersign">会签</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('approvalMethod') && flowType !== 'reject' && approvalMethod === 'countersign' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="示例:“财务经理张总已审核”,其中“已审核”为会签标记。">
                <QuestionCircleOutlined className="mk-form-tip" />
                会签标记
              </Tooltip>
            }>
              {getFieldDecorator('mark', {
                initialValue: data.mark || '已审核',
                rules: [
                  { required: true, message: '请输入会签标记!' }
                ]
              })(
                <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={24}>
            <Form.Item label="备注">
              {getFieldDecorator('remark', {
                initialValue: data.remark || ''
              })(
                <TextArea rows={2}/>
              )}
            </Form.Item>
          </Col>
          {options.includes('approver') ? <Col span={24}>
            <p className="mk-split">下一步审批权限</p>
          </Col> : null}
          {options.includes('approver') ? <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}
          {options.includes('members') ? <Col span={12}>
            <Form.Item label="审批人">
              {getFieldDecorator('members', {
                initialValue: data.members || [],
                rules: [
                  { required: true, message: '请添加审批人!' }
                ]
              })(
                <MemberForm orgs={orgs} title="审批人"/>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('copys') ? <Col span={12}>
            <Form.Item label="抄送人">
              {getFieldDecorator('copys', {
                initialValue: data.copys || []
              })(
                <MemberForm orgs={orgs} title="抄送人"/>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('execCondition') && flowType !== 'reject' ? <Col span={24}>
            <p className="mk-split">分支执行条件</p>
          </Col> : null}
          {options.includes('execCondition') && flowType !== 'reject' ? <Col span={12}>
            <Form.Item label="执行条件">
              {getFieldDecorator('execCondition', {
                valuePropName: 'checked',
                initialValue: execCondition
              })(
                <Switch checkedChildren="开启" unCheckedChildren="关闭" onChange={(val) => this.setState({execCondition: val})} />
              )}
            </Form.Item>
          </Col> : null}
          {flowType !== 'reject' && execCondition ? <Col span={12}>
            <Form.Item label="对比方式">
              {getFieldDecorator('match', {
                initialValue: data.match || '='
              })(
                <Radio.Group>
                  <Radio value="=">=</Radio>
                  <Radio value="<">&lt;</Radio>
                  <Radio value=">">&gt;</Radio>
                  <Radio value="<=">&lt;=</Radio>
                  <Radio value=">=">&gt;=</Radio>
                  <Radio value="!=">!=</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {flowType !== 'reject' && execCondition ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="对比值中不可包含制表符、空格、换行符等。">
                <QuestionCircleOutlined className="mk-form-tip" />
                对比值
              </Tooltip>
            }>
              {getFieldDecorator('matchVal', {
                initialValue: data.matchVal || ''
              })(
                <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('senior') && flowType !== 'reject' && approvalMethod !== 'countersign' ? <Col span={24}>
            <p className="mk-split">高级设置<span style={{fontSize: '12px', color: 'rgba(0, 0, 0, 0.45)'}}>(启用特殊审批人时,符合审批人列表时,优先使用此分支。)</span></p>
          </Col> : null}
          {options.includes('senior') && flowType !== 'reject' && approvalMethod !== 'countersign' ? <Col span={12}>
            <Form.Item label="特殊人员">
              {getFieldDecorator('seniorCondition', {
                valuePropName: 'checked',
                initialValue: seniorCondition
              })(
                <Switch checkedChildren="启用" unCheckedChildren="禁用" onChange={(val) => this.setState({seniorCondition: val})} />
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('senior') && flowType !== 'reject' && approvalMethod !== 'countersign' && seniorCondition ? <Col span={12}>
            <Form.Item label="审批人">
              {getFieldDecorator('seniorbers', {
                initialValue: data.seniorbers || [],
                rules: [
                  { required: true, message: '请添加审批人!' }
                ]
              })(
                <MemberForm orgs={orgs} title="审批人"/>
              )}
            </Form.Item>
          </Col> : null}
          {options.includes('senior') && flowType !== 'reject' && approvalMethod !== 'countersign' && seniorCondition ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="用于业务处理时的标记值@works_flow_sign@。">
                <QuestionCircleOutlined className="mk-form-tip" />
                分支标记
              </Tooltip>
            }>
              {getFieldDecorator('seniorSign', {
                initialValue: data.seniorSign || '',
                rules: [
                  { required: true, message: '请添加分支标记!' },
                  { pattern: /^[0-9a-zA-Z_]+$/, message: '只可输入英文、数字以及_。' }
                ]
              })(
                <Input autoComplete="off" onPressEnter={() => this.props.handleSubmit()}/>
              )}
            </Form.Item>
          </Col> : null}
        </Row>
      </Form>
    )
  }
}
 
export default Form.create()(NodeForm)