/* 格式化时间 */
function checkdate(data) {
    for (let i = 0; i < data.length; i++) {
        let checkdate = data[i].checkdate;
        data[i].checkdate = checkdate.slice(0, checkdate.lastIndexOf('.'));
    }
    return data;
}

/* 截取时间 只取年月日 */
function getYTD(data) {
    for (let i = 0; i < data.length; i++) {
        let checkdate = data[i].checkdate;
        const YTD = checkdate.split(' ');
        data[i].checkdate = YTD[0];
    }
    return data;
}

/* 供需列表数据排序 */
function listOrdering(data) {
    /* 处理排序 */
    const typeList = ['待对接', '正在对接', '已解决', '已过期'];
    let productList = [];
    for (let i = 0; i < typeList.length; i++) {
        for (let k = 0; k < data.length; k++) {
            if (typeList[i] == data[k].fstatus) productList[productList.length] = data[k];
        }
    };
    return productList;
}

module.exports = {
    checkdate,
    listOrdering,
    getYTD
}