From a5f99a5f0e2035851997221bc2430f8cfd1dc146 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 04 十二月 2019 23:21:04 +0800 Subject: [PATCH] 2019-12-04 --- src/tabviews/datamanage/search/index.jsx | 94 ++++++++++++++++++++++++---------------------- 1 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/tabviews/datamanage/search/index.jsx b/src/tabviews/datamanage/search/index.jsx index 138ad05..cc2d8de 100644 --- a/src/tabviews/datamanage/search/index.jsx +++ b/src/tabviews/datamanage/search/index.jsx @@ -4,10 +4,10 @@ import moment from 'moment' import './index.scss' -const {MonthPicker, WeekPicker} = DatePicker -const dateFormat = 'YYYY-MM-DD' -const weekFormat = 'YYYYMMDD' -const monthFormat = 'YYYY-MM' +// const {MonthPicker, WeekPicker} = DatePicker +// const dateFormat = 'YYYY-MM-DD' +// const weekFormat = 'YYYYMMDD' +// const monthFormat = 'YYYY-MM' class MainSearch extends Component { static propTpyes = { @@ -24,12 +24,6 @@ let formats = {} let match = {} this.props.searchlist.forEach(item => { - if (item.Type === 'date') { - // formats[item.FieldName] = dateFormat - formats[item.FieldName] = weekFormat - } else if (item.ID === 'WHE1400200905') { - formats[item.FieldName] = monthFormat - } match[item.FieldName] = item.Op }) this.setState({ @@ -72,37 +66,50 @@ </Col> ) } else if (item.Type === 'date') { // 鏃堕棿鎼滅储 - if (item.ID === 'WHE14002009024') { - fields.push( - <Col span={6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09-14', dateFormat) })( - <DatePicker format={dateFormat} /> - )} - </Form.Item> - </Col> - ) - } else if (item.ID === 'WHE1400200905') { - fields.push( - <Col span={6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09', monthFormat) })( - <MonthPicker format={monthFormat} /> - )} - </Form.Item> - </Col> - ) - } else if (item.ID === 'WHE1400200902') { - fields.push( - <Col span={6} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.FieldName, {initialValue: moment('20190906', weekFormat) })( - <WeekPicker /> - )} - </Form.Item> - </Col> - ) + let _initval = null + if (item.InitVal) { + _initval = moment().subtract(parseInt(item.InitVal), 'days') } + fields.push( + <Col span={6} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.FieldName, {initialValue: _initval })( + <DatePicker /> + )} + </Form.Item> + </Col> + ) + // if (item.ID === 'WHE14002009024') { + // fields.push( + // <Col span={6} key={index}> + // <Form.Item label={item.label}> + // {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09-14', dateFormat) })( + // <DatePicker format={dateFormat} /> + // )} + // </Form.Item> + // </Col> + // ) + // } else if (item.ID === 'WHE1400200905') { + // fields.push( + // <Col span={6} key={index}> + // <Form.Item label={item.label}> + // {getFieldDecorator(item.FieldName, {initialValue: moment('2019-09', monthFormat) })( + // <MonthPicker format={monthFormat} /> + // )} + // </Form.Item> + // </Col> + // ) + // } else if (item.ID === 'WHE1400200902') { + // fields.push( + // <Col span={6} key={index}> + // <Form.Item label={item.label}> + // {getFieldDecorator(item.FieldName, {initialValue: moment('20190906', weekFormat) })( + // <WeekPicker /> + // )} + // </Form.Item> + // </Col> + // ) + // } } }) @@ -153,14 +160,11 @@ Object.keys(searches).forEach(key => { let val = searches[key] || '' if (searches[key] && typeof(searches[key]) === 'object') { - if (this.state.formats[key] === weekFormat) { - val = moment(searches[key]).startOf('week').format(this.state.formats[key]) + ' ' + moment(searches[key]).endOf('week').format(this.state.formats[key]) - } else { - val = moment(searches[key]).format(this.state.formats[key]) - } + val = moment(searches[key]).format('YYYY-MM-DD') } search[key] = val }) + let valid = true // 鏍¢獙蹇呭~椤� this.props.searchlist.forEach(item => { let required = false -- Gitblit v1.8.0