king
2019-12-16 c0930736f5b5955efecdac4c0ca85957d4f7b574
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, '')
              })