import ConfirmButton from '../../components/common/ConfirmButton';
import { message } from "antd/lib/index";
import React from 'react';
import FormPage from '../../components/FormPage';

export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
  },
  onBeforeEdit: ({ isNew, stateData, setFieldEditable, setFieldVisible, setFieldRequired }) => {
    if (stateData.SHIFT_STATUS == 9) {
      setFieldVisible('AUDIT_OPINION', true);
    } else {
      setFieldVisible('AUDIT_OPINION', false);
      if (stateData.SHIFT_STATUS >= 2) {
        setFieldEditable('CURRENT_CLASS_STATUS', false);
        setFieldEditable('CURRENT_CLASS_QUESTION', false);
        setFieldEditable('CURRENT_CLASS_MEASURE', false);
        setFieldEditable('DEVICE_STATUS', false);
        setFieldEditable('DEVICE_QUESTION', false);
        setFieldEditable('DEVICE_MEASURE', false);
        setFieldEditable('ENVIRONMENT_STATUS', false);
        setFieldEditable('ENVIRONMENT_QUESTION', false);
        setFieldEditable('ENVIRONMENT_MEASURE', false);
        setFieldEditable('SUPPLIES_STATUS', false);
        setFieldEditable('SUPPLIES_USED', false);
        setFieldEditable('SUPPLIES_QUESTION', false);
        setFieldEditable('SUPPLIES_MEASURE', false);
        setFieldEditable('DEVICE_STORAGE', false);
        setFieldEditable('Nav_Files', false);
      }
    }
    if (stateData.CURRENT_CLASS_STATUS == 1) {
      setFieldRequired('CURRENT_CLASS_QUESTION', true);
      setFieldRequired('CURRENT_CLASS_MEASURE', true);
      setFieldVisible('CURRENT_CLASS_QUESTION', true);
      setFieldVisible('CURRENT_CLASS_MEASURE', true);
    } else {
      setFieldRequired('CURRENT_CLASS_QUESTION', false);
      setFieldRequired('CURRENT_CLASS_MEASURE', false);
      setFieldVisible('CURRENT_CLASS_QUESTION', false);
      setFieldVisible('CURRENT_CLASS_MEASURE', false);
    }
    if (stateData.DEVICE_STATUS == 1) {
      setFieldRequired('DEVICE_QUESTION', true);
      setFieldRequired('DEVICE_MEASURE', true);
      setFieldVisible('DEVICE_QUESTION', true);
      setFieldVisible('DEVICE_MEASURE', true);
    } else {
      setFieldRequired('DEVICE_QUESTION', false);
      setFieldRequired('DEVICE_MEASURE', false);
      setFieldVisible('DEVICE_QUESTION', false);
      setFieldVisible('DEVICE_MEASURE', false);
    }
    if (stateData.ENVIRONMENT_STATUS == 1) {
      setFieldRequired('ENVIRONMENT_QUESTION', true);
      setFieldRequired('ENVIRONMENT_MEASURE', true);
      setFieldVisible('ENVIRONMENT_QUESTION', true);
      setFieldVisible('ENVIRONMENT_MEASURE', true);
    } else {
      setFieldRequired('ENVIRONMENT_QUESTION', false);
      setFieldRequired('ENVIRONMENT_MEASURE', false);
      setFieldVisible('ENVIRONMENT_QUESTION', false);
      setFieldVisible('ENVIRONMENT_MEASURE', false);
    }
    if (stateData.SUPPLIES_STATUS == 1) {
      setFieldRequired('SUPPLIES_QUESTION', true);
      setFieldRequired('SUPPLIES_MEASURE', true);
      setFieldVisible('SUPPLIES_QUESTION', true);
      setFieldVisible('SUPPLIES_MEASURE', true);
    } else {
      setFieldRequired('SUPPLIES_QUESTION', false);
      setFieldRequired('SUPPLIES_MEASURE', false);
      setFieldVisible('SUPPLIES_QUESTION', false);
      setFieldVisible('SUPPLIES_MEASURE', false);
    }
  },

  onChange: ({ value, colInfo, getFieldValue, setFieldVisible, setFieldValue, setFieldEditable, setFieldRequired, resetFields }) => {
    if (colInfo.FIELD_NAME == 'CURRENT_CLASS_STATUS') {
      if (getFieldValue('CURRENT_CLASS_STATUS') == 1) {
        setFieldRequired('CURRENT_CLASS_QUESTION', true);
        setFieldRequired('CURRENT_CLASS_MEASURE', true);
        setFieldVisible('CURRENT_CLASS_QUESTION', true);
        setFieldVisible('CURRENT_CLASS_MEASURE', true);
      } else {
        setFieldRequired('CURRENT_CLASS_QUESTION', false);
        setFieldRequired('CURRENT_CLASS_MEASURE', false);
        setFieldVisible('CURRENT_CLASS_QUESTION', false);
        setFieldVisible('CURRENT_CLASS_MEASURE', false);
      }
    }
    if (colInfo.FIELD_NAME == 'DEVICE_STATUS') {
      if (getFieldValue('DEVICE_STATUS') == 1) {
        setFieldRequired('DEVICE_QUESTION', true);
        setFieldRequired('DEVICE_MEASURE', true);
        setFieldVisible('DEVICE_QUESTION', true);
        setFieldVisible('DEVICE_MEASURE', true);
      } else {
        setFieldRequired('DEVICE_QUESTION', false);
        setFieldRequired('DEVICE_MEASURE', false);
        setFieldVisible('DEVICE_QUESTION', false);
        setFieldVisible('DEVICE_MEASURE', false);
      }
    }
    if (colInfo.FIELD_NAME == 'ENVIRONMENT_STATUS') {
      if (getFieldValue('ENVIRONMENT_STATUS') == 1) {
        setFieldRequired('ENVIRONMENT_QUESTION', true);
        setFieldRequired('ENVIRONMENT_MEASURE', true);
        setFieldVisible('ENVIRONMENT_QUESTION', true);
        setFieldVisible('ENVIRONMENT_MEASURE', true);
      } else {
        setFieldRequired('ENVIRONMENT_QUESTION', false);
        setFieldRequired('ENVIRONMENT_MEASURE', false);
        setFieldVisible('ENVIRONMENT_QUESTION', false);
        setFieldVisible('ENVIRONMENT_MEASURE', false);
      }
    }
    if (colInfo.FIELD_NAME == 'SUPPLIES_STATUS') {
      if (getFieldValue('SUPPLIES_STATUS') == 1) {
        setFieldRequired('SUPPLIES_QUESTION', true);
        setFieldRequired('SUPPLIES_MEASURE', true);
        setFieldVisible('SUPPLIES_QUESTION', true);
        setFieldVisible('SUPPLIES_MEASURE', true);
      } else {
        setFieldRequired('SUPPLIES_QUESTION', false);
        setFieldRequired('SUPPLIES_MEASURE', false);
        setFieldVisible('SUPPLIES_QUESTION', false);
        setFieldVisible('SUPPLIES_MEASURE', false);
      }
    }
  },
};
