/* eslint-disable no-undef */
import {extendInclude, extendRule} from "../../utils/common";

//材料编辑 FM022
export default {
  onChange: ({value,colInfo,getFieldValue,setFieldValue,setFieldEditable}) => {
    if(colInfo&&colInfo.FIELD_NAME=='IS_PRODUCT_CHECK') {
      if (value == 'true' || value == 1) {
        setFieldEditable('PRODUCT_CHECK_TYPE', true);
        setFieldEditable('Nav_WorkStage.NAME', true);
      }
      else {
        setFieldEditable('PRODUCT_CHECK_TYPE', false);
        setFieldEditable('Nav_WorkStage.NAME', false);
      }
    }
  },
  onFetchAutoFilter:({colInfo,params,getFieldValue})=>{
    if(colInfo.FIELD_NAME=='Nav_WorkStage.NAME') {
      extendRule(params, 'TYPE', 1,2);
      extendRule(params, 'ENABLE_STATUS', 1,0);
    }
    else if(colInfo.FIELD_NAME=='Nav_ProductCategory.NAME') {
      extendRule(params, 'ENABLE_STATUS', 1,0);
      extendRule(params, 'PRODUCT_CATEGORY_TYPE', 1,2);
    };

  },
  onBeforeEdit:({isNew,getFieldValue,setFieldValueByBatch,setFieldEditable})=>{
    if(isNew){
      const temps=[];
      temps.push({field:'IS_PRODUCT_CHECK',value:true});
      temps.push({field:'PRODUCT_CHECK_TYPE',value: 1});
      temps.push({field:'PRODUCT_TYPE',value:2});
      setFieldValueByBatch(temps);
    }
    else if(getFieldValue('IS_PRODUCT_CHECK')==0||getFieldValue('IS_PRODUCT_CHECK')=='false'){
      setFieldEditable('PRODUCT_CHECK_TYPE',false);
      setFieldEditable('Nav_WorkStage.NAME', false);
    }
  },
  onBeforeSave:({data,getFieldValue,setFieldValue})=>{
  },
}
