/* eslint-disable no-undef */
import {extendInclude, extendRule, guid} from "../../utils/common";
import { message } from "antd";
//检验规则编辑
export default {
 
  onAfterAddSubRow:({pageCode,record,app})=>{
    if(pageCode==='Nav_Randoms'){
      const enums=app?app.enums:null;
      if(enums&&enums['QCDefectGradeEnum']&&enums['QCDefectGradeEnum'].options){
        const aqls=[];
        enums['QCDefectGradeEnum'].options.forEach((t,index)=>{
          aqls.push({
            ID:guid(),
            ROW_NO:(index+1),
            TEST_RULE_RANDOM_ID:record.ID,
            QC_DEFECT_GRADE:t.value,
            ORG_ID:record.ORG_ID,
          });
        });
        record['Nav_AQLs']=aqls;
       // updateSubTableData({pageCode:'Nav_AQLs',data:aqls});
      }
    }
  },
  onBeforeSave:({data,stateData,getFieldValue,setFieldValue})=>{
    let checkResult=false;
    if(stateData.Nav_Randoms && stateData.Nav_Randoms.length>0){
      let  Randoms= stateData.Nav_Randoms.filter(t=>!t.IS_DELETED );
      if(!Randoms || Randoms.length<=0){
        message.warn("检验规则明细不得为空");
        checkResult=true;
      }
    }else{
      message.warn("检验规则明细不得为空");
      checkResult=true;
    }
    return checkResult;
  },
}
