import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { fromJS } from 'immutable'
|
|
import MkIcon from '@/components/mk-icon'
|
import Utils from '@/utils/utils.js'
|
import ColumnForm from './columnform'
|
import asyncComponent from '@/utils/asyncComponent'
|
// import './index.scss'
|
|
const EditTable = asyncComponent(() => import('@/templates/zshare/editTable'))
|
|
class CardMenus extends Component {
|
static propTpyes = {
|
appType: PropTypes.string,
|
menulist: PropTypes.array,
|
menus: PropTypes.array,
|
update: PropTypes.func
|
}
|
|
state = {
|
columns: [
|
{
|
title: '标识',
|
dataIndex: 'sign',
|
inputType: 'input',
|
editable: true,
|
unique: true,
|
required: false,
|
width: '35%'
|
},
|
{
|
title: '颜色',
|
dataIndex: 'color',
|
inputType: 'color',
|
editable: true,
|
required: true,
|
width: '35%'
|
},
|
{
|
title: '图标',
|
dataIndex: 'icon',
|
inputType: 'icon',
|
editable: true,
|
required: false,
|
width: '35%',
|
render: (text, record) => record.icon ? <MkIcon type={record.icon}/> : ''
|
}
|
]
|
}
|
|
UNSAFE_componentWillMount() {
|
const { menus } = this.props
|
|
this.setState({
|
menus: fromJS(menus).toJS()
|
})
|
}
|
|
columnChange = (values) => {
|
const { menus } = this.state
|
values.uuid = Utils.getuuid()
|
let _menus = [...menus, values]
|
|
this.setState({menus: _menus})
|
this.props.update(_menus)
|
}
|
|
changeColumns = (columns) => {
|
this.setState({menus: columns})
|
this.props.update(columns)
|
}
|
|
render() {
|
const { menus, columns } = this.state
|
|
return (
|
<div style={{minHeight: '250px'}}>
|
<ColumnForm menus={menus} columnChange={this.columnChange}/>
|
<EditTable actions={['edit', 'move', 'copy', 'del']} type={'timenodes'} data={menus} columns={columns} onChange={this.changeColumns}/>
|
</div>
|
)
|
}
|
}
|
|
export default CardMenus
|