| | |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import {connect} from 'react-redux' |
| | | import { Modal, Button, notification } from 'antd' |
| | | import { Modal, Button } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import options from '@/store/options.js' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { getCardCellForm } from './formconfig' |
| | | import { getActionForm } from '@/menu/actioncomponent/formconfig' |
| | | import { getActionForm } from '@/menu/components/share/actioncomponent/formconfig' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | import ElementForm from './elementform' |
| | |
| | | |
| | | const { confirm } = Modal |
| | | |
| | | const ActionForm = asyncComponent(() => import('@/menu/actioncomponent/actionform')) |
| | | const ActionForm = asyncComponent(() => import('@/menu/components/share/actioncomponent/actionform')) |
| | | const CreateFunc = asyncComponent(() => import('@/templates/zshare/createfunc')) |
| | | const VerifyCard = asyncComponent(() => import('@/templates/zshare/verifycard')) |
| | | const VerifyPrint = asyncComponent(() => import('@/menu/actioncomponent/verifyprint')) |
| | | const VerifyExcelIn = asyncComponent(() => import('@/menu/actioncomponent/verifyexcelin')) |
| | | const VerifyExcelOut = asyncComponent(() => import('@/menu/actioncomponent/verifyexcelout')) |
| | | const VerifyPrint = asyncComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyprint')) |
| | | const VerifyExcelIn = asyncComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelin')) |
| | | const VerifyExcelOut = asyncComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelout')) |
| | | |
| | | class CardCellComponent extends Component { |
| | | static propTpyes = { |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | const { cards } = this.props |
| | | if (this.props.side !== nextProps.side) { |
| | | this.setState({ |
| | | elements: fromJS(nextProps.elements).toJS() |
| | | }) |
| | | } else if (nextProps.elements.length === 0 && this.state.elements.length > 0) { |
| | | this.setState({ |
| | | elements: [] |
| | | }) |
| | | } else if (cards.subtype === 'normaltable' && this.state.elements.length > nextProps.elements.length) { // 表格中按钮移出 |
| | | this.setState({ |
| | | elements: fromJS(nextProps.elements).toJS() |
| | | }) |
| | |
| | | const { cards, cardCell } = this.props |
| | | |
| | | let _style = element.style ? fromJS(element.style).toJS() : {} |
| | | let options = ['font', 'border', 'padding', 'margin'] |
| | | let options = ['font', 'border', 'padding', 'margin', 'backgroundColor'] |
| | | |
| | | if (element.eleType === 'button') { |
| | | options.push('background') |
| | | if (element.btnstyle) { |
| | | _style = {..._style, ...element.btnstyle} |
| | | } |
| | |
| | | |
| | | let _card = fromJS(card).toJS() |
| | | |
| | | if (card.eleType === 'button') { // 拆分style |
| | | if (_card.eleType === 'text' || _card.eleType === 'number') { |
| | | _card.style = style |
| | | |
| | | let fontSize = 14 |
| | | let lineHeight = 1.5 |
| | | let line = _card.height || 1 |
| | | |
| | | if (_card.style.fontSize) { |
| | | fontSize = parseInt(_card.style.fontSize) |
| | | } |
| | | if (_card.style.lineHeight) { |
| | | lineHeight = parseFloat(_card.style.lineHeight) |
| | | } |
| | | |
| | | _card.innerHeight = fontSize * lineHeight * line |
| | | } else if (_card.eleType === 'barcode') { |
| | | _card.style = style |
| | | |
| | | let fontSize = 14 |
| | | |
| | | if (_card.style.fontSize) { |
| | | fontSize = parseInt(_card.style.fontSize) |
| | | } |
| | | |
| | | _card.innerHeight = _card.barHeight + (_card.displayValue === 'true' ? fontSize + 2 : 0) |
| | | } else if (_card.eleType === 'button') { // 拆分style |
| | | let _style = fromJS(style).toJS() |
| | | _card.style = {} |
| | | |
| | |
| | | * @description 元素编辑,获取元素表单信息 |
| | | */ |
| | | handleElement = (card) => { |
| | | const { cards } = this.props |
| | | |
| | | if (card.eleType === 'button') { |
| | | this.handleAction(card) |
| | | } else { |
| | | this.setState({ |
| | | visible: true, |
| | | card: card, |
| | | formlist: getCardCellForm(card) |
| | | formlist: getCardCellForm(card, cards.type) |
| | | }) |
| | | } |
| | | } |
| | |
| | | handleAction = (card) => { |
| | | const { menu, cards } = this.props |
| | | |
| | | let ableField = menu.permFuncField ? menu.permFuncField.join(', ') : '' |
| | | 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) { |
| | | menulist = menu.fstMenuList.map(item => { |
| | | return { |
| | | value: item.MenuID, |
| | | label: item.text, |
| | | isLeaf: false |
| | | } |
| | | }) |
| | | let menulist = sessionStorage.getItem('fstMenuList') |
| | | if (menulist) { |
| | | try { |
| | | menulist = JSON.parse(menulist) |
| | | } catch { |
| | | menulist = [] |
| | | } |
| | | } else { |
| | | menulist = [] |
| | | } |
| | | |
| | | let modules = this.getModules(menu.components, cards.uuid) |
| | | |
| | | 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 |
| | | } |
| | | }) |
| | | } |
| | | |
| | | return submenu |
| | | }) |
| | | } |
| | | return item |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | actvisible: true, |
| | | card: card, |
| | | formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules) |
| | | }) |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | actvisible: true, |
| | | card: card, |
| | | formlist: getActionForm(card, functip, cards.setting, menu.permFuncField, 'card', menulist, modules) |
| | | }) |
| | | } |
| | | this.setState({ |
| | | actvisible: true, |
| | | card: card, |
| | | formlist: getActionForm(card, functip, cards.setting, usefulFields, 'card', menulist, modules) |
| | | }) |
| | | } |
| | | |
| | | getModules = (components, selfId) => { |
| | |
| | | handleSubmit = () => { |
| | | const { elements } = this.state |
| | | |
| | | this.elementFormRef.handleConfirm().then(ele => { |
| | | this.elementFormRef.handleConfirm().then(res => { |
| | | let _elements = elements.map(cell => { |
| | | if (cell.uuid === ele.uuid) { |
| | | ele.style = cell.style || {} |
| | | if (ele.eleType === 'splitline' && cell.eleType !== 'splitline') { |
| | | ele.style.paddingTop = '5px' |
| | | ele.style.paddingBottom = '5px' |
| | | if (cell.uuid === res.uuid) { |
| | | res.style = cell.style || {} |
| | | res.$type = cell.$type || '' |
| | | if (res.eleType === 'splitline' && cell.eleType !== 'splitline') { |
| | | res.style.paddingTop = '5px' |
| | | res.style.paddingBottom = '5px' |
| | | } else if (res.eleType === 'text' || res.eleType === 'number') { |
| | | let fontSize = 14 |
| | | let lineHeight = 1.5 |
| | | let line = res.height || 1 |
| | | |
| | | if (res.style && res.style.fontSize) { |
| | | fontSize = parseInt(res.style.fontSize) |
| | | } |
| | | if (res.style && res.style.lineHeight) { |
| | | lineHeight = parseFloat(res.style.lineHeight) |
| | | } |
| | | res.innerHeight = fontSize * lineHeight * line |
| | | |
| | | if (res.eleType === 'text' && res.link && !res.style.color) { |
| | | res.style.color = '#2440B3' |
| | | } |
| | | } else if (res.eleType === 'barcode') { |
| | | let fontSize = 14 |
| | | |
| | | if (res.style && res.style.fontSize) { |
| | | fontSize = parseInt(res.style.fontSize) |
| | | } |
| | | |
| | | res.innerHeight = res.barHeight + (res.displayValue === 'true' ? fontSize + 2 : 0) |
| | | } |
| | | |
| | | return ele |
| | | return res |
| | | } |
| | | return cell |
| | | }) |
| | |
| | | */ |
| | | handleActionSubmit = () => { |
| | | const { elements } = this.state |
| | | let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666' } |
| | | |
| | | this.actionFormRef.handleConfirm().then(res => { |
| | | let _elements = elements.map(cell => { |
| | | if (cell.uuid === res.uuid) { |
| | | res = {...cell, ...res} |
| | | delete res.focus |
| | | let btnstyle = {} |
| | | |
| | | if (res.class !== cell.class || res.show !== cell.show || !res.btnstyle) { |
| | | if (res.show === 'link' || res.show === 'icon') { |
| | | btnstyle.color = color[res.class] |
| | | btnstyle.backgroundColor = 'transparent' |
| | | } else { |
| | | btnstyle.color = '#ffffff' |
| | | btnstyle.backgroundColor = color[res.class] |
| | | } |
| | | } |
| | | res.btnstyle = {...res.btnstyle, ...btnstyle} |
| | | |
| | | return res |
| | | } |
| | | |
| | | return cell |
| | | }) |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | updateMarks = (card) => { |
| | | const { elements } = this.state |
| | | |
| | | let _elements = elements.map(cell => { |
| | | if (cell.uuid === card.uuid) return card |
| | | return cell |
| | | }) |
| | | |
| | | this.setState({ |
| | | elements: _elements |
| | | }, () => { |
| | | this.props.updateElement(_elements) |
| | | }) |
| | | } |
| | | |
| | | dropButton = (id) => { |
| | | const { cards } = this.props |
| | | let index = cards.action.findIndex(item => item.uuid === id) |
| | | |
| | | if (index === -1) return |
| | | |
| | | let btn = cards.action[index] |
| | | btn.eleType = 'button' |
| | | |
| | | let _elements = [...this.state.elements, btn] |
| | | let _action = cards.action.filter(item => item.uuid !== id) |
| | | |
| | | this.setState({ |
| | | elements: _elements |
| | | }, () => { |
| | | this.props.updateElement(_elements, _action) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { cards } = this.props |
| | | const { elements, visible, actvisible, profVisible, card, dict } = this.state |
| | |
| | | <div className="model-menu-card-cell-list"> |
| | | <DragElement |
| | | list={elements} |
| | | fields={cards.columns} |
| | | updateMarks={this.updateMarks} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleElement} |
| | | handleStyle={this.handleStyle} |
| | | dropButton={this.dropButton} |
| | | profileAction={this.profileAction} |
| | | handleSubConfig={this.handleSubConfig} |
| | | deleteMenu={this.deleteElement} |