From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 1692 ++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 1,130 insertions(+), 562 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index ac2b71c..489b48e 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -1,9 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import moment from 'moment' -import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { Button, Modal, notification, message, Drawer, Switch, Checkbox } from 'antd' +import { Button, Modal, notification, message, Drawer, Switch, Checkbox, Progress } from 'antd' import Api from '@/api' import Utils, { getSysDefaultSql } from '@/utils/utils.js' @@ -21,19 +20,14 @@ class NormalButton extends Component { static propTpyes = { - show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 - position: PropTypes.any, // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 style: PropTypes.any, // 鎸夐挳鏍峰紡 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 - Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� btn: PropTypes.object, // 鎸夐挳 columns: PropTypes.any, // 瀛楁鍒� setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 - ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� disabled: PropTypes.any, // 琛屾寜閽鐢� - lineId: PropTypes.any, // 琛岀储寮�+涓婚敭鍊硷紝鐢ㄤ簬琛屾寜閽弻鍑� } state = { @@ -45,9 +39,9 @@ btnconfig: null, loading: false, loadingNumber: '', + loadingTotal: '', disabled: false, hidden: false, - checkParam: null, autoMatic: false, check: false } @@ -97,13 +91,12 @@ } componentDidMount () { - const { position, btn } = this.props + const { btn } = this.props MKEmitter.addListener('triggerBtnId', this.actionTrigger) - if (position === 'form') { + if (btn.OpenType === 'formSubmit') { MKEmitter.addListener('triggerFormSubmit', this.actionSubmit) } - MKEmitter.addListener('returnModuleParam', this.resetModuleParam) if (btn.autoMatic) { MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) @@ -159,7 +152,6 @@ } MKEmitter.removeListener('triggerBtnId', this.actionTrigger) MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) - MKEmitter.removeListener('returnModuleParam', this.resetModuleParam) MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) } @@ -207,14 +199,6 @@ this.execSubmit(data, () => {}, res.form) } - resetModuleParam = (menuId, btnId, param) => { - const { btn } = this.props - - if (btn.$menuId !== menuId || btn.uuid !== btnId || !param) return - - this.moduleParams = param - } - /** * @description 鎸夐挳鐘舵�佹敼鍙� */ @@ -230,28 +214,21 @@ * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (triggerId, record, type) => { - const { Tab, BID, btn, selectedData, setting } = this.props + const { BID, btn, selectedData, setting } = this.props const { loading, disabled } = this.state if (loading || disabled) return - if (triggerId) { - if (btn.uuid !== triggerId) return - if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) { - return - } - } + if (triggerId && btn.uuid !== triggerId) return - if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { + if (setting.supModule && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', duration: 5 }) return - } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) { - if (record[0].$Index !== selectedData[0].$Index) { - return - } + } else if (type === 'linkbtn' && !btn.$toolbtn && !is(fromJS(selectedData || []), fromJS(record))) { + return } this.setState({autoMatic: type === 'autoMatic'}) @@ -277,12 +254,20 @@ return } else if (!['requiredSgl', 'notRequired', 'requiredOnce', 'required'].includes(btn.Ot)) { // 鏁版嵁閫夋嫨绫诲瀷鏍¢獙 - this.actionSettingError() + notification.warning({ + top: 92, + message: '鎸夐挳琛岃缃敊璇紒', + duration: 5 + }) return } else if (btn.intertype === 'system') { // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鎿嶄綔绫诲瀷鍜屾暟鎹簮涓嶅彲涓虹┖ if (!btn.sql || !btn.sqlType) { - this.actionSettingError() + notification.warning({ + top: 92, + message: '鎸夐挳鎿嶄綔绫诲瀷閿欒锛�', + duration: 5 + }) return } else if (data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { notification.warning({ @@ -295,12 +280,20 @@ } else if (btn.intertype === 'inner') { // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟涓嶅彲涓虹┖ if (!btn.innerFunc) { - this.actionSettingError() + notification.warning({ + top: 92, + message: '鎸夐挳鍐呴儴鍑芥暟涓嶅彲涓虹┖锛�', + duration: 5 + }) return } - } else if (btn.intertype === 'custom') { + } else if (btn.intertype === 'custom' || btn.intertype === 'outer') { if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { - this.actionSettingError() + notification.warning({ + top: 92, + message: '浣跨敤鑷畾涔夎剼鏈洖璋冩椂锛屽洖璋冭剼鏈笉鍙负绌猴紒', + duration: 5 + }) return } else if (btn.procMode === 'system' && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { notification.warning({ @@ -309,7 +302,7 @@ duration: 5 }) return - } else if (window.GLOB.systemType === 'production' && !btn.proInterface) { + } else if (btn.intertype === 'custom' && window.GLOB.systemType === 'production' && !btn.proInterface) { notification.warning({ top: 92, message: '灏氭湭璁剧疆姝e紡绯荤粺鎺ュ彛鍦板潃锛�', @@ -317,15 +310,13 @@ }) return } - } else if (btn.intertype === 'outer') { - // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 - if (!btn.interface && btn.sysInterface !== 'true') { - this.actionSettingError() - return - } } else if (!['inner', 'outer', 'system', 'custom'].includes(btn.intertype)) { // 鎺ュ彛绫诲瀷閿欒 - this.actionSettingError() + notification.warning({ + top: 92, + message: '鎸夐挳鎺ュ彛绫诲瀷閿欒锛�', + duration: 5 + }) return } @@ -382,7 +373,6 @@ let item = { type: type, - readonly: false, readin: true, writein: true, fieldlen: fieldlen, @@ -411,7 +401,6 @@ let param = { // 绯荤粺瀛樺偍杩囩▼ func: 'sPC_TableData_InUpDe' } - let check_param = null if (this.props.BID) { param.BID = this.props.BID @@ -429,11 +418,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -451,11 +440,9 @@ param.secretkey = Utils.encrypt('', param.timestamp) if (/\$check@|@check\$/ig.test(param.LText)) { - check_param = fromJS(param).toJS() - check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') - check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') - check_param.LText = Utils.formatOptions(check_param.LText) - + if (btn.intertype === 'system') { + param.$unCheckParam = fromJS(param).toJS() + } param.LText = param.LText.replace(/\$check@|@check\$/ig, '') } @@ -474,11 +461,11 @@ param.ID = primaryId || Utils.getguid() if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -496,11 +483,9 @@ param.secretkey = Utils.encrypt('', param.timestamp) if (/\$check@|@check\$/ig.test(param.LText)) { - check_param = fromJS(param).toJS() - check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') - check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') - check_param.LText = Utils.formatOptions(check_param.LText) - + if (btn.intertype === 'system') { + param.$unCheckParam = fromJS(param).toJS() + } param.LText = param.LText.replace(/\$check@|@check\$/ig, '') } @@ -509,11 +494,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -531,11 +516,9 @@ param.secretkey = Utils.encrypt('', param.timestamp) if (/\$check@|@check\$/ig.test(param.LText)) { - check_param = fromJS(param).toJS() - check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') - check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') - check_param.LText = Utils.formatOptions(check_param.LText) - + if (btn.intertype === 'system') { + param.$unCheckParam = fromJS(param).toJS() + } param.LText = param.LText.replace(/\$check@|@check\$/ig, '') } @@ -543,11 +526,8 @@ } } - if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - if (check_param) { - check_param.open_key = Utils.encryptOpenKey(check_param.secretkey, check_param.timestamp) - } } param.menuname = btn.logLabel @@ -556,9 +536,18 @@ param.s_debug_type = 'Y' } - if (check_param) { - check_param.menuname = btn.logLabel - this.setState({checkParam: check_param}) + if (window.GLOB.breakpoint) { + param.func = 'sPC_TableData_InUpDe_debug' + } + + if (param.$unCheckParam) { + param.$unCheckParam.LText = param.$unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') + param.$unCheckParam.LText = Utils.formatOptions(param.$unCheckParam.LText) + param.$unCheckParam.menuname = btn.logLabel + + if (window.GLOB.probation) { + param.$unCheckParam.s_debug_type = 'Y' + } } _params.push(param) @@ -578,11 +567,11 @@ param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -594,17 +583,28 @@ } else { param.LText = param.LText.replace(/@\$|\$@/ig, '') } - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) + + if (/\$check@|@check\$/ig.test(param.LText)) { + if (btn.intertype === 'system') { + param.$unCheckParam = fromJS(param).toJS() + } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + } + param.LText = Utils.formatOptions(param.LText) } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 if (index !== 0) { + let _cell = {} + Object.keys(cell).forEach(key => { + _cell[key.toLowerCase()] = cell[key] + }) formdata = formdata.map(_data => { - if (_data.readin && cell.hasOwnProperty(_data.key)) { - _data.value = cell[_data.key] + if (_data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { + _data.value = _cell[_data.key.toLowerCase()] } return _data }) @@ -614,11 +614,11 @@ param.ID = Utils.getguid() if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -630,21 +630,28 @@ } else { param.LText = param.LText.replace(/@\$|\$@/ig, '') } - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) + + if (/\$check@|@check\$/ig.test(param.LText)) { + if (btn.intertype === 'system') { + param.$unCheckParam = fromJS(param).toJS() + } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + } + param.LText = Utils.formatOptions(param.LText) } else { param.ID = primaryId if (retmsg) { - const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, retmsg, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� param.LText = sql param.$callbacksql = callbacksql } else { - param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� + param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, false, this.moduleParams, Utils.getAllSearchOptions) // 鏁版嵁婧� if (btn.output) { param.key_back_type = 'Y' } @@ -656,23 +663,42 @@ } else { param.LText = param.LText.replace(/@\$|\$@/ig, '') } - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) + + if (/\$check@|@check\$/ig.test(param.LText)) { + if (btn.intertype === 'system') { + param.$unCheckParam = fromJS(param).toJS() + } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + } + param.LText = Utils.formatOptions(param.LText) } } - if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } - if (param.func === 'sPC_TableData_InUpDe') { - param.menuname = btn.logLabel + param.menuname = btn.logLabel + if (window.GLOB.probation) { + param.s_debug_type = 'Y' + } + + if (window.GLOB.breakpoint) { + param.func = 'sPC_TableData_InUpDe_debug' + } + + if (param.$unCheckParam) { + param.$unCheckParam.LText = param.$unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') + param.$unCheckParam.LText = Utils.formatOptions(param.$unCheckParam.LText) + param.$unCheckParam.menuname = btn.logLabel + if (window.GLOB.probation) { - param.s_debug_type = 'Y' + param.$unCheckParam.s_debug_type = 'Y' } } @@ -683,13 +709,13 @@ return _params } - getInnerParam = (data, formdata) => { - const { setting, btn } = this.props + getInnerParam = (data, formdata, retmsg) => { + const { setting, btn, columns } = this.props let _params = [] if ( btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce' ) { let param = { - func: btn.innerFunc + func: btn.innerFunc || '' } if (this.props.BID) { @@ -714,10 +740,14 @@ }) } - if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 + if (window.GLOB.mkHS && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // special 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + if (retmsg) { + param.$callbacksql = this.getSysDeclareSql(btn, formdata, data[0], columns, primaryId, this.props.BID) } _params.push(param) @@ -735,9 +765,13 @@ if (btn.OpenType === 'pop') { // 琛ㄥ崟 if (index !== 0) { + let _cell = {} + Object.keys(cell).forEach(key => { + _cell[key.toLowerCase()] = cell[key] + }) formdata = formdata.map(_data => { - if (_data.readin && cell.hasOwnProperty(_data.key)) { - _data.value = cell[_data.key] + if (_data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { + _data.value = _cell[_data.key.toLowerCase()] } return _data }) @@ -751,10 +785,14 @@ param[setting.primaryKey] = primaryId } - if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 + if (window.GLOB.mkHS && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // special 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + if (retmsg) { + param.$callbacksql = this.getSysDeclareSql(btn, formdata, cell, columns, primaryId, this.props.BID) } return param @@ -762,6 +800,181 @@ } return _params + } + + /** + * @description 鑾峰彇鍥炶皟鑴氭湰鐨勫瓧娈靛畾涔� + */ + getSysDeclareSql = (btn, formdata, data, columns, primaryId, BID = '') => { + let datavars = {} // 澹版槑鐨勫彉閲忥紝琛ㄥ崟鍙婃樉绀哄垪 + // 闇�瑕佸0鏄庣殑鍙橀噺闆� + let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode', 'roleid', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid'] + + // sql璇彞 + let _sql = '' + + let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦 + let _initFormfields = [] + let _initColfields = [] + let _declarefields = [] + + // 鑾峰彇瀛楁閿�煎 + formdata && formdata.forEach(form => { + let _key = form.key.toLowerCase() + datavars[_key] = form.value + + if (!_initvars.includes(_key)) { + _initvars.push(_key) + + if (form.type === 'number' || form.type === 'rate') { + let val = form.value + if (isNaN(val)) { + val = 0 + } + _initFormfields.push(`@${_key}=${val}`) + } else if (['date', 'datemonth'].includes(form.type)) { + _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`) + } else { + _initFormfields.push(`@${_key}='${form.value}'`) + } + } + + if (!_vars.includes(_key)) { + _vars.push(_key) + + if (form.fieldlen && form.fieldlen > 2048) { + form.fieldlen = 'max' + } + + let _type = `nvarchar(${form.fieldlen})` + + if (form.type.match(/date/ig)) { + _type = 'datetime' + } else if (form.type === 'number') { + _type = `decimal(18,${form.fieldlen})` + } else if (form.type === 'rate') { + _type = `decimal(18,2)` + } + + _declarefields.push(`@${_key} ${_type}`) + } + }) + + if (data) { + Object.keys(data).forEach(key => { + data[key.toLowerCase()] = data[key] + }) + } + + // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) + if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) { + datavars = {...data, ...datavars} + + const setField = (col) => { + if (!col.field) return + let _key = col.field.toLowerCase() + + if (!_initvars.includes(_key)) { + let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' + + if (col.datatype && /^date/ig.test(col.datatype) && !_val) { + _val = '1949-10-01' + } + + _initvars.push(_key) + _initColfields.push(`@${_key}='${_val}'`) + } + + if (!_vars.includes(_key)) { + _vars.push(_key) + + if (col.datatype) { + _declarefields.push(`@${_key} ${col.datatype}`) + } else { + if (col.fieldlength && col.fieldlength > 2048) { + col.fieldlength = 'max' + } + + let _type = `nvarchar(${col.fieldlength || 50})` + + if (col.type === 'number') { + let _length = col.decimal ? col.decimal : 0 + _type = `decimal(18,${_length})` + } else if (col.type === 'picture' || col.type === 'textarea') { + _type = `nvarchar(${col.fieldlength || 512})` + } + + _declarefields.push(`@${_key} ${_type}`) + } + } + } + + columns.forEach(col => { + if (col.type === 'colspan' || col.type === 'old_colspan') { + col.subcols.forEach(cell => { + setField(cell) + }) + } else { + setField(col) + } + }) + } + + // 鍙橀噺澹版槑 + _declarefields = _declarefields.join(',') + if (_declarefields) { + _declarefields = ',' + _declarefields + } + _sql = `/* 绯荤粺鐢熸垚 */ + Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50),@ModularDetailCode nvarchar(50), @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)${_declarefields} + ` + + 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') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁 + _sql += ` + /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */ + select @BVoucher='',@FIBVoucherDate='',@FiYear='',@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}', @BillCode='', @ModularDetailCode='' + ` + + // 琛ㄥ崟鍙橀噺璧嬪�� + if (_initFormfields.length > 0) { + _sql += ` + /* 琛ㄥ崟鍙橀噺璧嬪�� */ + select ${_initFormfields.join(',')} + ` + } + // 鏄剧ず鍒楀彉閲忚祴鍊� + if (_initColfields.length > 0) { + _sql += ` + /* 鏄剧ず鍒楀彉閲忚祴鍊� */ + select ${_initColfields.join(',')} + ` + } + + _sql = _sql.replace(/@ID@/ig, `'${primaryId || ''}'`) + _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 || ''}'`) + + return _sql } /** @@ -776,25 +989,19 @@ btn.sqlType !== 'insert' && btn.Ot !== 'notRequired' && btn.verify && btn.verify.invalid === 'true' && setting.dataresource ) { - MKEmitter.emit('queryModuleParam', btn.$menuId, btn.uuid) - setTimeout(() => { - if (this.moduleParams) { - this.execRealSubmit(data, _resolve, formdata) - } else { - setTimeout(() => { - this.execRealSubmit(data, _resolve, formdata) - }, 100) - } - }, 50) + MKEmitter.emit('queryModuleParam', btn.$menuId, (param) => { + this.moduleParams = param + this.execRealSubmit(data, _resolve, formdata) + }) } else { this.execRealSubmit(data, _resolve, formdata) } } execRealSubmit = (data, _resolve, formdata) => { - const { setting, btn, Tab, BID } = this.props + const { setting, btn, BID } = this.props - if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { + if (setting.supModule && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', @@ -813,7 +1020,9 @@ params = this.getInnerParam(data, formdata) } - if (params.length <= 20) { + if (params[0].$unCheckParam) { + this.checkLoopRequest(params, _resolve) + } else if (params.length <= 20) { let deffers = params.map((param, i) => { return new Promise(resolve => { setTimeout(() => { @@ -843,6 +1052,10 @@ }) }, 600) } + + if (res.status) { + this.triggerNote(res) // 娑堟伅 + } resolve(res) }, () => { this.updateStatus() @@ -870,68 +1083,35 @@ _resolve() }) } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц + if (btn.progress === 'progressbar' && btn.$toolbtn) { + this.setState({ + loadingTotal: params.length + }) + } this.innerLoopRequest(params, btn, _resolve) } } else if (btn.intertype === 'outer') { /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ let _params = [] // 璇锋眰鍙傛暟鏁扮粍 - if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let param = {} + if (btn.procMode === 'system') { + _params = this.getSystemParam(data, formdata, true) + _params = _params.map(item => { + item.script_type = 'Y' + return item + }) + } else { + _params = this.getInnerParam(data, formdata, btn.callbackType === 'script') + } - if (this.props.BID) { - param.BID = this.props.BID - } - - if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - } - - // 鑾峰彇id - if (btn.Ot === 'notRequired') { - - } else if (btn.Ot === 'requiredSgl' && setting.primaryKey) { - param[setting.primaryKey] = data[0][setting.primaryKey] - } else if (btn.Ot === 'requiredOnce' && setting.primaryKey) { - let ids = data.map(d => { return d[setting.primaryKey]}) - param[setting.primaryKey] = ids.join(',') - } - - _params.push(param) - } else if (btn.Ot === 'required') { - // 閫夋嫨澶氳锛屽惊鐜皟鐢� - _params = data.map((cell, index) => { - let _cell = {} - - if (this.props.BID) { - _cell.BID = this.props.BID - } - - let _formparam = {} - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { - _formparam[_data.key] = cell[_data.key] - } else { - _formparam[_data.key] = _data.value - } - }) - } - - if (setting.primaryKey) { - _cell[setting.primaryKey] = cell[setting.primaryKey] - } - - _cell = {..._formparam, ..._cell} - - return _cell + if (_params.length > 1 && btn.progress === 'progressbar' && btn.$toolbtn) { + this.setState({ + loadingTotal: _params.length }) } // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� - this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) + this.outerLoopRequest(_params, _resolve) } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛 let params = [] @@ -942,7 +1122,13 @@ return item }) } else { - params = this.getInnerParam(data, formdata) + params = this.getInnerParam(data, formdata, btn.callbackType === 'script') + } + + if (params.length > 1 && btn.progress === 'progressbar' && btn.$toolbtn) { + this.setState({ + loadingTotal: params.length + }) } this.customLoopRequest(params, _resolve) @@ -956,7 +1142,7 @@ let param = params.shift() this.setState({ - loadingNumber: params.length || '' + loadingNumber: params.length }) let record = { @@ -966,6 +1152,11 @@ } delete param.$callbacksql + + if (!param.func) { + this.customOuterRequest(params, param, record, _resolve) + return + } Api.genericInterface(param).then(res => { if (res.status) { @@ -977,41 +1168,6 @@ } else { this.customOuterRequest(params, res, record, _resolve) } - } else if (res.ErrCode === 'C' && this.state.checkParam) { - const _this = this - confirm({ - title: res.message || res.ErrMesg, - content: '缁х画鎵ц锛�', - onOk() { - return new Promise(resolve => { - Api.genericInterface(_this.state.checkParam).then((result) => { - if (result.status) { - if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length === 0) { - _this.execSuccess(result) - _resolve() - } else if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length > 0) { - _this.customLoopRequest(params, _resolve) - } else { - _this.customOuterRequest(params, result, record, _resolve) - } - } else { - _this.execError(result) - _resolve() - } - resolve() - }, () => { - _this.updateStatus() - resolve() - _resolve() - }) - }) - }, - onCancel() { - _this.execError({...res, ErrCode: 'P'}) - _resolve() - } - }) - this.setState({checkParam: null}) } else { this.execError(res) _resolve() @@ -1094,6 +1250,88 @@ * @description 鍥炶皟璇锋眰寰幆鎵ц */ customCallbackRequest = (params, result, record, _resolve) => { + const { btn } = this.props + + let param = null + let callback = result.mk_ex_invoke + + delete result.mk_ex_invoke + + if (callback === 'false' || callback === false) { + if (result.status) { + if (params.length === 0) { + this.execSuccess(result) + _resolve() + } else { + this.customLoopRequest(params, _resolve) + } + } else { + this.execError(result) + _resolve() + } + return + } else if (btn.callbackType === 'script' || btn.callbackType === 'default') { + param = this.getCallBackSql(result, record) + } else if (btn.callbackType === 'func') { + param = { + ...result, + func: btn.callbackFunc + } + if (result.$ErrCode === 'E') { + delete param.$ErrCode + delete param.$ErrMesg + + param.ErrCode = 'E' + } + } else { + if (result.$ErrCode === 'E') { + result.status = false + result.message = result.$ErrMesg + result.ErrCode = 'E' + result.ErrMesg = result.$ErrMesg + } else { + result.status = result.status !== false + result.ErrCode = result.ErrCode || '-1' + } + + if (result.status) { + if (params.length === 0) { + this.execSuccess(result) + _resolve() + } else { + this.customLoopRequest(params, _resolve) + } + } else { + this.execError(result) + _resolve() + } + + return + } + + if (param.menuname) { + param.menuname = param.menuname + '(鍥炶皟)' + } + + Api.genericInterface(param).then(res => { + if (res.status) { + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.customLoopRequest(params, _resolve) + } + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus() + _resolve() + }) + } + + getCallBackSql = (result, record) => { const { btn } = this.props let lines = [] let pre = btn.callbackType === 'script' ? '@' : '' @@ -1202,8 +1440,13 @@ } }) - _backCustomScript += ` - aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + if (btn.output) { + _backCustomScript += ` + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg,${btn.output} as mk_b_id` + } else { + _backCustomScript += ` + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + } let sql = [...lineMap.values()].map(item => (` ${item.insert} @@ -1238,7 +1481,7 @@ param.s_debug_type = 'Y' } - if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + if (window.GLOB.mkHS) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } } else { @@ -1262,22 +1505,7 @@ } } - Api.genericInterface(param).then(res => { - if (res.status) { - if (params.length === 0) { - this.execSuccess(res) - _resolve() - } else { - this.customLoopRequest(params, _resolve) - } - } else { - this.execError(res) - _resolve() - } - }, () => { - this.updateStatus() - _resolve() - }) + return param } /** @@ -1287,7 +1515,7 @@ let param = params.shift() this.setState({ - loadingNumber: params.length || '' + loadingNumber: params.length }) let _param = null @@ -1319,6 +1547,9 @@ }) }, 600) } + + this.triggerNote(res) // 娑堟伅 + if (params.length === 0) { this.execSuccess(res) _resolve() @@ -1336,147 +1567,347 @@ } /** - * @description 澶栭儴璇锋眰寰幆鎵ц + * @description 鏁版嵁妫�楠屽惊鐜墽琛� */ - outerLoopRequest = (params, btn, _resolve, widthNumber) => { - if (!params && params.length === 0) return - + checkLoopRequest = (params, _resolve) => { let param = params.shift() - let _outParam = null + let unCheckParam = param.$unCheckParam - if (widthNumber) { - this.setState({ - loadingNumber: params.length || '' - }) - } + delete param.$unCheckParam - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc + this.setState({ + loadingNumber: params.length + }) - // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 - if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - - resolve(res) - } else { - this.execError(res, btn) - resolve(false) - _resolve() - } - }, () => { - this.updateStatus() - _resolve() - }) - } else { - resolve(param) - } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = JSON.parse(JSON.stringify(res)) - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - res.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - if (window.GLOB.systemType === 'production' && btn.proInterface) { - res.rduri = btn.proInterface - } else { - res.rduri = btn.interface - } - } - - // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 - if (res.func === 's_sDataDictb_TBBack' && res.LTextOut) { - res.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - res.secretkey = Utils.encrypt(res.LTextOut, res.timestamp) - res.open_key = Utils.encryptOpenKey(res.secretkey, res.timestamp) - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - if (window.GLOB.systemType === 'production' && btn.proInterface) { - res.rduri = btn.proInterface - } else { - res.rduri = btn.interface - } - } - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - // 鍥炶皟璇锋眰 - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - - // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 - if (this.props.menuType === 'HS' && _callbackparam.func === 's_sDataDictb_TBBack' && _callbackparam.LTextOut) { - _callbackparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _callbackparam.secretkey = Utils.encrypt(_callbackparam.LTextOut, _callbackparam.timestamp) - _callbackparam.open_key = Utils.encryptOpenKey(_callbackparam.secretkey, _callbackparam.timestamp) - } - - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� - - if (params.length === 0) { - this.execSuccess(response) - _resolve() - } else { - this.outerLoopRequest(params, btn, _resolve, widthNumber) - } - } else { - this.execError(response) - _resolve() - } - } - }).then(res => { - if (!res) return - + Api.genericInterface(param).then(res => { if (res.status) { + this.triggerNote(res) // 娑堟伅 + if (params.length === 0) { this.execSuccess(res) _resolve() } else { - this.outerLoopRequest(params, btn, _resolve, widthNumber) + this.checkLoopRequest(params, _resolve) + } + } else if (res.ErrCode === 'C') { + const _this = this + confirm({ + title: '缁х画鎵ц锛�', + content: res.message, + onOk() { + return new Promise(resolve => { + Api.genericInterface(unCheckParam).then(result => { + if (result.status) { + _this.triggerNote(result) // 娑堟伅 + + if (params.length === 0) { + _this.execSuccess(result) + _resolve() + } else { + _this.checkLoopRequest(params, _resolve) + } + } else { + _this.execError(result) + _resolve() + } + resolve() + }) + }) + }, + onCancel() { + _this.execError(res) + _resolve() + } + }) + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus() + _resolve() + }) + } + + /** + * @description 澶栭儴璇锋眰寰幆鎵ц + */ + outerLoopRequest = (params, _resolve) => { + if (!params && params.length === 0) return + + let param = params.shift() + + this.setState({ + loadingNumber: params.length + }) + + let record = { + BID: param.BID || '', + ID: param.ID || '', + callbacksql: param.$callbacksql || '' + } + + delete param.$callbacksql + + if (!param.func) { + this.outerOuterRequest(params, param, record, _resolve) + return + } + + Api.genericInterface(param).then(res => { + if (res.status) { + if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length === 0) { + this.execSuccess(res) + _resolve() + } else if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length > 0) { + this.outerLoopRequest(params, _resolve) + } else { + delete res.mk_ex_invoke + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID + if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { + res.BID = this.props.BID + } + + if (res.mk_api_key) { + record.mk_api_key = res.mk_api_key + } + delete res.mk_api_key + + this.outerOuterRequest(params, res, record, _resolve) + } + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus() + _resolve() + }) + } + + outerOuterRequest = (params, result, record, _resolve) => { + const { btn } = this.props + let outParam = JSON.parse(JSON.stringify(result)) + + if (btn.outerFunc) { + result.func = btn.outerFunc + } + if (window.GLOB.mkHS) { + if (btn.outerFunc === 's_app_version_upt') { // special 鏇存柊鐗堟湰鍙锋椂璁块棶sso + if (window.GLOB.mainSystemApi) { + result.rduri = window.GLOB.mainSystemApi + } + } else if (btn.sysInterface === 'true' && options.cloudServiceApi) { + result.rduri = options.cloudServiceApi + result.userid = sessionStorage.getItem('CloudUserID') || '' + result.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' + } else if (btn.sysInterface !== 'true') { + if (window.GLOB.systemType === 'production' && btn.proInterface) { + result.rduri = btn.proInterface + } else { + result.rduri = btn.interface + } + } + + // special 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 + if (result.func === 's_sDataDictb_TBBack' && result.LTextOut) { + result.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + result.secretkey = Utils.encrypt(result.LTextOut, result.timestamp) + result.open_key = Utils.encryptOpenKey(result.secretkey, result.timestamp) + } + } else { + if (btn.sysInterface === 'true') { + if (window.GLOB.mainSystemApi) { + result.rduri = window.GLOB.mainSystemApi + } + } else if (btn.sysInterface === 'external') { + if (window.GLOB.systemType === 'production') { + result.$token = btn.exProInterface || '' + } else { + result.$token = btn.exInterface || '' + } + } else { + if (window.GLOB.systemType === 'production' && btn.proInterface) { + result.rduri = btn.proInterface + } else { + result.rduri = btn.interface + } + + let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') + if (result.rduri.indexOf(host) === -1 && /\/dostars/.test(result.rduri)) { + result.$login = true + } + } + } + + Api.genericInterface(result).then(res => { + if (!res) return // LoginError鏃朵腑鏂姹� + this.outerCallbackRequest(params, res, record, outParam, _resolve) + }, () => { + this.outerCallbackRequest(params, {status: false, message: 500, ErrCode: 'E', ErrMesg: 500}, record, outParam, _resolve) + }) + } + + /** + * @description 鍥炶皟璇锋眰寰幆鎵ц + */ + outerCallbackRequest = (params, result, record, outParam, _resolve) => { + const { btn } = this.props + + let param = null + + if (record.mk_api_key) { + result.mk_api_key = record.mk_api_key + } + + let callback = result.mk_ex_invoke + + delete result.mk_ex_invoke + + if (callback === 'false' || callback === false) { + if (result.status) { + if (params.length === 0) { + this.execSuccess(result) + _resolve() + } else { + this.outerLoopRequest(params, _resolve) + } + } else { + this.execError(result) + _resolve() + } + return + } else if (window.GLOB.mkHS && btn.outerFunc === 's_get_sVersionDetail_Ltext' && btn.callbackFunc) { // special 鐗堟湰鍗囩骇鍥炶皟澶勭悊 + if (result.status) { + this.verupRequest(params, result, outParam, _resolve) + } else { + this.execError(result) + _resolve() + } + return + } else if (btn.callbackType === 'script' || btn.callbackType === 'default') { + param = this.getCallBackSql(result, record) + } else if (btn.callbackType === 'func' || btn.callbackFunc) { + delete result.message + delete result.status + + param = { + ...outParam, + ...result, + func: btn.callbackFunc + } + + // special 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 + if (window.GLOB.mkHS && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + } else { + if (result.status) { + if (params.length === 0) { + this.execSuccess(result) + _resolve() + } else { + this.outerLoopRequest(params, _resolve) + } + } else { + this.execError(result) + _resolve() + } + + return + } + + if (param.menuname) { + param.menuname = param.menuname + '(鍥炶皟)' + } + + Api.genericInterface(param).then(res => { + if (res.status) { + // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.outerLoopRequest(params, _resolve) } } else { this.execError(res) _resolve() } }) + } + + verupRequest = (params, result, outParam, _resolve) => { + const { btn } = this.props + + delete result.message + delete result.status + + result.func = btn.callbackFunc + + let ssoParam = null + let callParam = {...outParam, ...result} + + if (callParam.LTextOut) { + callParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + callParam.secretkey = Utils.encrypt(callParam.LTextOut, callParam.timestamp) + callParam.open_key = Utils.encryptOpenKey(callParam.secretkey, callParam.timestamp) + } + + if (callParam.UpType === 'SSO' && window.GLOB.mainSystemApi) { + ssoParam = fromJS(callParam).toJS() + + ssoParam.rduri = window.GLOB.mainSystemApi + + delete ssoParam.UpType + } else { + delete callParam.UpType + } + + if (ssoParam) { + Api.genericInterface(ssoParam).then(res => { + if (!res.status) { + this.execError(res) + _resolve() + } else { + Api.genericInterface(callParam).then(re => { + if (!re.status) { + this.execError(re) + _resolve() + } else { + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.outerLoopRequest(params, _resolve) + } + } + }) + } + }) + } else { + Api.genericInterface(callParam).then(re => { + if (!re.status) { + this.execError(re) + _resolve() + } else { + if (params.length === 0) { + this.execSuccess(re) + _resolve() + } else { + this.outerLoopRequest(params, _resolve) + } + } + }) + } } /** @@ -1504,6 +1935,11 @@ } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず } + + this.setState({ + loadingNumber: '', + loadingTotal: '', + }) if (autoMatic) { this.setState({ @@ -1519,13 +1955,13 @@ }) } - if (btn.verify && btn.verify.noteEnable === 'true') { - this.sendMessage() - } - let id = '' if (btn.output) { id = res.mk_b_id || res[btn.output] || '' + } + + if (res.mk_icon) { + sessionStorage.setItem('avatar', res.mk_icon) } let tabId = '' if (btn.refreshTab && btn.refreshTab.length > 0) { @@ -1545,6 +1981,12 @@ MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines) } + if (window.GLOB.breakpoint) { + MKEmitter.emit('refreshDebugTable') + } + + btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) + if (tabId) { MKEmitter.emit('reloadMenuView', tabId, 'table') } @@ -1554,33 +1996,193 @@ let node = document.getElementById('tab' + id) node && node.click() } + if (btn.anchors && btn.anchors.length > 0) { + let id = btn.anchors[btn.anchors.length - 1] + let node = document.getElementById('anchor' + id) + node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'}) + } - if (btn.openmenu && btn.openmenu.length > 0 && btn.MenuID) { - let newtab = { - MenuID: btn.MenuID, - MenuName: btn.MenuName, - MenuNo: btn.MenuNo, - type: btn.tabType, - param: { - $BID: id + if (btn.openmenu && Array.isArray(btn.openmenu) && btn.openmenu.length > 0) { + let menuId = btn.openmenu.slice(-1)[0] + let newtab = window.GLOB.mkThdMenus.filter(m => m.MenuID === menuId)[0] + + if (!newtab && btn.MenuID) { + newtab = { + MenuID: btn.MenuID, + MenuName: btn.MenuName, + MenuNo: btn.MenuNo, + type: btn.tabType } + } else if (!newtab) { + return } - if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { - MKEmitter.emit('modifyTabs', newtab, 'replace') - } else { - MKEmitter.emit('modifyTabs', newtab, 'plus', true) - } + newtab = {...newtab, param: { $BID: id }} + + MKEmitter.emit('modifyTabs', newtab, true) } } - sendMessage = () => { - const { btn : { verify } } = this.props + triggerNote = (res) => { + const { btn } = this.props + if (!btn.verify) return + if (btn.verify.noteEnable !== 'true' && btn.verify.wxNote !== 'true') return + + let id = '' + if (btn.output) { + id = res.mk_b_id || res[btn.output] || '' + } + + if (!id) return + + if (btn.verify.noteEnable === 'true') { + this.sendMessage(btn.verify, id) + } + if (btn.verify.wxNote === 'true') { + this.sendWxMessage(btn.verify, id) + } + } + + sendWxMessage = (verify, id) => { + if (!window.GLOB.nginx) { + notification.warning({ + top: 92, + message: 'nginx鏈嶅姟灏氭湭寮�鍚紝涓嶅彲鍙戦�佹ā鏉挎秷鎭��', + duration: 5 + }) + return + } + + let param = { + func: 's_get_sms_weixin_local', + upid: id + } + + param.LText = Utils.formatOptions(Utils.getuuid()) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + Api.genericInterface(param).then(res => { + // res.data = [{openid: 'o2E7gvoSFvQRG7I8_gZxf4y3ONkQ', send_id: '2223333', first: '鎮ㄧ殑缂磋垂淇℃伅濡備笅', keyword1: '010000000001', keyword2: '2022骞�07鏈�03鏃�', keyword3: '渚涙殩缂磋垂', keyword4: '20鍏�', keyword5: '鎴愬姛', remark: '鎰熻阿鎮ㄧ殑浣跨敤锛�'}] + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return + } else if (!res.send_data || res.send_data.length === 0) { + return + } + + let _param = { + touser: '', + template_id: verify.wxTemplateId, + data: {} + } + + if (verify.wxNoteLink === 'url' && verify.wxNoteLinkUrl) { + _param.url = verify.wxNoteLinkUrl + } else if (verify.wxNoteLink === 'miniProgram' && window.GLOB.WXminiAppID) { + _param.miniprogram = { + appid: window.GLOB.WXminiAppID, + pagepath: '/pages/index/index' + } + + if (verify.wxNoteLinkMenuId) { + _param.miniprogram.pagepath = `/pages/index/index?MenuId=${verify.wxNoteLinkMenuId}` + } + } + + verify.wxNoteKeys.forEach(item => { + _param.data[item.key] = {value: '', color: item.color} + }) + + let params = res.send_data.map(item => { + let m = fromJS(_param).toJS() + + m.touser = item.openid || '' + if (item.bid && m.miniprogram && m.miniprogram.pagepath.indexOf('MenuId') > -1) { + m.miniprogram.pagepath = m.miniprogram.pagepath + `&BID=${item.bid}` + } + + if (item.send_id) { // 闃查噸鍏d + m.client_msg_id = item.send_id + } + + verify.wxNoteKeys.forEach(note => { + if (item[note.value] !== undefined) { + m.data[note.key].value = item[note.value] + } + }) + + return m + }) + + Api.wxAccessToken().then(res => { + if (!res.oa_access_token) return + + params.forEach(n => { + if (!n.touser) return + + Api.wxNginxRequest(`cgi-bin/message/template/send?access_token=${res.oa_access_token}`, 'post', n).then(re => { + if (verify.wxNoteCallback === 'true') { + let _p = { + func: 's_get_sms_weixin_local_suc_err', + upid: id, + send_id: n.client_msg_id || '', + status_result: re.errcode === 0 ? 'S' : 'E', + errcode: re.errcode, + msg_result: re.errmsg + } + + _p.LText = Utils.formatOptions(Utils.getuuid()) + _p.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _p.secretkey = Utils.encrypt(_p.LText, _p.timestamp) + + Api.genericInterface(_p).then(result => { + if (!result.status) { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }) + } else if (re.errcode !== 0 && re.errmsg) { + let msgs = [ + {errcode: -1, errmsg: '绯荤粺绻佸繖锛岃绋嶅�欏啀璇�'}, + {errcode: 40001, errmsg: 'access_token 鏃犳晥'}, + {errcode: 40003, errmsg: '涓嶅悎娉曠殑 OpenID'}, + {errcode: 40014, errmsg: '涓嶅悎娉曠殑 access_token'}, + {errcode: 40033, errmsg: '涓嶅悎娉曠殑璇锋眰瀛楃'}, + {errcode: 43004, errmsg: '闇�瑕佹帴鏀惰�呭叧娉�'}, + {errcode: 43019, errmsg: '闇�瑕佸皢鎺ユ敹鑰呬粠榛戝悕鍗曚腑绉婚櫎'}, + {errcode: 50005, errmsg: '鐢ㄦ埛鏈叧娉ㄥ叕浼楀彿'} + ] + + let msg = msgs.filter(m => m.errcode === re.errcode)[0] + msg = msg || re + + notification.warning({ + top: 92, + message: msg.errmsg, + duration: 5 + }) + } + }) + }) + }) + }) + } + + sendMessage = (verify, id) => { let param = { func: 's_get_sms_local', TypeCharOne: verify.noteTemp, // N涓嶅悓鍐呭锛孻鐩稿悓鍐呭 - TypeCharTwo: verify.noteType // N瀹氭椂锛孻瀹炴椂 + TypeCharTwo: verify.noteType, // N瀹氭椂锛孻瀹炴椂 + upid: id } param.LText = Utils.formatOptions(Utils.getuuid()) @@ -1659,18 +2261,19 @@ } if (Ltext.length === 0) return + Ltext = Ltext.join(';') _param.LText = window.btoa(window.encodeURIComponent(Ltext)) _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - _param.rduri = 'http://sso.mk9h.cn/webapi/dostars' + _param.rduri = 'https://sso.mk9h.cn/webapi/dostars' _param.userid = 'bh0bapabtd45epsgra79segbch6c1ibk' _param.LoginUID = 'bh0bapabtd45epsgra79segbch6c1ibk' - Api.getLocalConfig(_param).then(result => { + Api.genericInterface(_param).then(result => { if (!result.status) { notification.warning({ top: 92, @@ -1717,58 +2320,21 @@ this.setState({ loading: false, loadingNumber: '', + loadingTotal: '', visible: false }) MKEmitter.emit('autoExecOver', btn.uuid, 'error') return + } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { + this.setState({ + loading: false + }) } this.setState({ - loading: false, - loadingNumber: '' + loadingNumber: '', + loadingTotal: '', }) - - if (res.ErrCode === 'C') { - const _this = this - if (this.state.checkParam) { - let param = this.state.checkParam - confirm({ - title: res.message || res.ErrMesg, - content: '缁х画鎵ц锛�', - onOk() { - return new Promise(resolve => { - Api.genericInterface(param).then((result) => { - if (result.status) { - _this.execSuccess(result) - } else { - _this.execError(result) - } - resolve() - }, () => { - _this.setState({ - visible: false - }) - resolve() - }) - }) - }, - onCancel() { - _this.setState({ - visible: false - }) - if (btn.execError !== 'never') { - MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) - } - } - }) - this.setState({checkParam: null}) - return - } else { - Modal.error({ - title: res.message || res.ErrMesg, - }) - } - } if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) { MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) @@ -1782,17 +2348,10 @@ let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null this.setState({check: data && data[btn.field] === btn.openVal}) } - } - /** - * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず - */ - actionSettingError = () => { - notification.warning({ - top: 92, - message: this.state.dict['main.action.settingerror'], - duration: 5 - }) + if (window.GLOB.breakpoint) { + MKEmitter.emit('refreshDebugTable') + } } handleModelConfig = (config) => { @@ -1802,8 +2361,7 @@ if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) - cell.data_sql = Utils.formatOptions(_option.sql) - cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) + cell.base_sql = _option.sql cell.arr_field = _option.field } @@ -1823,10 +2381,10 @@ */ improveAction = () => { const { btn } = this.props - const { btnconfig, autoMatic } = this.state + const { btnconfig } = this.state if (btnconfig) { - if (!autoMatic && (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1870,7 +2428,7 @@ this.setState({ btnconfig: _LongParam }, () => { - if (!autoMatic && (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec')) { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1888,6 +2446,7 @@ */ handleOk = () => { if (!this.formRef) return + this.formRef.handleConfirm().then(res => { this.setState({ confirmLoading: true }) @@ -1907,76 +2466,107 @@ } modelconfirm = () => { - const { BData, btn } = this.props + const { btn, BID } = this.props const { btnconfig, selines } = this.state let _this = this let result = [] + let _data = {} + let BData = {} + + if (selines[0]) { + Object.keys(selines[0]).forEach(key => { + _data[key.toLowerCase()] = selines[0][key] + }) + } + if (this.props.BData) { + Object.keys(this.props.BData).forEach(key => { + BData[key.toLowerCase()] = this.props.BData[key] + }) + } + btnconfig.fields.forEach(item => { if (!item.field) return - let _readin = item.readin !== 'false' - let _initval = item.initval - - if (item.type === 'linkMain' || item.type === 'funcvar') { - _readin = false - } - - if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) { - _initval = BData[item.field] - } else if (_readin && selines[0] && selines[0].hasOwnProperty(item.field)) { - _initval = selines[0][item.field] - } else if (item.type === 'date' && _initval) { - _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') - } else if (item.type === 'datemonth' && _initval) { - _initval = moment().subtract(_initval, 'month').format('YYYY-MM') - } else if (item.type === 'datetime' && _initval) { - _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD HH:mm:ss') - } - - let _fieldlen = item.fieldlength || 50 - if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { - _fieldlen = item.fieldlength || 512 - } else if (item.type === 'number') { - _fieldlen = item.decimal ? item.decimal : 0 - } - - if (_initval === undefined) { - _initval = '' - } - - let _type = item.type - - if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') { - _type = 'text' - } else if (item.type === 'rate') { - item.rateCount = item.rateCount || 5 - let allowHalf = item.allowHalf === 'true' - - if (allowHalf) { - _initval = parseFloat(_initval) - if (_initval % 0.5 !== 0) { - _initval = parseInt(_initval) - } - } else { - _initval = parseInt(_initval) - } - - if (isNaN(_initval) || _initval < 0) { - _initval = 0 - } else if (_initval > item.rateCount) { - _initval = item.rateCount - } - } - - result.push({ + let _item = { key: item.field, - readonly: item.readonly === 'true', readin: item.readin !== 'false' && item.readin !== 'top', - fieldlen: _fieldlen, + fieldlen: item.fieldlength || 50, writein: item.writein !== 'false', - type: _type, - value: _initval - }) + type: item.type + } + + let _initval = item.initval + let _readin = item.readin !== 'false' + let _format = item.precision || 'day' // 鏃堕棿鏍煎紡鍖� + + if (item.type === 'funcvar') { + _initval = '' + _readin = false + _item.readin = false + } else if (item.type === 'linkMain') { + _readin = false + _item.readin = false + } else if (item.type === 'date') { + if (_format !== 'day') { + _format = 'YYYY-MM-DD HH:mm:ss' + } else { + _format = 'YYYY-MM-DD' + } + } else if (item.type === 'datetime') { + _item.type = 'date' + _format = 'YYYY-MM-DD HH:mm:ss' + } + + let key = item.field.toLowerCase() + + if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) { + _initval = BData[key] + } else if (_readin && _data.hasOwnProperty(key)) { + _initval = _data[key] + } else if (_item.type === 'date' && _initval) { + _initval = moment().subtract(_initval, 'days').format(_format) + } else if (_item.type === 'datemonth' && _initval) { + _initval = moment().subtract(_initval, 'month').format('YYYY-MM') + } + + _item.value = _initval === undefined ? '' : _initval + + if (_item.type === 'number' || item.declare === 'decimal') { + _item.type = 'number' + _item.fieldlen = item.decimal || 0 + } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) { + _item.value = _item.value + '' + _item.value = _item.value.replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� + + if (item.interception !== 'false') { // 鍘婚櫎棣栧熬绌烘牸 + _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') + } + if (_item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲 + _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (BID || '')) + } + if (_item.type === 'text' && item.lenControl && item.lenControl !== 'limit') { + if (item.lenControl === 'left') { + _item.value = _item.value.substr(0, item.fieldlength) + } else { + _item.value = _item.value.slice(-item.fieldlength) + } + } + } else if (_item.type.indexOf('date') > -1) { + if (item.declareType === 'nvarchar(50)') { + _item.type = 'text' + } + } else if (_item.type === 'rate') { + let count = item.rateCount || 5 + _item.value = parseInt(_item.value) + + if (isNaN(_item.value) || _item.value < 0) { + _item.value = 0 + } else if (_item.value > count) { + _item.value = count + } + } + + result.push(_item) }) if (btnconfig.setting.display === 'exec') { @@ -2000,12 +2590,12 @@ * @description 鏄剧ず妯℃�佹 */ getModels = () => { - const { setting, BID, btn, BData } = this.props + const { BID, btn, BData } = this.props const { btnconfig, visible } = this.state if (!btnconfig || !btnconfig.setting) return null - let title = btnconfig.setting.title + let title = btn.label let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw' let clickouter = btnconfig.setting.clickouter === 'close' @@ -2030,7 +2620,6 @@ <MutilForm BID={BID} dict={this.state.dict} - menuType={this.props.menuType} action={btnconfig} inputSubmit={this.handleOk} data={this.state.selines[0]} @@ -2050,12 +2639,9 @@ } else { let container = document.body - if ( - (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) || - (btnconfig.setting.container === 'tab' && btn.ContainerId) - ) { + if (btnconfig.setting.container === 'tab' && btn.ContainerId) { width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%' - container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) + container = () => document.getElementById(btn.ContainerId) } return ( <Modal @@ -2073,7 +2659,6 @@ <MutilForm BID={BID} dict={this.state.dict} - menuType={this.props.menuType} action={btnconfig} inputSubmit={this.handleOk} data={this.state.selines[0]} @@ -2086,81 +2671,64 @@ } render() { - const { btn, show, style } = this.props - const { loadingNumber, loading, disabled, hidden, check } = this.state + const { btn } = this.props + const { loadingNumber, loadingTotal, loading, disabled, hidden, check } = this.state if (hidden) return null if (btn.OpenType === 'form') { - if (btn.formType === 'switch') { - return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/> + if (btn.formType === 'switch') { + return <Switch loading={loading} checked={check} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style} className={btn.size === 'large' ? 'ant-switch-large' : ''} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/> + } else if (btn.formType === 'radio') { + return <Checkbox disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox> } else { - return <Checkbox disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={style}></Checkbox> + return <Button type="link" icon="scan" disabled={true} style={btn.style} onClick={(e) => {e.stopPropagation()}}></Button> } - } else if (show === 'actionList') { - return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> - <Button - style={style} - icon={btn.icon} - loading={loading} - disabled={disabled} - title={disabled ? (btn.reason || '') : ''} - className={'mk-btn mk-' + btn.class} - onClick={() => {this.actionTrigger()}} - >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button> - {this.getModels()} - </div> - } else if (show && show.indexOf('plus') > -1) { - return <div style={{display: 'inline-block'}}> - <Button - type="link" - loading={loading} - icon={btn.icon || 'plus'} - style={{fontSize: show.substring(4) + 'px'}} - onClick={() => {this.actionTrigger()}} - ></Button> - {this.getModels()} - </div> - } else { // icon銆乼ext銆� all 鍗$墖 - let label = '' - let icon = '' - - if (show === 'button') { - label = btn.label - icon = btn.icon || '' - } else if (show === 'link') { - label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> - icon = '' - } else if (show === 'icon') { - icon = btn.icon || '' - } else { - label = btn.label - } - - return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> - <Button - type="link" - title={disabled ? (btn.reason || '') : (show === 'icon' ? btn.label : '')} - loading={loading} - disabled={disabled} - style={btn.style || style} - icon={icon} - onClick={() => {this.actionTrigger()}} - >{label}</Button> - {this.getModels()} - </div> } + + 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 = '' + } else if (btn.show === 'icon') { + icon = btn.icon || '' + } else if (!btn.$toolbtn) { + icon = btn.icon || '' + label = btn.label + className = 'mk-btn mk-' + (btn.class || 'unset') + } else { + type = '' + icon = btn.icon || '' + label = btn.label + className = 'mk-btn mk-' + (btn.class || 'unset') + } + + if (loadingNumber && !loadingTotal && btn.$toolbtn && (!btn.show || btn.show === 'button')) { + label = (loadingNumber && !loadingTotal ? `(${loadingNumber})` : '') + btn.label + } + + return <> + <Button + type={type} + icon={icon} + title={disabled ? (btn.reason || '') : (btn.show === 'icon' ? btn.label : '')} + loading={loading} + disabled={disabled} + style={btn.style} + className={className} + onClick={(e) => {e.stopPropagation(); this.actionTrigger()}} + >{label}</Button> + <span onClick={(e) => {e.stopPropagation()}}>{this.getModels()}</span> + {loadingTotal ? <Progress className="mk-button-progress" percent={(loadingTotal - loadingNumber) / loadingTotal * 100} size="small" showInfo={false} /> : null} + </> } } -const mapStateToProps = (state) => { - return { - menuType: state.editLevel - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(NormalButton) \ No newline at end of file +export default NormalButton \ No newline at end of file -- Gitblit v1.8.0