| | |
| | | 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 |
| | |
| | | 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: '分类'} |
| | | |
| | |
| | | (<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>) |
| | | } |
| | | ] |
| | |
| | | |
| | | 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() {} |
| | | }) |
| | |
| | | }) |
| | | } |
| | | if (editMenu.MenuID && editMenu.property === 'menu' && _menu.property !== 'menu') { |
| | | const _this = this |
| | | const that = this |
| | | confirm({ |
| | | content: '菜单将被重置,确定修改吗?', |
| | | onOk() { |
| | |
| | | } |
| | | return item |
| | | }) |
| | | _this.setState({data: _data, editMenu: null, visible: false}) |
| | | _this.props.menuUpdate({...menu, sublist: _data}) |
| | | that.setState({data: _data, editMenu: null, visible: false}) |
| | | that.props.menuUpdate({...menu, sublist: _data}) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | |
| | | |
| | | 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" |
| | |
| | | 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: '分类'} |
| | | |
| | |
| | | (<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>) |
| | | } |
| | | ] |
| | |
| | | |
| | | 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() {} |
| | | }) |
| | |
| | | }) |
| | | } |
| | | if (editMenu.MenuID && editMenu.property === 'menu' && _menu.property !== 'menu') { |
| | | const _this = this |
| | | const that = this |
| | | confirm({ |
| | | content: '菜单将被重置,确定修改吗?', |
| | | onOk() { |
| | |
| | | } |
| | | return item |
| | | }) |
| | | _this.setState({data: _data, editMenu: null, visible: false}) |
| | | _this.props.menuUpdate({...menu, sublist: _data}) |
| | | that.setState({data: _data, editMenu: null, visible: false}) |
| | | that.props.menuUpdate({...menu, sublist: _data}) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | |
| | | |
| | | 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" |
| | |
| | | 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: '分类'} |
| | | |
| | |
| | | (<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>) |
| | | } |
| | | ] |
| | |
| | | |
| | | 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() {} |
| | | }) |
| | |
| | | } |
| | | |
| | | if (editMenu.MenuID && editMenu.property === 'menu' && _menu.property !== 'menu') { |
| | | const _this = this |
| | | const that = this |
| | | confirm({ |
| | | content: '菜单将被重置,确定修改吗?', |
| | | onOk() { |
| | |
| | | } |
| | | return item |
| | | }) |
| | | _this.setState({data: _data, editMenu: null, visible: false}) |
| | | that.setState({data: _data, editMenu: null, visible: false}) |
| | | }, |
| | | onCancel() {} |
| | | }) |