| | |
| | | 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 } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | 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 Utils from '@/utils/utils.js' |
| | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | | updateStatus: PropTypes.func, |
| | | updateColumns: PropTypes.func, |
| | | addProcess: PropTypes.func, |
| | | config: PropTypes.object, // 组件配置 |
| | | setting: PropTypes.object, // 数据源配置 |
| | |
| | | innerRules: [], |
| | | innertip: '', |
| | | MenuType: sessionStorage.getItem('MenuType') || '', |
| | | ismain: false |
| | | ismain: false, |
| | | visible: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | } |
| | | |
| | | addProcess = () => { |
| | | let _sql = this.props.form.getFieldValue('dataresource') |
| | | this.setState({visible: true}) |
| | | } |
| | | |
| | | _sql = _sql + `\n/* select a.*,w.remark as remark_w,w.statusname as statusname_w,w.status as status_w,w.works_flow_param from (数据源) 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 */` |
| | | 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.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.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 } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { setting, modules, innerRules, innertip, MenuType } = this.state |
| | | const { setting, modules, innerRules, innertip, MenuType, visible } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | message: '请输入数据源名称!' |
| | | } |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={8}> |
| | |
| | | message: '表名只可使用字母、数字以及_' |
| | | } |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | })( |
| | | 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}> |
| | |
| | | </Col> : null} |
| | | </Row> |
| | | </Form> |
| | | <Modal |
| | | wrapClassName="mk-flow-type" |
| | | visible={visible} |
| | | width={400} |
| | | maskClosable={false} |
| | | closable={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> |
| | | ) |
| | | } |