king
2019-12-21 75347779d54c3c8a0893166dbb9c03bc06ea1eee
2019-12-21
5个文件已修改
196 ■■■■■ 已修改文件
src/tabviews/commontable/mainSearch/index.jsx 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/source.jsx 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/option.js 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/commontable/mainSearch/index.jsx
@@ -14,26 +14,39 @@
  state = {
    match: null, // 搜索条件匹配规则
    style: null
    style: null,
    searchlist: null
  }
  UNSAFE_componentWillMount () {
    let match = {}
    let style = {}
    let _list = []
    let fieldMap = new Map()
    this.props.searchlist.forEach(item => {
      if (fieldMap.has(item.field)) {
        item.field = item.field + '@tail@'
      }
      fieldMap.set(item.field, true)
      match[item.field] = item.match
      style[item.field] = item.type
      _list.push(item)
    })
    this.setState({
      match: match,
      style: style
      style: style,
      searchlist: _list
    })
  }
  getFields() {
    const { getFieldDecorator } = this.props.form
    const fields = []
    this.props.searchlist.forEach((item, index) => {
    this.state.searchlist.forEach((item, index) => {
      if (item.type === 'text') { // 文本搜索
        fields.push(
          <Col span={6} key={index}>
@@ -186,7 +199,7 @@
        }
        search.push({
          type: this.state.style[key],
          key: key,
          key: key.replace(/@tail@$/, ''),
          value: _value,
          match: this.state.match[key]
        })
@@ -197,7 +210,7 @@
        }
        search.push({
          type: this.state.style[key],
          key: key,
          key: key.replace(/@tail@$/, ''),
          value: _value,
          match: this.state.match[key]
        })
@@ -208,7 +221,7 @@
        }
        search.push({
          type: this.state.style[key],
          key: key,
          key: key.replace(/@tail@$/, ''),
          value: _value,
          match: this.state.match[key]
        })
@@ -219,14 +232,14 @@
        }
        search.push({
          type: this.state.style[key],
          key: key,
          key: key.replace(/@tail@$/, ''),
          value: _value,
          match: this.state.match[key]
        })
      } else {
        search.push({
          type: this.state.style[key],
          key: key,
          key: key.replace(/@tail@$/, ''),
          value: values[key].replace(/(^\s*|\s*$)/ig, ''),
          match: this.state.match[key]
        })
src/templates/comtableconfig/index.jsx
@@ -113,7 +113,6 @@
    }
    _config.tabs = _config.tabs || []
    _config.subtabs = _config.subtabs || []
    this.setState({
      originActions: _oriActions,
@@ -287,7 +286,7 @@
          this.handleAction(card)
        } else if (type === 'columns') {
          this.handleColumn(card)
        } else if (type === 'tabs' || type === 'subtabs') {
        } else if (type === 'tabs') {
          this.handleTab(card)
        }
      })
@@ -913,6 +912,28 @@
  }
  handleTab = (card) => {
    const { config } = this.state
    let menus = []
    config.tabs.forEach(item => {
      if (item.origin || card.uuid === item.uuid) return
      let menu = {
        value: item.uuid,
        text: item.label
      }
      menus.push(menu)
    })
    if (card.supMenu && card.supMenu !== 'mainTable') {
      let _menu = menus.filter(item => item.value === card.supMenu)[0]
      if (!_menu) {
        card.supMenu = ''
      }
    }
    this.setState({
      visible: true,
      formtemp: 'tabs',
@@ -939,22 +960,22 @@
        },
        {
          type: 'select',
          key: 'linkId',
          key: 'linkTab',
          label: '关联标签',
          initVal: card.linkId || '',
          required: true,
          initVal: card.linkTab || '',
          required: false,
          options: [{
            value: 'table',
            text: 'table'
            value: '',
            text: '新建'
          }, {
            value: 'bar-chart',
            text: 'bar-chart'
            value: 'jadisfjiasodjIjjaidfoasdf',
            text: '子表1'
          }, {
            value: 'pie-chart',
            text: 'pie-chart'
            value: 'dasjfsioafjiaga',
            text: '子表2'
          }, {
            value: 'line-chart',
            text: 'line-chart'
            value: 'jadsifjasgfisag',
            text: '子表3'
          }]
        },
        {
@@ -981,11 +1002,21 @@
          }]
        },
        {
          type: 'text',
          key: 'description',
          label: this.state.dict['header.form.description'],
          initVal: card.description || '',
          required: false
          type: 'select',
          key: 'supMenu',
          label: '关联菜单',
          initVal: card.supMenu || '',
          required: false,
          options: [
            {
              value: '',
              text: this.state.dict['header.form.empty']
            }, {
              value: 'mainTable',
              text: '主表'
            },
            ...menus
          ]
        }
      ]
    })
@@ -1718,9 +1749,6 @@
      if (config.tabs[0] && config.tabs[0].origin) {
        config.tabs = config.tabs.filter(item => !item.origin)
      }
      if (config.subtabs[0] && config.subtabs[0].origin) {
        config.subtabs = config.subtabs.filter(item => !item.origin)
      }
      let _LongParam = ''
      let _config = {...config, tables: this.state.selectedTables}
@@ -1977,8 +2005,7 @@
      (config.search[0] && config.search[0].origin) ||
      (config.action[0] && config.action[0].origin) ||
      (config.columns[0] && config.columns[0].origin) ||
      (config.tabs[0] && config.tabs[0].origin) ||
      (config.subtabs[0] && config.subtabs[0].origin)
      (config.tabs[0] && config.tabs[0].origin)
    ) {
      isAdd = true
    }
@@ -2339,8 +2366,7 @@
      (config.search[0] && config.search[0].origin) ||
      (config.action[0] && config.action[0].origin) ||
      (config.columns[0] && config.columns[0].origin) ||
      (config.tabs[0] && config.tabs[0].origin) ||
      (config.subtabs[0] && config.subtabs[0].origin)
      (config.tabs[0] && config.tabs[0].origin)
    ) {
      isAdd = true
    }
src/templates/comtableconfig/source.jsx
@@ -206,8 +206,8 @@
        label: 'tab1',
        icon: '',
        type: 'SubTable',
        linkId: '',
        description: ''
        linkTab: '',
        supMenu: ''
      },
      {
        origin: true,
@@ -215,11 +215,10 @@
        label: 'tab2',
        icon: '',
        type: 'SubTable',
        linkId: '',
        description: ''
        linkTab: '',
        supMenu: ''
      }
    ],
    subtabs: []
    ]
  }
  searchItems = [
src/utils/option.js
@@ -138,4 +138,25 @@
}, {
  MenuID: 'gray',
  text: '灰色'
}, {
  MenuID: 'dashed',
  text: '白底虚框'
}, {
  MenuID: 'border-primary',
  text: '白底蓝框'
}, {
  MenuID: 'border-yellow',
  text: '白底黄框'
}, {
  MenuID: 'border-danger',
  text: '白底红框'
}, {
  MenuID: 'border-green',
  text: '白底绿框'
}, {
  MenuID: 'border-dgreen',
  text: '白底深绿框'
}, {
  MenuID: 'border-purple',
  text: '白底紫框'
}]
src/utils/utils.js
@@ -242,17 +242,21 @@
    searches.forEach(item => {
      if (item.type === 'date') {
        let timetail = ''
        let _val = item.value
        if (item.match === '<' || item.match === '<=') {
          timetail = ' 23:59:59.999'
          timetail = ' 00:00:00.000'
          if (_val) {
            _val = moment(_val, 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD')
          }
        } else if (item.match === '>' || item.match === '>=') {
          timetail = ' 00:00:00.000'
        }
        if (newsearches[item.key]) {
          newsearches[item.key + '1'] = item.value ? item.value + timetail : null
          newsearches[item.key + '1'] = _val ? _val + timetail : null
        } else {
          newsearches[item.key] = item.value ? item.value + timetail : null
          newsearches[item.key] = _val ? _val + timetail : null
        }
      } else if (item.type === 'datemonth') {
        // 月-过滤条件,从月开始至结束
@@ -261,19 +265,27 @@
        if (item.value) {
          _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000'
          _endval = moment(item.value, 'YYYY-MM').endOf('month').format('YYYY-MM-DD') + ' 23:59:59.999'
          _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000'
        }
        
        newsearches[item.key] = _startval
        newsearches[item.key + '1'] = _endval
      } else if (item.type === 'dateweek') {
        let _endval = ''
        if (item.value) {
          _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD')
        }
        newsearches[item.key] = item.value ? item.value[0] + ' 00:00:00.000' : null
        newsearches[item.key + '1'] = item.value ? item.value[1] + ' 23:59:59.999' : null
        newsearches[item.key + '1'] = item.value ? _endval + ' 00:00:00.000' : null
      } else if (item.type === 'daterange') {
        let _endval = ''
        if (item.value) {
          _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD')
        }
        newsearches[item.key] = item.value ? item.value[0] + ' 00:00:00.000' : null
        newsearches[item.key + '1'] = item.value ? item.value[1] + ' 23:59:59.999' : null
        newsearches[item.key + '1'] = item.value ? _endval + ' 00:00:00.000' : null
      } else {
        newsearches[item.key] = item.value
      }
@@ -301,30 +313,37 @@
        // eslint-disable-next-line
        searchText += item.key + ' ' + item.match + ' ' + '\'' + str + item.value + str + '\''
      } else if (item.type === 'date') {
        let _val = item.value
        let timetail = ' 00:00:00.000'
        if (item.match === '<' || item.match === '<=') {
          timetail = ' 23:59:59.999'
        let _match = item.match
        if (item.match === '<' || item.match === '<=') { // 时间为<=时,匹配后一天的0点,匹配方式为<
          _match = '<'
          _val = moment(_val, 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD')
        } else if (item.match === '=') {
          timetail = ''
        }
        // eslint-disable-next-line
        searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + timetail + '\')'
      } else if (item.type === 'datemonth') {
        // 月-过滤条件,从月开始至结束
        searchText += '(' + item.key + ' ' + _match + ' ' + '\'' + _val + timetail + '\')'
      } else if (item.type === 'datemonth') { // 月-过滤条件,从月开始至结束,结束时间为月末加一天的0点,方式为<
        let _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000'
        let _endval = moment(item.value, 'YYYY-MM').endOf('month').format('YYYY-MM-DD') + ' 23:59:59.999'
        let _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000'
        // eslint-disable-next-line
        searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + _startval + '\' AND \'' + _endval + '\')'
      } else if (item.type === 'dateweek') {
        let stimetail = ' 00:00:00.000'
        let etimetail = ' 23:59:59.999'
        searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')'
      } else if (item.type === 'dateweek') { // 周-过滤条件
        let _startval = item.value[0] + ' 00:00:00.000'
        let _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000'
        // eslint-disable-next-line
        searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + stimetail + '\' AND \'' + item.value[1] + etimetail + '\')'
        searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')'
      } else if (item.type === 'daterange') {
        let stimetail = ' 00:00:00.000'
        let etimetail = ' 23:59:59.999'
        let _startval = item.value[0] + ' 00:00:00.000'
        let _endval = moment(item.value[1], 'YYYY-MM-DD').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000'
        // eslint-disable-next-line
        searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value[0] + stimetail + '\' AND \'' + item.value[1] + etimetail + '\')'
        searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')'
      } else {
        // eslint-disable-next-line
        searchText += '(' + item.key + ' ' + item.match + ' ' + '\'' + item.value + '\')'