| | |
| | | columns: null, |
| | | currentTabs: null, |
| | | selectTabs: [], |
| | | interReadonly: false |
| | | interReadonly: false, |
| | | primaryKey: '' |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { config, menu } = this.props |
| | | const { config } = this.props |
| | | |
| | | let _tabs = [] |
| | | let _select = [] |
| | |
| | | let _setting = config.setting |
| | | |
| | | try { |
| | | if (menu && menu.LongParam) { |
| | | _columns = menu.LongParam.columns.filter(item => item.field && item.type !== 'colspan') |
| | | } |
| | | config.groups.forEach(group => { |
| | | let list = group.sublist.filter(item => item.field) |
| | | _columns = [..._columns, ...list] |
| | |
| | | } |
| | | }) |
| | | |
| | | let primaryKey = _setting.primaryKey |
| | | if (primaryKey) { |
| | | let field = _columns.filter(column => column.field === primaryKey) |
| | | if (field.length !== 1) { |
| | | primaryKey = '' |
| | | } |
| | | } |
| | | if (!primaryKey) { |
| | | _columns.forEach(col => { |
| | | if (col.field.toLowerCase() === 'id') { |
| | | primaryKey = col.field |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | currentTabs: _tabs, |
| | | selectTabs: _select, |
| | | columns: _columns, |
| | | setting: _setting, |
| | | interReadonly: _setting.sysInterface === 'true' |
| | | interType: _setting.interType || 'inner', |
| | | interReadonly: _setting.sysInterface === 'true', |
| | | datatype: _setting.datatype || 'maintable', |
| | | primaryKey: primaryKey |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | sourceChange = (e) => { |
| | | const { interType } = this.state |
| | | |
| | | this.setState({ |
| | | datatype: e.target.value |
| | | }, () => { |
| | | if (interType === 'inner') return |
| | | |
| | | let _type = this.props.form.getFieldValue('sysInterface') |
| | | if (_type === 'true') { |
| | | this.props.form.setFieldsValue({ |
| | | interface: window.GLOB.mainSystemApi || window.GLOB.subSystemApi |
| | | }) |
| | | this.setState({ |
| | | interReadonly: true |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | interReadonly: false |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { dict, usefulFields, menu } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType, columns, selectTabs, setting } = this.state |
| | | const { interType, columns, selectTabs, setting, datatype, primaryKey } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 } |
| | | } |
| | | } |
| | | |
| | | let primaryKey = setting.primaryKey |
| | | if (primaryKey) { |
| | | let field = columns.filter(column => column.field === primaryKey) |
| | | if (field.length !== 1) { |
| | | primaryKey = '' |
| | | } |
| | | } |
| | | if (!primaryKey && columns.length === 0) { |
| | | primaryKey = 'ID' |
| | | } |
| | | |
| | | let str = '^(' + usefulFields.join('|') + ')' |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label={dict['header.menu.datasource']}> |
| | | {getFieldDecorator('datatype', { |
| | | initialValue: setting.datatype || 'maintable' |
| | | })( |
| | | <Radio.Group onChange={this.sourceChange}> |
| | | <Radio value="maintable">{dict['header.menu.maintable']}</Radio> |
| | | <Radio value="query">{dict['header.menu.query']}</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {datatype === 'query' ? <Col span={12}> |
| | | <Form.Item label="主键"> |
| | | {getFieldDecorator('primaryKey', { |
| | | initialValue: primaryKey || '' |
| | | })( |
| | | <Select |
| | | getPopupContainer={() => document.getElementById('commontable-setting-form')} |
| | | > |
| | | <Select.Option key='unset' value="">未设置</Select.Option> |
| | | {columns.map((option, index) => |
| | | <Select.Option id={option.uuid} title={option.label} key={index} value={option.field}>{option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {datatype === 'query' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.intertype']}> |
| | | {getFieldDecorator('interType', { |
| | | initialValue: setting.interType || 'inner' |
| | | initialValue: interType |
| | | })( |
| | | <Radio.Group onChange={this.onChange}> |
| | | <Radio value="inner">{dict['header.form.interface.inner']}</Radio> |
| | |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {interType === 'outer' ? <Col span={12}> |
| | | </Col> : null} |
| | | {datatype === 'query' && interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.sysInterface']}> |
| | | {getFieldDecorator('sysInterface', { |
| | | initialValue: setting.sysInterface || 'false' |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={12}> |
| | | {datatype === 'query' && interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.interface']}> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || window.GLOB.subSystemApi) : (setting.interface || ''), |
| | |
| | | })(<Input placeholder="" autoComplete="off" disabled={this.state.interReadonly} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType !== 'outer' ? <Col span={12}> |
| | | {datatype === 'query' && interType !== 'outer' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" overlayClassName="middle" title={`可自定义数据处理函数,函数名称需以${usefulFields.join(', ')}等字符开始;未设置时会调用系统函数,使用系统函数需完善数据源。`}> |
| | | <Icon type="question-circle" /> |
| | |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType !== 'outer' ? <Col span={24}> |
| | | {datatype === 'query' && interType !== 'outer' ? <Col span={24}> |
| | | <Form.Item help={'数据ID:' + menu.MenuID} label={ |
| | | <Tooltip placement="topLeft" title="使用系统函数时,需填写数据源,自定义函数时,可忽略。"> |
| | | <Icon type="question-circle" /> |
| | |
| | | })(<TextArea rows={4} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={12}> |
| | | {datatype === 'query' && interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.outerFunc']}> |
| | | {getFieldDecorator('outerFunc', { |
| | | initialValue: setting.outerFunc || '', |
| | |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | |
| | | <Col span={12}> |
| | | <Form.Item label="主键"> |
| | | {getFieldDecorator('primaryKey', { |
| | | initialValue: primaryKey |
| | | })( |
| | | <Select |
| | | getPopupContainer={() => document.getElementById('commontable-setting-form')} |
| | | > |
| | | <Select.Option key='unset' value="">不设置</Select.Option> |
| | | {columns.length === 0 ? |
| | | <Select.Option key='id' value="ID">ID</Select.Option> : null |
| | | } |
| | | {columns.map((option, index) => |
| | | <Select.Option id={option.uuid} title={option.label} key={index} value={option.field}>{option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="主表可选取关联标签,标签关联后,主表数据切换时,下级标签会跟随主表主键值变化。"> |