From c45a375e5b4ce0e33c7fc8a1aecdad67d60acc9e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 01 三月 2021 15:09:06 +0800 Subject: [PATCH] 2021-03-01 --- src/templates/sharecomponent/actioncomponent/index.jsx | 313 +++++++++++++++++++++++++++------------------------ 1 files changed, 165 insertions(+), 148 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index 43ee854..37ef9f8 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -1,48 +1,46 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' +import { is, fromJS } from 'immutable' import { Icon, Tooltip, Modal, notification, Button } from 'antd' import moment from 'moment' import Api from '@/api' -import Utils from '@/utils/utils.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 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')) -// **鎮茶鑰呭線寰�姝g‘锛屼箰瑙傝�呭線寰�鎴愬姛 class ActionComponent extends Component { static propTpyes = { type: PropTypes.string, // 鑿滃崟绫诲瀷锛屼富琛ㄦ垨瀛愯〃 menu: PropTypes.object, // 鑿滃崟淇℃伅锛堣彍鍗昳d锛岃彍鍗曞弬鏁帮紝鑿滃崟鍚嶇О锛� config: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 - menuformRef: PropTypes.any, // 鑿滃崟鍩烘湰淇℃伅琛ㄥ崟瀵硅薄 - pasteContent: PropTypes.object, // 绮樿创閰嶇疆淇℃伅 - usefulFields: PropTypes.array, // 鑷畾涔夊嚱鏁板彲鐢ㄥ瓧娈� tabs: PropTypes.array, // 鎵�鏈夋爣绛� setSubConfig: PropTypes.func, // 璁剧疆瀛愰厤缃俊鎭� updateaction: PropTypes.func // 鑿滃崟閰嶇疆鏇存柊 } state = { - dict: (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS, + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, card: null, // 缂栬緫涓厓绱� formlist: null, // 琛ㄥ崟淇℃伅 actionlist: null, // 鎸夐挳缁� copying: false, // 鎸夐挳澶嶅埗涓� visible: false, // 妯℃�佹鎺у埗 + printTemps: [], // 鍗曟嵁鎵撳嵃妯℃澘 profVisible: false // 楠岃瘉淇℃伅妯℃�佹 } @@ -61,10 +59,62 @@ UNSAFE_componentWillReceiveProps (nextProps) { const { actionlist } = this.state - if (nextProps.pasteContent && nextProps.pasteContent.copyType === 'action') { - this.setState({actionlist: [...actionlist, nextProps.pasteContent]}) - this.handleAction(nextProps.pasteContent) + 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()}) } + } + + componentDidMount () { + this.getBillPrintTemp() + } + + getBillPrintTemp = () => { + 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 + 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` + + let param = { + func: 'sPC_Get_SelectedList', + LText: Utils.formatOptions(_sql), + obj_name: 'data', + arr_field: 'PN,ID,Images' + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉 + + Api.getSystemConfig(param).then(res => { + if (res.status) { + let temps = res.data.map(temp => { + return { + value: temp.ID, + text: temp.PN + } + }) + + this.setState({ + printTemps: temps + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) } /** @@ -77,25 +127,63 @@ this.setState({actionlist: list}) this.handleAction(card) } else { - this.setState({actionlist: list}) - this.props.updateaction({...config, action: list}) + this.setState({actionlist: list}, () => { + this.props.updateaction({...config, action: list}) + }) } } /** - * @description 鎼滅储鏉′欢缂栬緫锛岃幏鍙栨悳绱㈡潯浠惰〃鍗曚俊鎭� + * @description 鎸夐挳缂栬緫锛岃幏鍙栨寜閽〃鍗曚俊鎭� */ handleAction = (card) => { - let ableField = this.props.usefulFields.join(', ') + const { menu } = this.props + + let usefulFields = sessionStorage.getItem('permFuncField') + if (usefulFields) { + try { + usefulFields = JSON.parse(usefulFields) + } catch { + 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) { + let trees = fromJS(menu.fstMenuList).toJS() + + 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 + + snd.children = snd.children.map(thd => { + thd.value = thd.MenuID + thd.label = thd.MenuName + thd.disabled = thd.MenuID === menu.MenuID + return thd + }) + return snd + }) + return fst + }) + } this.setState({ visible: true, card: card, - formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type) + formlist: getActionForm(card, functip, this.props.config, usefulFields, this.props.type, menulist, this.state.printTemps) }) } @@ -103,18 +191,18 @@ * @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, @@ -131,14 +219,9 @@ * 4銆佷笅鎷夎彍鍗曟暟鎹簮璇硶楠岃瘉 */ handleSubmit = () => { - const { config, menuformRef } = this.props + const { config, menu } = this.props const { card } = this.state let _actionlist = fromJS(this.state.actionlist).toJS() - let menu = fromJS(this.props.menu).toJS() // 鑿滃崟淇℃伅锛屽瓨鍦ㄨ〃鍗曞璞℃椂锛屼粠鑿滃崟涓洿鏂� - - if (menuformRef) { - menu = {...menu, MenuName: menuformRef.props.form.getFieldValue('MenuName'), MenuNo: menuformRef.props.form.getFieldValue('MenuNo')} - } this.actionFormRef.handleConfirm().then(btn => { _actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid) @@ -159,7 +242,7 @@ if (labelrepet) { notification.warning({ top: 92, - message: this.state.dict['model.name.exist'] + ' !', + message: '鍚嶇О宸插瓨鍦�!', duration: 5 }) return @@ -179,12 +262,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') @@ -214,20 +297,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 { 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() @@ -245,7 +329,6 @@ _temp = 'FormTab' } catch { console.warn('Stringify Failure') - _LongParam = '' _temp = '' } } @@ -338,7 +421,7 @@ Align: 'center', IsSort: 'false', uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], + label: this.state.dict['model.operation'], type: 'action', style: 'button', show: 'horizontal', @@ -350,9 +433,9 @@ actionlist: _actionlist, copying: false, visible: false + }, () => { + this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, copyActionId) }) - - this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, copyActionId) }) }) } @@ -401,7 +484,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, @@ -434,7 +517,7 @@ btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) - btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_tab))) @@ -543,17 +626,11 @@ confirm({ content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} 锛焋, - okText: dict['model.confirm'], - cancelText: this.state.dict['header.cancel'], onOk() { let _actionlist = fromJS(_this.state.actionlist).toJS() _actionlist = _actionlist.filter(item => item.uuid !== card.uuid) - _this.setState({ - actionlist: _actionlist - }) - let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0 let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null @@ -565,7 +642,7 @@ Align: 'center', IsSort: 'false', uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], + label: this.state.dict['model.operation'], type: 'action', style: 'button', show: 'horizontal', @@ -578,7 +655,11 @@ card: card } - _this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, '', delcard) + _this.setState({ + actionlist: _actionlist + }, () => { + _this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, '', delcard) + }) }, onCancel() {} }) @@ -603,7 +684,6 @@ this.verifyRef.handleConfirm().then(res => { let _actionlist = fromJS(this.state.actionlist).toJS() - _actionlist = _actionlist.filter(item => !item.origin || item.uuid === card.uuid) _actionlist = _actionlist.map(item => { @@ -617,8 +697,9 @@ this.setState({ actionlist: _actionlist, profVisible: false + }, () => { + this.props.updateaction({...config, action: _actionlist}) }) - this.props.updateaction({...config, action: _actionlist}) }) } @@ -626,50 +707,19 @@ * @description 鍒涘缓鎸夐挳瀛樺偍杩囩▼ */ creatFunc = () => { - const { config, menuformRef } = this.props + const { menu } = this.props let _config = fromJS(this.props.config).toJS() - let menu = fromJS(this.props.menu).toJS() // 鑿滃崟淇℃伅锛屽瓨鍦ㄨ〃鍗曞璞℃椂锛屼粠鑿滃崟涓洿鏂� - - if (menuformRef) { - menu = {...menu, MenuName: menuformRef.props.form.getFieldValue('MenuName'), MenuNo: menuformRef.props.form.getFieldValue('MenuNo')} - } this.actionFormRef.handleConfirm().then(res => { let btn = res // 鎸夐挳淇℃伅 let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - let _actionlist = fromJS(this.state.actionlist).toJS() - - _actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid) - - let labelrepet = false - _actionlist = _actionlist.map(item => { - if (item.uuid !== btn.uuid && item.label === btn.label) { - labelrepet = true - } - - if (item.uuid === btn.uuid) { - return btn - } else { - return item - } - }) - - if (labelrepet) { - notification.warning({ - top: 92, - message: this.state.dict['model.name.exist'] + ' !', - duration: 5 - }) - return - } - // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 - if (!btn.innerFunc) { + if (btn.intertype !== 'inner') { notification.warning({ top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁帮紒', + message: '浣跨敤鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', duration: 5 }) return @@ -709,8 +759,8 @@ fields: fields, menuNo: menu.MenuNo } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(Utils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } else { notification.warning({ @@ -727,8 +777,8 @@ funcName: btn.innerFunc, menuNo: menu.MenuNo } - newLText = Utils.formatOptions(Utils.getexcelInfunc(_param, btn, menu)) - DelText = Utils.formatOptions(Utils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getexcelInfunc(_param, btn, menu)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } else { notification.warning({ @@ -743,8 +793,8 @@ innerFunc: btn.innerFunc } - newLText = Utils.formatOptions(Utils.getTableFunc(_param, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - DelText = Utils.formatOptions(Utils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getTableFunc(_param, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } else { @@ -754,42 +804,14 @@ fields: '', menuNo: menu.MenuNo } - newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(Utils.dropfunc(btn.innerFunc)) + newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) + DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) resolve(true) } }).then(res => { if (!res) return - this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { - if (result !== 'success') return - - // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� - let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0 - let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null - - if (_gridBtn) { - _gridBtn.display = _hasGridbtn - } else { - _gridBtn = { - display: _hasGridbtn, - Align: 'center', - IsSort: 'false', - uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], - type: 'action', - style: 'button', - show: 'horizontal', - Width: 120 - } - } - - this.setState({ - actionlist: _actionlist - }) - - this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}) - }) + this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText) }) }) } @@ -798,15 +820,9 @@ * @description 鍒涘缓鎸夐挳鎺ュ彛锛堝啓鍏ワ級 */ btnCreatInterface = () => { - const { config, type, menuformRef } = this.props - let menu = fromJS(this.props.menu).toJS() // 鑿滃崟淇℃伅锛屽瓨鍦ㄨ〃鍗曞璞℃椂锛屼粠鑿滃崟涓洿鏂� - - if (menuformRef) { - menu = {...menu, MenuName: menuformRef.props.form.getFieldValue('MenuName'), MenuNo: menuformRef.props.form.getFieldValue('MenuNo')} - } + const { config, type, menu } = this.props this.actionFormRef.handleConfirm().then(result => { - let _menu = { type: type, MenuID: menu.MenuID, @@ -821,9 +837,10 @@ /** * @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, @@ -831,6 +848,10 @@ duration: 5 }) } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } /** @@ -846,13 +867,8 @@ const { config } = this.props const { actionlist, visible, card, dict, copying, profVisible } = this.state - let hasbtncrtinter = false - if (card && !card.copyType && config.setting.interType === 'inner' && !config.setting.innerFunc && config.setting.dataresource) { - hasbtncrtinter = true - } - return ( - <div className="model-table-action-list"> + <div className="model-table-action-list" style={config.charts.length > 1 ? {paddingTop: 25} : null}> <Tooltip placement="bottomLeft" overlayClassName="middle" title={dict['model.tooltip.action.guide']}> <Icon type="question-circle" /> </Tooltip> @@ -869,14 +885,15 @@ {/* 缂栬緫鎸夐挳锛氬鍒躲�佺紪杈� */} <Modal title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])} + wrapClassName="model-table-action-edit-modal" visible={visible} - width={750} + width={850} maskClosable={false} onCancel={this.editModalCancel} footer={[ - hasbtncrtinter ? <CreateInterface key="interface" dict={dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/> : null, - card && !card.copyType ? <CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, - <Button key="cancel" onClick={this.editModalCancel}>{dict['header.cancel']}</Button>, + <CreateInterface key="interface" dict={dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/>, + <CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/>, + <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>, <Button key="confirm" type="primary" loading={copying} onClick={this.handleSubmit}>{dict['model.confirm']}</Button> ]} destroyOnClose @@ -899,14 +916,13 @@ width={'75vw'} maskClosable={false} style={{minWidth: '900px', maxWidth: '1200px'}} - okText={dict['header.submit']} + okText={dict['model.submit']} onOk={this.verifySubmit} onCancel={() => { this.setState({ profVisible: false }) }} destroyOnClose > {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ? <VerifyCard - floor={this.props.type} card={card} dict={dict} config={config} @@ -934,6 +950,7 @@ <VerifyExcelOut card={card} dict={dict} + config={config} wrappedComponentRef={(inst) => this.verifyRef = inst} /> : null } -- Gitblit v1.8.0