import ConfirmButton from '../../components/common/ConfirmButton';
import { Button, message } from 'antd'
import storage from '../../utils/storage'
import config from "../../config.js"
import { extendInclude, extendRule, getDataFieldValue, initFilter, empty, extendOrder, guid, getSubTableData, onBeforeSaveHandleRecordLog, auditOptionShow2 } from "../../utils/common";
import Item from 'antd/lib/list/Item';
import styles from '../../components/CustomPages/HI/StepForm.css';
import EditRowShowModal from '../../components/common/EditRowShowModal';
import FormPage from '../../components/FormPage';
export default {
  onBeforeEdit: ({ data, setFieldEditable, setFieldValueByBatch }) => {
    if (data.rules && data.rules.length > 0) {
      // var parentInfo = data.rules[0].value
      var parentInfo = data.rules[0]//.value

      if (parentInfo.Nav_ListCheckRiskArea && parentInfo.Nav_ListCheckProject && parentInfo.Nav_ListCheckProjectCategory) {
        var AREA_IDS = ''
        var PROJECT_IDS = ''
        var CATEGORY_IDS = ''
        for (var i = 0; i < parentInfo.Nav_ListCheckRiskArea.length; i++) {
          AREA_IDS += ',' + parentInfo.Nav_ListCheckRiskArea[i].RISK_AREA_ID
        }
        for (var i = 0; i < parentInfo.Nav_ListCheckProject.length; i++) {
          PROJECT_IDS += ',' + parentInfo.Nav_ListCheckProject[i].CHECK_PROJECT_ID
        }
        for (var i = 0; i < parentInfo.Nav_ListCheckProjectCategory.length; i++) {
          CATEGORY_IDS += ',' + parentInfo.Nav_ListCheckProjectCategory[i].CHECK_PROJECT_CATEGORY_ID
        }
        let temps = [];
        temps.push({ field: "ROW_NO", value: parentInfo.Nav_ListSafeCheckDetail.length });
        temps.push({ field: "SAFE_CHECK_ID", value: parentInfo.ID });
        temps.push({ field: "AREA_IDS", value: AREA_IDS });
        temps.push({ field: "PROJECT_IDS", value: PROJECT_IDS });
        temps.push({ field: "CATEGORY_IDS", value: CATEGORY_IDS });
        temps.push({ field: "CHECK_TYPE_ID", value: parentInfo.CHECK_TYPE_ID });
        temps.push({ field: "CHECK_TYPE_LEVEL_ID", value: parentInfo.CHECK_TYPE_LEVEL_ID });
        temps.push({ field: "DEPARTMENT_ID", value: parentInfo.DEPARTMENTID });
        temps.push({ field: "CHECKOBJECT", value: parentInfo.CHECKOBJECT });
        temps.push({ field: "Nav_ListUserCheck", value: parentInfo.Nav_ListSafeCheckDetail[0].Nav_ListCheckDetailUser });
        if (parentInfo.Nav_ListCheckRiskArea != null && parentInfo.Nav_ListCheckRiskArea.length == 1) {
          temps.push({ field: "Nav_CheckArea.NAME", value: parentInfo.Nav_ListCheckRiskArea[0].Nav_RiskArea.NAME });
          temps.push({ field: "RISK_AREA_ID", value: parentInfo.Nav_ListCheckRiskArea[0].RISK_AREA_ID });
          // setFieldEditable("Nav_CheckArea.NAME", false)
        }

        setFieldValueByBatch(temps);
      }
    }
  },
}
