import moment from "moment";
export default {
    toCityObjData(excelData) {

        const result = excelData.map(item => {
            const row = {
                city: item[0],
                monitorTime: moment(item[1]).valueOf(),
                so2: Number(item[2]) || null,
                no2: Number(item[3]) || null,
                pm10: Number(item[4]) || null,
                co: Number(item[5]) || null,
                o3: Number(item[6]) || null,
                pm25: Number(item[7]) || null,
                aqi: Number(item[8]) || null,
                primaryPollutant: item[9],
                aqiLevel: item[10],
                airQualityStatus: item[11],
                remark: item[12]
            }
            return row;

        })
        return result;
    },
    toCountyObjData(excelData) {
        const result = excelData.map(item => {
            const place = item[0];
            const county = place.substr(0,place.indexOf("县") + 1);
            const area = place.substr(0,place.indexOf("区") + 1);
            const row = {
                place,
                county,
                area,
                monitorTime: moment(item[1]).valueOf(),
                airQualityStatus: item[2],
                aqiLevel: item[3],
                aqi: Number(item[4]) || null,
                primaryPollutant: item[5],
                so2: Number(item[6]) || null,
                no2: Number(item[7]) || null,
                pm10: Number(item[8]) || null,
                co: Number(item[9]) || null,
                o3: Number(item[10]) || null,
                pm25: Number(item[11]) || null,
                remark: item[12]
            }
            return row;
        })
        return result;
    },
    toPlaceObjData(excelData) {
        console.log(excelData[8][2]);
        console.log(moment(excelData[8][2]));
        const result = excelData.map(item => {
            const place = item[1];
            // const county = place.substr(0,place.indexOf("县"))
            const row = {
                city: item[0],
                // county,
                place,
                monitorTime: moment(item[2]).valueOf(),
                so2: Number(item[3]) || null,
                no2: Number(item[4]) || null,
                pm10: Number(item[5]) || null,
                co: Number(item[6]) || null,
                o3: Number(item[7]) || null,
                pm25: Number(item[8]) || null,
                aqi: Number(item[9]) || null,
                primaryPollutant: item[10],
                aqiLevel: item[11],
                airQualityStatus: item[12],
                remark: item[13],
            }
            return row;
        })
        return result;
    },
}