| | |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import { getActionForm } from './formconfig' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | import ActionForm from './actionform' |
| | | import VerifyCard from '@/templates/zshare/verifycard' |
| | | import CreateFunc from '@/templates/zshare/createfunc' |
| | |
| | | class ActionComponent extends Component { |
| | | static propTpyes = { |
| | | type: PropTypes.string, // 菜单类型,主表或子表 |
| | | plus: PropTypes.any, // 是否存在添加按钮,值为false时隐藏 |
| | | config: PropTypes.object, // 菜单配置信息 |
| | | setSubConfig: PropTypes.func, // 设置子配置信息 |
| | | updateaction: PropTypes.func // 菜单配置更新 |
| | |
| | | }) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('addButton', this.addButton) |
| | | } |
| | | |
| | | /** |
| | | * @description 监听到按钮复制时,触发按钮编辑 |
| | | */ |
| | |
| | | if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) { |
| | | this.setState({actionlist: fromJS(nextProps.config.action).toJS()}) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新,清除快捷键设置 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('addButton', this.addButton) |
| | | } |
| | | |
| | | addButton = (cardId, element) => { |
| | | if (cardId !== this.props.config.uuid) return |
| | | |
| | | const { actionlist } = this.state |
| | | |
| | | this.setState({actionlist: [...actionlist, element]}) |
| | | this.handleAction(element) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.props.updateaction({...config, action: list}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | getModules = (components, selfId) => { |
| | | let modules = components.map(item => { |
| | | if (item.uuid === selfId) { |
| | | return { |
| | | children: null |
| | | } |
| | | } else if (item.format) { |
| | | return { |
| | | value: item.uuid, |
| | | label: item.name |
| | | } |
| | | } else if (item.type === 'tabs') { |
| | | let _item = { |
| | | value: item.uuid, |
| | | label: item.name, |
| | | children: item.subtabs.map(f_tab => { |
| | | let subItem = { |
| | | value: f_tab.uuid, |
| | | label: f_tab.label, |
| | | children: this.getModules(f_tab.components, selfId) |
| | | } |
| | | |
| | | if (!subItem.children || subItem.children.length === 0) { |
| | | return {children: null} |
| | | } |
| | | return subItem |
| | | }) |
| | | } |
| | | |
| | | _item.children = _item.children.filter(t => t.children !== null) |
| | | |
| | | if (_item.children.length === 0) { |
| | | return {children: null} |
| | | } |
| | | |
| | | return _item |
| | | } else { |
| | | return { |
| | | children: null |
| | | } |
| | | } |
| | | }) |
| | | |
| | | modules = modules.filter(mod => mod.children !== null) |
| | | |
| | | if (modules.length === 0) { |
| | | return null |
| | | } |
| | | return modules |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | |
| | | // let modules = [] |
| | | |
| | | // menu.components.forEach(item => { |
| | | // if (item.uuid === config.uuid) return |
| | | |
| | | // modules.push({ |
| | | // value: item.uuid, |
| | | // text: item.setting.name |
| | | // }) |
| | | // }) |
| | | |
| | | // if (supModule && supModule !== 'empty') { |
| | | // if (modules.filter(item => item.value === supModule).length === 0) { |
| | | // supModule = '' |
| | | // } |
| | | // } |
| | | let modules = this.getModules(menu.components, config.uuid) |
| | | |
| | | if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) { |
| | | let _param = { |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | card: card, |
| | | formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist) |
| | | formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules) |
| | | }) |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | visible: true, |
| | | card: card, |
| | | formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist) |
| | | formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules) |
| | | }) |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { config, type } = this.props |
| | | const { config, plus } = this.props |
| | | const { actionlist, visible, card, dict, copying, profVisible } = this.state |
| | | |
| | | return ( |
| | | <div className="model-menu-action-list"> |
| | | <DragElement |
| | | type={type} |
| | | plus={plus} |
| | | list={actionlist} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleAction} |