king
2021-07-28 137fb8ea6af2789b3238b22bac31d80bced41dfe
src/tabviews/subtabtable/index.jsx
@@ -136,17 +136,17 @@
        config.action = config.action.filter(item => permAction[item.uuid])
      }
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      // 字段权限黑名单
      config.search = config.search.filter(item => {
        item.oriInitval = item.initval
        if (!item.blacklist || item.blacklist.length === 0) return item
        if (item.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
          item.Hide = 'true'
        }
      config.search = Utils.initSearchVal(config.search)
        return item
      let hasReqFields = false
      config.search.forEach(field => {
        if (field.required) {
          hasReqFields = true
        }
      })
      // 字段权限黑名单
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      config.columns = config.columns.map(col => {
        if (!col.blacklist || col.blacklist.length === 0) return col
@@ -235,16 +235,6 @@
        _columns.push(config.gridBtn)
      }
      let valid = true // 搜索条件必填验证
      let hasReqFields = false
      config.search.forEach(field => {
        if (field.required !== 'true') return
        hasReqFields = true
        if (!field.initval) {
          valid = false
        }
      })
      config.setting.tabType = 'subtab'
      // 数据源信息预处理
      config.setting.laypage = config.setting.laypage !== 'false'     // 是否分页,转为boolean 统一格式
@@ -281,6 +271,26 @@
          config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '')
          config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '')
        }
        let userName = sessionStorage.getItem('User_Name') || ''
        let fullName = sessionStorage.getItem('Full_Name') || ''
        let city = sessionStorage.getItem('city') || ''
        if (sessionStorage.getItem('isEditState') === 'true') {
          userName = sessionStorage.getItem('CloudUserName') || ''
          fullName = sessionStorage.getItem('CloudFullName') || ''
        }
        let regs = [
          { reg: /@userName@/ig, value: `'${userName}'` },
          { reg: /@fullName@/ig, value: `'${fullName}'` },
          { reg: /@login_city@/ig, value: `'${city}'` }
        ]
        regs.forEach(cell => {
          config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value)
          config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value)
        })
      }
      this.setState({
@@ -297,7 +307,7 @@
        search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化)
        hasReqFields
      }, () => {
        if (config.setting.onload !== 'false' && valid) { // 初始化可加载
        if (config.setting.onload !== 'false') { // 初始化可加载
          this.loadData()
        }
      })
@@ -323,23 +333,17 @@
      searches = [...mainSearch, ...searches]
    }
    let requireFields = []
    if (hasReqFields) {
      requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
      let requireFields = searches.filter(item => item.required && item.value === '')
      if (requireFields.length > 0) {
        this.setState({
          loading: false
        })
        return
      }
    }
    if (requireFields.length > 0) {
      let labels = requireFields.map(item => item.label)
      labels = Array.from(new Set(labels))
      notification.warning({
        top: 92,
        message: this.state.dict['form.required.input'] + labels.join('、') + ' !',
        duration: 3
      })
      return
    } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) {
    if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) {
      notification.warning({
        top: 92,
        message: '未设置正式系统地址!',
@@ -428,7 +432,7 @@
    })
    Api.directRequest(url, setting.method, param, setting.cross).then(res => {
      if (typeof(res) !== 'object' || Array.isArray(res)) {
      if (typeof(res) !== 'object') {
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
@@ -443,6 +447,9 @@
        this.customCallbackRequest(_result)
      } else {
        if (Array.isArray(res)) {
          res = { data: res }
        }
        res.mk_api_key = mkey
        this.customCallbackRequest(res)
      }
@@ -559,6 +566,11 @@
    this.getStatFieldsValue(searches)
    if (result.status) {
      let start = 1
      if (setting.laypage) {
        start = pageSize * (pageIndex - 1) + 1
      }
      this.setState({
        data: result.data.map((item, index) => {
          if (absFields.length) {
@@ -572,6 +584,7 @@
          item.key = index
          item.$$uuid = item[setting.primaryKey] || ''
          item.$$BID = BID || ''
          item.$Index = start + index + ''
          return item
        }),
@@ -702,7 +715,7 @@
  /**
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  getexceloutparam = (menuId, btnId) => {
  queryModuleParam = (menuId, btnId) => {
    const { Tab, mainSearch, MenuID } = this.props
    const { arr_field, orderBy, search, setting} = this.state
@@ -713,7 +726,7 @@
      searches = [...mainSearch, ...search]
    }
    MKEmitter.emit('execExcelout', MenuID, btnId, {
    MKEmitter.emit('returnModuleParam', MenuID, btnId, {
      arr_field: arr_field,
      orderBy: orderBy || setting.order,
      search: searches,
@@ -753,7 +766,7 @@
  }
  componentDidMount () {
    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
  }
@@ -764,7 +777,7 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
@@ -775,7 +788,7 @@
      <div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
        {loadingview && <Spin />}
        {searchlist && searchlist.length ?
          <SubSearch BID={this.props.BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
          <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
        }
        {config ? <Row className="chart-view" gutter={16}>
          {/* 视图组 */}