import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, empty } from "../../utils/common";
import { connect } from 'dva';
import moment from 'moment'

/**
 * @return {string}
 */
// 编辑
export default {
    onChange: ({ colInfo, getFieldValue, setFieldValue, dispatch, updateSubTableData }) => {
        if (colInfo.FIELD_NAME == 'Nav_Class.NAME') {
            let name = getFieldValue('Nav_Class.NAME')
            if (name != null) {
                const json = initFilter();
                extendRule(json, 'NAME', 1, name);
                extendInclude(json, 'Nav_ClassDetail');
                dispatch({
                    type: 'app/getDataByPost',
                    url: 'FM/Class/OrderPaged',
                    payload: json,
                    onlyData: false,
                    onComplete: (re) => {
                        if (re && re.IsSuccessful && re.Data) {
                            let DATE_TIME = moment(getFieldValue('DATE_TIME')).format('YYYY-MM-DD');
                            let starttime=moment(re.Data[0].Nav_ClassDetail[0].STARTTIME).format('HH:mm:ss');
                            let endtime=moment(re.Data[0].Nav_ClassDetail[0].ENDTIME).format('HH:mm:ss');
                            setFieldValue('START_TIME',DATE_TIME+" "+starttime);
                            setFieldValue('END_TIME',DATE_TIME+" "+endtime);
                        }
                    }
                })
            }
        }
    },
}
