/*
 * @Author: Fly
 * @Date: 2025-12-25 10:55:22
 * @LastEditTime: 2025-12-29 15:54:46
 * @Description: 
 */
import { ShippingMethodEnum, TransactionStatusOption, TransactionStatusEnum, RightsStatusEnum, ShippingStatusEnum } from './Status.js'
export default {
    data() {
        return {
            queryStatusList: [
                { label: '全部', value: undefined },
                ...TransactionStatusOption
            ],
        };
    },
    watch: {},
    created() {

    },
    methods: {
        /**
         * 备货条件：自提点自提、待发货、无维权、有效订单
         * @param {*} row 
         * @returns 
         */
        isStock(row) {
            try {
                const { shippingMethod, transactionStatus, rightsStatus, effective } = row;
                if (shippingMethod === ShippingMethodEnum.PICKUP && // 自提点自提
                    transactionStatus === TransactionStatusEnum.WAIT_SHIPPING && // 待发货
                    rightsStatus === RightsStatusEnum.NO_RIGHTS && // 无维权
                    effective // 有效订单
                ) {
                    return true;
                } else {
                    return false;
                }
            } catch (error) {
                return false;
            }
        },

        /**
         * 整包发货条件：普通快递、待发货、无维权、待发货订单
         * @param {*} row 
         * @returns 
         */
        isTotalShipments(row) {
            try {
                const { shippingMethod, transactionStatus, rightsStatus, shippingStatus } = row;
                if (shippingMethod === ShippingMethodEnum.EXPRESS  // 物流方式 - 普通快递
                    && transactionStatus === TransactionStatusEnum.WAIT_SHIPPING // 交易状态 - 待发货
                    && rightsStatus === RightsStatusEnum.NO_RIGHTS  // 维权状态 - 无维权
                    && shippingStatus === ShippingStatusEnum.WAIT_SHIPPING //  发货状态 - 待发货
                ) {
                    return true;
                } else {
                    return false;
                }
            } catch (error) {
                return false;
            }
        },
        /**
         * 分包发货条件：普通快递、待发货、无维权、待发货/部分发货订单
         * @param {*} row 
         * @returns 
         */
        isSubpackageShipments(row) {
            //  v-if="item.shippingMethod == 0 && item.transactionStatus == 10 && item.rightsStatus == 0"
            try {
                const { shippingMethod, transactionStatus, rightsStatus, shippingStatus } = row;
                if (shippingMethod === ShippingMethodEnum.EXPRESS  // 物流方式 - 普通快递
                    && transactionStatus === TransactionStatusEnum.WAIT_SHIPPING // 交易状态 - 待发货
                    && rightsStatus === RightsStatusEnum.NO_RIGHTS  // 维权状态 - 无维权
                    && [ShippingStatusEnum.WAIT_SHIPPING, ShippingStatusEnum.PARTIALLY_SHIPPED].includes(shippingStatus)  // 发货状态 - 待发货 , 部分发货
                ) {
                    return true;
                } else {
                    return false;
                }
            } catch (error) {
                return false;
            }
        },
        /**
         * 发货明细
         * @param {*} row 
         * @returns 
         * 普通快递、不是待发货订单
         */
        isShipmentsDetail(row) {
            // v-if="item.shippingMethod == 0 && item.shippingStatus > 0"
            try {
                const { shippingMethod, shippingStatus } = row;
                if (shippingMethod === ShippingMethodEnum.EXPRESS  // 普通快递
                    && shippingStatus > ShippingStatusEnum.WAIT_SHIPPING // 待发货
                ) {
                    return true;
                } else {
                    return false;
                }
            } catch (error) {
                return false;
            }
        },
        /**
         * 退款条件
         * @param {*} row 
         * @returns 
         * 
         */
        isRefund(row) {
            // v-if="item.transactionStatus == 10 && item.rightsStatus == 0 && item.effective"
            try {
                const { transactionStatus, rightsStatus, effective } = row;
                if (transactionStatus === TransactionStatusEnum.WAIT_SHIPPING // 待发货
                    && rightsStatus === RightsStatusEnum.NO_RIGHTS  // 无维权
                    && effective // 有效订单
                ) {
                    return true;
                } else {
                    return false;
                }
            } catch (error) {
                return false;
            }
        },




        shippingStatusHandle(mainOrder, child) {
            let text = "发";
            if (mainOrder.shippingMethod == 10) {
                text = "备";
            }
            if (child.shippingStatus == 0) {
                return '待' + text + "货";
            } else if (child.shippingStatus == 10) {
                return '部分' + text + "货";
            } else {
                return '已' + text + "货";
            }

        },
        receivingStatusHandle(mainOrder, child) {
            let text = "收货";
            if (mainOrder.shippingMethod == 10) {
                text = "自提";
            }
            if (child.receivingStatus == 0) {
                return '待' + text;
            } else if (child.receivingStatus == 10) {
                return '部分' + text;
            } else {
                return '已' + text;
            }
        },
        rightsStatusHandle(mainOrder, child) {
            // if (mainOrder.rightsMethod == 0) {
            //   return ""
            // } else if (mainOrder.rightsMethod == 5) {
            //   return child.rightsStatus == 5 ? '退款中' : '退款完成'
            // } else {
            //   return child.rightsStatus == 5 ? '退货中' : '退货完成'
            // }
            return child.rightsStatus == 5 ? '退货中' : '退货完成'
        },

    },

}