<template>
    <div class="app-container">
        <div class="flexBet searchTop">
            <div class="title flex m20">
                <div class="bar"></div>
                <div class="text">{{ $route.meta.title }}</div>
            </div>
            <el-row :gutter="10" class="mb8">
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>
        </div>
        <div class="bg">
            <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="86px"
                class="flex form" style="padding:0 20px">
                <el-form-item label="商户订单号" prop="outTradeNo">
                    <el-input size="medium" v-model="queryParams.outTradeNo" placeholder="请输入商户订单号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>
                <el-form-item label="平台订单号" prop="orderNo">
                    <el-input size="medium" v-model="queryParams.orderNo" placeholder="请输入平台订单号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>
                <!-- <el-form-item label="渠道订单号" prop="transactionId">
                    <el-input size="medium" v-model="queryParams.transactionId" placeholder="请输入渠道订单号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item> -->
                <!-- <el-form-item label="支付商户号" prop="mchId">
                    <el-input size="medium" v-model="queryParams.mchId" placeholder="请输入支付商户号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item> -->
                <!-- <el-form-item label="支付商户名" prop="mchName">
                    <el-input size="medium" v-model="queryParams.mchName" placeholder="请输入支付商户名"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item> -->
                <el-form-item label="商户名称" prop="storeName">
                    <el-input size="medium" v-model="queryParams.storeName" placeholder="请输入商户名称"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>
                <el-form-item label="付款人" prop="userKey">
                    <el-input size="medium" v-model="queryParams.userKey" placeholder="请输入付款人"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item>

                <!-- <el-form-item label="商户编号" prop="storeNo">
                    <el-input size="medium" v-model="queryParams.storeNo" placeholder="请输入商户编号"
                        @keyup.enter.native="handleQuery" style="width: 215px;border-color: #E6F1FF;" />
                </el-form-item> -->

                <el-form-item label="订单状态" prop="orderStatus">
                    <el-select v-model="queryParams.orderStatus" placeholder="请选择订单状态" size="medium">
                        <el-option v-for="dict in dict.type.pay_status" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>

                <el-form-item label="结算状态" prop="storeSettle">
                    <el-select v-model="queryParams.storeSettle" placeholder="请选择结算状态" size="medium">
                        <el-option v-for="dict in dict.type.settle_status" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>

                <el-form-item label="支付渠道" prop="channelType">
                    <el-select v-model="queryParams.channelType" placeholder="请选择支付渠道" clearable size="medium">
                        <el-option v-for="(item, i) in userLevType" :key="i" :label="item.channelName"
                            :value="item.payChannel"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="支付类型" prop="payType">
                    <el-select v-model="queryParams.payType" placeholder="请选择支付类型" clearable size="medium">
                        <el-option v-for="(item, i) in sortLevType" :key="i" :label="item.typeName"
                            :value="item.payType"></el-option>
                    </el-select>
                </el-form-item>
                <!-- <el-form-item label="交易时间">
                    <el-date-picker v-model="dateRange" style="width: 240px;border-color: #E6F1FF;"
                        value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期"
                        end-placeholder="结束日期" :picker-options="pickerOptions" :unlink-panels="true"></el-date-picker>
                </el-form-item> -->

                <el-form-item label="创建时间">
                    <el-date-picker v-model="dateRange[0]" size="small" style="width: 340px"
                        value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="-" start-placeholder="开始日期"
                        end-placeholder="结束日期" :unlink-panels="true" :default-time="['00:00:00', '23:59:59']"
                        :picker-options="pickerOptions"></el-date-picker>
                </el-form-item>

                <el-form-item label="支付时间">
                    <el-date-picker v-model="dateRange[1]" size="small" style="width: 340px"
                        value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="-" start-placeholder="开始日期"
                        end-placeholder="结束日期" :unlink-panels="true" :default-time="['00:00:00', '23:59:59']"
                        :picker-options="pickerOptions"></el-date-picker>
                </el-form-item>


                <el-form-item>
                    <div class="searchTop flexBet" style="align-items: center;">
                        <el-row :gutter="10" class="mb8">
                            <el-button type="primary" icon="" size="medium" @click="handleQuery">搜索</el-button>
                            <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
                        </el-row>

                        <el-row :gutter="10" class="mb8" style="margin-left:20px">
                            <el-col :span="1.5">
                                <el-button type="primary" plain icon="" size="medium" @click="handleExport"
                                    v-hasPermi="['order:rechargeRecord:export']">导出</el-button>
                            </el-col>
                            <el-col :span="1.5">
                                <el-button type="primary" plain icon="" size="medium" @click="handleSay" :disabled="single"
                                    v-hasPermi="['order:rechargeRecord:reissueNotice']">补发通知</el-button>
                            </el-col>
                        </el-row>
                    </div>

                </el-form-item>
            </el-form>
            <el-table stripe v-loading="loading" :data="infoList" @selection-change="handleSelectionChange"
                :row-class-name="tableRowClassName">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column :label="'商户订单号\n平台订单号'" align="center" prop="storeNo" min-width="150">
                    <template slot-scope="scope">
                        {{ scope.row.outTradeNo }}<br />
                        {{ scope.row.orderNo }}
                    </template>
                </el-table-column>
                <el-table-column :label="'商户名称\n商户编号'" align="center" prop="storeNo" min-width="120">
                    <template slot-scope="scope">
                        {{ scope.row.storeName }}<br />
                        {{ scope.row.storeNo }}
                    </template>
                </el-table-column>
                <el-table-column label="付款人" align="center" prop="userKey" min-width="80"></el-table-column>

                <el-table-column :label="'请求金额\n交易金额\n实付金额\n到账金额'" align="center" prop="storeNo" min-width="80">
                    <template slot-scope="scope">
                        <span> {{ scope.row.requestAmt }}</span>
                        <br />
                        <span> {{ scope.row.tranAmt }}</span>
                        <br />
                        <span> {{ scope.row.payAmt }}</span>
                        <br />
                        <span> {{ scope.row.realAmt }}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="'手续费率(%)\n通道费率(%)'" align="center" prop="storeNo" min-width="80">
                    <template slot-scope="scope">
                        {{ NumberMul(scope.row.rate, 100) }}%<br />
                        {{ NumberMul(scope.row.channelRate, 100) }}%
                    </template>
                </el-table-column>
                <el-table-column :label="'渠道类型\n支付类型'" align="center" prop="storeNo" min-width="80">
                    <template slot-scope="scope">
                        {{ scope.row.channelType }}<br />
                        {{ scope.row.cardType == 0 ? '借记卡' : '贷记卡' }}
                    </template>
                </el-table-column>

                <el-table-column :label="'交易状态\n结算状态'" align="center" prop="storeNo" min-width="100">
                    <template slot-scope="scope">
                        <el-tag :type="scope.row.orderStatus == 'pay_unpaid' ? 'warning' : scope.row.orderStatus == 'pay_success' ? 'success' :
                            scope.row.orderStatus == 'pay_failure' ? 'danger' : scope.row.orderStatus == 'pay_processing' ? 'warning' : 'primary'
                            ">
                            {{ scope.row.orderStatus == 'pay_unpaid' ? '未支付' : scope.row.orderStatus == 'pay_success' ?
                                '支付成功' :
                                scope.row.orderStatus == 'pay_failure' ? '支付失败' : scope.row.orderStatus ==
                                    'pay_processing' ? '支付处理中' : '已关闭' }}
                        </el-tag>
                        <br />
                        <el-tag :type="scope.row.storeSettle == 'yes' ? 'success' : scope.row.storeSettle == 'no' || !scope.row.storeSettle ? 'danger' :
                            scope.row.storeSettle == 'error' ? 'warning' : 'primary'
                            ">
                            {{ scope.row.storeSettle == 'yes' ? '已结算' : scope.row.storeSettle == 'no' ||
                                !scope.row.storeSettle ? '未结算' :
                                scope.row.storeSettle == 'error' ? '结算失败' : '部分结算' }}
                        </el-tag>
                    </template>
                </el-table-column>

                <el-table-column label="备注" align="center" prop="orderMsg" min-width="80"></el-table-column>


                <el-table-column :label="'交易时间\n结算时间'" align="center" prop="storeNo" min-width="120">
                    <template slot-scope="scope">
                        {{ scope.row.createTime }}<br />
                        {{ scope.row.storeSettleTime }}
                    </template>
                </el-table-column>

                <!-- <el-table-column label="渠道订单号" align="center" prop="transactionId" min-width="150" /> -->
                <!-- <el-table-column :label="'商户名\n商户号'" align="center" prop="storeNo" min-width="150">
                    <template slot-scope="scope">
                        {{ scope.row.mchName }}<br />
                        {{ scope.row.mchId }}
                    </template>
                </el-table-column> -->
                <!-- <el-table-column :label="'商户姓名\n商户手机'" align="center" prop="storeNo" min-width="150">
                    <template slot-scope="scope">
                        {{ scope.row.name }}<br />
                        {{ scope.row.mobile }}
                    </template>
                </el-table-column> -->
                <!-- <el-table-column label="商户类型" align="center" prop="divideType" /> -->
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right"
                    min-width="80">
                    <template slot-scope="scope">
                        <el-button size="small" v-if="scope.row.storeSettle == 'error'" type="text" style="color: #006EFF;"
                            @click="handleSettle(scope.row)">手动结算</el-button>


                        <el-button size="small" type="text" style="color: #006EFF;"
                            @click="handleViewMy(scope.row)">详情</el-button>
                        <el-button v-if="scope.row.orderStatus == 'pay_unpaid' || scope.row.orderStatus == 'pay_processing'"
                            size="small" type="text" style="color: #006EFF;" @click="handleOrder(scope.row)"
                            v-hasPermi="['order:rechargeRecord:payHandle']">手工处理</el-button>
                        <el-button size="small" type="text" style="color: #006EFF;"
                            @click="handleSayReissueNotice(scope.row)"
                            v-hasPermi="['order:rechargeRecord:reissueNotice']">补发通知</el-button>

                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>

        <!-- 处理当前代付订单 -->
        <!-- <el-dialog v-dialogDrag :close-on-click-modal="false" title="信息" :visible.sync="isShowDetail" width="18%"
            append-to-body>
            <div class="m20">确认要处理当前支付订单？</div>
            <el-form ref="form" :model="form" :rules="rules" label-width="0px">
                <el-form-item label="" prop="googleCode">
                    <el-input v-model="form.googleCode" placeholder="请输入谷歌动态验证码" />
                </el-form-item>
            </el-form>
            <el-button type="primary" icon="" size="small" @click="submitForm('pay_success')">置为成功</el-button>
            <el-button plain size="small" @click="submitForm('pay_failure')">置为取消</el-button>
            <el-button plain size="small" @click="cancel">取消</el-button>
        </el-dialog> -->

        <!-- 处理当前代付订单 -->
        <el-dialog v-dialogDrag title="信息" :visible.sync="isShowDetail" width="500px" append-to-body
            :close-on-click-modal="false" :before-close="cancel">
            <div class="m20">确认要处理当前支付订单？</div>
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-form-item label="订单状态" prop="orderStatus">
                    <el-select v-model="form.orderStatus" placeholder="请选择订单状态" clearable size="medium">
                        <el-option v-for="(item, i) in orderStatusType" :key="i" :label="item.label"
                            :value="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="谷歌动态验证码" prop="googleCode">
                    <el-input v-model="form.googleCode" placeholder="请输入谷歌动态验证码" style="width:217px" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button :disabled="!form.orderStatus || !form.googleCode"
                    :type="form.orderStatus && form.googleCode ? 'primary' : 'info'" icon="" size="small"
                    @click="submitForm('pay_success')">确定</el-button>
                <el-button plain size="small" @click="cancel">取消</el-button>
            </div>
        </el-dialog>



        <!-- 详情 -->
        <el-dialog v-dialogDrag :close-on-click-modal="false" :title="detailTitle" :visible.sync="isShowDetailMy"
            width="73%" append-to-body>
            <el-form label-width="142px" :label-suffix="':'">
                <div class="card-detail flex">
                    <div>

                        <el-form-item label="平台订单号">
                            {{ detailInfoList.orderNo }}
                        </el-form-item>

                        <el-form-item label="通知状态">
                            {{
                                detailInfoList.notifyStatus == 'notify_failed' ? '回调失败' : detailInfoList.notifyStatus ==
                                    'notify_success' ? '回调成功' : '未回调'
                            }}
                        </el-form-item>


                        <el-form-item label='交易状态'>
                            <el-tag v-if="detailInfoList.orderStatus" :type="detailInfoList.orderStatus == 'pay_unpaid' ? 'warning' : detailInfoList.orderStatus == 'pay_success' ? 'success' :
                                detailInfoList.orderStatus == 'pay_failure' ? 'danger' : detailInfoList.orderStatus == 'pay_processing' ? 'warning' : 'primary'
                                ">
                                {{ detailInfoList.orderStatus == 'pay_unpaid' ? '未支付' : detailInfoList.orderStatus ==
                                    'pay_success' ?
                                    '支付成功' :
                                    detailInfoList.orderStatus == 'pay_failure' ? '支付失败' : detailInfoList.orderStatus ==
                                        'pay_processing' ? '支付处理中' : '已关闭' }}
                            </el-tag>
                        </el-form-item>
                        <el-form-item v-if="detailInfoList.sourceType" :label="'订单来源'">
                            {{ detailInfoList.sourceType == 's_manual' ? '手工提单' : 'API充值' }}
                        </el-form-item>
                        <el-form-item label="商户id">
                            {{ detailInfoList.storeId }}
                        </el-form-item>
                        <el-form-item label="商户订单号">
                            {{ detailInfoList.outTradeNo }}
                        </el-form-item>
                        <el-form-item label="成功交易金额">
                            {{ detailInfoList.payAmt }}
                        </el-form-item>
                        <el-form-item label="内充渠道">
                            {{ detailInfoList.payChannelName }}
                        </el-form-item>
                        <el-form-item label="支付时间">
                            {{ detailInfoList.payTime }}
                        </el-form-item>
                        <el-form-item label="支付类型">
                            {{ detailInfoList.payTypeName }}
                        </el-form-item>


                        <!-- <el-form-item label="备注">
                            {{ detailInfoList.attach }}
                        </el-form-item> -->
                        <el-form-item label="备注">
                            {{ detailInfoList.orderMsg }}
                        </el-form-item>
                        <!-- <el-form-item label="keyId">
                            {{ detailInfoList.keyId }}
                        </el-form-item> -->
                    </div>
                    <div>
                        <el-form-item label="付款人">
                            {{ detailInfoList.userKey }}
                        </el-form-item>
                        <el-form-item label="通知备注">
                            {{ detailInfoList.notifyRemark }}
                        </el-form-item>

                        <el-form-item label="通道手续费金额">
                            {{ detailInfoList.poundageAmt }}
                        </el-form-item>
                        <el-form-item label="通道手续费率">
                            {{ NumberMul(detailInfoList.poundageRate, 100) }}%
                        </el-form-item>
                        <el-form-item label="商户名称">
                            {{ detailInfoList.storeName }}
                        </el-form-item>
                        <el-form-item label="商户编号">
                            {{ detailInfoList.storeNo }}
                        </el-form-item>
                        <el-form-item :label="'结算状态'">
                            <el-tag v-if="detailInfoList.storeSettle" :type="detailInfoList.storeSettle == 'yes' ? 'success' : detailInfoList.storeSettle == 'no' || !detailInfoList.storeSettle ? 'danger' :
                                detailInfoList.storeSettle == 'error' ? 'warning' : 'primary'
                                ">
                                {{ detailInfoList.storeSettle == 'yes' ? '已结算' : detailInfoList.storeSettle == 'no' ||
                                    !detailInfoList.storeSettle ? '未结算' :
                                    detailInfoList.storeSettle == 'error' ? '结算失败' : '部分结算' }}
                            </el-tag>
                        </el-form-item>
                        <el-form-item label="结算时间">
                            {{ detailInfoList.storeSettleTime }}
                        </el-form-item>
                        <el-form-item label="商户类型">
                            <el-tag v-if="detailInfoList.storeType" :type="detailInfoList.storeType == 'my_store'
                                ? 'success'
                                : detailInfoList.storeType == 'directly_under' ? 'primary' : 'danger'
                                ">
                                {{ detailInfoList.storeType == 'my_store'
                                    ? '代理自己商户'
                                    : detailInfoList.storeType == 'directly_under' ? '平台直属商户' : '代理下级商户' }}
                            </el-tag>
                        </el-form-item>
                        <el-form-item label="变动金额">
                            {{ detailInfoList.tranAmt }}
                        </el-form-item>
                        <el-form-item label="渠道订单号">
                            {{ detailInfoList.transactionId }}
                        </el-form-item>
                        <el-form-item label="用户id">
                            {{ detailInfoList.userId }}
                        </el-form-item>
                        <!-- <el-form-item label="version">
                            {{ detailInfoList.version }}
                        </el-form-item> -->

                    </div>
                    <div>
                        <el-form-item label="修改时间">
                            {{ detailInfoList.updateTime }}
                        </el-form-item>
                        <el-form-item label="创建时间">
                            {{ detailInfoList.createTime }}
                        </el-form-item>
                        <el-form-item label="商品名称">
                            {{ detailInfoList.productName }}
                        </el-form-item>
                        <el-form-item label="手续费">
                            {{ detailInfoList.rateAmt }}
                        </el-form-item>
                        <el-form-item label="充值金额">
                            {{ detailInfoList.realAmt }}
                        </el-form-item>
                        <el-form-item label="签名方式">
                            {{ detailInfoList.signType }}
                        </el-form-item>
                        <el-form-item label="银行编号">
                            {{ detailInfoList.bankCode }}
                        </el-form-item>
                        <el-form-item label="银行ID">
                            {{ detailInfoList.bankId }}
                        </el-form-item>
                        <el-form-item label="银行卡类型">
                            <el-tag v-if="detailInfoList.cardType" :type="detailInfoList.cardType == 'debit_card' ? 'success' : 'primary'
                                ">
                                {{ detailInfoList.cardType == 'debit_card' ? '借记卡' : '贷记卡' }}
                            </el-tag>
                        </el-form-item>
                        <el-form-item label="渠道类型">
                            {{ detailInfoList.channelType }}
                        </el-form-item>
                        <!-- <el-form-item label="charset">
                            {{ detailInfoList.charset }}
                        </el-form-item> -->
                    </div>
                    <div>
                        <el-form-item label="商品描述">
                            {{ detailInfoList.productDesc }}
                        </el-form-item>

                        <el-form-item label="费率">
                            {{ NumberMul(detailInfoList.rate, 100) }}%
                        </el-form-item>
                        <el-form-item label="商户返回地址">
                            {{ detailInfoList.backUrl }}
                        </el-form-item>
                        <el-form-item label="商户号">
                            {{ detailInfoList.mchId }}
                        </el-form-item>
                        <el-form-item label="支付商户名">
                            {{ detailInfoList.mchName }}
                        </el-form-item>
                        <el-form-item label="请求类型">
                            {{ detailInfoList.mediaType }}
                        </el-form-item>
                        <el-form-item label="手机号码">
                            {{ detailInfoList.mobile }}
                        </el-form-item>
                        <el-form-item label="用户名">
                            {{ detailInfoList.name }}
                        </el-form-item>
                        <el-form-item label="二维码图片">
                            <el-image style="width: 100px; height: 100px" v-if="detailInfoList.qrcodeImg"
                                :src="detailInfoList.qrcodeImg" @click="previewImage(detailInfoList.qrcodeImg)"
                                :preview-src-list="srcList">
                                <div slot="placeholder">
                                    <div style="margin-top: 40px">
                                        加载中<i class="el-icon-loading" />
                                    </div>
                                </div>
                            </el-image>

                            <el-image v-if="!detailInfoList.qrcodeImg" class="image-slot">
                                <div slot="error">
                                    无
                                </div>
                            </el-image>

                        </el-form-item>

                        <!-- <el-form-item label="二维码地址">
                            {{ detailInfoList.qrcodeUrl }}
                        </el-form-item> -->
                        <el-form-item label="回调地址">
                            {{ detailInfoList.notifyUrl }}
                        </el-form-item>
                    </div>
                </div>
            </el-form>
        </el-dialog>







    </div>
</template>
  
<script>
import { common_api, payOrder } from "@/api/form";

export default {
    name: "PkAdWeiList",
    dicts: ['pay_status', 'settle_status'],
    data() {
        return {
            orderStatusType: [
                {
                    label: '成功',
                    value: 'pay_success',
                },
                {
                    label: '驳回',
                    value: 'pay_failure',
                },
            ],
            // 详情
            detailInfoList: {
                rate: '',
                poundageRate: '',
                agentRate: '',
            },
            pickerOptions: {
                shortcuts: [
                    {
                        text: '最近一天',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近三天',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 3);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近三个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 3);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近半年',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 6);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近一年',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 12);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近两年',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 24);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                    {
                        text: '最近三年',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30 * 36);
                            picker.$emit('pick', [start, end]);
                        }
                    },
                ]
            },
            userLevType: [

            ],
            sortLevType: [],

            settleStatusCon: [
                {
                    label: '已结算',
                    value: 'yes',
                },
                {
                    label: '未结算',
                    value: 'no',
                }, {
                    label: '部分结算',
                    value: 'part',
                },
            ],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            dateRange: [],
            // 新增广告图片地址
            imageUrl: "",
            // 遮罩层
            loading: true,
            // 导出遮罩层
            exportLoading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 广告表格数据
            infoList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 20,
                userId: null,
                storeId: null,
                storeNo: null,
                outTradeNo: null,
                orderNo: null,
                transactionId: null,
                mchId: null,
                mchName: null,
                orderStatus: null,
                storeName: null,
                storeSettle: null,
                payType: null,
                channelType: null,
                userKey: null,
            },

            // 表单参数
            form: {},
            // 表单校验
            rules: {
            },
            detailData: {},
            isShowDetail: false,
            // 详情
            isShowDetailMy: false,
            detailTitle: '',
            // 预览
            srcList: ['https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg'],
            systemDate: '',
        };
    },
    created() {
        this.addDate();
        this.getList();
        this.init();
    },
    methods: {
        /** 结算按钮操作 */
        handleSettle(row) {
            this.$modal.confirm('是否确认手动结算平台订单号为"' + row.orderNo + '"的数据项？').then(function () {
                return payOrder.manualSettle(row.keyId);
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess("结算成功");
            }).catch(() => { });
        },
        // 获取今天
        addDate() {
            let nowDate = new Date();
            let date = {
                year: nowDate.getFullYear(),
                month: nowDate.getMonth() + 1,
                date: nowDate.getDate(),
            }
            if (date.date <= 9) {
                this.systemDate = date.year + '-' + 0 + date.month + '-' + 0 + date.date;
            } else {
                this.systemDate = date.year + '-' + 0 + date.month + '-' + date.date;
            }
            this.dateRange[0] = [this.systemDate + ' ' + '00' + ':' + '00' + ':' + '00', this.systemDate + ' ' + '23' + ':' + '59' + ':' + '59']
            this.$forceUpdate()
        },

        // 通知
        handleSayReissueNotice(row) {
            this.loading = true;
            // payOrder.paymentReissueNotice(row.keyId).then((response) => {
            //     if (response.code == 200) {
            //         this.$message.success('补发成功')
            //         this.loading = false;
            //     }
            // }).catch(() => {
            //     this.loading = false;
            // });
            payOrder.reissueNotice(row.keyId).then((response) => {
                if (response.code == 200) {
                    this.$message.success('补发成功')
                    this.loading = false;
                }
            }).catch(() => {
                this.loading = false;
            });
        },
        tableRowClassName({ row, rowIndex }) {
            if (row.orderStatus == 'pay_unpaid') {
                return "yellowOrder";
            }
            if (row.orderStatus == 'pay_success') {
                return "greenOrder";
            }
            if (row.orderStatus == 'pay_failure') {
                return "redOrder";
            }
            if (row.orderStatus == 'pay_processing') {
                return "blueOrder";
            }
            if (row.orderStatus == 'pay_closed') {
                return "greyOrder";
            }
        },
        // 预览图片
        previewImage(abUrl) {
            this.srcList[0] = abUrl;
        },
        // 查看详情
        handleViewMy(row) {
            this.reset();
            this.detailInfoList = row;
            this.isShowDetailMy = true;
            this.detailTitle = "订单流水详情";
        },
        /** 手工处理 */
        handleOrder(row) {
            this.reset()
            this.detailData = row
            this.isShowDetail = true
        },
        // 通知
        handleSay() {
            this.loading = true;
            payOrder.reissueNotice(this.ids[0]).then((response) => {
                if (response.code == 200) {
                    this.$message.success('补发成功')
                    this.loading = false;
                }
            }).catch(() => {
                this.loading = false;
            });
        },
        init() {
            common_api.payChannelAll().then((response) => {
                this.userLevType = response.data
            });
            common_api.payTypeAll().then((response) => {
                this.sortLevType = response.data
            });
        },
        /** 导出按钮操作 */
        handleExport() {
            const queryParams = this.queryParams;
            this.$confirm("是否确认导出订单流水?", "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(function () {
                    return payOrder.export(queryParams);
                })
                .then((response) => {
                    this.download(response.msg);
                    this.queryParams.pageNum = 1;
                    this.queryParams.pageSize = 20;
                });
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.keyId)
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        getList() {
            this.loading = true;
            payOrder
                .rechargeRecord(this.addSESDateRange(this.queryParams, this.dateRange, 'type'))
                .then((response) => {
                    this.infoList = response.rows;
                    this.total = Number(response.total);
                    this.loading = false;
                });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.isShowDetail = false
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {};
            this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 提交按钮 */
        submitForm(type) {
            if (!this.form.googleCode) {
                this.$message.error('请输入谷歌动态验证码')
                return;
            }
            this.$refs["form"].validate((valid) => {
                if (valid) {
                    const loading = this.$loading({
                        lock: true,
                        text: `正在手动处理`,
                        spinner: "el-icon-loading",
                        background: "rgba(0, 0, 0, 0.7)",
                    });
                    let form = {
                        id: this.detailData.keyId,
                        status: this.form.orderStatus,
                        googleCode: this.form.googleCode
                    }
                    payOrder.payHandle(form).then((response) => {
                        loading.close();
                        this.isShowDetail = false;
                        this.msgSuccess("处理成功");
                        this.getList();
                    }).catch(() => {
                        loading.close();
                        this.isShowDetail = false;
                    })

                }
            });
        },

    },
};
</script>
<style scoped>
::v-deep .el-dialog:not(.is-fullscreen) {
    margin-top: 10vh !important;
}

::v-deep .el-table tbody tr:hover>td {
    background-color: rgba(0, 0, 0, 0) !important
}

::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {
    background: none !important;
}
</style>