import React from 'react'; import { Modal,Cascader,Checkbox, Row, Col,message,Select } from 'antd'; class EDUnitUseSettingModal extends React.Component { constructor(props) { super(props); this.state = { visible: false, pOptions :[], pDefaultValue:[], tOptions :[], tDefaultValue:"", boxData:[], boxDefaultValue:[], }; }; componentDidMount(){ if(this.props.onRef) { this.props.onRef(this) } }; showModal = () => { this.getUnitNameCheckboxData(); this.getProNameCheckboxData(); this.getClassNameCheckboxData(); this.setState({ visible: true, }); } handleOk = e => { this.ProNameSettingSave(this.state.boxDefaultValue,"ProNameSelect_" + this.props.login.userId + "_Select",true); this.ProNameSettingSave(this.state.boxDefaultValue,"ProNameSelect_" + this.props.login.userId,true); message.success("配置成功"); var t = this.props.searchRules; this.setState({ visible: false, },()=>{this.props.getUnitUseChartData(this.props.searchRules,false)}); }; handleCancel = e => { this.setState({ visible: false, }); }; //获取生产单元数据(选择数据项) getUnitNameCheckboxData = () => { const json = { OrgId: this.props.login.OrgId, ParentIds: this.state.pDefaultValue, Code: "ProNameSelect_" + this.props.login.userId + "_Pro", IsFirst: false } this.props.dispatch({ type: 'app/getDataByPost', url: 'BD/BDMeterNode/GetUnitSelectTreeData', payload: json, onlyData: false, onComplete: (re) => { if (re && re.IsSuccessful && re.Data) { this.setState({ pOptions: re.Data.Options, pDefaultValue: re.Data.DefaultValue }) } } }) }; //班组信息(选择数据项) getClassNameCheckboxData = () => { const json = { OrgId: this.props.login.OrgId, } this.props.dispatch({ type: 'app/getDataByPost', url: 'BD/BDMeterNode/GetTeamSelectData', payload: json, onlyData: false, onComplete: (re) => { if (re && re.IsSuccessful && re.Data) { this.setState({ tOptions: re.Data.Options, tDefaultValue: re.Data.DefaultValue }) } } }) }; //产品名称(数据项) getProNameCheckboxData = () => { var pId = ""; if(this.state.pDefaultValue && this.state.pDefaultValue.length > 0){ pId = this.state.pDefaultValue[this.state.pDefaultValue.length-1] } const json = { OrgId: this.props.login.OrgId, ParentIds: this.state.boxDefaultValue, Code: "ProNameSelect_" + this.props.login.userId, IsFirst: false, UnitId: pId, TeamId: this.state.tDefaultValue } this.props.dispatch({ type: 'app/getDataByPost', url: 'FM/Product/GetProNameList', payload: json, onlyData: false, onComplete: (re) => { if (re && re.IsSuccessful && re.Data) { this.setState({ boxData: re.Data.Options, boxDefaultValue: re.Data.DefaultValue }) } } }) }; onChange = (value) =>{ this.setState({ pDefaultValue: value },()=>{ this.getProNameCheckboxData(false); }); } onClassChange = (value) =>{ this.setState({ tDefaultValue: value },()=>{ this.getProNameCheckboxData(false); }); } onCheck = (checkedValues)=> { if(checkedValues && checkedValues.length > 8) { message.error("最多选择8个产品!"); return; } this.setState({ boxDefaultValue: checkedValues },()=>{ }); } //保存选中项 ProNameSettingSave = (select,code,isReData = true) => { const json = { OrgId: this.props.login.OrgId, UserId: this.props.login.userId, ChildIds: select, Code: code } this.props.dispatch({ type: 'app/getDataByPost', url: 'FM/Product/ProNameSelectSave', payload: json, onlyData: false, onComplete: (re) => { if (re && re.IsSuccessful && re.Data) { } } }) } render(){ const { pDefaultValue,pOptions,tDefaultValue,tOptions,boxData,boxDefaultValue } = this.state return( { boxData.map(item=>{ return ( {item.Label} ); }) } ) } } export default EDUnitUseSettingModal