From 3193df5faaacb0fe903ce993b16319276528524f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 06 七月 2020 23:14:17 +0800 Subject: [PATCH] 2020-07-06 --- src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 125 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 122 insertions(+), 3 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 8a9df3f..17f211e 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -1,7 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber } from 'antd' +import { Form, Row, Col, Input, Select, Icon, Radio, notification, Tooltip, InputNumber, Cascader } from 'antd' import { btnIcons, btnClasses, formRule } from '@/utils/option.js' + +import Api from '@/api' +import options from '@/store/options.js' import Utils from '@/utils/utils.js' import './index.scss' @@ -68,6 +71,7 @@ UNSAFE_componentWillMount () { const { card } = this.props + let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || '' let _opentype = card.OpenType // 鎵撳紑鏂瑰紡 let _tabType = card.tabType || 'SubTable' // 鎸夐挳涓哄脊绐楋紙鏍囩锛夋椂锛屾爣绛剧殑绫诲瀷 let _options = null // 閫夐」鍒楄〃 @@ -84,10 +88,13 @@ if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] if (card.pageTemplate === 'custom') { - _options.push('url') + _options.push('url', 'joint') } } else if (_opentype === 'blank' || _opentype === 'tab') { // 鏂版爣绛炬垨褰撳墠椤甸潰鏇挎崲 _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] + if (card.tabTemplate === 'ThdMenu') { + _options.push('linkmenu') + } } else if (_opentype === 'popview') { // 妯℃�佹鏍囩椤� _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] } else if (_opentype === 'excelOut') { // 瀵煎叆瀵煎嚭 @@ -123,6 +130,7 @@ } this.setState({ openType: _opentype, + menulist: _menulist.options || [], interType: card.intertype || 'inner', position: card.position || 'toolbar', funcType: card.funcType, @@ -192,10 +200,13 @@ if (value === 'innerpage') { _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] if (card.pageTemplate === 'custom') { - _options.push('url') + _options.push('url', 'joint') } } else if (value === 'blank' || value === 'tab') { _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] + if (card.tabTemplate === 'ThdMenu') { + _options.push('linkmenu') + } } else if (value === 'popview') { _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] } else if (value === 'excelOut') { @@ -390,6 +401,21 @@ _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'url', 'icon', 'class', 'position'] } else { _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] + } + + this.setState({ + openType: value, + formlist: this.state.formlist.map(item => { + item.hidden = !_options.includes(item.key) + + return item + }) + }) + } else if (key === 'tabTemplate') { + let _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] + + if (value === 'ThdMenu') { + _options.push('linkmenu') } this.setState({ @@ -627,13 +653,87 @@ </Form.Item> </Col> ) + } else if (item.type === 'cascader') { // 澶氶�� + fields.push( + <Col span={12} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.key, { + initialValue: item.initVal || [], + rules: [ + { + required: !!item.required, + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Cascader + options={this.state.menulist} + loadData={this.loadData} + placeholder="" + /> + )} + </Form.Item> + </Col> + ) } }) return fields } + loadData = selectedOptions => { + const { MenuID } = this.props + const targetOption = selectedOptions[selectedOptions.length - 1] + targetOption.loading = true + + let _param = { + func: 'sPC_Get_FunMenu', + ParentID: targetOption.value, + systemType: options.sysType, + debug: 'Y' + } + + Api.getSystemConfig(_param).then(result => { + if (result.status) { + targetOption.loading = false + targetOption.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 === MenuID + } + }) + } + + return submenu + }) + + this.setState({ + menulist: [...this.state.menulist] + }) + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + targetOption.loading = false + } + }) + } + handleConfirm = () => { const { setting } = this.props + const { menulist } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { @@ -673,6 +773,25 @@ } } + // 鍏宠仈涓夌骇鑿滃崟 + if (values.OpenType === 'tab' && values.linkmenu && values.linkmenu.length > 0) { + let linkThdMenu = '' + menulist.forEach(menu => { + if (menu.value === values.linkmenu[0]) { + menu.children.forEach(item => { + if (item.value === values.linkmenu[1]) { + item.children.forEach(cell => { + if (cell.value === values.linkmenu[2]) { + linkThdMenu = cell + } + }) + } + }) + } + }) + values.linkThdMenu = linkThdMenu + } + if (values.innerFunc === '' && values.sql === '') { notification.warning({ top: 92, -- Gitblit v1.8.0