king
2024-09-12 ffa0d7a5e06556c358bf8bbb1af30082214d4376
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'
@@ -220,16 +221,49 @@
      } 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]
          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') {
@@ -356,6 +390,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 +451,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