| | |
| | | dict: PropTypes.object, // 字典项 |
| | | menu: PropTypes.object, |
| | | data: PropTypes.object, |
| | | columns: PropTypes.array |
| | | columns: PropTypes.array, |
| | | usefulFields: PropTypes.array |
| | | } |
| | | |
| | | state = { |
| | | interType: this.props.data.interType || 'inner' |
| | | interType: this.props.data.interType || 'inner', |
| | | columns: this.props.columns.filter(item => item.field && item.type !== 'colspan') |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | |
| | | return new Promise((resolve, reject) => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.actionfixed = values.actionfixed === 'true' |
| | | values.columnfixed = values.columnfixed === 'true' |
| | | |
| | | if (values.interType === 'inner' && !values.innerFunc && !values.dataresource) { |
| | | notification.warning({ |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { data, dict, menu } = this.props |
| | | const { data, dict, menu, usefulFields } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType } = this.state |
| | | const { interType, columns } = this.state |
| | | |
| | | const formItemLayout = { |
| | | labelCol: { |
| | |
| | | |
| | | let primaryKey = data.primaryKey |
| | | if (primaryKey) { |
| | | let field = this.props.columns.filter(column => column.field === primaryKey) |
| | | let field = columns.filter(column => column.field === primaryKey) |
| | | if (field.length !== 1) { |
| | | primaryKey = '' |
| | | } |
| | | } |
| | | console.log(menu) |
| | | |
| | | let str = '^(' + usefulFields.join('|') + ')' |
| | | let _patten = new RegExp(str + '[0-9a-zA-Z_]*$', 'g') |
| | | |
| | | return ( |
| | | <Form {...formItemLayout} className="ant-advanced-search-form commontable-setting-form" id="commontable-setting-form"> |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType !== 'outer' ? <Col span={12}> |
| | | <Form.Item label={dict['header.form.innerFunc']}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" overlayClassName="middle" title={`可自定义数据处理函数,函数名称需以${usefulFields.join(', ')}等字符开始;未设置时会调用系统函数,使用系统函数需完善数据源。`}> |
| | | <Icon type="question-circle" /> |
| | | {dict['header.form.innerFunc']} |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('innerFunc', { |
| | | initialValue: data.innerFunc || '' |
| | | initialValue: data.innerFunc || '', |
| | | rules: [ |
| | | { |
| | | pattern: _patten, |
| | | message: '名称只允许包含数字、字母和下划线,且以指定字符开始。' |
| | | }, { |
| | | max: 50, |
| | | message: '内部函数名称不超过50个字符。' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | |
| | | <Col span={12}> |
| | | <Form.Item label="固定按钮"> |
| | | {getFieldDecorator('actionfixed', { |
| | | initialValue: data.actionfixed |
| | | initialValue: data.actionfixed ? 'true' : 'false' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value={true}>是</Radio> |
| | | <Radio value={false}>否</Radio> |
| | | </Radio.Group> |
| | | <Select> |
| | | <Select.Option value="true">是</Select.Option> |
| | | <Select.Option value="false">否</Select.Option> |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={12}> |
| | | <Form.Item label="固定列"> |
| | | {getFieldDecorator('columnfixed', { |
| | | initialValue: data.columnfixed |
| | | initialValue: data.columnfixed ? 'true' : 'false' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value={true}>是</Radio> |
| | | <Radio value={false}>否</Radio> |
| | | </Radio.Group> |
| | | <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', { |
| | | initialValue: primaryKey ? primaryKey : (this.props.columns.length === 0 ? 'ID' : '') |
| | | initialValue: primaryKey ? primaryKey : (columns.length === 0 ? 'ID' : '') |
| | | })( |
| | | <Select |
| | | getPopupContainer={() => document.getElementById('commontable-setting-form')} |
| | | > |
| | | <Select.Option value="">不设置</Select.Option> |
| | | {this.props.columns.length === 0 ? |
| | | <Select.Option value="ID">ID</Select.Option> : null |
| | | <Select.Option key='unset' value="">不设置</Select.Option> |
| | | {columns.length === 0 ? |
| | | <Select.Option key='id' value="ID">ID</Select.Option> : null |
| | | } |
| | | {this.props.columns.map(option => |
| | | <Select.Option id={option.uuid} title={option.label} key={option.uuid} value={option.field}>{option.label}</Select.Option> |
| | | {columns.map((option, index) => |
| | | <Select.Option id={option.uuid} title={option.label} key={index} value={option.field}>{option.label}</Select.Option> |
| | | )} |
| | | </Select> |
| | | )} |