import { extendRule, initFilter, extendInclude, guid } from "../../utils/common";
import storage from "../../utils/storage";

export default {
    onBeforeEdit: ({ isNew, dispatch, getFieldValue, setFieldValueByBatch, setFieldEditable }) => {
        if (isNew) {
            let orgId = storage('lacal').getItem('webOrgId').val;
            let json = initFilter(orgId);
            extendInclude(json, 'Nav_FQCWorkStage');
            dispatch({
                type: 'FMProcess/getBaseConfig',
                payload: json,
                onComplete: (ret) => {
                    if (ret) {
                        let temps = [];
                        temps.push({ field: 'IS_FQC', value: ret.IS_FQC })
                        temps.push({ field: 'FQC_TYPE', value: ret.FQC_TYPE })
                        temps.push({ field: 'FQC_WORKSTAGE_ID', value: ret.FQC_WORKSTAGE_ID })
                        temps.push({ field: 'FQC_AUTO_INSPEC', value: ret.FQC_AUTO_INSPEC })
                        temps.push({ field: 'FQC_INSPEC_TYPE', value: ret.FQC_INSPEC_TYPE })
                        temps.push({ field: 'FQC_INSPEC_QTY', value: ret.FQC_INSPEC_QTY })
                        temps.push({ field: 'FQC_INSPEC_QTY_OVER', value: ret.FQC_INSPEC_QTY_OVER })
                        temps.push({ field: 'Nav_FQCWorkStage.NAME', value: ret.Nav_FQCWorkStage ? ret.Nav_FQCWorkStage.NAME : null })

                        setFieldValueByBatch(temps);
                    }
                }
            });
        }

    },
}
