king
2024-02-03 8acfcd6e349ef2d1b797a7483940a2f3f2dfcfe6
src/tabviews/zshare/topSearch/mkDatePicker/index.jsx
@@ -15,28 +15,16 @@
    const config = props.config
    let mode = 'date'
    let format = 'YYYY-MM-DD'
    let format = config.format || 'YYYY-MM-DD'
    if (config.type === 'datemonth') {
      mode = 'month'
      format = 'YYYY-MM'
    } else if (config.type === 'week') {
      mode = 'week'
      format = 'YYYY-MM-DD'
    } else {
      if (config.type === 'daterange') {
    } else if (config.type === 'daterange') {
        mode = 'daterange'
      }
      if (config.precision === 'day') {
        format = 'YYYY-MM-DD'
      } else if (config.precision === 'hour') {
        format = 'YYYY-MM-DD HH'
      } else if (config.precision === 'minute') {
        format = 'YYYY-MM-DD HH:mm'
      } else if (config.precision === 'second') {
        format = 'YYYY-MM-DD HH:mm:ss'
      }
    }
    let value = config.initval || null
    if (mode === 'daterange') {
@@ -62,6 +50,20 @@
    return !is(fromJS(this.state), fromJS(nextState))
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { config } = this.props
    if (config.checkShift && nextProps.config.initval && nextProps.config.initval !== config.initval) {
      let val = nextProps.config.initval.split(',')
      this.setState({
        value: [moment(val[0], config.format), moment(val[1], config.format)]
      })
      this.props.onChange(nextProps.config.initval, true)
    }
  }
  componentWillUnmount () {
    this.setState = () => {
      return
@@ -78,9 +80,9 @@
      if (_val && !_val[0]) {
        _val = ''
      }
      this.props.onChange(_val ? `${moment(_val[0]).format(format)},${moment(_val[1]).format(format)}` : '')
      this.props.onChange(_val ? `${moment(_val[0]).format(format)},${moment(_val[1]).format(format)}` : '', false)
    } else {
      this.props.onChange(val ? moment(val).format(format) : '')
      this.props.onChange(val ? moment(val).format(format) : '', false)
    }
  }