From 2f71678db0378c7c841e721dfebaea6d159e13b2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 15 一月 2022 00:46:12 +0800 Subject: [PATCH] 2022-01-15 --- src/pc/components/login/normal-login/options.jsx | 13 ++++ /dev/null | 0 src/components/normalform/modalform/mkTable/index.jsx | 23 +++++++ src/menu/components/card/data-card/options.jsx | 62 +++++++++++++++----- src/menu/components/card/cardcomponent/index.jsx | 2 src/menu/components/card/data-card/index.jsx | 30 +++++---- 6 files changed, 101 insertions(+), 29 deletions(-) diff --git a/src/components/normalform/modalform/mkTable/index.jsx b/src/components/normalform/modalform/mkTable/index.jsx index 053316f..2760640 100644 --- a/src/components/normalform/modalform/mkTable/index.jsx +++ b/src/components/normalform/modalform/mkTable/index.jsx @@ -297,6 +297,29 @@ }) }) }) + } else if (col.inputType === 'cascader') { + let keys = record[col.dataIndex] + let _options = [] + let rematch = (options, level) => { + options.some(m => { + if (!m.value || m.value !== keys[level]) return false + + _options.push(m) + + if (m.children && keys[level + 1]) { + rematch(m.children, level + 1) + } + return true + }) + } + + rematch(col.options, 0) + + if (_options.length) { + col.extends.forEach(n => { + record[n.value] = _options.map(o => o[n.key]).join(' / ') + }) + } } else { let key = record[col.dataIndex] let option = col.options.filter(m => m.value === key)[0] diff --git a/src/menu/components/card/cardcomponent/index.jsx b/src/menu/components/card/cardcomponent/index.jsx index 491e76d..d7739c2 100644 --- a/src/menu/components/card/cardcomponent/index.jsx +++ b/src/menu/components/card/cardcomponent/index.jsx @@ -226,6 +226,8 @@ _card.menus = res.menus delete res.menus + } else { + delete _card.menus } this.setState({ diff --git a/src/menu/components/card/data-card/index.jsx b/src/menu/components/card/data-card/index.jsx index 7692420..335e3f9 100644 --- a/src/menu/components/card/data-card/index.jsx +++ b/src/menu/components/card/data-card/index.jsx @@ -15,7 +15,6 @@ const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) const NormalForm = asyncIconComponent(() => import('@/components/normalform')) const CardComponent = asyncComponent(() => import('../cardcomponent')) -const Nodes = asyncComponent(() => import('./node-wrap')) const MobPagination = asyncIconComponent(() => import('@/menu/components/share/mobPagination')) const LogComponent = asyncIconComponent(() => import('@/menu/components/share/logcomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) @@ -479,11 +478,25 @@ getWrapForms = () => { const { card } = this.state - return getWrapForm(card.wrap, card.subtype, card.columns) + return getWrapForm(card.wrap, card.subtype, card.columns, card.uuid, card.supNodes) } updateWrap = (res) => { - this.updateComponent({...this.state.card, wrap: res}) + let _card = {...this.state.card, wrap: res} + + if (res.supNodes) { + _card.supNodes = res.supNodes + _card.supNodes = _card.supNodes.map(item => { + item.componentId = item.nodes[item.nodes.length - 1] + return item + }) + + delete res.supNodes + } else { + delete _card.supNodes + } + + this.updateComponent(_card) } pasteComponent = (res, resolve) => { @@ -624,16 +637,6 @@ } } - updateSupNodes = (res) => { - const { card } = this.state - - this.setState({ - card: {...card, supNodes: res} - }) - - this.updateComponent({...card, supNodes: res}) - } - render() { const { card, appType } = this.state @@ -661,7 +664,6 @@ <NormalForm title="鏁版嵁鍗¤缃�" width={800} update={this.updateWrap} getForms={this.getWrapForms}> <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> </NormalForm> - {card.wrap.supType === 'multi' && appType !== 'mob' ? <Nodes card={card} updateMenus={this.updateSupNodes}/> : null} <CopyComponent type="datacard" card={card}/> <PasteComponent options={['action', 'search', 'form', 'cardcell']} updateConfig={this.pasteComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> diff --git a/src/menu/components/card/data-card/node-wrap/index.jsx b/src/menu/components/card/data-card/node-wrap/index.jsx deleted file mode 100644 index 9282ca6..0000000 --- a/src/menu/components/card/data-card/node-wrap/index.jsx +++ /dev/null @@ -1,69 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Modal } from 'antd' -import { ForkOutlined } from '@ant-design/icons' - -import MenusForm from './menus' -import './index.scss' - -class NodesWrap extends Component { - static propTpyes = { - card: PropTypes.object, - updateMenus: PropTypes.func - } - - state = { - visible: false, - supNodes: [], - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) - } - - trigger = () => { - const { card } = this.props - - this.setState({ - visible: true, - supNodes: card.supNodes || [] - }) - } - - submit = () => { - this.setState({ - visible: false - }) - this.props.updateMenus(this.state.supNodes) - } - - update = (supNodes) => { - this.setState({supNodes}) - } - - render() { - const { card } = this.props - const { visible, supNodes } = this.state - - return ( - <> - <ForkOutlined title="涓婄骇缁勪欢" style={{color: 'orange'}} onClick={this.trigger}/> - <Modal - title="涓婄骇缁勪欢" - wrapClassName="menus-field-modal" - visible={visible} - width={700} - maskClosable={false} - onOk={this.submit} - onCancel={() => { this.setState({ visible: false })}} - destroyOnClose - > - <MenusForm supNodes={supNodes} card={card} update={this.update}/> - </Modal> - </> - ) - } -} - -export default NodesWrap \ No newline at end of file diff --git a/src/menu/components/card/data-card/node-wrap/index.scss b/src/menu/components/card/data-card/node-wrap/index.scss deleted file mode 100644 index 52caa86..0000000 --- a/src/menu/components/card/data-card/node-wrap/index.scss +++ /dev/null @@ -1,9 +0,0 @@ -.menus-field-modal { - .ant-modal { - top: 70px; - } - .ant-modal-body { - min-height: 150px; - padding-top: 40px; - } -} \ No newline at end of file diff --git a/src/menu/components/card/data-card/node-wrap/menus/columnform/index.jsx b/src/menu/components/card/data-card/node-wrap/menus/columnform/index.jsx deleted file mode 100644 index 6c6a36b..0000000 --- a/src/menu/components/card/data-card/node-wrap/menus/columnform/index.jsx +++ /dev/null @@ -1,82 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Button, Cascader, notification } from 'antd' -// import './index.scss' - -class MenusColumn extends Component { - static propTpyes = { - supNodes: PropTypes.array, - modules: PropTypes.array, - columnChange: PropTypes.func - } - - state = {options: []} - - handleConfirm = () => { - const { supNodes } = this.props - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.componentId = values.nodes[values.nodes.length - 1] - if (supNodes.filter(item => item.componentId === values.componentId).length > 0) { - notification.warning({ - top: 92, - message: '缁勪欢宸叉坊鍔狅紒', - duration: 2 - }) - return - } - - values.label = this.state.options.map(item => item.label).join(' / ') - - this.props.columnChange(values) - } - }) - } - - onChange = (values, options) => { - this.setState({options: options}) - } - - render() { - const { modules } = this.props - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout}> - <Row gutter={24}> - <Col span={16}> - <Form.Item label="缁勪欢"> - {getFieldDecorator('nodes', { - initialValue: [], - rules: [ - { - required: true, - message: '璇烽�夋嫨缁勪欢!' - } - ] - })(<Cascader options={modules} onChange={this.onChange} placeholder=""/>)} - </Form.Item> - </Col> - <Col span={6} offset={2} style={{paddingTop: '4px'}}> - <Button onClick={this.handleConfirm} type="primary" className="mk-green"> - 娣诲姞 - </Button> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(MenusColumn) \ No newline at end of file diff --git a/src/menu/components/card/data-card/node-wrap/menus/columnform/index.scss b/src/menu/components/card/data-card/node-wrap/menus/columnform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/menu/components/card/data-card/node-wrap/menus/columnform/index.scss +++ /dev/null diff --git a/src/menu/components/card/data-card/node-wrap/menus/index.jsx b/src/menu/components/card/data-card/node-wrap/menus/index.jsx deleted file mode 100644 index 37990be..0000000 --- a/src/menu/components/card/data-card/node-wrap/menus/index.jsx +++ /dev/null @@ -1,69 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { fromJS } from 'immutable' - -import Utils from '@/utils/utils.js' -import ColumnForm from './columnform' -import asyncComponent from '@/utils/asyncComponent' -import MenuUtils from '@/utils/utils-custom.js' -// import './index.scss' - -const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) - -class SupNodes extends Component { - static propTpyes = { - card: PropTypes.object, - supNodes: PropTypes.array, - update: PropTypes.func - } - - state = { - modules: [], - columns: [ - { - title: '缁勪欢', - dataIndex: 'label', - editable: false, - width: '60%' - } - ] - } - - UNSAFE_componentWillMount() { - const { supNodes, card } = this.props - - let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, card.uuid) || [] - - this.setState({ - modules, - supNodes: fromJS(supNodes).toJS() - }) - } - - columnChange = (values) => { - const { supNodes } = this.state - values.uuid = Utils.getuuid() - let _nodes = [...supNodes, values] - - this.setState({supNodes: _nodes}) - this.props.update(_nodes) - } - - changeColumns = (columns) => { - this.setState({supNodes: columns}) - this.props.update(columns) - } - - render() { - const { supNodes, columns, modules } = this.state - - return ( - <div style={{minHeight: '250px'}}> - <ColumnForm supNodes={supNodes} modules={modules} columnChange={this.columnChange}/> - <EditTable actions={['del']} data={supNodes} columns={columns} onChange={this.changeColumns}/> - </div> - ) - } -} - -export default SupNodes \ No newline at end of file diff --git a/src/menu/components/card/data-card/node-wrap/menus/index.scss b/src/menu/components/card/data-card/node-wrap/menus/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/menu/components/card/data-card/node-wrap/menus/index.scss +++ /dev/null diff --git a/src/menu/components/card/data-card/options.jsx b/src/menu/components/card/data-card/options.jsx index 7d8ef6a..33b8ebc 100644 --- a/src/menu/components/card/data-card/options.jsx +++ b/src/menu/components/card/data-card/options.jsx @@ -4,7 +4,7 @@ /** * @description Wrap琛ㄥ崟閰嶇疆淇℃伅 */ -export default function (wrap, subtype, columns = [], id = '') { +export default function (wrap, subtype, columns = [], id = '', supNodes = []) { let appType = sessionStorage.getItem('appType') let MenuType = '' let menu = fromJS(window.GLOB.customMenu).toJS() @@ -13,7 +13,7 @@ MenuType = 'billPrint' } let modules = [] - if (subtype === 'propcard') { + if (subtype === 'propcard' || subtype === 'datacard') { modules = MenuUtils.getSupModules(menu.components, id) || [] } @@ -133,19 +133,6 @@ {value: 'false', label: '鏃�'}, {value: 'init', label: '鍒濆鍖�'}, {value: 'always', label: '鏁版嵁鍔犺浇'}, - ] - }, - { - type: 'radio', - field: 'supType', - label: '涓婄骇绫诲瀷', - initval: wrap.supType || 'single', - tooltip: '涓婄骇缁勪欢涓哄崟涓�缁勪欢鎴栧涓粍浠躲��', - required: false, - forbid: subtype !== 'datacard' || appType === 'mob', - options: [ - {value: 'single', label: '鍗曠粍浠�'}, - {value: 'multi', label: '澶氱粍浠�'}, ] }, { @@ -299,6 +286,22 @@ forbid: subtype !== 'datacard' }, { + type: 'radio', + field: 'supType', + label: '涓婄骇绫诲瀷', + initval: wrap.supType || 'single', + tooltip: '涓婄骇缁勪欢涓哄崟涓�缁勪欢鎴栧涓粍浠躲��', + required: false, + forbid: subtype !== 'datacard' || appType === 'mob', + options: [ + {value: 'single', label: '鍗曠粍浠�'}, + {value: 'multi', label: '澶氱粍浠�'}, + ], + controlFields: [ + {field: 'supNodes', values: ['multi']}, + ] + }, + { type: 'multiselect', field: 'blacklist', label: '榛戝悕鍗�', @@ -307,6 +310,35 @@ options: roleList, forbid: !!appType }, + { + type: 'table', + field: 'supNodes', + label: '涓婄骇缁勪欢', + initval: supNodes, + required: true, + forbid: subtype !== 'datacard' || appType === 'mob', + span: 24, + columns: [ + { + title: '搴忓彿', + dataIndex: '$index', + editable: false, + required: false, + width: '20%' + }, + { + title: '鑿滃崟', + dataIndex: 'nodes', + inputType: 'cascader', + editable: true, + required: true, + extends: [{key: 'label', value: 'label'}], + width: '50%', + render: (text, record) => record.label, + options: modules + } + ] + } ] return cardWrapForm.map(item => { diff --git a/src/pc/components/login/normal-login/options.jsx b/src/pc/components/login/normal-login/options.jsx index 295099c..45aaffe 100644 --- a/src/pc/components/login/normal-login/options.jsx +++ b/src/pc/components/login/normal-login/options.jsx @@ -131,6 +131,19 @@ {value: 'autologon', label: '鑷姩鐧诲綍'}, ] }, + // { + // type: 'radio', + // field: 'shortcut', + // label: '蹇嵎鏂瑰紡', + // initval: wrap.shortcut || 'remember', + // tooltip: '璐﹀彿瀵嗙爜鐧诲綍鏃剁殑蹇嵎鏂瑰紡銆�', + // required: false, + // options: [ + // {value: 'none', label: '鏃�'}, + // {value: 'remember', label: '璁颁綇瀵嗙爜'}, + // {value: 'autologon', label: '鑷姩鐧诲綍'}, + // ] + // }, ] return wrapForm -- Gitblit v1.8.0