From 98ed63fb6b2380bb8a9f562a8d1fc7783288635e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 06 三月 2023 17:32:19 +0800 Subject: [PATCH] 2023-03-06 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 419 +++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 276 insertions(+), 143 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 3e58939..29ac925 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -42,7 +42,6 @@ loadingTotal: '', disabled: false, hidden: false, - checkParam: null, autoMatic: false, check: false } @@ -50,30 +49,11 @@ moduleParams = null UNSAFE_componentWillMount () { - const { btn, selectedData, BData } = this.props - let disabled = false + const { btn, selectedData, BData, disabled } = this.props - if (btn.controlField && selectedData && selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� - selectedData.forEach(item => { - let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' - if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { - disabled = true - } - }) - this.setState({hidden: disabled && btn.control === 'hidden'}) - } else if (btn.control === 'parent') { - if (!BData || !BData.hasOwnProperty(btn.controlField)) { - this.setState({hidden: true}) - } else { - let s = BData[btn.controlField] + '' - if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { - this.setState({hidden: true}) - } else { - this.setState({hidden: false}) - } - } - } - if (this.props.disabled || disabled) { + if (btn.controlField) { + this.setStatus(btn, selectedData || [], BData, disabled) + } else if (disabled) { this.setState({disabled: true}) } @@ -105,36 +85,12 @@ } UNSAFE_componentWillReceiveProps (nextProps) { - const { btn, selectedData, BData } = this.props + const { btn } = this.props - let disabled = false - if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { - if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 琛ㄦ牸涓寜閽殣钘忔帶鍒� - nextProps.selectedData.forEach(item => { - let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' - if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { - disabled = true - } - }) - } - this.setState({hidden: disabled && btn.control === 'hidden'}) - } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) { - if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) { - this.setState({hidden: true}) - } else { - let s = nextProps.BData[btn.controlField] + '' - if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { - this.setState({hidden: true}) - } else { - this.setState({hidden: false}) - } - } - } - - if (nextProps.disabled || disabled) { - this.setState({disabled: true}) + if (btn.controlField) { + this.setStatus(btn, nextProps.selectedData || [], nextProps.BData, nextProps.disabled) } else { - this.setState({disabled: false}) + this.setState({disabled: nextProps.disabled === true}) } if (btn.OpenType === 'form') { @@ -154,6 +110,43 @@ MKEmitter.removeListener('triggerBtnId', this.actionTrigger) MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) + } + + setStatus = (btn, data, BData, disprop) => { + let disabled = false + let hidden = false + + if (btn.control !== 'parent') { + if (data.length > 0) { + data.forEach(item => { + let s = item[btn.controlField] !== undefined ? item[btn.controlField] + '' : '' + if (btn.controlVals.includes(s)) { + disabled = true + } + }) + } else if (btn.controlVals.includes('')) { + disabled = true + } + } else { + if (!BData || !BData.hasOwnProperty(btn.controlField)) { + hidden = true + } else { + let s = BData[btn.controlField] + '' + if (btn.controlVals.includes(s)) { + hidden = true + } + } + } + + if (disabled && btn.control === 'hidden') { + hidden = true + } + + if (disprop) { + disabled = true + } + + this.setState({hidden, disabled}) } triggerBtnPopSubmit = (id) => { @@ -402,7 +395,6 @@ let param = { // 绯荤粺瀛樺偍杩囩▼ func: 'sPC_TableData_InUpDe' } - let check_param = null if (this.props.BID) { param.BID = this.props.BID @@ -442,11 +434,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, '') } @@ -487,11 +477,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, '') } @@ -522,11 +510,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, '') } @@ -536,9 +522,6 @@ 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 @@ -547,13 +530,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) @@ -589,11 +577,18 @@ } 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) { @@ -629,11 +624,18 @@ } 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 @@ -655,11 +657,18 @@ } 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) } } @@ -675,6 +684,16 @@ 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' + } } return param @@ -842,7 +861,7 @@ } // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) - if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) { + if (data && btn.Ot !== 'notRequired' && columns && columns.length > 0) { datavars = {...data, ...datavars} const setField = (col) => { @@ -948,6 +967,7 @@ _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(/@typename@/ig, `'admin'`) return _sql } @@ -995,7 +1015,9 @@ params = this.getInnerParam(data, formdata) } - if (params.length <= 20) { + if (params[0].$unCheckParam) { + this.checkLoopRequest(params, _resolve) + } else if (params.length <= 20 && btn.execType !== 'single') { let deffers = params.map((param, i) => { return new Promise(resolve => { setTimeout(() => { @@ -1041,6 +1063,7 @@ let iserror = false let errorMsg = '' result.forEach(res => { + if (iserror) return if (res.status) { errorMsg = res } else { @@ -1056,7 +1079,7 @@ _resolve() }) } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц - if (btn.progress === 'progressbar' && btn.$toolbtn) { + if (btn.progress === 'progressbar' && btn.$toolbtn && params.length > 1) { this.setState({ loadingTotal: params.length }) @@ -1430,6 +1453,14 @@ sql = _prevCustomScript + sql sql = sql + _backCustomScript + sql = sql.replace(/@ID@/ig, `'${record.ID || ''}'`) + sql = sql.replace(/@BID@/ig, `'${this.props.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(/@typename@/ig, `'admin'`) + if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { console.info(sql.replace(/\n\s{8}/ig, '\n')) } @@ -1529,6 +1560,69 @@ } else { this.innerLoopRequest(params, btn, _resolve) } + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus() + _resolve() + }) + } + + /** + * @description 鏁版嵁妫�楠屽惊鐜墽琛� + */ + checkLoopRequest = (params, _resolve) => { + let param = params.shift() + let unCheckParam = param.$unCheckParam + + delete param.$unCheckParam + + this.setState({ + loadingNumber: params.length + }) + + Api.genericInterface(param).then(res => { + if (res.status) { + this.triggerNote(res) // 娑堟伅 + + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + 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() @@ -1828,21 +1922,38 @@ * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execSuccess = (res) => { + execSuccess = (res = {}) => { const { btn } = this.props const { btnconfig, autoMatic } = this.state - if ((res && (res.ErrCode === 'S' || !res.ErrCode)) || autoMatic) { // 鎵ц鎴愬姛 + if (res.message && /^@speak@/.test(res.message)) { + res.message = res.message.replace('@speak@', '') + let val = res.message.match(/<<.*>>/) + res.message = res.message.replace(/\s*<<.*>>\s*/g, '') + val = val ? val[0].replace(/<<|>>/g, '') : '' + + if (/^http/.test(val)) { + let audio = document.createElement('audio') + audio.src = val + audio.play() + } + + if (!res.message) { + res.ErrCode = '-1' + } + } + + if ((res.ErrCode === 'S' || !res.ErrCode) || autoMatic) { // 鎵ц鎴愬姛 notification.success({ top: 92, - message: res.ErrMesg || this.state.dict['main.action.confirm.success'], + message: res.message || '鎵ц鎴愬姛锛�', duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 }) - } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛 + } else if (res.ErrCode === 'Y') { // 鎵ц鎴愬姛 Modal.success({ - title: res.ErrMesg || this.state.dict['main.action.confirm.success'] + title: res.message || '鎵ц鎴愬姛锛�' }) - } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + } else if (res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず } @@ -1929,11 +2040,7 @@ newtab = {...newtab, param: { $BID: id }} - if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) { - MKEmitter.emit('modifyTabs', newtab, 'replace') - } else { - MKEmitter.emit('modifyTabs', newtab, 'plus', true) - } + MKEmitter.emit('modifyTabs', newtab, true) } } @@ -2209,25 +2316,42 @@ const { btn } = this.props const { btnconfig, autoMatic } = this.state + if (res.message && /^@speak@/.test(res.message)) { + res.message = res.message.replace('@speak@', '') + let val = res.message.match(/<<.*>>/) + res.message = res.message.replace(/\s*<<.*>>\s*/g, '') + val = val ? val[0].replace(/<<|>>/g, '') : '' + + if (/^http/.test(val)) { + let audio = document.createElement('audio') + audio.src = val + audio.play() + } + + if (!res.message) { + res.ErrCode = '-1' + } + } + if (res.ErrCode === 'E' && !autoMatic) { Modal.error({ - title: res.message || res.ErrMesg, + title: res.message || '鎵ц澶辫触锛�', }) } else if (res.ErrCode === 'N' || autoMatic) { notification.error({ top: 92, - message: res.message || res.ErrMesg, + message: res.message || '鎵ц澶辫触锛�', 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 || res.ErrMesg, + message: res.message || '鎵ц澶辫触锛�', duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 10 }) } else if (res.ErrCode === 'NM') { - message.error(res.message || res.ErrMesg) + message.error(res.message || '鎵ц澶辫触锛�') } if (autoMatic) { @@ -2249,48 +2373,6 @@ 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) @@ -2317,8 +2399,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 } @@ -2347,7 +2428,20 @@ this.setState({ visible: true }) + + if (btnconfig.setting.display === 'modal' && btnconfig.setting.moveable === 'true') { + setTimeout(() => { + this.setMove() + }, 100) + } } + } else if (!btn.$old) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�', + duration: 5 + }) + this.setState({ loading: false }) } else { Api.getCacheConfig({ func: 'sPC_Get_LongParam', @@ -2600,15 +2694,17 @@ width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%' container = () => document.getElementById(btn.ContainerId) } + return ( <Modal title={title} maskClosable={clickouter} getContainer={container} - wrapClassName='action-modal' + wrapClassName={'action-modal' + (btnconfig.setting.moveable === 'true' ? ' moveable-modal modal-' + btn.uuid : '')} visible={visible} width={width} onOk={this.handleOk} + maskStyle={btnconfig.setting.moveable === 'true' ? {backgroundColor: 'rgba(0, 0, 0, 0.15)'} : null} confirmLoading={this.state.confirmLoading} onCancel={this.handleCancel} destroyOnClose @@ -2627,6 +2723,43 @@ } } + setMove = () => { + const { btn } = this.props + let wrap = document.getElementsByClassName('modal-' + btn.uuid)[0] + + if (!wrap) return + + let node = wrap.getElementsByClassName('ant-modal-header')[0] + + if (!node) return + + node.onmousedown = function(e) { + let orileft = 0 + let oritop = 0 + let oleft = e.clientX + let otop = e.clientY + + if (node.parentNode.style.left) { + orileft = parseFloat(node.parentNode.style.left) + } + if (node.parentNode.style.top) { + oritop = parseFloat(node.parentNode.style.top) + } + + document.onmousemove = function(e) { + let left = e.clientX - oleft + let top = e.clientY - otop + + node.parentNode.style.left = (orileft + left) + 'px' + node.parentNode.style.top = (oritop + top) + 'px' + } + } + + document.onmouseup = function() { + document.onmousemove = null + } + } + render() { const { btn } = this.props const { loadingNumber, loadingTotal, loading, disabled, hidden, check } = this.state @@ -2637,7 +2770,7 @@ 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> + return <Checkbox className={btn.checkType || ''} disabled={disabled || loading} title={disabled ? (btn.reason || '') : ''} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={btn.style}></Checkbox> } else { return <Button type="link" icon="scan" disabled={true} style={btn.style} onClick={(e) => {e.stopPropagation()}}></Button> } -- Gitblit v1.8.0