| | |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | menu: PropTypes.object, |
| | | data: PropTypes.object, |
| | | config: PropTypes.object, |
| | | columns: PropTypes.array, |
| | | usefulFields: PropTypes.array |
| | | } |
| | | |
| | | state = { |
| | | interType: this.props.data.interType || 'inner', |
| | | columns: this.props.columns.filter(item => item.field && item.type !== 'colspan'), |
| | | interType: null, |
| | | columns: null, |
| | | currentTabs: null, |
| | | selectTabs: [] |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { config, data } = this.props |
| | | const { config, menu } = this.props |
| | | console.log(menu) |
| | | console.log(config) |
| | | let _tabs = [] |
| | | let _select = [] |
| | | let _tabMap = new Map() |
| | | let _columns = [] |
| | | let _interType = 'inner' |
| | | let _setting = config.setting |
| | | |
| | | try { |
| | | _columns = menu.LongParam.columns.filter(item => item.field && item.type !== 'colspan') |
| | | // config.groups.forEach(group => { |
| | | // if (group.isDefault) { |
| | | // _columns.push() |
| | | // } |
| | | // group.sublist |
| | | // }) |
| | | _interType = menu.LongParam.setting.interType |
| | | } catch { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '菜单信息错误!', |
| | | duration: 10 |
| | | }) |
| | | } |
| | | |
| | | config.tabgroups.forEach(groupname => { |
| | | config[groupname].forEach(tab => { |
| | |
| | | }) |
| | | }) |
| | | |
| | | data.subtabs && data.subtabs.forEach(tabId => { |
| | | _setting.subtabs && _setting.subtabs.forEach(tabId => { |
| | | if (_tabMap.has(tabId)) { |
| | | _select.push(tabId) |
| | | } |
| | |
| | | |
| | | this.setState({ |
| | | currentTabs: _tabs, |
| | | selectTabs: _select |
| | | selectTabs: _select, |
| | | columns: _columns, |
| | | interType: _interType, |
| | | setting: _setting |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | selectChange = (val) => { |
| | | // let _order = this.props.form.getFieldValue('order') |
| | | this.props.form.setFieldsValue({ |
| | | order: `${val} desc` |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { data, dict, menu, usefulFields } = this.props |
| | | const { dict, menu, usefulFields } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType, columns, selectTabs } = this.state |
| | | const { interType, columns, selectTabs, setting } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | } |
| | | } |
| | | |
| | | let primaryKey = data.primaryKey |
| | | let primaryKey = setting.primaryKey |
| | | if (primaryKey) { |
| | | let field = columns.filter(column => column.field === primaryKey) |
| | | if (field.length !== 1) { |
| | |
| | | <Col span={12}> |
| | | <Form.Item label="表名"> |
| | | {getFieldDecorator('tableName', { |
| | | initialValue: data.tableName, |
| | | initialValue: setting.tableName, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="表格属性"> |
| | | {getFieldDecorator('tableType', { |
| | | initialValue: data.tableType |
| | | })( |
| | | <Select |
| | | getPopupContainer={() => document.getElementById('commontable-setting-form')} |
| | | > |
| | | <Select.Option value="">不可选</Select.Option> |
| | | <Select.Option value="radio">单选</Select.Option> |
| | | <Select.Option value="checkbox">多选</Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label={dict['header.form.intertype']}> |
| | | {getFieldDecorator('interType', { |
| | | initialValue: data.interType || 'inner' |
| | | initialValue: setting.interType || 'inner' |
| | | })( |
| | | <Radio.Group onChange={this.onChange}> |
| | | <Radio value="inner">{dict['header.form.interface.inner']}</Radio> |
| | |
| | | {interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.interface']}> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: data.interface || '', |
| | | initialValue: setting.interface || '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('innerFunc', { |
| | | initialValue: data.innerFunc || '', |
| | | initialValue: setting.innerFunc || '', |
| | | rules: [ |
| | | { |
| | | pattern: _patten, |
| | |
| | | </Tooltip> |
| | | } className="textarea"> |
| | | {getFieldDecorator('dataresource', { |
| | | initialValue: data.dataresource |
| | | initialValue: setting.dataresource |
| | | })(<TextArea rows={4} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={12}> |
| | | <Form.Item label="固定按钮"> |
| | | {getFieldDecorator('actionfixed', { |
| | | initialValue: data.actionfixed ? 'true' : 'false' |
| | | })( |
| | | <Select> |
| | | <Select.Option value="true">是</Select.Option> |
| | | <Select.Option value="false">否</Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {interType === 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.outerFunc']}> |
| | | {getFieldDecorator('outerFunc', { |
| | | initialValue: data.outerFunc || '', |
| | | initialValue: setting.outerFunc || '', |
| | | rules: [ |
| | | { |
| | | pattern: formRule.func.pattern, |
| | |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={12}> |
| | | <Form.Item label="固定列"> |
| | | {getFieldDecorator('columnfixed', { |
| | | initialValue: data.columnfixed ? 'true' : 'false' |
| | | })( |
| | | <Select> |
| | | <Select.Option value="true">是</Select.Option> |
| | | <Select.Option value="false">否</Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | |
| | | <Col span={12}> |
| | | <Form.Item label="主键"> |
| | | {getFieldDecorator('primaryKey', { |
| | |
| | | {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="默认排序"> |
| | | {getFieldDecorator('order', { |
| | | initialValue: data.order || (primaryKey ? primaryKey + ' desc' : ''), |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.input'] + '默认排序字段!' |
| | | }, |
| | | { |
| | | max: formRule.input.max, |
| | | message: formRule.input.message |
| | | } |
| | | ] |
| | | })(<Input placeholder="ID asc, UID desc" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="初始化"> |
| | | {getFieldDecorator('onload', { |
| | | initialValue: data.onload || 'true' |
| | | })( |
| | | <Select> |
| | | <Select.Option value="true">加载数据</Select.Option> |
| | | <Select.Option value="false">不加载数据</Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |