import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { fromJS } from 'immutable'
|
|
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: 'name',
|
inputType: 'input',
|
editable: true,
|
unique: true,
|
width: '30%'
|
},
|
{
|
title: '菜单',
|
dataIndex: 'menu',
|
inputType: !this.props.appType ? 'cascader' : 'select',
|
editable: true,
|
required: true,
|
width: '40%',
|
render: (text) => {
|
if (text === 'image') {
|
return '图片'
|
} else {
|
return '文本'
|
}
|
},
|
options: this.props.menulist
|
}
|
]
|
}
|
|
UNSAFE_componentWillMount() {
|
const { menus } = this.props
|
|
this.setState({
|
menus: fromJS(menus).toJS()
|
})
|
}
|
|
columnChange = (values) => {
|
const { menus } = this.state
|
|
this.setState({menus: [...menus, values]})
|
}
|
|
changeColumns = (columns) => {
|
// const { menus } = this.state
|
|
this.setState({menus: columns})
|
}
|
|
render() {
|
const { appType, menulist } = this.props
|
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>
|
)
|
}
|
}
|
|
export default CardMenus
|