From c06e58c80240afd703d289bb1c584e08b9783383 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 13 六月 2025 20:24:25 +0800 Subject: [PATCH] 2025-06-13 --- src/pc/components/navbar/normal-navbar/menusetting/menutable/index.jsx | 132 ++++++++++++++++++++++++++++++------------- 1 files changed, 92 insertions(+), 40 deletions(-) diff --git a/src/pc/components/navbar/normal-navbar/menusetting/menutable/index.jsx b/src/pc/components/navbar/normal-navbar/menusetting/menutable/index.jsx index a96ea84..e0a85cf 100644 --- a/src/pc/components/navbar/normal-navbar/menusetting/menutable/index.jsx +++ b/src/pc/components/navbar/normal-navbar/menusetting/menutable/index.jsx @@ -1,11 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Table, Button, Modal, Icon } from 'antd' +import { Table, Button, Modal } from 'antd' +import { PlusOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons' import MenuForm from '../menuform' import Utils from '@/utils/utils.js' -// import MKEmitter from '@/utils/events.js' import './index.scss' const { confirm } = Modal @@ -21,7 +21,7 @@ editMenu: null, columns: [ { title: '鑿滃崟鍚嶇О', dataIndex: 'name', key: 'name' }, - { title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo' }, + // { title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo' }, { title: '鑿滃崟灞炴��', dataIndex: 'property', key: 'property', render: text => { const trans = {menu: '鑿滃崟', link: '閾炬帴', linkmenu: '鍏宠仈鑿滃崟', classify: '鍒嗙被'} @@ -42,8 +42,8 @@ (<div> <Button type="link" style={{padding: '0 5px', marginRight: '5px'}} onClick={() => this.editMenu(record)}>缂栬緫</Button> <Button type="link" style={{color: '#ff4d4f', padding: '0 5px', marginRight: '5px'}} onClick={() => this.delMenu(record)}>鍒犻櫎</Button> - <Icon type="arrow-up" style={{color: '#26C281', cursor: 'pointer', padding: '0 5px', marginRight: '5px'}} onClick={() => this.moveUp(record)}/> - <Icon type="arrow-down" style={{color: '#ff4d4f', cursor: 'pointer', padding: '0 5px'}} onClick={() => this.moveDown(record)}/> + <ArrowUpOutlined style={{color: '#26C281', cursor: 'pointer', padding: '0 5px', marginRight: '5px'}} onClick={() => this.moveUp(record)}/> + <ArrowDownOutlined style={{color: '#ff4d4f', cursor: 'pointer', padding: '0 5px'}} onClick={() => this.moveDown(record)}/> </div>) } ] @@ -88,15 +88,15 @@ delMenu = (record) => { const { menu } = this.props - const _this = this + const that = this confirm({ title: '纭畾鍒犻櫎鍚楋紵', content: '', onOk() { - let _data = _this.state.data.filter(item => item.MenuID !== record.MenuID) - _this.setState({data: _data}) - _this.props.menuUpdate({...menu, sublist: _data}) + let _data = that.state.data.filter(item => item.MenuID !== record.MenuID) + that.setState({data: _data}) + that.props.menuUpdate({...menu, sublist: _data}) }, onCancel() {} }) @@ -123,7 +123,7 @@ this.menuRef.handleConfirm().then(res => { let _menu = {...editMenu, ...res} - let _data = this.state.data + let _data = fromJS(this.state.data).toJS() if (!_menu.MenuID) { _menu.MenuID = Utils.getuuid() _data.push(_menu) @@ -136,8 +136,26 @@ } }) } - this.setState({data: _data, editMenu: null, visible: false}) - this.props.menuUpdate({...menu, sublist: _data}) + if (editMenu.MenuID && editMenu.property === 'menu' && _menu.property !== 'menu') { + const that = this + confirm({ + content: '鑿滃崟灏嗚閲嶇疆锛岀‘瀹氫慨鏀瑰悧锛�', + onOk() { + _data = _data.map(item => { + if (item.MenuID === _menu.MenuID) { + item.MenuID = Utils.getuuid() + } + return item + }) + that.setState({data: _data, editMenu: null, visible: false}) + that.props.menuUpdate({...menu, sublist: _data}) + }, + onCancel() {} + }) + } else { + this.setState({data: _data, editMenu: null, visible: false}) + this.props.menuUpdate({...menu, sublist: _data}) + } }) } @@ -146,7 +164,7 @@ return ( <div className="thdmenu-control-wrap"> - <Icon type="plus" style={{color: '#26C281', padding: '5px', fontSize: '16px'}} onClick={this.plusMenu}/> + <PlusOutlined style={{color: '#26C281', padding: '5px', fontSize: '16px'}} onClick={this.plusMenu}/> <Table rowKey="MenuID" size="small" @@ -185,7 +203,7 @@ editMenu: null, columns: [ { title: '鑿滃崟鍚嶇О', dataIndex: 'name', key: 'name' }, - { title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo' }, + // { title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo' }, { title: '鑿滃崟灞炴��', dataIndex: 'property', key: 'property', render: text => { const trans = {menu: '鑿滃崟', link: '閾炬帴', linkmenu: '鍏宠仈鑿滃崟', classify: '鍒嗙被'} @@ -206,8 +224,8 @@ (<div> <Button type="link" style={{padding: '0 5px', marginRight: '5px'}} onClick={() => this.editMenu(record)}>缂栬緫</Button> <Button type="link" style={{color: '#ff4d4f', padding: '0 5px', marginRight: '5px'}} onClick={() => this.delMenu(record)}>鍒犻櫎</Button> - <Icon type="arrow-up" style={{color: '#26C281', cursor: 'pointer', padding: '0 5px', marginRight: '5px'}} onClick={() => this.moveUp(record)}/> - <Icon type="arrow-down" style={{color: '#ff4d4f', cursor: 'pointer', padding: '0 5px'}} onClick={() => this.moveDown(record)}/> + <ArrowUpOutlined style={{color: '#26C281', cursor: 'pointer', padding: '0 5px', marginRight: '5px'}} onClick={() => this.moveUp(record)}/> + <ArrowDownOutlined style={{color: '#ff4d4f', cursor: 'pointer', padding: '0 5px'}} onClick={() => this.moveDown(record)}/> </div>) } ] @@ -253,15 +271,15 @@ delMenu = (record) => { const { menu } = this.props - const _this = this + const that = this confirm({ title: (record.property === 'classify' && record.sublist.length > 0 ? '鑿滃崟涓嬪惈鏈夊瓙鑿滃崟锛�' : '') + '纭畾鍒犻櫎鍚楋紵', content: '', onOk() { - let _data = _this.state.data.filter(item => item.MenuID !== record.MenuID) - _this.setState({data: _data}) - _this.props.menuUpdate({...menu, sublist: _data}) + let _data = that.state.data.filter(item => item.MenuID !== record.MenuID) + that.setState({data: _data}) + that.props.menuUpdate({...menu, sublist: _data}) }, onCancel() {} }) @@ -288,7 +306,7 @@ this.menuRef.handleConfirm().then(res => { let _menu = {...editMenu, ...res} - let _data = this.state.data + let _data = fromJS(this.state.data).toJS() if (!_menu.MenuID) { _menu.MenuID = Utils.getuuid() _data.push(_menu) @@ -301,8 +319,26 @@ } }) } - this.setState({data: _data, editMenu: null, visible: false}) - this.props.menuUpdate({...menu, sublist: _data}) + if (editMenu.MenuID && editMenu.property === 'menu' && _menu.property !== 'menu') { + const that = this + confirm({ + content: '鑿滃崟灏嗚閲嶇疆锛岀‘瀹氫慨鏀瑰悧锛�', + onOk() { + _data = _data.map(item => { + if (item.MenuID === _menu.MenuID) { + item.MenuID = Utils.getuuid() + } + return item + }) + that.setState({data: _data, editMenu: null, visible: false}) + that.props.menuUpdate({...menu, sublist: _data}) + }, + onCancel() {} + }) + } else { + this.setState({data: _data, editMenu: null, visible: false}) + this.props.menuUpdate({...menu, sublist: _data}) + } }) } @@ -326,7 +362,7 @@ return ( <div className="submenu-control-wrap"> - <Icon type="plus" style={{color: '#26C281', padding: '5px', fontSize: '16px'}} onClick={this.plusMenu}/> + <PlusOutlined style={{color: '#26C281', padding: '5px', fontSize: '16px'}} onClick={this.plusMenu}/> <Table size="middle" rowKey="MenuID" @@ -366,7 +402,7 @@ editMenu: null, columns: [ { title: '鑿滃崟鍚嶇О', dataIndex: 'name', key: 'name' }, - { title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo' }, + // { title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo' }, { title: '鑿滃崟灞炴��', dataIndex: 'property', key: 'property', render: text => { const trans = {menu: '鑿滃崟', link: '閾炬帴', linkmenu: '鍏宠仈鑿滃崟', classify: '鍒嗙被'} @@ -387,8 +423,8 @@ (<div> <Button type="link" style={{padding: '0 5px', marginRight: '5px'}} onClick={() => this.editMenu(record)}>缂栬緫</Button> <Button type="link" style={{color: '#ff4d4f', padding: '0 5px', marginRight: '5px'}} onClick={() => this.delMenu(record)}>鍒犻櫎</Button> - <Icon type="arrow-up" style={{color: '#26C281', cursor: 'pointer', padding: '0 5px', marginRight: '5px'}} onClick={() => this.moveUp(record)}/> - <Icon type="arrow-down" style={{color: '#ff4d4f', cursor: 'pointer', padding: '0 5px'}} onClick={() => this.moveDown(record)}/> + <ArrowUpOutlined style={{color: '#26C281', cursor: 'pointer', padding: '0 5px', marginRight: '5px'}} onClick={() => this.moveUp(record)}/> + <ArrowDownOutlined style={{color: '#ff4d4f', cursor: 'pointer', padding: '0 5px'}} onClick={() => this.moveDown(record)}/> </div>) } ] @@ -430,13 +466,13 @@ delMenu = (record) => { const { data } = this.state - const _this = this + const that = this confirm({ title: (record.property === 'classify' && record.sublist.length > 0 ? '鑿滃崟涓嬪惈鏈夊瓙鑿滃崟锛�' : '') + '纭畾鍒犻櫎鍚楋紵', content: '', onOk() { - _this.setState({data: data.filter(item => item.MenuID !== record.MenuID)}) + that.setState({data: data.filter(item => item.MenuID !== record.MenuID)}) }, onCancel() {} }) @@ -462,22 +498,38 @@ this.menuRef.handleConfirm().then(res => { let _menu = {...editMenu, ...res} + let _data = fromJS(data).toJS() if (!_menu.MenuID) { _menu.MenuID = Utils.getuuid() - this.setState({data: [...data, _menu], editMenu: null, visible: false}) + _data.push(_menu) } else { - this.setState({ - editMenu: null, - visible: false, - data: data.map(item => { - if (item.MenuID === _menu.MenuID) { - return _menu - } else { - return item - } - }) + _data = _data.map(item => { + if (item.MenuID === _menu.MenuID) { + return _menu + } else { + return item + } }) } + + if (editMenu.MenuID && editMenu.property === 'menu' && _menu.property !== 'menu') { + const that = this + confirm({ + content: '鑿滃崟灏嗚閲嶇疆锛岀‘瀹氫慨鏀瑰悧锛�', + onOk() { + _data = _data.map(item => { + if (item.MenuID === _menu.MenuID) { + item.MenuID = Utils.getuuid() + } + return item + }) + that.setState({data: _data, editMenu: null, visible: false}) + }, + onCancel() {} + }) + } else { + this.setState({data: _data, editMenu: null, visible: false}) + } }) } -- Gitblit v1.8.0