From 9f9d68cf40f1d7470bfb49220266b26663cbb722 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 23 十一月 2019 14:55:11 +0800 Subject: [PATCH] 2019-11-23-01 --- src/templates/comtableconfig/searchform/index.jsx | 46 +++++++++++++++++++++++++++++++++++----------- 1 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/templates/comtableconfig/searchform/index.jsx b/src/templates/comtableconfig/searchform/index.jsx index 1e08bf7..d71d855 100644 --- a/src/templates/comtableconfig/searchform/index.jsx +++ b/src/templates/comtableconfig/searchform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd' -import moment from 'moment' +// import moment from 'moment' import EditTable from '../editable' import './index.scss' @@ -17,7 +17,13 @@ state = { openType: null, resourceType: null, - formlist: null + formlist: null, + dateoptions: { + date: [{value: '', text: '绌�'}, {value: '0', text: '褰撳ぉ'}, {value: 1, text: '鍓嶄竴澶�'}, {value: 3, text: '鍓嶄笁澶�'}, {value: 7, text: '鍓嶄竷澶�'}, {value: 30, text: '鍓�30澶�'}], + dateweek: [{value: '', text: '绌�'}, {value: '0', text: '鏈懆'}, {value: 1, text: '涓婂懆'}, {value: 3, text: '鍓嶄笁鍛�'}, {value: 7, text: '鍓嶄竷鍛�'}], + datemonth: [{value: '', text: '绌�'}, {value: '0', text: '鏈湀'}, {value: 1, text: '涓婃湀'}, {value: 3, text: '鍓嶄笁鏈�'}, {value: 7, text: '鍓嶄竷鏈�'}], + dateyear: [{value: '', text: '绌�'}, {value: '0', text: '褰撳勾'}, {value: 1, text: '鍘诲勾'}, {value: 3, text: '鍓嶅勾'}], + } } openTypeChange = (key, value) => { @@ -37,7 +43,26 @@ openType: value, formlist: this.state.formlist.map(form => { form.hidden = !_options.includes(form.key) + if (form.key === 'initval') { + if (this.state.dateoptions.hasOwnProperty(value)) { + form.options = this.state.dateoptions[value] + form.type = 'select' + } else { + form.type = 'text' + } + form.initVal = '' + form.hidden = true + } return form + }) + }, () => { + this.setState({ + formlist: this.state.formlist.map(form => { + if (form.key === 'initval') { + form.hidden = false + } + return form + }) }) }) } @@ -74,12 +99,6 @@ if (item.hidden) return if (item.type === 'text') { // 鏂囨湰鎼滅储 - let placeholder = '' - if (item.key === 'initval' && this.state.openType === 'date') { - placeholder = '渚嬶細' + moment().format('YYYY-MM-DD') - } else if (item.key === 'initval' && this.state.openType === 'datetime') { - placeholder = '渚嬶細' + moment().format('YYYY-MM-DD HH:mm:ss') - } fields.push( <Col span={12} key={index}> <Form.Item label={item.label}> @@ -91,7 +110,7 @@ message: this.props.dict['form.required.input'] + item.label + '!' } ] - })(<Input placeholder={placeholder} autoComplete="off" disabled={item.readonly} />)} + })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)} </Form.Item> </Col> ) @@ -115,7 +134,7 @@ getPopupContainer={() => document.getElementById('commontable-search-form-box')} > {item.options.map(option => - <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}> + <Select.Option id={option.value} title={option.text} key={option.value} value={option.value}> {item.key === 'icon' && <Icon type={option.text} />} {option.text} </Select.Option> )} @@ -141,7 +160,7 @@ { item.options.map(option => { return ( - <Radio key={option.MenuID} value={option.MenuID}>{option.text}</Radio> + <Radio key={option.value} value={option.value}>{option.text}</Radio> ) }) } @@ -175,6 +194,7 @@ ) } }) + return fields } @@ -241,6 +261,10 @@ openType: type, resourceType: resourceType, formlist: formlist.map(form => { + if (this.state.dateoptions.hasOwnProperty(type) && form.key === 'initval') { + form.options = this.state.dateoptions[type] + form.type = 'select' + } form.hidden = !_options.includes(form.key) return form }) -- Gitblit v1.8.0