From 044a4ec4ebe85f8c00e889fe3914de17a6ea1f28 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 17 十月 2024 18:18:01 +0800 Subject: [PATCH] 2024-10-17 --- src/tabviews/zshare/actionList/newpagebutton/index.jsx | 182 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 155 insertions(+), 27 deletions(-) diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index 1c7f2bb..3c1c12e 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/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,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') { @@ -239,10 +270,34 @@ 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 = '' + + if (btn.wxApp) { + appId = btn.wxApp + if (!window.GLOB.WXApps || window.GLOB.WXApps.findIndex(item => item.appId === btn.wxApp) === -1) { + notification.warning({ + top: 92, + message: '鎸夐挳鍏宠仈搴旂敤涓嶅湪鍙敤鍒楄〃涓紝璇烽噸鏂颁繚瀛樻寜閽厤缃紒', + duration: 5 + }) + return + } + } + if (btn.wxMerch) { + merchId = btn.wxMerch + if (!window.GLOB.WXApps || window.GLOB.WXApps.findIndex(item => item.appId === btn.wxMerch) === -1) { + notification.warning({ + top: 92, + message: '鎸夐挳鍏宠仈鍟嗘埛涓嶅湪鍙敤鍒楄〃涓紝璇烽噸鏂颁繚瀛樻寜閽厤缃紒', + duration: 5 + }) + return + } + } if (btn.payMode === 'system' || btn.payMode === 'inner') { - this.prequest(Id, data[0] || {}) + this.prequest(Id, data[0] || {}, appId, merchId) } else { confirm({ title: '璇峰湪浠樻椤甸潰瀹屾垚璁㈠崟鏀粯銆�', @@ -259,13 +314,7 @@ }, }) - let appId = '' - - if (btn.wxApp && window.GLOB.WXApps && window.GLOB.WXApps.findIndex(item => item.appId === btn.wxApp) > -1) { - appId = btn.wxApp - } - - window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, appId: appId })))) + window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, appId, merchId })))) } } else if (btn.pageTemplate === 'custom') { let url = btn.url @@ -319,11 +368,16 @@ } if (window.GLOB.systemType === 'production') { - MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _name}) + let _temname = { + billprint: '鍗曟嵁鎵撳嵃', + pay: '鐩存帴鎵ц', + } + + MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _temname[btn.pageTemplate] || '鏂伴〉闈�'}) } } - prequest = (ID, data) => { + prequest = (ID, data, appId, merchId) => { const { btn, BID } = this.props let param = null @@ -336,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) @@ -388,17 +444,89 @@ }, }) - let appId = '' - - if (btn.wxApp && window.GLOB.WXApps && window.GLOB.WXApps.findIndex(item => item.appId === btn.wxApp) > -1) { - appId = btn.wxApp - } - - window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: id, appId: appId })))) + window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: id, appId, merchId })))) } else { this.execError(res) } }) + } + + 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) => { @@ -502,8 +630,8 @@ } if (window.GLOB.debugger === true) { - console.info('%c' + btn.logLabel, 'color: blue') - console.info(_sql) + window.mkInfo('%c' + btn.logLabel, 'color: blue') + window.mkInfo(_sql) } return _sql -- Gitblit v1.8.0