From 31ec63f0419895876cbaba99637a884a32d33d0d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 01 九月 2021 10:31:45 +0800 Subject: [PATCH] 2021-09-01 --- src/templates/sharecomponent/actioncomponent/index.jsx | 217 ++++++++++++++++++++++------------------------------- 1 files changed, 90 insertions(+), 127 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index 9d03aa8..50cdb74 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -5,39 +5,37 @@ import moment from 'moment' import Api from '@/api' -import options from '@/store/options.js' -import Utils from '@/utils/utils.js' -import DevUtils from '@/utils/devutils.js' +import Utils, { FuncUtils } from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import { getActionForm } from '@/templates/zshare/formconfig' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import ActionForm from './actionform' -import VerifyCard from '@/templates/zshare/verifycard' import CreateFunc from '@/templates/zshare/createfunc' import CreateInterface from '@/templates/zshare/createinterface' -import VerifyPrint from './verifyprint' -import VerifyExcelIn from './verifyexcelin' -import VerifyExcelOut from './verifyexcelout' +import { updateForm } from '@/utils/utils-update.js' import DragElement from './dragaction' import './index.scss' const { confirm } = Modal +const VerifyCard = asyncSpinComponent(() => import('@/templates/zshare/verifycard')) +const VerifyPrint = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyprint')) +const VerifyExcelIn = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelin')) +const VerifyExcelOut = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelout')) class ActionComponent extends Component { static propTpyes = { type: PropTypes.string, // 鑿滃崟绫诲瀷锛屼富琛ㄦ垨瀛愯〃 menu: PropTypes.object, // 鑿滃崟淇℃伅锛堣彍鍗昳d锛岃彍鍗曞弬鏁帮紝鑿滃崟鍚嶇О锛� config: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 - pasteContent: PropTypes.object, // 绮樿创閰嶇疆淇℃伅 - usefulFields: PropTypes.array, // 鑷畾涔夊嚱鏁板彲鐢ㄥ瓧娈� tabs: PropTypes.array, // 鎵�鏈夋爣绛� setSubConfig: PropTypes.func, // 璁剧疆瀛愰厤缃俊鎭� updateaction: PropTypes.func // 鑿滃崟閰嶇疆鏇存柊 } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, card: null, // 缂栬緫涓厓绱� formlist: null, // 琛ㄥ崟淇℃伅 actionlist: null, // 鎸夐挳缁� @@ -62,10 +60,12 @@ UNSAFE_componentWillReceiveProps (nextProps) { const { actionlist } = this.state - if (nextProps.pasteContent && nextProps.pasteContent.copyType === 'action') { - this.setState({actionlist: [...actionlist, nextProps.pasteContent]}) - this.handleAction(nextProps.pasteContent) - } else if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) { + if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) { + let len = nextProps.config.action.length + let item = nextProps.config.action[len - 1] + if (item && item.focus) { + this.handleAction(item) + } this.setState({actionlist: fromJS(nextProps.config.action).toJS()}) } } @@ -75,11 +75,11 @@ } getBillPrintTemp = () => { - let _sql = `select PrintTempNO,Images,PrintTempNO+PrintTempName as PN from sPrintTemplate - where appkey= @appkey@ and Deleted=0 and typechartwo='web_print' + let _sql = `select ID,Images,PrintTempNO+PrintTempName as PN from sPrintTemplate + where appkey= @appkey@ and Deleted=0 and typechartwo='web_print' union select ID,Images,a.PrintTempNO+PrintTempName as PN - from (select * from sPrintTemplate where appkey= '' and Deleted=0 and typechartwo='web_print') a - left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@ and Deleted=0 ) b + from (select * from sPrintTemplate where appkey= '' and Deleted=0 and typechartwo='web_print') a + left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@ and Deleted=0 ) b on a.PrintTempNO=b.PrintTempNO left join (select Srcid from sPrintTemplate_Log where appkey='' and apicode= @appkey@ and Deleted=0 ) c on a.ID=c.Srcid where b.PrintTempNO is null and c.Srcid is null` @@ -88,7 +88,7 @@ func: 'sPC_Get_SelectedList', LText: Utils.formatOptions(_sql), obj_name: 'data', - arr_field: 'PN,PrintTempNO,Images' + arr_field: 'PN,ID,Images' } param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -100,7 +100,7 @@ if (res.status) { let temps = res.data.map(temp => { return { - value: temp.PrintTempNO, + value: temp.ID, text: temp.PN } }) @@ -139,98 +139,71 @@ */ handleAction = (card) => { const { menu } = this.props - let ableField = this.props.usefulFields.join(', ') + + let usefulFields = sessionStorage.getItem('permFuncField') + if (usefulFields) { + try { + usefulFields = JSON.parse(usefulFields) + } catch (e) { + usefulFields = [] + } + } else { + usefulFields = [] + } + + let ableField = usefulFields.join(', ') let functip = <div> <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p> - <p>{this.state.dict['model.tooltip.func.outface']}</p> </div> let menulist = [] + if (menu.fstMenuList) { - menulist = menu.fstMenuList.map(item => { - return { - value: item.MenuID, - label: item.text, - isLeaf: false - } - }) - } + let trees = fromJS(menu.fstMenuList).toJS() - if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) { - let _param = { - func: 'sPC_Get_FunMenu', - ParentID: card.linkmenu[0], - systemType: options.sysType, - debug: 'Y' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - menulist = menulist.map(item => { - if (item.value === card.linkmenu[0]) { - item.children = result.data.map(item => { - let submenu = { - value: item.ParentID, - label: item.MenuNameP, - children: item.FunMenu.map(cell => { - return { - value: cell.MenuID, - label: cell.MenuName, - MenuID: cell.MenuID, - MenuName: cell.MenuName, - MenuNo: cell.MenuNo, - Ot: cell.Ot, - PageParam: cell.PageParam, - LinkUrl: cell.LinkUrl, - disabled: cell.MenuID === menu.MenuID - } - }) - } + menulist = trees.map(fst => { + fst.value = fst.MenuID + fst.label = fst.MenuName + fst.isLeaf = false + fst.children = fst.children.map(snd => { + snd.value = snd.MenuID + snd.label = snd.MenuName - return submenu - }) - } - return item + snd.children = snd.children.map(thd => { + thd.value = thd.MenuID + thd.label = thd.MenuName + thd.disabled = thd.MenuID === menu.MenuID + return thd }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist, this.state.printTemps) + return snd }) - }) - } else { - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist, this.state.printTemps) + return fst }) } + + this.setState({ + visible: true, + card: card, + formlist: getActionForm(card, functip, this.props.config, usefulFields, this.props.type, menulist, this.state.printTemps) + }) } /** * @description 鍙栨秷淇濆瓨锛屽鏋滃厓绱犱负鏂版坊鍏冪礌锛屽垯浠庡簭鍒椾腑鍒犻櫎 */ editModalCancel = () => { - const { card } = this.state + const { config } = this.props + const { card, actionlist } = this.state if (card.focus) { - let actionlist = fromJS(this.state.actionlist).toJS() - - actionlist = actionlist.filter(item => item.uuid !== card.uuid) + let _actionlist = actionlist.filter(item => item.uuid !== card.uuid) this.setState({ card: null, - actionlist: actionlist, + actionlist: _actionlist, visible: false }) + this.props.updateaction({...config, action: _actionlist}) } else { this.setState({ card: null, @@ -270,7 +243,7 @@ if (labelrepet) { notification.warning({ top: 92, - message: this.state.dict['model.name.exist'] + ' !', + message: '鍚嶇О宸插瓨鍦�!', duration: 5 }) return @@ -290,12 +263,12 @@ new Promise(resolve => { if ( !card.originCard || - (btn.OpenType === 'pop' && card.originCard.OpenType !== 'pop') || - (['tab', 'blank'].includes(btn.OpenType) && !['tab', 'blank'].includes(card.originCard.OpenType)) || - (btn.OpenType === 'popview' && (!btn.createTab || card.originCard.OpenType !== 'popview' || !card.originCard.linkTab)) + (btn.OpenType !== card.originCard.OpenType) || + (btn.OpenType === 'tab' && btn.tabTemplate !== 'FormTab') || + (btn.OpenType === 'funcbutton' && btn.execMode !== 'pop') ) { // 鎸夐挳涓嶆槸澶嶅埗锛屾垨鎸夐挳鍓嶅悗绫诲瀷涓嶄竴鑷存椂锛岀洿鎺ヤ繚瀛� resolve('save') - } else if (btn.OpenType === 'pop' || btn.OpenType === 'tab' || btn.OpenType === 'blank') { + } else if (btn.OpenType === 'pop' || btn.OpenType === 'tab' || btn.execMode === 'pop') { resolve('subconf') } else if (btn.OpenType === 'popview') { resolve('subtab') @@ -325,20 +298,21 @@ } } + if (!_LongParam) return 'save' + let _temp = '' // 閰嶇疆淇℃伅绫诲瀷 // 淇敼妯℃�佹鏍囬鍚嶇О - if (btn.OpenType === 'pop' && _LongParam && _LongParam.type === 'Modal') { + if ((btn.OpenType === 'pop' || btn.execMode === 'pop') && _LongParam.type === 'Modal') { try { _LongParam.setting.title = btn.label _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam))) _temp = 'Modal' - } catch { + } catch (e) { console.warn('Stringify Failure') - _LongParam = '' _temp = '' } - } else if (['tab', 'blank'].includes(btn.OpenType) && _LongParam && _LongParam.type === 'FormTab') { + } else if (btn.OpenType === 'tab' && _LongParam.type === 'FormTab') { try { _LongParam.action = _LongParam.action.map(_btn => { _btn.uuid = Utils.getuuid() @@ -354,9 +328,8 @@ }) _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam))) _temp = 'FormTab' - } catch { + } catch (e) { console.warn('Stringify Failure') - _LongParam = '' _temp = '' } } @@ -512,7 +485,7 @@ _tab.action = _tab.action.map((item, index) => { let uuid = Utils.getuuid() - if (item.OpenType === 'pop') { + if (item.OpenType === 'pop' || item.execMode === 'pop') { _oriActions.push({ prebtn: JSON.parse(JSON.stringify(item)), curuuid: uuid, @@ -549,7 +522,7 @@ btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_tab))) - } catch { + } catch (e) { console.warn('Stringify Failure') _LongParam = '' _resolve('save') @@ -772,23 +745,16 @@ } if (_LongParam) { - let fields = [] - if (_LongParam.groups.length > 0) { - _LongParam.groups.forEach(group => { - fields = [...fields, ...group.sublist] - }) - } else { - fields = _LongParam.fields - } + _LongParam = updateForm(_LongParam) let _param = { funcName: btn.innerFunc, name: _config.setting.tableName || '', - fields: fields, + fields: _LongParam.fields, menuNo: menu.MenuNo } - newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } else { notification.warning({ @@ -805,8 +771,8 @@ funcName: btn.innerFunc, menuNo: menu.MenuNo } - newLText = Utils.formatOptions(DevUtils.getexcelInfunc(_param, btn, menu)) - DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getexcelInfunc(_param, btn, menu)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } else { notification.warning({ @@ -821,8 +787,8 @@ innerFunc: btn.innerFunc } - newLText = Utils.formatOptions(DevUtils.getTableFunc(_param, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getTableFunc(_param, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } else { @@ -832,8 +798,8 @@ fields: '', menuNo: menu.MenuNo } - newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } }).then(res => { @@ -865,15 +831,12 @@ /** * @description 鎸夐挳鍙屽嚮瑙﹀彂瀛愰厤缃� */ - btnDoubleClick = (element) => { - if (!element.origin && (element.OpenType === 'pop' || element.OpenType === 'popview' || element.OpenType === 'blank' || element.OpenType === 'tab')) { - this.props.setSubConfig(element) + btnDoubleClick = (el) => { + // execMode === 'pop' 涓� OpenType === 'funcbutton' + if (!el.origin && (el.OpenType === 'pop' || el.execMode === 'pop' || el.OpenType === 'popview' || (el.OpenType === 'tab' && el.tabTemplate === 'FormTab'))) { + this.props.setSubConfig(el) } else { - notification.warning({ - top: 92, - message: '姝ゆ寜閽棤瀛愰厤缃」锛�', - duration: 5 - }) + this.handleAction(el) } } @@ -912,8 +875,9 @@ {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} <Modal title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} + wrapClassName="model-table-action-edit-modal" visible={visible} - width={800} + width={850} maskClosable={false} onCancel={this.editModalCancel} footer={[ @@ -941,7 +905,6 @@ visible={profVisible} width={'75vw'} maskClosable={false} - style={{minWidth: '900px', maxWidth: '1200px'}} okText={dict['model.submit']} onOk={this.verifySubmit} onCancel={() => { this.setState({ profVisible: false }) }} -- Gitblit v1.8.0