/** * Created by mar105 on 2019-02-27. */ /* eslint-disable object-curly-newline,prefer-destructuring */ import React, { Component } from 'react'; import { ExportOutlined, PrinterOutlined, SaveOutlined } from '@ant-design/icons'; import { Row, Col } from 'antd'; import styles from '../Common/ToolBar/index.less'; import ShowType from '../Common/CommonComponent'; import * as commonUtils from '../../utils/utils';/* 通用方法 */ import AffixMenu from '../../routes/common/AffixMenu'; import ProductionPlan1 from '../../assets/ProductionPlan-1.svg'; import ProductionPlan2 from '../../assets/ProductionPlan-2.svg'; import ProductionPlan7 from '../../assets/ProductionPlan-7.svg'; import ProductionPlan8 from '../../assets/ProductionPlan-8.svg'; import ProductionPlan11 from '../../assets/ProductionPlan-11.svg'; export default class productionHeader extends Component { /** 构造函数 */ constructor(props) { super(props); this.state = { enabled: props.enabled, masterConfig: props.masterConfig, stateValue: props.stateValue, masterData: props.masterData, }; } /** 渲染前只执行一次 */ componentWillMount() { /* state和this属性赋值 */ this.assignmentWillProps(this.props); } /** props改变的时候触发 */ componentWillReceiveProps(nextProps) { /* state和this属性赋值 */ this.assignmentWillProps(nextProps); } /** 返回true执行渲染,返回false不渲染 */ shouldComponentUpdate(nextProps, nextState) { const { masterConfig, stateValue, enabled, masterData, } = this.state; const ret = enabled !== nextState.enabled || JSON.stringify(masterConfig) !== JSON.stringify(nextState.masterConfig) || JSON.stringify(masterData) !== JSON.stringify(nextState.masterData) || JSON.stringify(stateValue) !== JSON.stringify(nextState.stateValue); return ret; } assignmentWillProps = (props) => { this.setState({ enabled: props.enabled, masterConfig: props.masterConfig, masterData: props.masterData, stateValue: props.stateValue, }); } // 获取header按钮状态 stateValue HandlerHeaderButtonShowState = (props) => { const { masterData, searchSolution } = props; let filterCondition = []; let stateValue = 99; if (commonUtils.isNotEmptyObject(masterData) && commonUtils.isNotEmptyObject(masterData.sSearchSolutionId)) { const iIndex = searchSolution.findIndex(item => item.sId === masterData.sSearchSolutionId); if (iIndex > -1) { filterCondition = JSON.parse(searchSolution[iIndex].sCondition); let state = ''; let frozen = ''; filterCondition.forEach((item) => { if (item.bFilterName === 'sState') { state = item.bFilterValue; } if (item.bFilterName === 'bFrozen') { frozen = item.bFilterValue; } }); if (commonUtils.isEmptyObject(frozen) && commonUtils.isNotEmptyObject(state)) { if (state === '未排程') { stateValue = 0; } else if (state === '未下达' || state === '已排程') { stateValue = 1; } else if (state === '已下达') { stateValue = 2; } else if (state === '已暂停') { stateValue = 3; } else if (state === '已完成') { stateValue = 5; } } else if (commonUtils.isNotEmptyObject(frozen)) { stateValue = 4; } else if (commonUtils.isNotEmptyObject(frozen) && commonUtils.isNotEmptyObject(state)) { stateValue = 99; } } } return { stateValue }; } handleClick = (iTag) => { this.props.onButtonClick(iTag); } handleSwitchChange = (value) => { this.props.onSwitchChange(value); } rowReturnType = (child, i) => { const { enabled, stateValue } = this.state; const sMemo = child.sName.toLowerCase().endsWith('memo'); const iColValue = sMemo ? 21 : child.iColValue * 2; const iOrder = sMemo ? 100 : child.iOrder > 100 ? 100 : child.iOrder; const enabledNew = (enabled && !child.bReadonly && !child.specialControl); const type = commonUtils.isNotEmptyObject(child.sControlName) && child.sControlName.toLowerCase().startsWith('btn'); let showTypeProps = {}; if (!type) { const switchBtn = child.sControlName.toLowerCase().startsWith('switch'); if (!switchBtn) { showTypeProps = { name: 'master', form: this.props.form, formId: this.props.sModelsId, getSqlDropDownData: this.props.getSqlDropDownData, getSqlCondition: this.props.getSqlCondition, handleSqlDropDownNewRecord: this.props.handleSqlDropDownNewRecord, getFloatNum: this.props.getFloatNum, getDateFormat: this.props.getDateFormat, onChange: this.props.onChange, showConfig: child, textArea: sMemo, enabled: enabledNew, dataValue: commonUtils.isNotEmptyObject(this.props.masterData) ? this.props.masterData[child.sName] : '', bTable: false, }; return (