batchPayment.js 3.12 KB
Newer Older
wangcong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
import paymentService from "@/query-actions/payments/PaymentConstant";
import PaymentConstant from "@/query-actions/payments/PaymentConstant";

/**
 * 线上批量支付动作
 * batchPayment
 */
export default {
    execute(context, param) {
        console.log('s1 batchPayment')
        if (context.selects.length === 0) {
            context.dom.$Message.info(paymentService.paymentNotSelectMessage);
            return;
        }
        debugger
        try {
            context.selects.forEach(e => paymentService.checkSingletonSelectData(e))
        } catch (e) {
            context.dom.$Message.info(e.message);
            return;
        }
        let warnInfo = PaymentConstant.paymentConfirmMessage
        try {
            PaymentConstant.checkMultiSelectData(context.selects);
        } catch (e) {
            if (e.message === PaymentConstant.PAYMENT_DATA_CHECK_FAIL_COMMON) {
                context.dom.$Message.info(paymentService.PAYMENT_DATA_CHECK_FAIL_COMMON);
                return;
            }
            warnInfo = e.message;
        }
        context.dom.$Modal.confirm({
            title: '信息提示',
            content: warnInfo,
            onOk: () => {
                let param = {
                    "payIds": [],
                    "tableName": PaymentConstant.tableName
                }
                context.selects.forEach(e => {
                    param.payIds.push(e.id)
                })
                paymentService.postPaymentOnlineRequest(param, (data) => {
                    if (data.code === 200 && data.data.extErrorFlag) {
                        setTimeout(() => {
                            context.dom.$Modal.error({
                                title: "错误",
                                content: data.data.errorMessage
                            });
                        }, 400)
                    } else {
                        let allDataLength = param.payIds.length;
                        let failureLength = data.data.failureItems.length;
                        let info = '提交待支付数据完成,本次共提交' + allDataLength + '条记录。\n失败:' + failureLength + '条。\n'
                        if (failureLength > 0) {
                            let msg = ''
                            data.data.failureItems.forEach(e => {
                                msg += e.message + '\n'
                            })
                            info = info + '详细信息:\n' + msg
                        }
                        setTimeout(() => {
                            context.dom.$Modal.info({
                                title: "支付结果",
                                content: info.replace(/\n/g, '<br/>'),
                                onOk: () => {
                                    GMS.vbus.$emit('custom-query-refresh');
                                    GMS.vbus.$emit('tab-count-refresh');
                                }
                            })
                        }, 400)
                    }
                }, (resp) => {
                })
            },
            onCancel() {
            }
        });
    },
}