export function getOption(ref, main, whAreaCategoryCodeList, caseQty) {
    let record = ref.clickTest;
    let newOptions = null;
    var tempData = null
    console.log(main.rcvType, record.itemHealthStoreCategory, 'itemHealthStoreCategory');
    if (main.rcvType == '8') {
        newOptions = whAreaCategoryCodeList.filter(t => {
            if (t.value == 'DGK') return true;
            else return false;
        });
    }
     //销售退回有效期至超过当前日期，库别默认退货库
    tempData = new Date(record.batchExpiredDate)
    if (tempData < new Date()) {
        if (main.rcvType == '2') {
            newOptions = whAreaCategoryCodeList.filter(t => {
                if (t.value == 'THK') return true;
                else return false;
            });
        }
    }

    // 10.整散合一库 只能入整散合一的商品，即整散合一的商品默认并且只能入整散合一库
    else if (record.itemHealthStoreCategory.indexOf('合一') >= 0) {
        newOptions = whAreaCategoryCodeList.filter(t => {
            //不再限制越库区
            if (main.rcvType == '7' && (t.value == 'ZDK' || t.value == 'YKQ')) { return true; }
            if (main.rcvType == '6' && t.value == 'YKQ') { return true; }
            if (t.value == 'HYK' || t.value == 'YKQ') return true;
            else return false;

        });
    }
    // 其它组合
    else {
        // 
        //整件caseQty;
        let oddPieceQty = +record.oddPieceQty || 0;//零散
        newOptions = whAreaCategoryCodeList.filter(t => {
            //特殊单据直调、越库 需单独判断是否整散分开
            // 1.整件库 只能入整散分开的整件
            //不再限制越库区
            if (main.rcvType == '7' && caseQty > 0 && oddPieceQty == 0 && (t.value == 'ZJK' || t.value == 'ZDK' || t.value == 'YKQ')) { return true; }
            if (main.rcvType == '6' && caseQty > 0 && oddPieceQty == 0 && (t.value == 'ZJK' || t.value == 'YKQ')) { return true; }
            // 2.零货库 只能入整散分开的
            if (main.rcvType == '7' && caseQty == 0 && oddPieceQty > 0 && (t.value == 'LHK' || t.value == 'ZDK' || t.value == 'YKQ')) { return true; }
            if (main.rcvType == '6' && caseQty == 0 && oddPieceQty > 0 && (t.value == 'LHK' || t.value == 'YKQ')) { return true; }

            // 14.其他订单判断是否整散，再选择库别
            if (caseQty > 0 && oddPieceQty == 0 && (t.value == 'ZJK' || t.value == 'YKQ')) { return true; }
            if (caseQty == 0 && oddPieceQty > 0 && (t.value == 'LHK' || t.value == 'YKQ')) { return true; }
            // if ((main.rcvType == '6' || main.rcvType == '1' || main.rcvType == '2') && t.value == 'YKQ') { return true; }
            // 11.待处理库 收货结论为不合格的才可以入待处理库
            if (record.qcResult1 == '1' && t.value == 'CLK') { return true; }
            if (t.value == 'YKQ') return true;
            return false;
        });
    }
    return newOptions

}
