From c0930736f5b5955efecdac4c0ca85957d4f7b574 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 16 十二月 2019 22:55:17 +0800 Subject: [PATCH] 2019-12-16 --- src/tabviews/commontable/mutilform/index.jsx | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/tabviews/commontable/mutilform/index.jsx b/src/tabviews/commontable/mutilform/index.jsx index 391eb45..9bf97eb 100644 --- a/src/tabviews/commontable/mutilform/index.jsx +++ b/src/tabviews/commontable/mutilform/index.jsx @@ -2,6 +2,7 @@ import PropTypes from 'prop-types' import { Form, Row, Col, Input, InputNumber, Select, DatePicker } from 'antd' import moment from 'moment' +import Utils from '@/utils/utils.js' import './index.scss' const {MonthPicker} = DatePicker @@ -10,17 +11,20 @@ static propTpyes = { action: PropTypes.object, // 鎼滅储鏉′欢鍒楄〃 dict: PropTypes.object, // 瀛楀吀椤� - data: PropTypes.any // 琛ㄦ牸鏁版嵁 + data: PropTypes.any, // 琛ㄦ牸鏁版嵁 + configMap: PropTypes.object } state = { datatype: null, + readtype: null, formlist: [] } componentDidMount () { const { action } = this.props let datatype = {} + let readtype = {} let formlist = [] if (action.groups.length > 0) { action.groups.forEach(group => { @@ -36,17 +40,36 @@ group.sublist.forEach(item => { datatype[item.field] = item.type + readtype[item.field] = item.readonly === 'true' formlist.push(item) }) }) } else { formlist = action.fields.map(item => { datatype[item.field] = item.type + readtype[item.field] = item.readonly === 'true' + + if (item.type === 'select' || item.type === 'link') { + if (item.setAll === 'true') { + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: this.props.dict['main.all'] + }) + } + + if (item.resourceType === '1' && this.props.configMap.hasOwnProperty(item.uuid)) { + item.options = [...item.options, ...this.props.configMap[item.uuid]] + } + console.log(item) + } + return item }) } this.setState({ + readtype: readtype, datatype: datatype, formlist: formlist }) @@ -114,7 +137,7 @@ </Form.Item> </Col> ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 + } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 fields.push( <Col span={24 / cols} key={index}> <Form.Item label={item.label}> @@ -130,7 +153,7 @@ <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById('form-box')} + // getPopupContainer={() => document.getElementById('form-box')} > {item.options.map(option => <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> @@ -226,39 +249,50 @@ if (!err) { let search = [] Object.keys(values).forEach(key => { - if (this.state.style[key] === 'datetime') { + if (this.state.datatype[key] === 'datetime') { let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM-DD HH:mm:ss') } search.push({ - type: this.state.style[key], + type: this.state.datatype[key], + readonly: this.state.readtype[key], key: key, value: _value }) - } else if (this.state.style[key] === 'datemonth') { + } else if (this.state.datatype[key] === 'datemonth') { let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM') } search.push({ - type: this.state.style[key], + type: this.state.datatype[key], + readonly: this.state.readtype[key], key: key, value: _value }) - } else if (this.state.style[key] === 'date') { + } else if (this.state.datatype[key] === 'date') { let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM-DD') } search.push({ - type: this.state.style[key], + type: this.state.datatype[key], + readonly: this.state.readtype[key], key: key, value: _value }) + } else if (this.state.datatype[key] === 'number') { + search.push({ + type: this.state.datatype[key], + readonly: this.state.readtype[key], + key: key, + value: values[key] + }) } else { search.push({ - type: this.state.style[key], + type: this.state.datatype[key], + readonly: this.state.readtype[key], key: key, value: values[key].replace(/(^\s*|\s*$)/ig, '') }) -- Gitblit v1.8.0