From f36141f3075edf9d41928d64f759ad6bd1b1ac60 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 七月 2020 17:43:34 +0800 Subject: [PATCH] 2020-07-14 --- src/mob/datasource/verifycard/settingform/index.jsx | 394 +++++++++++++++++++++++++------------------------------ 1 files changed, 181 insertions(+), 213 deletions(-) diff --git a/src/mob/datasource/verifycard/settingform/index.jsx b/src/mob/datasource/verifycard/settingform/index.jsx index 9720ab4..361cc5e 100644 --- a/src/mob/datasource/verifycard/settingform/index.jsx +++ b/src/mob/datasource/verifycard/settingform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification, InputNumber } from 'antd' +// import { fromJS } from 'immutable' +import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd' import moment from 'moment' import Api from '@/api' @@ -15,18 +15,18 @@ static propTpyes = { type: PropTypes.string, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� - menu: PropTypes.object, // 鑿滃崟淇℃伅 - config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 + menuId: PropTypes.string, // 鑿滃崟Id + setting: PropTypes.object, // 鏁版嵁婧愰厤缃� formlist: PropTypes.array, // 琛ㄥ崟淇℃伅 } state = { - + interType: 'inner', + structure: 'array' } handleConfirm = (otype) => { - const { menu } = this.props - const { setting } = this.state + const { setting } = this.props // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { @@ -92,12 +92,12 @@ values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && - this.props.config.setting.dataresource !== values.dataresource + setting.dataresource !== values.dataresource ) { let param = { func: 's_DataSrc_Save', LText: values.dataresource, - MenuID: menu.MenuID + MenuID: this.props.menuId } param.LText = Utils.formatOptions(param.LText) @@ -127,217 +127,23 @@ onRadioChange = (e, key) => { let value = e.target.value - let _formlist = fromJS(this.state.formlist).toJS() if (key === 'interType') { this.setState({ - formlist: _formlist.map(item => { - item.hidden = false - - if (value === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } else if (value === 'outer' && ['innerFunc', 'dataresource', 'queryType'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } - - return item - }) + interType: value }) - } else if (key === 'sysInterface') { - if (value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - } + } else if (key === 'structure') { this.setState({ - formlist: _formlist.map(item => { - if (item.key === 'interface') { - item.readonly = value === 'true' - } - - return item - }) + structure: value }) } } - getFields(formlist) { - const { getFieldDecorator } = this.props.form - const fields = [] - - formlist.forEach((item, index) => { - if (item.hidden || item.forbid) return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - let rules = item.rules || [] - - fields.push( - <Col span={8} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - }, - ...rules - ] - })(<Input placeholder={item.placeholder || ''} autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || 6, - rules: [ - { - required: item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<InputNumber min={item.min} max={item.max} precision={0} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => { - return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || - option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 - }} - onChange={(value) => {this.selectChange(item.key, value)}} - getPopupContainer={() => document.getElementById('model-table-setting-form')} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}> - {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Radio.Group onChange={(e) => {this.onRadioChange(e, item.key)}}> - { - item.options.map((option, i) => { - return ( - <Radio key={i} value={option.value}>{option.text}</Radio> - ) - }) - } - </Radio.Group>, - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datasource') { - fields.push( - <Col span={24} key={index} style={{paddingLeft: '7px'}}> - <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } help={item.help} label={ - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<TextArea rows={4} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'textarea') { - fields.push( - <Col span={20} offset={4} key={index}> - <Form.Item className="text-area"> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<TextArea rows={4} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 澶氶�� - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || [] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } - }) - - return fields - } - render() { + const { columns } = this.props const { getFieldDecorator } = this.props.form - // const { formlist } = this.state + const { interType, structure } = this.state + const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -350,22 +156,184 @@ } return ( - <div className="model-table-setting-form-box"> - <Form {...formItemLayout} className="model-table-setting-form"> + <div className="mob-datasource-setting-form-box"> + <Form {...formItemLayout} className="mob-setting-form"> <Row gutter={24}> <Col span={8}> <Form.Item label="鍚嶇О"> - {getFieldDecorator('label', { + {getFieldDecorator('name', { initialValue: '', rules: [ { required: true, - message: this.props.dict['form.required.input'] + '鍚嶇О!' + message: this.props.dict['mob.required.input'] + '鍚嶇О!' }, ] })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> </Col> + <Col span={8}> + <Form.Item label="琛ㄥ悕"> + {getFieldDecorator('tableName', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['mob.required.input'] + '琛ㄥ悕!' + }, + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label="鏁版嵁缁撴瀯"> + {getFieldDecorator('structure', { + initialValue: structure, + rules: [ + { + required: true, + message: this.props.dict['mob.required.select'] + '琛ㄥ悕!' + }, + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'structure')}}> + <Radio value="array">鏁扮粍</Radio> + <Radio value="field">瀛楁</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label="鎺ュ彛绫诲瀷"> + {getFieldDecorator('interType', { + initialValue: interType, + rules: [ + { + required: true, + message: this.props.dict['mob.required.select'] + '鎺ュ彛绫诲瀷!' + }, + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> + <Radio value="inner">鍐呴儴</Radio> + <Radio value="outer">澶栭儴</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {interType === 'inner' ? <Col span={8}> + <Form.Item label="鍐呴儴鍑芥暟"> + {getFieldDecorator('innerFunc', { + initialValue: '', + rules: [ + + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={8}> + <Form.Item label="鎺ュ彛鍦板潃"> + {getFieldDecorator('interface', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['mob.required.input'] + '鎺ュ彛鍦板潃!' + }, + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={8}> + <Form.Item label="澶栭儴鍑芥暟"> + {getFieldDecorator('outerFunc', { + initialValue: '', + rules: [ + + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + <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={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}> + <Icon type="question-circle" /> + 鏁版嵁婧� + </Tooltip> + }> + {getFieldDecorator('dataresource', { + initialValue: '' + })(<TextArea rows={4} />)} + </Form.Item> + </Col> + {structure === 'array' ? <Col span={8}> + <Form.Item label="涓婚敭"> + {getFieldDecorator('primaryKey', { + initialValue: '', + rules: [ + + ] + })( + <Select onChange={(value) => {this.selectChange('primaryKey', value)}}> + {columns.map((option, i) => + <Select.Option key={i} value={option.value}> + {option.text} + </Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> : null} + {structure === 'array' ? <Col span={8}> + <Form.Item label="榛樿鎺掑簭"> + {getFieldDecorator('order', { + initialValue: '', + rules: [ + + ] + })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {structure === 'array' ? <Col span={8}> + <Form.Item label="鍒嗛〉"> + {getFieldDecorator('laypage', { + initialValue: '', + rules: [ + + ] + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'inner' ? <Col span={8}> + <Form.Item label="榛樿sql"> + {getFieldDecorator('execute', { + initialValue: 'true', + rules: [ + + ] + })( + <Radio.Group> + <Radio value="true">鎵ц</Radio> + <Radio value="false">涓嶆墽琛�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + <Col span={8}> + <Form.Item label="鎼滅储鏉′欢"> + {getFieldDecorator('search', { + initialValue: 'true', + rules: [ + + ] + })( + <Radio.Group> + <Radio value="true">鎺ユ敹</Radio> + <Radio value="false">涓嶆帴鏀�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> </Row> </Form> </div> -- Gitblit v1.8.0