From 5223edbcccfed84a33a706e5637ee65a61f377aa Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 十二月 2021 18:00:39 +0800 Subject: [PATCH] 2021-12-22 --- src/menu/components/card/cardcomponent/menus-wrap/menus/index.jsx | 79 ++++++++++++++++++++++++++++++--------- 1 files changed, 61 insertions(+), 18 deletions(-) diff --git a/src/menu/components/card/cardcomponent/menus-wrap/menus/index.jsx b/src/menu/components/card/cardcomponent/menus-wrap/menus/index.jsx index 98f4c98..a37b890 100644 --- a/src/menu/components/card/cardcomponent/menus-wrap/menus/index.jsx +++ b/src/menu/components/card/cardcomponent/menus-wrap/menus/index.jsx @@ -1,10 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' +import { is, fromJS } from 'immutable' +import Utils from '@/utils/utils.js' import ColumnForm from './columnform' import asyncComponent from '@/utils/asyncComponent' -import './index.scss' +// import './index.scss' const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) @@ -20,11 +21,12 @@ columns: [ { title: '鏍囪瘑', - dataIndex: 'name', + dataIndex: 'sign', inputType: 'input', editable: true, unique: true, - width: '30%' + required: false, + width: '35%' }, { title: '鑿滃崟', @@ -32,14 +34,8 @@ inputType: !this.props.appType ? 'cascader' : 'select', editable: true, required: true, - width: '40%', - render: (text) => { - if (text === 'image') { - return '鍥剧墖' - } else { - return '鏂囨湰' - } - }, + width: '35%', + render: (text, record) => record.label, options: this.props.menulist } ] @@ -55,14 +51,62 @@ columnChange = (values) => { const { menus } = this.state + values.uuid = Utils.getuuid() + let _menus = [...menus, values] - this.setState({menus: [...menus, values]}) + this.setState({menus: _menus}) + this.props.update(_menus) } changeColumns = (columns) => { - // const { menus } = this.state + const { appType, menulist } = this.props + const { menus } = this.state + let m = {} + menus.forEach(item => { + m[item.uuid] = item + }) + + columns = columns.map(col => { + let ori = m[col.uuid] + if (ori && is(fromJS({...col, $index: 1}), fromJS({...ori, $index: 1}))) return col + if (!appType) { + let fId = col.menu[0] || '' + let sId = col.menu[1] || '' + let tId = col.menu[2] || '' + let label = '' + + menulist.forEach(f => { + if (!fId || fId !== f.value) return + label = f.label + + f.children.forEach(s => { + if (!sId || sId !== s.value) return + label += ' / ' + s.label + + s.children.forEach(t => { + if (!tId || tId !== t.value) return + label += ' / ' + t.label + + col.MenuID = t.MenuID + col.MenuName = t.MenuName + col.MenuNo = t.MenuNo + col.tabType = t.type + col.label = label + }) + }) + }) + } else { + menulist.forEach(f => { + if (col.menu !== f.value) return + col.label = f.label + }) + } + return col + }) + this.setState({menus: columns}) + this.props.update(columns) } render() { @@ -70,10 +114,9 @@ const { menus, columns } = this.state return ( - <div className="menus-box-wrap"> - <ColumnForm appType={appType} menulist={menulist} columnChange={this.columnChange}/> - {/* <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>濡傞渶瀵煎嚭搴忓彿锛岃浣跨敤瀛楁 $Index銆�</div> */} - <EditTable actions={['edit', 'move', 'del']} type="excelcolumn" data={menus} columns={columns} onChange={this.changeColumns}/> + <div style={{minHeight: '250px'}}> + <ColumnForm appType={appType} menus={menus} menulist={menulist} columnChange={this.columnChange}/> + <EditTable actions={['edit', 'move', 'copy', 'del']} type={appType + 'cardmenus'} data={menus} columns={columns} onChange={this.changeColumns}/> </div> ) } -- Gitblit v1.8.0