king
2024-01-06 920e94fc5483b081b3d43c86df8f56d838f2f14d
2024-01-06
16个文件已修改
389 ■■■■ 已修改文件
src/menu/components/share/pasteforms/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/basetable/index.jsx 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/card/data-card/index.jsx 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/card/double-data-card/index.jsx 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/share/normalheader/index.jsx 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/base-table/index.jsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/edit-table/index.jsx 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/normal-table/index.jsx 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/index.jsx 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/popview/index.jsx 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/topSearch/index.jsx 171 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/topSearch/mkDatePicker/index.jsx 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/topSearch/mkSelect/index.jsx 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/searchcomponent/searchform/index.jsx 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/formconfig.jsx 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/pasteforms/index.jsx
@@ -38,6 +38,8 @@
      if (res.copyType === 'form') {
        delete res.copyType
        res = {fields: [res]}
      } else if (res.copyType === 'simpleform') {
        res = {fields: res.subcards[0].fields}
      }
      res.fields = res.fields || []
src/tabviews/basetable/index.jsx
@@ -346,11 +346,6 @@
        item.name = (MenuName || '')
      }
      // 搜索条件初始化
      Utils.initSearchVal(item)
      item.$searches = Utils.initMainSearch(item.search)
      if (item.setting.supModule) {
        let pid = item.setting.supModule.pop()
        if (pid && pid !== 'empty') {
@@ -360,6 +355,11 @@
        }
      }
      // 搜索条件初始化
      Utils.initSearchVal(item)
      item.$searches = Utils.initMainSearch(item.search)
      let statFields = []
      let getCols = (cols) => {
        return cols.filter(col => {
src/tabviews/custom/components/card/data-card/index.jsx
@@ -705,7 +705,9 @@
      if (!config.setting.supModule || config.setting.supModule !== MenuID) return
      if (id !== this.state.BID || id !== '') {
        this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
          this.loadData()
          if (!config.checkBid) {
            this.loadData()
          }
        })
      }
    }
src/tabviews/custom/components/card/double-data-card/index.jsx
@@ -546,7 +546,9 @@
    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
    if (id !== this.state.BID || id !== '') {
      this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
        this.loadData()
        if (!config.checkBid) {
          this.loadData()
        }
      })
    }
  }
src/tabviews/custom/components/share/normalheader/index.jsx
@@ -27,7 +27,14 @@
    })
  }
  shouldComponentUpdate (nextProps, nextState) { return false }
  shouldComponentUpdate (nextProps, nextState) {
    const { config } = this.props
    if (config.checkBid && this.props.BID !== nextProps.BID) {
      return true
    }
    return false
  }
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
src/tabviews/custom/components/table/base-table/index.jsx
@@ -566,8 +566,10 @@
        BID: id,
        BData: data
      }, () => {
        this.loadmaindata(true, 'true')
        this.getStatFieldsValue()
        if (!setting.checkBid) {
          this.loadmaindata(true, 'true')
          this.getStatFieldsValue()
        }
      })
    }
  }
src/tabviews/custom/components/table/edit-table/index.jsx
@@ -584,9 +584,11 @@
        BID: id,
        BData: data
      }, () => {
        setTimeout(() => {
          this.loadmaindata(true, 'true')
        }, setting.delay || 0)
        if (!setting.checkBid) {
          setTimeout(() => {
            this.loadmaindata(true, 'true')
          }, setting.delay || 0)
        }
      })
    }
  }
src/tabviews/custom/components/table/normal-table/index.jsx
@@ -784,7 +784,9 @@
        BID: id,
        BData: data
      }, () => {
        this.loadmaindata(true, 'true')
        if (!setting.checkBid) {
          this.loadmaindata(true, 'true')
        }
      })
    }
  }
src/tabviews/custom/index.jsx
@@ -563,13 +563,6 @@
        item.type = 'card'
      }
      // 搜索条件初始化
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(item.search)
      }
      if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件
        item.setting.supModule = item.supNodes[0].componentId
      } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
@@ -581,6 +574,13 @@
        }
      }
      // 搜索条件初始化
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(item.search)
      }
      let pass = skip
      if (item.wrap && item.wrap.permission === 'false') {
src/tabviews/custom/popview/index.jsx
@@ -323,13 +323,6 @@
        }
      }
      // 搜索条件初始化
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(item.search)
      }
      if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件
        item.setting.supModule = item.supNodes[0].componentId
      } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
@@ -341,6 +334,13 @@
        }
      }
      // 搜索条件初始化
      if (item.search) {
        Utils.initSearchVal(item)
        item.$searches = Utils.initMainSearch(item.search)
      }
      // 权限过滤
      if (item.action && item.action.length > 0) {
        item.action = item.action.filter(cell => {
src/tabviews/zshare/topSearch/index.jsx
@@ -25,8 +25,8 @@
class MainSearch extends Component {
  static propTpyes = {
    BID: PropTypes.any,          // 父级Id,用于查询下拉选择项
    config: PropTypes.object,    // 组件配置信息
    BID: PropTypes.any,
    config: PropTypes.object
  }
  state = {
@@ -121,6 +121,36 @@
        item.advanced = false
      }
      if (item.checkShift && !item.initval) {
        let d = ''
        if (window.GLOB.CacheData.has(item.$supId)) {
          d = window.GLOB.CacheData.get(item.$supId)
          d = d[item.dateShift] || ''
          if (d) {
            d = moment(d).format('YYYY-MM-DD')
            d = d === 'Invalid date' ? '' : d
          }
        }
        if (d) {
          if (item.$initval === 'week') {
            item.initval = [moment(d).startOf('week').format(item.format), moment(d).endOf('week').format(item.format)].join(',')
          } else if (item.$initval === 'month') {
            item.initval = [moment(d).startOf('month').format(item.format), moment(d).endOf('month').format(item.format)].join(',')
          } else if (item.$initval === 'lastMonth') {
            item.initval = [moment(d).subtract(1, 'months').startOf('month').format(item.format), moment(d).subtract(1, 'months').endOf('month').format(item.format)].join(',')
          } else {
            try {
              let _initval = JSON.parse(item.$initval)
              let _vals = [moment(d).subtract(_initval[0], 'days').format(item.format), moment(d).subtract(_initval[1], 'days').format(item.format)]
              item.initval = _vals.join(',')
            } catch (e) {
              item.initval = ''
            }
          }
        }
      }
      if (item.type === 'group') {
        record[item.field] = item.initType
        record[item.datefield] = item.initval
@@ -144,24 +174,34 @@
        if (item.resourceType === '1' && item.dataSource) {
          let _option = Utils.getSelectQueryOptions(item)
          _option.sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`)
          let exec = true
          if (item.checkBid) {
            item.sql = _option.sql
            item.arr_field = _option.field
          if (window.GLOB.debugger === true) {
            console.info(_option.sql)
            exec = !!BID
          }
          // 测试系统单个请求
          if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && !window.GLOB.systemType) {
            deForms.push({
              ...item,
              arr_field: _option.field,
              data_sql: Utils.formatOptions(_option.sql)
            })
          } else { // 合并请求,区分本地及系统
            if (item.database === 'sso') {
              mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`)
            } else {
              localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`)
          if (exec) {
            _option.sql = _option.sql.replace(/@BID@/ig, `'${BID || ''}'`)
            if (window.GLOB.debugger === true) {
              console.info(_option.sql)
            }
            // 测试系统单个请求
            if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && !window.GLOB.systemType) {
              deForms.push({
                ...item,
                arr_field: _option.field,
                data_sql: Utils.formatOptions(_option.sql)
              })
            } else { // 合并请求,区分本地及系统
              if (item.database === 'sso') {
                mainItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`)
              } else {
                localItems.push(`select '${item.field}' as obj_name,'${_option.field}' as arr_field,'${window.btoa(window.encodeURIComponent(_option.sql.replace(/%/ig, ' mpercent ')))}' as LText`)
              }
            }
          }
        }
@@ -233,11 +273,80 @@
      searchlist: _list
    }, () => {
      if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
        this.improveSimpleSearch(deForms)
        this.improveSimpleSearch(deForms, false)
      } else if (mainItems.length > 0 || localItems.length > 0) {
        this.improveSearch(mainItems, localItems)
      }
    })
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { config, BID } = this.props
    if (config.checkBid && nextProps.BID !== BID) {
      this.resetOptions(nextProps.BID)
    }
  }
  resetOptions = (BID) => {
    let deForms = []
    let searchlist = fromJS(this.state.searchlist).toJS().map(item => {
      if (item.checkBid) {
        let sql = item.sql.replace(/@BID@/ig, `'${BID || ''}'`)
        if (window.GLOB.debugger === true) {
          console.info(sql)
        }
        deForms.push({
          ...item,
          arr_field: item.arr_field,
          data_sql: Utils.formatOptions(sql)
        })
      } else if (item.checkShift) {
        let d = ''
        if (window.GLOB.CacheData.has(item.$supId)) {
          d = window.GLOB.CacheData.get(item.$supId)
          d = d[item.dateShift] || ''
          if (d) {
            d = moment(d).format('YYYY-MM-DD')
            d = d === 'Invalid date' ? '' : d
          }
        }
        if (d) {
          if (item.$initval === 'week') {
            item.initval = [moment(d).startOf('week').format(item.format), moment(d).endOf('week').format(item.format)].join(',')
          } else if (item.$initval === 'month') {
            item.initval = [moment(d).startOf('month').format(item.format), moment(d).endOf('month').format(item.format)].join(',')
          } else if (item.$initval === 'lastMonth') {
            item.initval = [moment(d).subtract(1, 'months').startOf('month').format(item.format), moment(d).subtract(1, 'months').endOf('month').format(item.format)].join(',')
          } else {
            try {
              let _initval = JSON.parse(item.$initval)
              let _vals = [moment(d).subtract(_initval[0], 'days').format(item.format), moment(d).subtract(_initval[1], 'days').format(item.format)]
              item.initval = _vals.join(',')
            } catch (e) {
              item.initval = ''
            }
          }
        }
      }
      return item
    })
    if (deForms.length > 0) {
      this.improveSimpleSearch(deForms, true, searchlist)
    } else {
      this.setState({
        searchlist: searchlist
      })
      setTimeout(() => {
        this.handleSubmit()
      }, 20)
    }
  }
  resetCheckcard = (item) => {
@@ -364,12 +473,12 @@
      delete result.message
      delete result.status
      this.resetSearch(result)
      this.resetSearch(result, false)
    })
  }
  // 测试系统单个请求下拉选项
  improveSimpleSearch = (deForms) => {
  improveSimpleSearch = (deForms, trigger, searchlist) => {
    if (deForms.length === 0) return
    let deffers = deForms.map((item, index) => {
@@ -421,13 +530,13 @@
      delete result.message
      delete result.status
      this.resetSearch(result)
      this.resetSearch(result, trigger, searchlist)
    })
  }
  resetSearch = (result) => {
    let trigger = false
    let _searchlist = fromJS(this.state.searchlist).toJS().map(item => {
  resetSearch = (result, submit, searchlist) => {
    let trigger = submit
    let _searchlist = fromJS(searchlist || this.state.searchlist).toJS().map(item => {
      if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
        let options = []
        let map = new Map()
@@ -492,9 +601,13 @@
        item.options = item.oriOptions
      }
      if (item.$first && item.options.length > 0) {
        item.initval = item.options[0].Value
        trigger = true
      if (item.$first) {
        if (item.options.length > 0) {
          item.initval = item.options[0].Value
          trigger = true
        } else {
          item.initval = ''
        }
      }
      return item
@@ -507,7 +620,7 @@
    if (trigger) {
      setTimeout(() => {
        this.handleSubmit()
      }, 10)
      }, 20)
    }
  }
@@ -567,7 +680,7 @@
      } else if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') {
        content = (<MKSelect config={item} onChange={(val, defer) => this.recordChange(val, defer, item)} />)
      } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'dateweek' || item.type === 'daterange') {
        content = (<MKDatePicker config={item} onChange={(val) => this.recordChange(val, false, item)} />)
        content = (<MKDatePicker config={item} onChange={(val, defer) => this.recordChange(val, defer, item)} />)
      } else if (item.type === 'group') {
        field = item.datefield
        content = <DateGroup position={index} config={item} onChange={(val, type) => this.dateGroupChange(val, type, item)} />
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') {
        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'
      }
    } else if (config.type === 'daterange') {
      mode = 'daterange'
    }
    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)
    }
  }
src/tabviews/zshare/topSearch/mkSelect/index.jsx
@@ -47,10 +47,12 @@
        options: fromJS(nextProps.config.options).toJS()
      })
      if (config.$first && nextProps.config.initval) {
      if (config.type !== 'multiselect') {
        this.setState({
          value: nextProps.config.initval
        })
        this.props.onChange(nextProps.config.initval, true)
      }
    }
  }
src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -240,6 +240,10 @@
      }
      shows.push('linkField')
      reRequired.linkField = false
    } else if (type === 'daterange') {
      if (this.record.initval) {
        shows.push('dateShift')
      }
    }
    if (dateOptions.hasOwnProperty(type)) { // 根据搜索条件类型,选择初始值的类型及数据
@@ -509,7 +513,7 @@
        rules = [
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        if (item.key === 'field' || item.key === 'datefield') {
        if (item.key === 'field' || item.key === 'datefield' || item.key === 'dateShift') {
          rules.push({
            pattern: (type === 'text' || type === 'select' || type === 'daterange') ? formRule.field.multipattern : formRule.field.pattern,
            message: formRule.field.message
src/templates/zshare/formconfig.jsx
@@ -467,6 +467,15 @@
      forbid: appType === 'mob'
    },
    {
      type: 'text',
      key: 'dateShift',
      label: '日期偏移',
      initVal: card.dateShift || '',
      tooltip: '可以填入上级字段,用于控制初始值,例如:上级字段值为2023-12-10,初始值为本月,则初始区间为 2023-12-01 ~ 2023-12-31。',
      required: false,
      forbid: appType === 'mob'
    },
    {
      type: 'radio',
      key: 'precision',
      label: '精确度',
src/utils/utils.js
@@ -260,10 +260,13 @@
          format = 'YYYY-MM-DD HH:mm:ss'
        }
        item.format = format
        item.initval = item.initval ? moment().subtract(item.initval, 'days').format(format) : ''
      } else if (item.type === 'datemonth') {
        item.format = 'YYYY-MM'
        item.initval = item.initval ? moment().subtract(item.initval, 'month').format('YYYY-MM') : ''
      } else if (item.type === 'dateweek') {
        item.format = 'YYYY-MM-DD'
        item.initval = item.initval ? moment().subtract(item.initval * 7, 'days').format('YYYY-MM-DD') : ''
      } else if (item.type === 'daterange') {
        let format = 'YYYY-MM-DD'
@@ -276,19 +279,65 @@
        } else if (item.precision === 'second') {
          format = 'YYYY-MM-DD HH:mm:ss'
        }
        if (item.initval === 'week') {
          item.initval = [moment().startOf('week').format(format), moment().endOf('week').format(format)].join(',')
        } else if (item.initval === 'month') {
          item.initval = [moment().startOf('month').format(format), moment().endOf('month').format(format)].join(',')
        } else if (item.initval === 'lastMonth') {
          item.initval = [moment().subtract(1, 'months').startOf('month').format(format), moment().subtract(1, 'months').endOf('month').format(format)].join(',')
        } else if (item.initval) {
          try {
            let _initval = JSON.parse(item.initval)
            let _vals = [moment().subtract(_initval[0], 'days').format(format), moment().subtract(_initval[1], 'days').format(format)]
            item.initval = _vals.join(',')
          } catch (e) {
        item.format = format
        if (item.initval) {
          if (!item.dateShift) {
            if (item.initval === 'week') {
              item.initval = [moment().startOf('week').format(format), moment().endOf('week').format(format)].join(',')
            } else if (item.initval === 'month') {
              item.initval = [moment().startOf('month').format(format), moment().endOf('month').format(format)].join(',')
            } else if (item.initval === 'lastMonth') {
              item.initval = [moment().subtract(1, 'months').startOf('month').format(format), moment().subtract(1, 'months').endOf('month').format(format)].join(',')
            } else if (item.initval) {
              try {
                let _initval = JSON.parse(item.initval)
                let _vals = [moment().subtract(_initval[0], 'days').format(format), moment().subtract(_initval[1], 'days').format(format)]
                item.initval = _vals.join(',')
              } catch (e) {
                item.initval = ''
              }
            }
          } else {
            item.$initval = item.initval
            item.$supId = config.$pageId
            if (config.setting && config.setting.supModule) {
              item.$supId = config.setting.supModule
            }
            config.checkBid = true
            config.setting.checkBid = true
            item.checkShift = true
            item.initval = ''
            let d = ''
            if (window.GLOB.CacheData.has(item.$supId)) {
              d = window.GLOB.CacheData.get(item.$supId)
              d = d[item.dateShift] || ''
              if (d) {
                d = moment(d).format('YYYY-MM-DD')
                d = d === 'Invalid date' ? '' : d
              }
            }
            if (d) {
              if (item.$initval === 'week') {
                item.initval = [moment(d).startOf('week').format(format), moment(d).endOf('week').format(format)].join(',')
              } else if (item.$initval === 'month') {
                item.initval = [moment(d).startOf('month').format(format), moment(d).endOf('month').format(format)].join(',')
              } else if (item.$initval === 'lastMonth') {
                item.initval = [moment(d).subtract(1, 'months').startOf('month').format(format), moment(d).subtract(1, 'months').endOf('month').format(format)].join(',')
              } else {
                try {
                  let _initval = JSON.parse(item.$initval)
                  let _vals = [moment(d).subtract(_initval[0], 'days').format(format), moment(d).subtract(_initval[1], 'days').format(format)]
                  item.initval = _vals.join(',')
                } catch (e) {
                  item.initval = ''
                }
              }
            }
          }
        }
      } else if (item.type === 'group') {
@@ -348,9 +397,16 @@
          item.initval = ''
          item.initType = ''
        }
      } else if ((item.type === 'select' || item.type === 'link') && item.initval === '$first' && item.resourceType === '1') {
        item.initval = ''
        item.$first = true
      } else if ((item.type === 'select' || item.type === 'link') && item.resourceType === '1') {
        if (/@BID@/ig.test(item.dataSource) && config.setting && config.setting.supModule) {
          config.checkBid = true
          config.setting.checkBid = true
          item.checkBid = true
        }
        if (item.initval === '$first') {
          item.initval = ''
          item.$first = true
        }
      }
      
      item.oriInitval = item.initval