king
2025-05-08 400fee62fb40006a9839f1c3a8244b82566b5057
src/tabviews/zshare/actionList/newpagebutton/index.jsx
@@ -3,6 +3,7 @@
import { is, fromJS } from 'immutable'
import { Button, notification, Modal, message } from 'antd'
import moment from 'moment'
import md5 from 'md5'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -158,10 +159,7 @@
      lang = data[0].lang_s || ''
    }
    // let _name = '新页面'
    if (btn.pageTemplate === 'billprint') {
      // _name = '单据打印'
      if (btn.preHandle === 'true' && btn.pre_func) {
        MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => {
          let searches = {}
@@ -220,16 +218,51 @@
      } else {
        if (btn.Ot === 'required') {
          data.forEach(item => {
            let _id = item.$$uuid || ''
            let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') })))
            let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
            Object.keys(item).forEach(key => {
              if (/^\$/.test(key)) return
              if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return
              if (typeof(item[key]) === 'string' && item[key].length > 50) return
              if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return
              _param[key.toLowerCase()] = item[key]
            })
            let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
            window.open(url)
          })
        } else if (btn.Ot === 'requiredOnce') {
          Id = data.map(item => item.$$uuid).filter(Boolean).join(',')
          let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
          let item = data[0]
          Object.keys(item).forEach(key => {
            if (/^\$/.test(key)) return
            if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return
            if (typeof(item[key]) === 'string' && item[key].length > 50) return
            if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return
            _param[key.toLowerCase()] = item[key]
          })
  
          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
        } else {
          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM') }))))
          let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')}
          let item = data[0]
          if (item) {
            Object.keys(item).forEach(key => {
              if (/^\$/.test(key)) return
              if (typeof(item[key]) !== 'string' && typeof(item[key]) !== 'number') return
              if (typeof(item[key]) === 'string' && item[key].length > 50) return
              if (['id', 'tempid', 'pageid', 'datam'].includes(key.toLowerCase())) return
              _param[key.toLowerCase()] = item[key]
            })
          }
          window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param))))
        }
      }
    } else if (btn.pageTemplate === 'billprintTemp') {
@@ -239,8 +272,6 @@
      let src = '#/print/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, lang })))
      window.open(src)
    } else if (btn.pageTemplate === 'pay') {
      // _name = '支付'
      let appId = ''
      let merchId = ''
@@ -338,9 +369,14 @@
      window.open(url)
    }
    // if (window.GLOB.systemType === 'production') {
    //   MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _name})
    // }
    if (window.GLOB.systemType === 'production') {
      let _temname = {
        billprint: '单据打印',
        pay: '直接执行',
      }
      MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _temname[btn.pageTemplate] || '新页面'})
    }
  }
  prequest = (ID, data, appId, merchId) => {
@@ -356,6 +392,8 @@
        dataM: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
        ID: ID
      }
    } else if (window.backend && window.GLOB.CacheData.has('sql_' + btn.uuid)) {
      param = this.getbackParam(ID, data)
    } else {
      let sql = this.getSysDeclareSql(ID, data)
@@ -415,6 +453,84 @@
    })
  }
  getbackParam = (ID, data) => {
    const { columns, btn, BID } = this.props
    let ex = window.GLOB.CacheData.get('sql_' + btn.uuid)
    let exps = []
    let values = {
      time_id: Utils.getguid(),
      roleid: sessionStorage.getItem('role_id') || '',
      mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
      mk_organization: sessionStorage.getItem('organization') || '',
      mk_user_type: sessionStorage.getItem('mk_user_type') || '',
      mk_nation: sessionStorage.getItem('nation') || '',
      mk_province: sessionStorage.getItem('province') || '',
      mk_city: sessionStorage.getItem('city') || '',
      mk_district: sessionStorage.getItem('district') || '',
      mk_address: sessionStorage.getItem('address') || '',
      id: ID || '',
      bid: BID || '',
      typename: 'admin',
      datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
      datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
      datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
    }
    if (window.GLOB.externalDatabase !== null) {
      values.db = window.GLOB.externalDatabase
    }
    ex.reps.forEach(n => {
      let key = n.toLowerCase()
      if (values.hasOwnProperty(key)) {
        exps.push({
          key: n,
          value: values[key]
        })
      }
    })
    let _data = {}
    Object.keys(data).forEach(key => {
      _data[key.toLowerCase()] = data[key]
    })
    columns.forEach(col => {
      if (!ex.reps.includes(col.field)) return
      if (!col.datatype) return
      let _key = col.field.toLowerCase()
      let _val = _data.hasOwnProperty(_key) ? _data[_key] : ''
      if (/^date/ig.test(col.datatype) && !_val) {
        _val = '1949-10-01'
      }
      exps.push({
        key: 'mk_' + col.field + '_mk',
        value: _val
      })
    })
    let md5_id = ''
    if (window.GLOB.probation) {
      md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000))
      md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18)
    }
    return {
      $backend: true,
      $type: 's_TableData_InUpDe',
      data: [{
        id: ex.id,
        menuname: btn.logLabel || '',
        exps: exps,
        md5_id: md5_id
      }]
    }
  }
  getSysDeclareSql = (ID, data) => {
    const { columns, btn, BID } = this.props