| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Icon, Tooltip, Modal, notification, Button } from 'antd' |
| | | import { Tooltip, Modal, notification, Button } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | 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 MKEmitter from '@/utils/events.js' |
| | | 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 VerifyMegvii = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifymegvii')) |
| | | const VerifyExcelOut = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelout')) |
| | | |
| | | class ActionComponent extends Component { |
| | | static propTpyes = { |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | card: null, // 编辑中元素 |
| | | formlist: null, // 表单信息 |
| | | actionlist: null, // 按钮组 |
| | | copying: false, // 按钮复制中 |
| | | visible: false, // 模态框控制 |
| | | printTemps: [], // 单据打印模板 |
| | | profVisible: false // 验证信息模态框 |
| | | profVisible: false, // 验证信息模态框 |
| | | record: null |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 监听到按钮复制时,触发按钮编辑 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { actionlist } = this.state |
| | | |
| | | 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() |
| | | MKEmitter.addListener('revert', this.revert) |
| | | MKEmitter.addListener('pasteButton', this.pasteButton) |
| | | } |
| | | |
| | | revert = () => { |
| | | this.setState({ |
| | | actionlist: fromJS(this.props.config.action).toJS() |
| | | }) |
| | | } |
| | | |
| | | pasteButton = (MenuId, btn) => { |
| | | const { config } = this.props |
| | | const { actionlist } = this.state |
| | | |
| | | if (MenuId !== config.uuid) return |
| | | |
| | | this.setState({ |
| | | actionlist: [...actionlist, btn], |
| | | }, () => { |
| | | this.handleAction(btn) |
| | | }) |
| | | } |
| | | |
| | | getBillPrintTemp = () => { |
| | |
| | | if (usefulFields) { |
| | | try { |
| | | usefulFields = JSON.parse(usefulFields) |
| | | } catch { |
| | | } 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) { |
| | | let trees = fromJS(menu.fstMenuList).toJS() |
| | | |
| | | menulist = trees.map(fst => { |
| | | fst.value = fst.MenuID |
| | | fst.label = fst.MenuName |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | card: card, |
| | | formlist: getActionForm(card, functip, this.props.config, usefulFields, this.props.type, menulist, this.state.printTemps) |
| | | formlist: getActionForm(card, this.props.config, usefulFields, this.props.type, menulist, this.state.printTemps, this.props.tabs) |
| | | }) |
| | | } |
| | | |
| | |
| | | if (labelrepet) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['model.name.exist'] + ' !', |
| | | message: '名称已存在!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | |
| | | 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') |
| | |
| | | |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: card.originCard.uuid |
| | | MenuID: card.originCard.uuid, |
| | | appkey: card.originCard.appkey || '' |
| | | }) |
| | | }).then(result => { // 复制按钮配置信息,保存至新添加按钮 |
| | | if (result === 'save' || result === 'subtab') return result |
| | |
| | | } |
| | | } |
| | | |
| | | 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() |
| | |
| | | }) |
| | | _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam))) |
| | | _temp = 'FormTab' |
| | | } catch { |
| | | } catch (e) { |
| | | console.warn('Stringify Failure') |
| | | _LongParam = '' |
| | | _temp = '' |
| | | } |
| | | } |
| | |
| | | |
| | | return Api.getSystemConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: card.originCard.linkTab |
| | | MenuID: card.originCard.linkTab, |
| | | appkey: card.originCard.appkey || '' |
| | | }) |
| | | }).then(result => { // 标签复制 |
| | | if (result === 'save') return result |
| | |
| | | _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, |
| | |
| | | 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') |
| | |
| | | profVisible: true, |
| | | card: element |
| | | }) |
| | | |
| | | MKEmitter.emit('modalStatus', '验证信息') |
| | | } |
| | | |
| | | /** |
| | |
| | | }, () => { |
| | | this.props.updateaction({...config, action: _actionlist}) |
| | | }) |
| | | |
| | | MKEmitter.emit('modalStatus', false) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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({ |
| | |
| | | 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({ |
| | |
| | | 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 { |
| | |
| | | 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 => { |
| | |
| | | /** |
| | | * @description 按钮双击触发子配置 |
| | | */ |
| | | btnDoubleClick = (element) => { |
| | | if (!element.origin && (element.OpenType === 'pop' || element.OpenType === 'popview' || element.OpenType === 'blank')) { |
| | | 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) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('revert', this.revert) |
| | | MKEmitter.removeListener('pasteButton', this.pasteButton) |
| | | } |
| | | |
| | | getVerify = (card) => { |
| | | const { config } = this.props |
| | | const { dict } = this.state |
| | | |
| | | if (!card) return null |
| | | |
| | | if (['pop', 'prompt', 'exec'].includes(card.OpenType)) { |
| | | return <VerifyCard |
| | | card={card} |
| | | dict={dict} |
| | | config={config} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | } else if (card.OpenType === 'excelIn') { |
| | | return <VerifyExcelIn |
| | | card={card} |
| | | dict={dict} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | } else if (card.OpenType === 'excelOut') { |
| | | return <VerifyExcelOut |
| | | card={card} |
| | | dict={dict} |
| | | config={config} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | } else if (card.OpenType === 'funcbutton' && card.funcType === 'print') { |
| | | return <VerifyPrint |
| | | card={card} |
| | | dict={dict} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | } else if (card.OpenType === 'funcbutton' && card.funcType === 'megvii') { |
| | | return <VerifyMegvii |
| | | card={card} |
| | | dict={dict} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { actionlist, visible, card, dict, copying, profVisible } = this.state |
| | | const { actionlist, visible, card, dict, copying, profVisible, record } = this.state |
| | | |
| | | return ( |
| | | <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" /> |
| | | <div className="model-table-action-list" style={config.charts && config.charts.length > 1 ? {paddingTop: 25} : null}> |
| | | <Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《按钮》中,选择对应类型的按钮拖至此处添加,如选择按钮类型为表单、新标签页等含有配置页面的按钮,可在左侧工具栏-按钮-可配置按钮处,点击按钮完成相关配置。注:当设置按钮显示位置为表格时,显示列会增加操作列。"> |
| | | <QuestionCircleOutlined style={{color: '#c49f47', position: 'absolute', left: '5px', top: '5px'}} /> |
| | | </Tooltip> |
| | | <DragElement |
| | | list={actionlist} |
| | |
| | | deleteMenu={this.deleteElement} |
| | | profileMenu={this.profileAction} |
| | | doubleClickCard={this.btnDoubleClick} |
| | | placeholder={dict['header.form.action.placeholder']} |
| | | /> |
| | | {/* 编辑按钮:复制、编辑 */} |
| | | <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={920} |
| | | maskClosable={false} |
| | | onCancel={this.editModalCancel} |
| | | footer={[ |
| | | <CreateInterface key="interface" dict={dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/>, |
| | | <CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/>, |
| | | record && ['pop', 'exec', 'prompt'].includes(record.OpenType) && record.intertype === 'system' ? <CreateInterface key="interface" dict={dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/> : null, |
| | | record && record.intertype === 'inner' ? <CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, |
| | | <Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>, |
| | | <Button key="confirm" type="primary" loading={copying} onClick={this.handleSubmit}>{dict['model.confirm']}</Button> |
| | | ]} |
| | |
| | | <ActionForm |
| | | dict={dict} |
| | | card={card} |
| | | tabs={this.props.tabs} |
| | | formlist={this.state.formlist} |
| | | inputSubmit={this.handleSubmit} |
| | | setting={config.setting} |
| | | updRecord={(record) => this.setState({record: fromJS(record).toJS()})} |
| | | wrappedComponentRef={(inst) => this.actionFormRef = inst} |
| | | /> |
| | | </Modal> |
| | | {/* 按钮使用系统存储过程时,验证信息模态框 */} |
| | | <Modal |
| | | wrapClassName="model-table-action-verify-modal" |
| | | title={'验证信息'} |
| | | title={(card && card.label ? card.label + ' - ' : '') + '验证信息'} |
| | | visible={profVisible} |
| | | width={'75vw'} |
| | | width={'90vw'} |
| | | maskClosable={false} |
| | | style={{minWidth: '900px', maxWidth: '1200px'}} |
| | | okText={dict['model.submit']} |
| | | onOk={this.verifySubmit} |
| | | onCancel={() => { this.setState({ profVisible: false }) }} |
| | | onCancel={() => { |
| | | if (this.verifyRef.handleCancel) { |
| | | this.verifyRef.handleCancel().then(() => { |
| | | this.setState({ profVisible: false }) |
| | | MKEmitter.emit('modalStatus', false) |
| | | }) |
| | | } else { |
| | | this.setState({ profVisible: false }) |
| | | MKEmitter.emit('modalStatus', false) |
| | | } |
| | | }} |
| | | destroyOnClose |
| | | > |
| | | {card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ? |
| | | <VerifyCard |
| | | card={card} |
| | | dict={dict} |
| | | config={config} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> : null |
| | | } |
| | | {card && card.execMode ? |
| | | <VerifyPrint |
| | | card={card} |
| | | dict={dict} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> : null |
| | | } |
| | | {card && card.OpenType === 'excelIn' ? |
| | | <VerifyExcelIn |
| | | card={card} |
| | | dict={dict} |
| | | columns={config.columns} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> : null |
| | | } |
| | | {card && card.OpenType === 'excelOut' ? |
| | | <VerifyExcelOut |
| | | card={card} |
| | | dict={dict} |
| | | config={config} |
| | | wrappedComponentRef={(inst) => this.verifyRef = inst} |
| | | /> : null |
| | | } |
| | | {this.getVerify(card)} |
| | | </Modal> |
| | | </div> |
| | | ) |