import paymentService from "@/query-actions/payments/PaymentConstant";
import PaymentConstant from "@/query-actions/payments/PaymentConstant";
/**
 * 线下批量支付动作
 * offlinePayment
 */
export default {
    execute(context, param) {
        console.log('s1 offlinePayment')
        if (context.selects.length === 0) {
            context.dom.$Message.info(paymentService.paymentNotSelectMessage);
            return;
        }
        let confirmMessage = PaymentConstant.paymentOfflineConfirmMessage;
        context.dom.$Modal.confirm({
            title: '信息提示',
            content: confirmMessage,
            onOk: () => {
                let param = {
                    "payIds": [],
                    "tableName": PaymentConstant.tableName
                }
                context.selects.forEach(e => {
                    param.payIds.push(e.id)
                })
                paymentService.postPaymentOfflineRequest(param, (data) => {
                    if (data.code === 200 && data.data.extErrorFlag) {
                        setTimeout(() => {
                            context.dom.$Modal.error({
                                title: "错误",
                                content: data.data.errorMessage
                            });
                        }, 400)
                    } else {
                        context.dom.$Message.success('线下支付完成')
                        GMS.vbus.$emit('custom-query-refresh');
                        GMS.vbus.$emit('tab-count-refresh');
                    }
                }, (resp) => {
                })
            },
            onCancel() {
            }
        });
    },
}
