import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { Modal, notification, Spin } from 'antd'
|
import { UnlockOutlined } from '@ant-design/icons'
|
|
import Api from '@/api'
|
import MKEmitter from '@/utils/events.js'
|
import TransferForm from '@/templates/zshare/basetransferform'
|
|
class ThawMenu extends Component {
|
static propTpyes = {
|
ParentId: PropTypes.string,
|
Type: PropTypes.string
|
}
|
|
state = {
|
visible: false,
|
targetKeys: [],
|
menulist: null,
|
loading: false
|
}
|
|
trigger = () => {
|
this.setState({
|
visible: true,
|
targetKeys: [],
|
menulist: null,
|
loading: false
|
})
|
|
Api.getSystemConfig({
|
func: 'sPC_Get_FrozenMenu',
|
ParentID: this.props.ParentId,
|
TYPE: +this.props.Type
|
}).then(res => {
|
if (res.status) {
|
this.setState({
|
menulist: res.data.map(menu => {
|
return {
|
key: menu.MenuID,
|
title: menu.MenuName
|
}
|
})
|
})
|
} else {
|
this.setState({
|
menulist: []
|
})
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 5
|
})
|
}
|
})
|
this.setState({visible: true})
|
}
|
|
submit = () => {
|
const { targetKeys } = this.state
|
// 三级菜单解除冻结
|
if (targetKeys.length === 0) {
|
notification.warning({
|
top: 92,
|
message: this.state.dict['form.required.select'] + this.state.dict['model.menu'],
|
duration: 5
|
})
|
return
|
}
|
|
this.setState({
|
loading: true
|
})
|
let defers = targetKeys.map(item => {
|
return new Promise((resolve) => {
|
Api.getSystemConfig({
|
func: 'sPC_MainMenu_ReDel',
|
MenuID: item
|
}).then(res => {
|
if (res.status) {
|
resolve('')
|
} else {
|
resolve(res.message)
|
}
|
})
|
})
|
})
|
Promise.all(defers).then(res => {
|
let msg = res.filter(Boolean)[0]
|
if (msg) {
|
notification.error({
|
top: 92,
|
message: msg,
|
duration: 10
|
})
|
} else {
|
this.setState({
|
loading: false,
|
visible: false,
|
targetKeys: [],
|
thawmenulist: null
|
})
|
|
MKEmitter.emit('mkUpdateMenuList')
|
}
|
})
|
}
|
|
render() {
|
const { visible, menulist, loading } = this.state
|
|
return (
|
<>
|
<UnlockOutlined onClick={this.trigger} style={{color: 'orange'}}/>
|
<Modal
|
title="解冻菜单"
|
visible={visible}
|
width={600}
|
onOk={this.submit}
|
confirmLoading={loading}
|
onCancel={() => this.setState({visible: false})}
|
destroyOnClose
|
>
|
{!menulist ?
|
<Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" /> :
|
<TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={menulist}/>
|
}
|
</Modal>
|
</>
|
)
|
}
|
}
|
|
export default ThawMenu
|