| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button, notification, Modal } from 'antd' |
| | | 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' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import './index.scss' |
| | |
| | | btn: PropTypes.object, // 按钮 |
| | | selectedData: PropTypes.any, // 子表中选择数据 |
| | | disabled: PropTypes.any, // 行按钮禁用 |
| | | name: PropTypes.any |
| | | } |
| | | |
| | | state = { |
| | | disabled: false, |
| | | loading: false, |
| | | hidden: false, |
| | | visible: false |
| | | visible: false, |
| | | dict: window.GLOB.dict |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | /** |
| | | * @description 触发按钮操作 |
| | | */ |
| | | actionTrigger = (triggerId, record, type) => { |
| | | const { btn, selectedData, BID } = this.props |
| | | const { disabled } = this.state |
| | | actionTrigger = (triggerId, record, type, lid) => { |
| | | const { btn, selectedData, BID, LID } = this.props |
| | | const { disabled, dict } = this.state |
| | | |
| | | if (disabled) return |
| | | if (triggerId && btn.uuid !== triggerId) return |
| | | |
| | | if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { |
| | | return |
| | | } |
| | | if (type === 'linkbtn' && !btn.$toolbtn && LID !== lid) return |
| | | |
| | | let data = record || selectedData || [] |
| | | |
| | |
| | | // 需要选择行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择行!', |
| | | message: dict['select_row'] || '请选择行!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | // 需要选择单行时,校验数据 |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择单行数据!', |
| | | message: dict['select_single_row'] || '请选择单行数据!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.pageTemplate === 'custom' && window.GLOB.systemType === 'production' && !btn.proUrl) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: dict['no_prod_link'] || '尚未设置正式系统链接地址!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | let Id = '' |
| | | let name = '' |
| | | let MenuNo = '' |
| | | let Remark = '' |
| | | let lang = '' |
| | | if (btn.Ot === 'requiredSgl' && data[0]) { |
| | | Id = data[0].$$uuid || '' |
| | | name = data[0].PrintTempName || '' |
| | | MenuNo = data[0].PrintTempNO || '' |
| | | Remark = data[0].Remark || '' |
| | | lang = data[0].lang_s || '' |
| | | } |
| | | |
| | | let _name = '新页面' |
| | | |
| | | if (btn.pageTemplate === 'billprint') { |
| | | _name = '单据打印' |
| | | 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, dataM: sessionStorage.getItem('dataM') }))) |
| | | window.open(url) |
| | | }) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | Id = data.map(item => item.$$uuid).filter(Boolean).join(',') |
| | | if (btn.preHandle === 'true' && btn.pre_func) { |
| | | MKEmitter.emit('queryModuleParam', btn.$menuId, (res) => { |
| | | let searches = {} |
| | | res.search && res.search.forEach(item => { |
| | | searches[item.key] = item.value |
| | | }) |
| | | |
| | | window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') })))) |
| | | if (btn.Ot === 'requiredOnce') { |
| | | Id = data.map(item => item.$$uuid).filter(Boolean).join(',') |
| | | } |
| | | |
| | | if (btn.Ot === 'required') { |
| | | data.forEach(item => { |
| | | let _param = { id: item.$$uuid || '', tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')} |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func) |
| | | _param = func(btn, searches, [item], _param, window.GLOB.systemType) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | } |
| | | |
| | | if (!_param || _param.error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: _param ? _param.error : '未获取到打印参数,自定义脚本错误!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))) |
| | | }) |
| | | } else { |
| | | let _param = { id: Id, tempId: btn.printTemp, pageId: btn.$MenuID || '', dataM: sessionStorage.getItem('dataM')} |
| | | try { |
| | | // eslint-disable-next-line |
| | | let func = new Function('btn', 'searches', 'data', 'param', 'systemType', btn.pre_func) |
| | | _param = func(btn, searches, data, _param, window.GLOB.systemType) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | } |
| | | |
| | | if (!_param || _param.error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: _param ? _param.error : '未获取到打印参数,自定义脚本错误!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | 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, dataM: sessionStorage.getItem('dataM') })))) |
| | | if (btn.Ot === 'required') { |
| | | data.forEach(item => { |
| | | 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(_param)))) |
| | | } else { |
| | | 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') { |
| | | let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '打印', Remark: Remark }))) |
| | | let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '打印', lang }))) |
| | | window.open(src) |
| | | } else if (btn.pageTemplate === 'print') { |
| | | let cloudmsg = '&cuid=' + (sessionStorage.getItem('CloudUserID') || '') + '&clid=' + (sessionStorage.getItem('CloudLoginUID') || '') + '&cun=' + (sessionStorage.getItem('CloudUserName') || '') |
| | | let msg = '&uid=' + sessionStorage.getItem('UserID') + '&lid=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name') |
| | | let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg) |
| | | let src = '#/print/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, lang }))) |
| | | window.open(src) |
| | | } else if (btn.pageTemplate === 'pay') { |
| | | let _p = `ID=${Id}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID')}&logo=${window.GLOB.doclogo}&name=${sessionStorage.getItem('Full_Name')}&icp=${window.GLOB.ICP}©Right=${window.GLOB.copyRight}` |
| | | let url = '#/pay/' + window.btoa(window.encodeURIComponent(_p)) |
| | | _name = '支付' |
| | | |
| | | confirm({ |
| | | title: '请在付款页面完成订单支付。', |
| | | content: '', |
| | | className: 'pay-query', |
| | | okText: '支付成功', |
| | | cancelText: '支付遇到问题', |
| | | onOk() { |
| | | // 支付后刷新界面 |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn) |
| | | }, |
| | | onCancel() { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn) |
| | | }, |
| | | }) |
| | | window.open(url) |
| | | 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] || {}, appId, merchId) |
| | | } else { |
| | | confirm({ |
| | | title: '请在付款页面完成订单支付。', |
| | | content: '', |
| | | className: 'pay-query', |
| | | okText: '支付成功', |
| | | cancelText: '支付遇到问题', |
| | | onOk() { |
| | | // 支付后刷新界面 |
| | | MKEmitter.emit('reloadMenuView', btn.$MenuID) |
| | | }, |
| | | onCancel() { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn) |
| | | }, |
| | | }) |
| | | |
| | | window.open('#/pay/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, appId, merchId })))) |
| | | } |
| | | } else if (btn.pageTemplate === 'custom') { |
| | | let url = btn.url |
| | | if (window.GLOB.systemType === 'production' && btn.proUrl) { |
| | | if (window.GLOB.systemType === 'production') { |
| | | url = btn.proUrl |
| | | } |
| | | |
| | |
| | | |
| | | if (/#\/iframe\//.test(url)) { |
| | | url = url.replace(/@loginuid@/ig, sessionStorage.getItem('LoginUID')) |
| | | |
| | | if (btn.joint === 'true' && Id) { |
| | | url = url + '/' + Id |
| | | } |
| | | url = url + '/' + Id |
| | | |
| | | let menu = { |
| | | MenuID: btn.uuid, |
| | |
| | | return |
| | | } |
| | | |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(url)) { |
| | | con = '&' |
| | | } |
| | | |
| | | if (btn.joint === 'true') { |
| | | let con = '?' |
| | | |
| | | if (/\?/ig.test(url)) { |
| | | con = '&' |
| | | } |
| | | url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}` |
| | | } else if (Id) { |
| | | url = url + `${con}id=${Id}` |
| | | } else if (/@/.test(url)) { |
| | | url = url.replace(/@id@/ig, Id) |
| | | url = url.replace(/@appkey@/ig, window.GLOB.appkey) |
| | | url = url.replace(/@userid@/ig, sessionStorage.getItem('UserID')) |
| | | url = url.replace(/@LoginUID@/ig, sessionStorage.getItem('LoginUID')) |
| | | |
| | | if (btn.Ot === 'requiredSgl' && data[0]) { |
| | | Object.keys(data[0]).forEach(key => { |
| | | if (/^\$/.test(key)) return |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | url = url.replace(reg, data[0][key]) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | window.open(url) |
| | | } |
| | | |
| | | 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, appId, merchId) => { |
| | | const { btn, BID } = this.props |
| | | |
| | | let param = null |
| | | if (btn.payMode === 'inner') { |
| | | param = { |
| | | func: btn.innerFunc || '', |
| | | BID: BID || '', |
| | | username: sessionStorage.getItem('User_Name') || '', |
| | | fullname: sessionStorage.getItem('Full_Name') || '', |
| | | 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) |
| | | |
| | | param = { |
| | | func: 'sPC_TableData_InUpDe', |
| | | BID: BID || '', |
| | | exec_type: window.GLOB.execType || 'y', |
| | | timestamp: moment().format('YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | param.LText = Utils.formatOptions(sql, param.exec_type) |
| | | |
| | | if (btn.output) { |
| | | param.key_back_type = 'Y' |
| | | } |
| | | |
| | | if (window.GLOB.mkHS) { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | |
| | | param.menuname = btn.logLabel |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.s_debug_type = 'Y' |
| | | } |
| | | } |
| | | |
| | | this.setState({loading: true}) |
| | | Api.genericInterface(param).then(res => { |
| | | this.setState({loading: false}) |
| | | if (res.status) { |
| | | let id = ID |
| | | if (btn.output) { |
| | | id = res.mk_b_id || res[btn.output] || ID |
| | | } |
| | | |
| | | confirm({ |
| | | title: '请在付款页面完成订单支付。', |
| | | content: '', |
| | | className: 'pay-query', |
| | | okText: '支付成功', |
| | | cancelText: '支付遇到问题', |
| | | onOk() { |
| | | // 支付后刷新界面 |
| | | MKEmitter.emit('reloadMenuView', btn.$MenuID) |
| | | }, |
| | | onCancel() { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, 'grid', btn) |
| | | }, |
| | | }) |
| | | |
| | | 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) => { |
| | | const { columns, btn, BID } = this.props |
| | | |
| | | // 系统变量 |
| | | let _vars = ['tbid', 'errorcode', 'retmsg', 'username', 'fullname', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid'] |
| | | let _declare = [] |
| | | let _initVal = [] |
| | | |
| | | let _data = {} |
| | | Object.keys(data).forEach(key => { |
| | | _data[key.toLowerCase()] = data[key] |
| | | }) |
| | | |
| | | columns.forEach(col => { |
| | | let _key = col.field.toLowerCase() |
| | | |
| | | if (_vars.includes(_key)) return |
| | | |
| | | _declare.push(`@${_key} ${col.datatype}`) |
| | | |
| | | let _val = _data.hasOwnProperty(_key) ? _data[_key] : '' |
| | | |
| | | if (/^date/ig.test(col.datatype) && !_val) { |
| | | _val = '1949-10-01' |
| | | } |
| | | |
| | | if (/'/.test(_val)) { |
| | | _val = _val.replace(/'/ig, '"') |
| | | } |
| | | |
| | | _initVal.push(`@${_key}='${_val}'`) |
| | | }) |
| | | |
| | | // 变量声明 |
| | | _declare = _declare.join(',') |
| | | if (_declare) { |
| | | _declare = ',' + _declare |
| | | } |
| | | |
| | | let _sql = `/* 系统生成 */ |
| | | Declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@bid nvarchar(50),@tbid nvarchar(50)${_declare} |
| | | ` |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let RoleID = sessionStorage.getItem('role_id') || '' |
| | | let departmentcode = sessionStorage.getItem('departmentcode') || '' |
| | | let organization = sessionStorage.getItem('organization') || '' |
| | | let mk_user_type = sessionStorage.getItem('mk_user_type') || '' |
| | | let nation = sessionStorage.getItem('nation') || '' |
| | | let province = sessionStorage.getItem('province') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | let district = sessionStorage.getItem('district') || '' |
| | | let address = sessionStorage.getItem('address') || '' |
| | | |
| | | // 初始化凭证及用户信息字段 |
| | | _sql += ` |
| | | /* 用户信息初始化赋值 */ |
| | | select @ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}', @bid='${BID}' |
| | | ` |
| | | _sql += ` |
| | | /* 显示列变量赋值 */ |
| | | select ${_initVal.join(',')} |
| | | ` |
| | | |
| | | btn.verify.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | _sql += ` |
| | | ${item.sql} |
| | | ` |
| | | }) |
| | | |
| | | if (btn.output) { |
| | | _sql += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` |
| | | } else { |
| | | _sql += ` |
| | | aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` |
| | | } |
| | | |
| | | _sql = _sql.replace(/@ID@/ig, `'${ID || ''}'`) |
| | | _sql = _sql.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _sql = _sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _sql = _sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _sql = _sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | _sql = _sql.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`) |
| | | _sql = _sql.replace(/@typename@/ig, `'admin'`) |
| | | |
| | | if (window.GLOB.externalDatabase !== null) { |
| | | _sql = _sql.replace(/@db@/ig, window.GLOB.externalDatabase) |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`) |
| | | } else { |
| | | _sql = _sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`) |
| | | } |
| | | |
| | | if (window.GLOB.debugger === true) { |
| | | window.mkInfo('%c' + btn.logLabel, 'color: blue') |
| | | window.mkInfo(_sql) |
| | | } |
| | | |
| | | return _sql |
| | | } |
| | | |
| | | execError = (res) => { |
| | | const { btn } = this.props |
| | | const { dict } = this.state |
| | | |
| | | if (!['LoginError', 'C', '-2', 'E', 'N', 'F', 'NM'].includes(res.ErrCode)) { |
| | | res.ErrCode = 'E' |
| | | } |
| | | |
| | | if (res.ErrCode === 'E') { |
| | | Modal.error({ |
| | | title: res.message || dict['exc_fail'] || '执行失败!', |
| | | okText: dict['got_it'] || '知道了' |
| | | }) |
| | | } else if (res.ErrCode === 'N') { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || dict['exc_fail'] || '执行失败!', |
| | | duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 |
| | | }) |
| | | } else if (res.ErrCode === 'F') { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | top: 92, |
| | | message: res.message || dict['exc_fail'] || '执行失败!', |
| | | duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10 |
| | | }) |
| | | } else if (res.ErrCode === 'NM') { |
| | | message.error(res.message || dict['exc_fail'] || '执行失败!') |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { btn } = this.props |
| | | const { disabled, hidden } = this.state |
| | | const { btn, name } = this.props |
| | | const { disabled, hidden, loading } = this.state |
| | | |
| | | if (hidden) return null |
| | | |
| | | let label = '' |
| | | let icon = '' |
| | | let type = 'link' |
| | | let className = '' |
| | | |
| | | if (btn.show === 'button') { |
| | | label = btn.label |
| | | icon = btn.icon || '' |
| | | } else if (btn.show === 'link') { |
| | | label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> |
| | | icon = '' |
| | | if (btn.show === 'link') { |
| | | label = <span>{name || btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon} /> : ''}</span> |
| | | } else if (btn.show === 'icon') { |
| | | icon = btn.icon || '' |
| | | } else if (!btn.$toolbtn) { |
| | | icon = btn.icon || '' |
| | | label = btn.label |
| | | className = 'mk-btn mk-' + btn.class |
| | | label = <MkIcon type={btn.icon} /> |
| | | } else { |
| | | type = '' |
| | | icon = btn.icon || '' |
| | | label = btn.label |
| | | className = 'mk-btn mk-' + btn.class |
| | | label = <span>{btn.icon ? <MkIcon style={{marginRight: '8px'}} type={btn.icon} /> : ''}{name || btn.label}</span> |
| | | } |
| | | |
| | | return ( |
| | | <Button |
| | | type={type} |
| | | type="link" |
| | | id={'button' + btn.uuid} |
| | | title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} |
| | | style={btn.style || null} |
| | | loading={loading} |
| | | disabled={disabled} |
| | | icon={icon} |
| | | className={className} |
| | | className={btn.hover || ''} |
| | | onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} |
| | | >{label}</Button> |
| | | ) |