/**
 * @return {string}
 */

export default {
    onChange: ({ value, colInfo, getFieldValue, setFieldVisible, setFieldValue, setFieldEditable }) => {
        if (colInfo.FIELD_NAME == 'Nav_Var.NAME') {
            setFieldVisible('START_TIME', false);
            setFieldVisible('END_TIME', false);
            setFieldVisible('START_MONTH', false);
            setFieldVisible('END_MONTH', false);
            setFieldVisible('START_YEAR', false);
            setFieldVisible('END_YEAR', false);

            const val = getFieldValue('Nav_Var.Nav_SrcTag.Nav_DataFrequency.FREQUENCY_TYPE');
            switch (val) {
                case 2:
                    setFieldVisible('START_MONTH', true);
                    setFieldVisible('END_MONTH', true);
                    break;
                case 3:
                    setFieldVisible('START_YEAR', true);
                    setFieldVisible('END_YEAR', true);
                    break;
                default:
                    setFieldVisible('START_TIME', true);
                    setFieldVisible('END_TIME', true);
            }
        }
        if(colInfo.FIELD_NAME=='START_MONTH' || colInfo.FIELD_NAME=='START_YEAR')
        {
            setFieldValue('START_TIME',value);
        }
        if(colInfo.FIELD_NAME=='END_MONTH' || colInfo.FIELD_NAME=='END_YEAR')
        {
            setFieldValue('END_TIME',value);
        }

    },

    onBeforeEdit: ({ isNew, stateData, login, getFieldValue, setFieldValue, setFieldValueByBatch, setFieldEditable, setFieldVisible }) => {
        setFieldVisible('START_MONTH', false);
        setFieldVisible('END_MONTH', false);
        setFieldVisible('START_YEAR', false);
        setFieldVisible('END_YEAR', false);
        if(!isNew)
        {
            setFieldEditable('Nav_Var.NAME', false);
            setFieldEditable('START_TIME', false);
            setFieldEditable('END_TIME', false);        
        }
    },
}
