weaver_trunk_cli/pc4mobx/prj/components/dialog/taskCreateDialog.js

116 lines
4.5 KiB
JavaScript
Raw Normal View History

2023-03-08 15:22:38 +08:00
import React from 'react';
import { inject, observer } from 'mobx-react';
import {WeaDialog,WeaRightMenu,WeaNewScroll,WeaLocaleProvider} from "ecCom"
import {Button,Modal} from "antd"
import {WeaTableNew,WeaSwitch} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;
import {toJS} from "mobx"
import CptInfo from './cptInfo'
@observer
export default class CptEdit extends React.Component{
componentWillReceiveProps(nextProps){
}
shouldComponentUpdate(){
return true;
}
render(){
const {contentStore,isdata} = this.props;
const {showEditDialog,cptForm,cptInfo} = this.props.contentStore;
return (
<WeaDialog
title={isdata == "2" ?"编辑资产" :"编辑资产资料" }
visible={showEditDialog}
buttons={this.getBottomButtons()}
icon="icon-coms-project"
iconBgcolor="#217346"
onCancel={()=>{contentStore.showCptInfo(false)}}
style={{width:1000,height:700}}>
<WeaRightMenu datas={this.getRightMenu()} onClick={this.onRightMenuClick.bind(this)} >
<WeaNewScroll height={"100%"}>
{showEditDialog && <CptInfo form={cptForm} condition={cptInfo} />}
</WeaNewScroll>
</WeaRightMenu>
</WeaDialog>
)
}
getBottomButtons(){
const {contentStore} = this.props;
const {cptInfo,saveCptInfo,capitalid,showCptInfo} = this.props.contentStore;
let btnArr = [];
let rightMenu = toJS(cptInfo.rightMenus) || [];
rightMenu && rightMenu.length>0 && rightMenu.map(m=>{
m.isTop == '1' && btnArr.length < 4 && btnArr.push(
<Button type="primary"
onClick={()=>{
if(m.type == "BTN_SUBMIT"){ //
saveCptInfo();
}else if(m.type == "BTN_EDIT"){
showCptInfo(true,{capitalid:capitalid,viewtype:'edit'});
}
}}>
{m.menuName}
</Button>
);
});
btnArr.push(<Button type="primary" onClick={()=>{contentStore.showCptInfo(false)}}>关闭</Button>)
return btnArr;
}
getRightMenu(){
const {contentStore} = this.props;
const {cptInfo,} = this.props.contentStore;
let btnArr = [];
let rightMenu = toJS(cptInfo.rightMenus) || [];
rightMenu && rightMenu.length>0 && rightMenu.map(m=>{
btnArr.push({
icon: <i className={m.menuIcon} />,
content: m.menuName
})
});
return btnArr
}
onRightMenuClick(key){
const {contentStore} = this.props;
const {cptInfo,saveCptInfo,capitalid,showCptInfo,onCptDel,doMend,onGiveback} = this.props.contentStore;
let rightMenu = toJS(cptInfo.rightMenus) || [];
let that = this;
rightMenu && rightMenu.length>0 && rightMenu.map((m,i)=>{
if(Number(key) == i){
if(m.type == "BTN_SUBMIT"){ //验收
saveCptInfo();
}else if(m.type == 'BTN_BACK'){ //返回
showCptInfo(true,{capitalid:capitalid,viewtype:'edit'});
}else if(m.type == "BTN_EDIT"){
showCptInfo(true,{capitalid:capitalid,viewtype:'edit'});
}else if(m.type == "BTN_DELETE"){
Modal.confirm({
title: '您确认要删除吗?',
content: '',
onOk() {
onCptDel({capitalid:capitalid,viewtype:'cptdel'});
showCptInfo(false);
},
onCancel() {},
});
}else if(m.type == "BTN_GIVEBACK"){ //归还
let params = {viewtype:'cptbackone',capitalid:capitalid}
Modal.confirm({
title: '您确认要归还吗?',
content: '',
onOk() {
onGiveback(params);
},
onCancel() {},
});
}else if(m.type == "BTN_MEND"){ //送修
doMend(true,{capitalid:capitalid})
}
}
});
}
}