From ff045a6a19e2e0bd5c2433aae71145401627c22d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 19 十二月 2019 19:08:32 +0800 Subject: [PATCH] 2019-12-19 --- src/templates/comtableconfig/settingform/index.jsx | 68 ++++++++++++++++++++++------------ 1 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/templates/comtableconfig/settingform/index.jsx b/src/templates/comtableconfig/settingform/index.jsx index 9b0ab62..52d3212 100644 --- a/src/templates/comtableconfig/settingform/index.jsx +++ b/src/templates/comtableconfig/settingform/index.jsx @@ -10,11 +10,13 @@ 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 = () => { @@ -22,6 +24,8 @@ 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({ @@ -46,9 +50,9 @@ } 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: { @@ -63,12 +67,14 @@ 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"> @@ -134,9 +140,23 @@ </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} @@ -155,41 +175,41 @@ <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> )} -- Gitblit v1.8.0