king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
src/tabviews/commontable/index.jsx
@@ -22,8 +22,6 @@
const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable'))
const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent'))
const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage'))
const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic'))
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
const { TabPane } = Tabs
@@ -47,7 +45,6 @@
    shortcuts: null,      // 快捷键
    actions: null,        // 按钮集
    columns: null,        // 显示列
    arr_field: '',        // 查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: [],             // 列表数据集
    selectedData: [],     // 已选表格数据
@@ -63,7 +60,6 @@
    statFields: [],       // 合计字段
    statFValue: [],       // 合计值
    absFields: [],        // 绝对值字段
    hasReqFields: false,
    autoMatic: null,
    visible: false
  }
@@ -117,7 +113,7 @@
      }
      
      // HS不使用自定义设置
      if (result.LongParamUser && !window.GLOB.mkHS) {
      if (result.LongParamUser) {
        try { // 配置信息解析
          let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
          if (userConfig && !userConfig.version) {
@@ -142,8 +138,8 @@
              })
            })
          } else if (userConfig) {
            shortcuts = userConfig.action
            userConfig.printers.forEach(item => {
            shortcuts = userConfig.action || []
            userConfig.printers && userConfig.printers.forEach(item => {
              window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item)
            })
          }
@@ -209,19 +205,13 @@
        chartId = config.charts[0] ? config.charts[0].uuid : ''
      }
      config.search = Utils.initSearchVal(config.search)
      Utils.initSearchVal(config)
      // 字段透视及必填标志
      let hasReqFields = false
      config.search = config.search.map(item => {
        if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) {
        if (['text', 'select', 'link', 'checkcard'].includes(item.type) && param && param.$searchkey === item.field.toLowerCase()) {
          item.initval = param.$searchval
        }
        if (item.required) {
          hasReqFields = true
        }
        return item
      })
@@ -263,10 +253,8 @@
        }
  
        if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
          config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*')
          config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/')
          config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*')
          config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/')
          config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/')
          config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/')
        } else {
          config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '')
          config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '')
@@ -274,11 +262,6 @@
        let userName = sessionStorage.getItem('User_Name') || ''
        let fullName = sessionStorage.getItem('Full_Name') || ''
        if (sessionStorage.getItem('isEditState') === 'true') {
          userName = sessionStorage.getItem('CloudUserName') || ''
          fullName = sessionStorage.getItem('CloudFullName') || ''
        }
        let regs = [
          { reg: /@userName@/ig, value: `'${userName}'` },
@@ -299,6 +282,8 @@
            config.setting.customScript = config.setting.customScript.replace(reg, val)
          })
        }
      } else {
        config.setting.dataresource = ''
      }
      let _arrField = []     // 字段集
@@ -310,12 +295,27 @@
      let _actions = []      // 工具栏按钮
      let _operations = []   // 操作列按钮(存在时)
      let colors = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#E7E7EF', default: 'rgba(0, 0, 0, 0.65)' }
      config.action.forEach(item => {
        item.logLabel = MenuName + '-' + item.label // 用于sPC_TableData_InUpDe记录操作按钮
        item.$menuId = this.props.MenuID
        item.$old = true
        item.ContainerId = this.state.ContainerId
        if (item.OpenType === 'excelOut') { // 导出
          item.$menuName = MenuName
        }
        if (item.verify && item.verify.invalid === 'true') {
          if (item.sqlType === 'insert') {
            item.verify.invalid = 'false'
          } else if (item.Ot === 'notRequired') {
            item.verify.invalid = 'false'
          } else if (item.intertype !== 'system' && item.procMode !== 'system') {
            item.verify.invalid = 'false'
          }
        }
        if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify) { // 打印机设置
          let _item = window.GLOB.UserCacheMap.get(this.props.MenuID + item.uuid)
@@ -340,11 +340,26 @@
            item.controlVals = [(item.controlVal || '')]
          }
        }
        item.show = 'button'
        let _c = item.class ? item.class.replace('border-', '') : ''
        let color = colors[_c] || '#1890ff'
        if (item.position === 'toolbar') {
          item.$toolbtn = true
          if (item.class === 'default') {
            item.style = {color: 'rgba(0, 0, 0, 0.65)', backgroundColor: '#fff', borderColor: '#d9d9d9', marginRight: '15px'}
          } else if (item.class.indexOf('border') > -1) {
            item.style = {color: color, backgroundColor: '#fff', borderColor: color, marginRight: '15px'}
          } else {
            item.style = {color: item.class === 'gray' ? 'rgba(0, 0, 0, 0.65)' : '#fff', backgroundColor: color, borderColor: color, marginRight: '15px'}
          }
          _actions.push(item)
        } else if (item.position === 'grid') {
          item.style = {color: color, backgroundColor: 'transparent', borderColor: 'transparent'}
          _operations.push(item)
        }
      })
@@ -356,7 +371,7 @@
          if (col.linkmenu && col.linkmenu.length > 0) {
            let menu_id = col.linkmenu.slice(-1)[0]
            col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || ''
            col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
          } else {
            col.linkThdMenu = ''
          }
@@ -454,7 +469,10 @@
        searchRatio: config.setting.searchRatio || '',
        searchLwidth: config.setting.searchLwidth,
        borderRadius: config.setting.borderRadius,
        resetContrl: config.setting.resetContrl,
      }
      config.setting.arr_field = _arrField.join(',')
      this.setState({
        pageSize: config.setting.pageSize || 10,
@@ -468,10 +486,8 @@
        setting: config.setting,
        actions: _actions,
        columns: _columns,
        arr_field: _arrField.join(','),
        BID: param && param.$BID ? param.$BID : '',
        search: Utils.initMainSearch(config.search),
        hasReqFields
        search: Utils.initMainSearch(config.search)
      }, () => {
        if (config.setting.onload !== 'false') { // 初始化可加载
          this.loadData()
@@ -512,7 +528,6 @@
      let _shortcut = `${preKey}+${keyCode}`
      if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') {
        window.debugger = false
        window.GLOB.breakpoint = false
        sessionStorage.removeItem('breakpoint')
        
@@ -539,14 +554,14 @@
  loadData = (id) => {
    const { MenuID } = this.props
    const { setting, search, hasReqFields, ContainerId } = this.state
    const { setting, search, config, ContainerId } = this.state
    this.setState({
      selectedData: []
    })
    MKEmitter.emit('changeTableLine', ContainerId, MenuID, '', '')
    if (hasReqFields) {
    if (config.$s_req) {
      let requireFields = search.filter(item => item.required && item.value === '')
      if (requireFields.length > 0) {
@@ -573,14 +588,16 @@
   * @description 主表数据加载
   */ 
  async loadmaindata (id) {
    const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state
    const { setting, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state
    this.setState({
      loading: true
    })
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID)
    let param = UtilsDM.getQueryDataParams(setting, search, _orderBy, pageIndex, pageSize, BID)
    delete param.s_version_up
    let result = await Api.genericInterface(param)
@@ -664,14 +681,16 @@
   * @description 获取单行数据
   */ 
  async loadmainLinedata (id) {
    const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state
    const { setting, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state
    this.setState({
      loading: true
    })
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, id)
    let param = UtilsDM.getQueryDataParams(setting, search, _orderBy, pageIndex, pageSize, BID, id)
    delete param.s_version_up
    let result = await Api.genericInterface(param)
    if (result.status) {
@@ -863,16 +882,14 @@
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  queryModuleParam = (menuId, callback) => {
    const { MenuName, MenuID } = this.props
    const { arr_field, orderBy, search, setting} = this.state
    const { MenuID } = this.props
    const { orderBy, search, setting } = this.state
    if (MenuID !== menuId) return
    callback({
      arr_field: arr_field,
      orderBy: orderBy || setting.order,
      search: search,
      menuName: MenuName
      search: search
    })
  }
@@ -1005,7 +1022,7 @@
  render() {
    const { MenuID } = this.props
    const { BID, setting, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts, autoMatic } = this.state
    const { BID, setting, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts } = this.state
    return (
      <div className="commontable" id={this.state.ContainerId}>
@@ -1143,9 +1160,7 @@
          </Tabs>))
        }
        {setting && window.GLOB.breakpoint ? <DebugTable /> : null}
        {!window.GLOB.mkHS && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config} /> : null}
        {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config}/> : null}
        {!window.GLOB.mkHS && setting ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null}
        {setting ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null}
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>
    )