king
2025-05-12 d0764c7facff9abf00af6f3ff06a26260d1d8770
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Form, Row, Col, Input, Radio, Tooltip, notification, Select, InputNumber, Cascader, Modal, Button } from 'antd'
import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons'
 
import { formRule } from '@/utils/option.js'
import MenuUtils from '@/utils/utils-custom.js'
import { checkSQL } from '@/utils/utils-custom.js'
import CodeMirror from '@/templates/zshare/codemirror'
import KeyInterface from '@/components/keyInterface'
import './index.scss'
 
const { TextArea } = Input
 
class SettingForm extends Component {
  static propTpyes = {
    updateStatus: PropTypes.func,
    updateColumns: PropTypes.func,
    addProcess: PropTypes.func,
    config: PropTypes.object,     // 组件配置
    setting: PropTypes.object,    // 数据源配置
    columns: PropTypes.array,     // 列设置
    scripts: PropTypes.array,     // 自定义脚本
  }
 
  state = {
    setting: null,
    modules: [],
    innerRules: [],
    innertip: '',
    MenuType: sessionStorage.getItem('MenuType') || '',
    ismain: false,
    visible: false
  }
 
  UNSAFE_componentWillMount () {
    const { config, setting } = this.props
 
    let menu = window.GLOB.customMenu
    let modules = []
    let ismain = false
 
    if (menu.Template === 'BaseTable') {
      ismain = config.name === '主表'
    }
 
    if (config.type === 'interface') {
      menu.components.forEach(item => {
        if (item.type === 'module' && item.subtype === 'account') {
          modules.push({
            value: item.uuid,
            label: item.name
          })
        }
      })
    } else {
      modules = MenuUtils.getSupModules(menu.components, config.uuid, menu.interfaces)
    }
 
    modules.unshift({
      value: 'empty',
      label: '无'
    })
 
    let usefulFields = sessionStorage.getItem('permFuncField')
    let innerRules = []
    let innertip = ''
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
 
        if (usefulFields.length > 0) {
          innertip = '开头可用字符:' + usefulFields.join(', ')
          let str = '^(' + usefulFields.join('|') + ')'
          let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g')
    
          innerRules.push({
            pattern: _patten,
            message: formRule.func.innerMessage
          })
        }
      } catch (e) {
        innerRules = []
      }
    }
 
    let _setting = fromJS(setting).toJS()
    _setting.interType = setting.interType || 'system'
    _setting.laypage = setting.laypage || 'true'
    _setting.useMSearch = setting.useMSearch || 'false'
    _setting.sysInterface = setting.sysInterface || 'false'
    _setting.supModule = setting.supModule || []
    _setting.execute = setting.execute || 'true'
 
    if (_setting.supModule.length > 0 && _setting.supModule[0] !== 'empty') {
      let has = MenuUtils.checkSupModules(modules, _setting.supModule.slice(-1)[0])
      if (!has) {
        _setting.supModule = []
      }
    }
 
    this.setState({modules, innerRules, innertip, setting: _setting, ismain})
  }
 
  handleConfirm = () => {
    const { config } = this.props
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          values.sync = values.sync || 'false'
 
          if (['navbar', 'balcony', 'menubar', 'interface'].includes(config.type)) {
            values.onload = 'true'
          }
 
          if (values.interType === 'system' && values.onload === 'false') {
            values.sync = 'false'
          }
          if (values.interType === 'system' && values.database === 'sso') {
            values.sync = 'false'
          }
 
          // 数据源前端验证
          if (values.interType === 'system' && values.execute !== 'false' && values.dataresource) {
            let pass = checkSQL(values.dataresource)
 
            if (!pass) {
              reject()
              return
            }
          }
 
          resolve(values)
        } else {
          reject(err)
        }
      })
    })
  }
 
  onOptionChange = (value, key) => {
    let setting = fromJS(this.state.setting).toJS()
    setting[key] = value
 
    this.setState({setting})
 
    if (key === 'sysInterface' && value === 'true') {
      this.props.form.setFieldsValue({interface: window.GLOB.mainSystemApi})
    }
    this.props.updateStatus(setting)
  }
 
  addProcess = () => {
    this.setState({visible: true})
  }
 
  execAddProcess = (type) => {
    let _sql = this.props.form.getFieldValue('dataresource')
    let tableName = this.props.form.getFieldValue('tableName') || '表名'
 
    if (type === 'flowstart') {
      _sql = _sql + `\n/* select a.*, w.remark as remark_w, w.statusname  as statusname_w,w.status as status_w,w.works_flow_param,w.works_flow_detail_id,w.modifydate as modifydate_w  from (select * from ${tableName} where status=0 and deleted=0 $@ and createuserid=@userid@ @$) a
    inner join (select * from  s_my_works_flow  where works_flow_code=@works_flow_code@ and status=0 and deleted=0) w on a.id=w.works_flow_id */`
    } else if (type === 'flowcheck') {
      _sql = _sql + `\n/* select a.*, w.remark as remark_w, w.statusname  as statusname_w,w.status as status_w,w.works_flow_param,w.works_flow_detail_id,w.modifydate as modifydate_w  
    from (select * from ${tableName} where status=0 and deleted=0 ) a
    inner join (select * from  s_my_works_flow  where works_flow_code=@works_flow_code@ and status>0 and status<888 and deleted=0) w 
    on a.id=w.works_flow_id 
    $@ inner join (select works_flow_id  from s_my_works_flow_role where userid=@userid@ and  works_flow_code=@works_flow_code@ and deleted=0 ) r
    on r.works_flow_id=w.works_flow_id @$ */`
    }
 
    this.props.form.setFieldsValue({
      dataresource: _sql
    })
 
    this.setState({visible: false})
 
    this.props.addProcess()
  }
 
  addSql = () => {
    let tableName = this.props.form.getFieldValue('tableName')
 
    if (!tableName) {
      notification.warning({
        top: 92,
        message: '请添加表名。',
        duration: 5
      })
      return
    }
 
    let _sql = this.props.form.getFieldValue('dataresource')
 
    if (/^\s*$/.test(_sql)) {
      this.props.form.setFieldsValue({
        dataresource: `select * from ${tableName} where deleted=0`
      })
    }
 
    this.props.updateColumns(tableName)
  }
 
  render() {
    const { columns, config, hasMainSearch } = this.props
    const { getFieldDecorator } = this.props.form
    const { setting, modules, innerRules, innertip, MenuType, visible } = this.state
 
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
 
    return (
      <div className="model-datasource-setting-form-box">
        <Form {...formItemLayout} className="model-setting-form">
          <Row gutter={24}>
            {config.type === 'interface' ? <Col span={8}>
              <Form.Item label="数据源名称">
                {getFieldDecorator('name', {
                  initialValue: setting.name,
                  rules: [
                    {
                      required: true,
                      message: '请输入数据源名称!'
                    }
                  ]
                })(<Input placeholder="" autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            <Col span={8}>
              <Form.Item label="表名">
                {getFieldDecorator('tableName', {
                  initialValue: setting.tableName,
                  rules: [
                    {
                      required: true,
                      message: '请输入表名!'
                    },
                    {
                      max: 50,
                      message: '表名最长为50个字符!'
                    },
                    {
                      pattern: /^[a-zA-Z0-9@_]+$/,
                      message: '表名只可使用字母、数字以及_'
                    }
                  ]
                })(
                  setting.interType === 'system' && ((columns.length === 0 && config.subtype !== 'basetable') || !setting.dataresource) ?
                  <Input placeholder="" autoComplete="off" addonAfter={<PlusOutlined onClick={this.addSql} />}/> :
                  <Input placeholder="" autoComplete="off"/>
                  )}
              </Form.Item>
            </Col>
            <Col span={8}>
              <Form.Item label="接口类型">
                {getFieldDecorator('interType', {
                  initialValue: setting.interType,
                  rules: [
                    {
                      required: true,
                      message: '请选择接口类型!'
                    },
                  ]
                })(
                <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'interType')}}>
                  <Radio value="system">系统</Radio>
                  <Radio value="inner">内部</Radio>
                  <Radio value="outer">外部</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col>
            {setting.interType === 'outer' ? <Col span={8} className="compact">
              <Form.Item label={
                <Tooltip placement="topLeft" title="业务系统指同一sso下的其他业务系统,外部系统指不同sso下的其他业务系统。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  系统类型
                </Tooltip>
              }>
                {getFieldDecorator('sysInterface', {
                  initialValue: setting.sysInterface,
                  rules: [
                    {
                      required: true,
                      message: '请选择系统类型!'
                    }
                  ]
                })(
                <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'sysInterface')}}>
                  <Radio value="false">业务</Radio>
                  <Radio value="true">单点</Radio>
                  <Radio value="external">外部</Radio>
                  <Radio value="custom">自定义</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'inner' ? <Col span={8}>
              <Form.Item label={innertip ?
                <Tooltip placement="topLeft" title={innertip}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  内部函数
                </Tooltip> : '内部函数'
              }>
                {getFieldDecorator('innerFunc', {
                  initialValue: setting.innerFunc || '',
                  rules: [
                    {
                      required: true,
                      message: '请输入内部函数!'
                    },
                    ...innerRules
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'outer' && setting.sysInterface !== 'external' ? <Col className="outer-interface" span={24}>
              <Form.Item label="接口地址">
                {getFieldDecorator('interface', {
                  initialValue: setting.interface || (setting.sysInterface === 'true' ? window.GLOB.mainSystemApi : ''),
                  rules: [
                    {
                      required: setting.sysInterface !== 'true' ? true : false,
                      message: '请输入接口地址!'
                    }
                  ]
                })(<TextArea rows={2} readOnly={setting.sysInterface === 'true'}/>)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'outer' && setting.sysInterface === 'external' ? <Col className="outer-interface" span={24}>
              <Form.Item label="接口地址">
                {getFieldDecorator('exInterface', {
                  initialValue: setting.exInterface,
                  rules: [
                    {
                      required: true,
                      message: '请编辑接口地址!'
                    }
                  ]
                })(<KeyInterface type="develop"/>)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'outer' && (setting.sysInterface === 'false' || setting.sysInterface === 'custom') ? <Col className="outer-interface" span={24}>
              <Form.Item label={<Tooltip placement="topLeft" title="正式系统接口地址,为空时使用接口地址。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  正式地址
                </Tooltip>
              }>
                {getFieldDecorator('proInterface', {
                  initialValue: setting.proInterface || ''
                })(<TextArea rows={2}/>)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'outer' && setting.sysInterface === 'external' ? <Col className="outer-interface" span={24}>
              <Form.Item label={<Tooltip placement="topLeft" title="正式系统接口地址。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  正式地址
                </Tooltip>
              }>
                {getFieldDecorator('exProInterface', {
                  initialValue: setting.exProInterface || ''
                })(<KeyInterface type="product"/>)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'outer' && setting.sysInterface === 'custom' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
              <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={
                <Tooltip placement="topLeft" title="外部接口入参及出参的自定义处理。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  自定义脚本
                </Tooltip>
              }>
                {getFieldDecorator('js_script', {
                  initialValue: setting.js_script || ''
                })(<CodeMirror mode="text/javascript" theme="cobalt" />)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'outer' ? <Col span={8}>
              <Form.Item label="外部函数">
                {getFieldDecorator('outerFunc', {
                  initialValue: setting.outerFunc || ''
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}>
              {window.GLOB.process && !['invoice', 'invTable'].includes(config.subtype) ? <span className="process-btn" onClick={this.addProcess}>工作流</span> : null}
              <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={
                <Tooltip placement="topLeft" title={`使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 ''、 @$ -> */ 或 ''。`}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  数据源
                </Tooltip>
              }>
                {getFieldDecorator('dataresource', {
                  initialValue: setting.dataresource || '',
                  rules: [
                    {
                      required: setting.execute !== 'false' ? true : false,
                      message: '请输入数据源!'
                    }
                  ]
                })(<CodeMirror />)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'system' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'查询时,搜索条件以where条件拼接进入sql,统计时,将数据源中以“@+搜索字段+@”的内容,以搜索条件中的值进行替换后,提交查询,注:查询类型仅在使用系统函数时有效。'}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  查询类型
                </Tooltip>
              }>
                {getFieldDecorator('queryType', {
                  initialValue: setting.queryType || 'query'
                })(
                <Radio.Group>
                  <Radio value="query">查询</Radio>
                  <Radio value="statistics">统计</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {!['invTable'].includes(config.subtype) ? <Col span={8}>
              <Form.Item label="主键">
                {getFieldDecorator('primaryKey', {
                  initialValue: setting.primaryKey || ''
                })(
                  <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}>
                    {columns.map((option, i) =>
                      <Select.Option key={i} value={option.field}>
                        {`${option.label}(${option.field})`}
                      </Select.Option>
                    )}
                  </Select>
                )}
              </Form.Item>
            </Col> : null}
            {/* 数组数据,需设置排序规则 */}
            {config.format === 'array' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="如果在自定义脚本中使用了@pageSize@或@orderBy@,请在数据源中单独写排序语句。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  默认排序
                </Tooltip>
              }>
                {getFieldDecorator('order', {
                  initialValue: setting.order || 'ID desc',
                  rules: [
                    {
                      required: true,
                      message: '请输入默认排序!'
                    },
                    {
                      pattern: /^[^'+]+$/,
                      message: '排序中不可使用\'与+'
                    }
                  ]
                })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'system' ? <Col span={8}>
              <Form.Item label="默认sql">
                {getFieldDecorator('execute', {
                  initialValue: setting.execute
                })(
                <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'execute')}}>
                  <Radio value="true">执行</Radio>
                  <Radio value="false">不执行</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {!['balcony', 'menubar', 'commonbar', 'tabbar', 'invTable'].includes(config.subtype) && (!config.wrap || config.wrap.supType !== 'multi') && MenuType !== 'billPrint' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'该组件如果受其他组件控制,请选项相应的组件,没有时选“无”。'}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  上级组件
                </Tooltip>
              }>
                {getFieldDecorator('supModule', {
                  initialValue: setting.supModule,
                  rules: [
                    {
                      required: true,
                      message: '请选择上级组件!'
                    }
                  ]
                })(
                  <Cascader options={modules} onChange={(val) => {this.onOptionChange(val, 'supModule')}} expandTrigger="hover" placeholder="" />
                )}
              </Form.Item>
            </Col> : null}
            {config.pageable ? <Col span={8}>
              <Form.Item label="分页">
                {getFieldDecorator('laypage', {
                  initialValue: setting.laypage || 'true'
                })(
                  <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'laypage')}}>
                    <Radio value="true">是</Radio>
                    <Radio value="false">否</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {config.pageable && setting.laypage !== 'false' ? <Col span={8}>
              <Form.Item label="每页数量">
                {getFieldDecorator('pageSize', {
                  initialValue: setting.pageSize || 10,
                  rules: [
                    {
                      required: true,
                      message: '请输入每页数量!'
                    }
                  ]
                })(<InputNumber min={1} max={500} precision={0} />)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'inner' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="当选择“是”时,内部函数的传参会增加 username 与 fullname。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  记录用户
                </Tooltip>
              }>
                {getFieldDecorator('recordUser', {
                  initialValue: setting.recordUser || 'false'
                })(
                <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'recordUser')}}>
                  <Radio value="false">否</Radio>
                  <Radio value="true">是</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'system' ? <Col span={8}>
              <Form.Item label="数据库">
                {getFieldDecorator('database', {
                  initialValue: setting.database || 'local'
                })(
                <Radio.Group>
                  <Radio value="local">本地</Radio>
                  <Radio value="sso">单点</Radio>
                </Radio.Group>)}
              </Form.Item>
            </Col> : null}
            {/* 1、不分页且不存在上级模块 */}
            {!['navbar', 'interface', 'calendar'].includes(config.type) && !['editable', 'basetable', 'dualdatacard', 'invoice', 'invTable'].includes(config.subtype) && (!config.pageable || (config.pageable && setting.laypage === 'false')) && (setting.supModule.length === 0 || setting.supModule[0] === 'empty') && setting.interType === 'system' && setting.onload !== 'false' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={'初始化加载时,是否与其他组件一同加载数据。'}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  同步查询
                </Tooltip>
              }>
                {getFieldDecorator('sync', {
                  initialValue: setting.sync || 'false'
                })(
                  <Radio.Group>
                    <Radio value="true">是</Radio>
                    <Radio value="false">否</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {!['navbar', 'balcony', 'menubar'].includes(config.type) && !['basetable', 'invoice', 'invTable'].includes(config.subtype) ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title={config.type === 'interface' ? '单独搜索组件可作为公共数据源的搜索条件。' : '优先使用同级的搜索条件组件,同级搜索不存在时,依次向上选取,与当前组件的搜索条件一同用作数据过滤(当前组件的搜索条件优先)。'}>
                  <QuestionCircleOutlined className="mk-form-tip" />
                  外部搜索
                </Tooltip>
              }>
                {getFieldDecorator('useMSearch', {
                  initialValue: setting.useMSearch || 'true'
                })(
                  <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'useMSearch')}}>
                    <Radio value="true">使用{!hasMainSearch ? <Tooltip placement="top" title="无可使用的外部搜索条件"><span className="mk-dot"></span></Tooltip> : null}</Radio>
                    <Radio value="false">不使用</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {config.subtype === 'basetable' && !this.state.ismain ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="是否使用主表的搜索条件">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  主表搜索
                </Tooltip>
              }>
                {getFieldDecorator('useMSearch', {
                  initialValue: setting.useMSearch || 'false'
                })(
                  <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'useMSearch')}}>
                    <Radio value="true">使用</Radio>
                    <Radio value="false">不使用</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) ? <Col span={8}>
              <Form.Item label="初始化数据">
                {getFieldDecorator('onload', {
                  initialValue: setting.onload || 'true'
                })(
                  <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'onload')}}>
                    <Radio value="true">加载</Radio>
                    <Radio value="false">不加载</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {setting.interType === 'system' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="使用后端sql脚本时有效。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  事务
                </Tooltip>
              }>
                {getFieldDecorator('transact', {
                  initialValue: setting.transact || 'false'
                })(
                  <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'transact')}}>
                    <Radio value="true">启用</Radio>
                    <Radio value="false">禁用</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {config.type === 'interface' && ((setting.supModule && setting.supModule[0] === 'empty') || MenuType === 'billPrint') ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="初始化加载将在页面加载前执行。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  加载方式
                </Tooltip>
              }>
                {getFieldDecorator('loadlevel', {
                  initialValue: setting.loadlevel || 'default'
                })(
                  <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'loadlevel')}}>
                    <Radio value="default">默认</Radio>
                    <Radio value="init">初始化</Radio>
                  </Radio.Group>
                )}
              </Form.Item>
            </Col> : null}
            {config.type === 'interface' && MenuType !== 'billPrint' ? <Col span={8}>
              <Form.Item label="定时器">
                {getFieldDecorator('timer', {
                  initialValue: setting.timer || ''
                })(
                  <Select onChange={(value) => {this.onOptionChange(value, 'timer')}}>
                    <Select.Option value=""> 无 </Select.Option>
                    <Select.Option value="2s"> 2秒 </Select.Option>
                    <Select.Option value="5s"> 5秒 </Select.Option>
                    <Select.Option value="15s"> 15秒 </Select.Option>
                    <Select.Option value="30s"> 30秒 </Select.Option>
                    <Select.Option value="1min"> 1分钟 </Select.Option>
                    <Select.Option value="5min"> 5分钟 </Select.Option>
                    <Select.Option value="10min"> 10分钟 </Select.Option>
                    <Select.Option value="15min"> 15分钟 </Select.Option>
                    <Select.Option value="30min"> 30分钟 </Select.Option>
                    <Select.Option value="1hour"> 1小时 </Select.Option>
                  </Select>
                )}
              </Form.Item>
            </Col> : null}
            {config.type === 'interface' && setting.timer ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="定时器执行次数。注:0表示没有限制。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  执行次数
                </Tooltip>
              }>
                {getFieldDecorator('timerRepeats', {
                  initialValue: setting.timerRepeats || 0
                })(<InputNumber min={0} max={500} precision={0} />)}
              </Form.Item>
            </Col> : null}
            {config.subtype === 'dualdatacard' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="子表在主表中的数据集名称,使用 sub_data_string 时数据以 JSON 字符串形式返回(字段集中需添加 sub_data_string 字段);当主表字段存在 sub_data_string 且值不为空时,优先使用主表的 sub_data_string。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  子表字段
                </Tooltip>
              }>
                {getFieldDecorator('subdata', {
                  initialValue: setting.subdata || 'sub_data',
                  rules: [
                    {
                      required: true,
                      message: '请输入子表字段!'
                    }
                  ]
                })(<Input placeholder={''} autoComplete="off" />)}
              </Form.Item>
            </Col> : null}
            {config.subtype === 'dualdatacard' ? <Col span={8}>
              <Form.Item label="子表主键">
                {getFieldDecorator('subKey', {
                  initialValue: setting.subKey || ''
                })(
                  <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}>
                    {this.props.subColumns.map((option, i) =>
                      <Select.Option key={i} value={option.field}>
                        {`${option.label}(${option.field})`}
                      </Select.Option>
                    )}
                  </Select>
                )}
              </Form.Item>
            </Col> : null}
            {config.subtype === 'dualdatacard' ? <Col span={8}>
              <Form.Item label="子表BID">
                {getFieldDecorator('subBID', {
                  initialValue: setting.subBID || ''
                })(
                  <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}>
                    {this.props.subColumns.map((option, i) =>
                      <Select.Option key={i} value={option.field}>
                        {`${option.label}(${option.field})`}
                      </Select.Option>
                    )}
                  </Select>
                )}
              </Form.Item>
            </Col> : null}
            {setting.onload !== 'false' ? <Col span={8}>
              <Form.Item label={
                <Tooltip placement="topLeft" title="可延迟初始化数据的加载时间,单位毫秒(ms)。">
                  <QuestionCircleOutlined className="mk-form-tip" />
                  延时加载
                </Tooltip>
              }>
                {getFieldDecorator('delay', {
                  initialValue: setting.delay,
                })(<InputNumber min={0} max={60000} precision={0} />)}
              </Form.Item>
            </Col> : null}
          </Row>
        </Form>
        <Modal
          wrapClassName="mk-flow-type"
          visible={visible}
          width={400}
          onCancel={() => this.setState({visible: false})}
          footer={[
            <Button key="cancel" className="mk-green" onClick={() => this.execAddProcess('flowstart')}>发起</Button>,
            <Button key="confirm" className="mk-primary" onClick={() => this.execAddProcess('flowcheck')}>审批</Button>
          ]}
          destroyOnClose
        >
          请选择工作流类型。
        </Modal>
      </div>
    )
  }
}
 
export default Form.create()(SettingForm)