<template>
  <div class="app-container">
    <div class="flexBet searchTop">
      <!-- <div class="title flex m20">
        <div class="bar"></div>
        <div class="text">全部订单</div>
      </div> -->

    </div>


    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="116px" class="flex form"
      style="position: relative">
      <el-form-item label="平台订单号" prop="orderNo">
        <el-input size="medium" v-model="queryParams.orderNo" placeholder="请输入平台订单号" @keyup.enter.native="handleQuery"
          style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>
      <el-form-item label="商户订单号" prop="merchantOrderNo">
        <el-input size="medium" v-model="queryParams.merchantOrderNo" placeholder="请输入商户订单号"
          @keyup.enter.native="handleQuery" style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>
      <el-form-item label="商户下游订单号" prop="downstreamMerchantOrderNo">
        <el-input size="medium" v-model="queryParams.downstreamMerchantOrderNo" placeholder="请输入商户下游订单号"
          @keyup.enter.native="handleQuery" style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>
      <el-form-item label="收款卡号" prop="cardNumber">
        <el-input size="medium" v-model="queryParams.cardNumber" placeholder="请输入收款卡号" @keyup.enter.native="handleQuery"
          style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>

      <el-form-item label="商户名称" prop="merchantName">
        <el-input size="medium" v-model="queryParams.merchantName" placeholder="请输入商户名称" @keyup.enter.native="handleQuery"
          style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>

      <el-form-item label="姓名" prop="accountName">
        <el-input size="medium" v-model="queryParams.accountName" placeholder="请输入姓名" @keyup.enter.native="handleQuery"
          style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>

      <el-form-item label="订单金额" prop="reqAmount">
        <el-input size="medium" v-model="queryParams.reqAmount" placeholder="请输入订单金额" @keyup.enter.native="handleQuery"
          style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>

      <el-form-item label="批次号" prop="batchNo">
        <el-input size="medium" v-model="queryParams.batchNo" placeholder="请输入批次号" @keyup.enter.native="handleQuery"
          style="width: 180px; border-color: #e6f1ff" />
      </el-form-item>


      <el-collapse>
        <el-collapse-item name="1">
          <el-form-item label="类型" prop="orderSource">
            <el-select v-model="queryParams.orderSource" placeholder="请选择类型" clearable size="medium">
              <el-option v-for="(item, i) in showAll" :key="i" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="通道" prop="platformChannelId">
            <el-select v-model="queryParams.platformChannelId" placeholder="请选择通道" clearable size="medium">
              <el-option v-for="(item, i) in channelAll" :key="i" :label="item.channelName" :value="item.id"></el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="状态" prop="orderStatus">
            <el-select v-model="queryParams.orderStatus" placeholder="请选择状态" clearable size="medium">
              <el-option v-for="(item, i) in dictCon" :key="i" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </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']"></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']"></el-date-picker>
          </el-form-item>
        </el-collapse-item>
      </el-collapse>
      <el-form-item style="margin-left:10px">
        <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:8px">
            <el-col :span="1.5">
              <el-button type="primary" plain icon="" size="medium" @click="handleExport()" v-hasPermi="['order:TransferOrder:export']">导出</el-button>
            </el-col>
          </el-row>
          <!-- <el-row :gutter="10" class="mb8">
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row> -->

        </div>
      </el-form-item>
    </el-form>

    <div class="searchTop flexBet">

    </div>

    <div class="bg">


      <el-table stripe :data="infoList" v-loading="loading" :row-class-name="tableRowClassName">
        <el-table-column label="订单号" align="center" prop="orderNo" />
        <el-table-column label="商户" align="center" prop="merchantName" />
        <el-table-column label="商户订单号" align="center" prop="merchantOrderNo" />
        <el-table-column label="商户下游订单号" align="center" prop="downstreamMerchantOrderNo" min-width="120" />
        <el-table-column label="批次号" align="center" prop="batchNo" min-width="120" />
        <el-table-column :label="'类型'" align="center" prop="securityDepositAmount">
          <template slot-scope="scope">
            {{ scope.row.orderSource == 1 ? '接口' : scope.row.orderSource == 2 ? '商户提现' : scope.row.orderSource
              == 3 ? '商户后台付款' : '码商提现' }}
          </template>
        </el-table-column>

        <el-table-column :label="'订单金额'" align="center" prop="reqAmount">
          <template slot-scope="scope">
            {{ parseFloat(NumberDiv(scope.row.reqAmount, 100)).toFixed(2) }}
          </template>
        </el-table-column>

        <el-table-column :label="'手续费'" align="center" prop="merchantFee">
          <template slot-scope="scope">
            {{ parseFloat(NumberDiv(scope.row.merchantFee, 100)).toFixed(2) }}
          </template>
        </el-table-column>

        <el-table-column :label="'已完成代付金额'" align="center" prop="payeeRealAmount">
          <template slot-scope="scope">
            {{ parseFloat(NumberDiv(scope.row.payeeRealAmount, 100)).toFixed(2) }}
          </template>
        </el-table-column>

        <el-table-column :label="'剩余可申请金额'" align="center" prop="payeeRealAmount">
          <template slot-scope="scope">
            {{ parseFloat(NumberDiv(scope.row.applicableAmount, 100)).toFixed(2) }}
          </template>
        </el-table-column>

        <!-- <el-table-column :label="'实扣金额'" align="center" prop="payeeRealAmount">
          <template slot-scope="scope">
            {{ parseFloat(NumberDiv(scope.row.decreaseAmount, 100)).toFixed(2) }}
          </template>
        </el-table-column> -->
        <el-table-column label="银行名称" align="center" prop="bankName" />
        <el-table-column label="卡号" align="center" prop="cardNumber" />
        <el-table-column label="姓名" align="center" prop="accountName" />
        <el-table-column label="开户行" align="center" prop="branchName" />
        <el-table-column :label="'状态'" align="center" prop="payeeRealAmount">
          <template slot-scope="scope">
            {{ scope.row.orderStatus == 1 ? '待支付' : scope.row.orderStatus == 2 ? '支付成功' : '支付失败' }}
          </template>
        </el-table-column>


        <!-- <el-table-column :label="'审核状态'" align="center" prop="auditStatus">
                    <template slot-scope="scope">
                        <span :class="scope.row.auditStatus == 'turn_down'?'red':scope.row.auditStatus == 'unaudited'?'yellow':scope.row.auditStatus == 'examination_passed'?'green':''">
                            {{ scope.row.auditStatus == 'unaudited' ? '未审核' : scope.row.auditStatus == 'examination_passed' ?
                            '审核通过' : scope.row.auditStatus == 'turn_down' ? '驳回' : '无需审核' }}
                        </span>
                     
                    </template>
                </el-table-column> -->

        <el-table-column label="备注" align="center" prop="remark" />


        <el-table-column label="创建时间" align="center" prop="createTime" min-width="180" />
        <el-table-column label="更新时间" align="center" prop="updateTime" min-width="180" />

        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" min-width="120">
          <template slot-scope="scope">
            <el-button size="small" type="text" @click="handleView(scope.row)" style="color: #006eff" v-hasPermi="['order:TransferOrder:query']">详情</el-button>
            <el-button size="small" type="text" @click="handleNotify(scope.row)" style="color: #006eff" v-hasPermi="['order:TransferOrder:notify']">通知</el-button>
            <el-button size="small" type="text" @click="getCertificate(scope.row)" style="color: #006eff"
              v-if="scope.row.orderStatus == 2">查看凭证</el-button>
            <el-button size="small" type="text" @click="handleSonOrder(scope.row)" style="color: #006eff" v-hasPermi="['order:carddealerWithdrawOrder:selectOrderSub']">子单</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">
      </pagination>
    </div>

    <!-- 详情 -->
    <el-dialog v-dialogDrag :close-on-click-modal="false" :title="detailTitle" :visible.sync="isShowDetail" width="40%"
      append-to-body>
      <el-form label-width="142px" :label-suffix="':'">
        <div style="display: flex;justify-content: space-around;">
          <div class="card-detail">
            <el-form-item label="平台单号">
              {{ detailInfoList.orderNo }}
            </el-form-item>
            <el-form-item label="批次号">
              {{ detailInfoList.batchNo }}
            </el-form-item>
            <el-form-item label="商户订单号">
              {{ detailInfoList.merchantOrderNo }}
            </el-form-item>
            <el-form-item label="商户下游订单号">
              {{ detailInfoList.downstreamMerchantOrderNo }}
            </el-form-item>
            <el-form-item label="商户名称">
              {{ detailInfoList.merchantName }}
            </el-form-item>
            <el-form-item label="商户编号">
              {{ detailInfoList.merchantNo }}
            </el-form-item>
            <el-form-item label="订单请求金额">
              {{ parseFloat(NumberDiv(detailInfoList.reqAmount, 100)).toFixed(2) }}
            </el-form-item>
            <el-form-item label="手续费">
              {{ parseFloat(NumberDiv(detailInfoList.merchantFee, 100)).toFixed(2) }}
            </el-form-item>
            <el-form-item label="到账金额">
              {{ parseFloat(NumberDiv(detailInfoList.payeeRealAmount, 100)).toFixed(2) }}
            </el-form-item>
            <el-form-item label="创建时间">
              {{ detailInfoList.createTime }}
            </el-form-item>
            <!-- <el-form-item label="实扣金额">
              {{ parseFloat(NumberDiv(detailInfoList.decreaseAmount, 100)).toFixed(2) }}
            </el-form-item> -->
            <el-form-item label="更新时间">
              {{ detailInfoList.updateTime }}
            </el-form-item>
          </div>
          <div class="card-detail">
            <el-form-item label="收款卡号">
              {{ detailInfoList.cardNumber }}
            </el-form-item>


            <!-- <el-form-item label="审核状态">
              <span>
                {{ detailInfoList.auditStatus == 'unaudited' ? '未审核' : detailInfoList.auditStatus == 'examination_passed'
                  ?
                  '审核通过' : detailInfoList.auditStatus == 'turn_down' ? '驳回' : '无需审核' }}
              </span>

            </el-form-item> -->


            <el-form-item label="订单状态">
              {{ detailInfoList.orderStatus == 1 ? '待支付' : detailInfoList.orderStatus == 2 ? '支付成功' : '支付失败' }}
            </el-form-item>
            <el-form-item label="开户行">
              {{ detailInfoList.branchName }}
            </el-form-item>
            <el-form-item label="通道">
              {{ detailInfoList.platformChannelName }}
            </el-form-item>
            <el-form-item label="银行名称">
              {{ detailInfoList.bankName }}
            </el-form-item>
            <el-form-item label="类型">
              {{ detailInfoList.orderSource == 1 ? '接口' : detailInfoList.orderSource == 2 ? '商户提现' :
                detailInfoList.orderSource
                  == 3 ? '商户后台付款' : '码商提现' }}
            </el-form-item>
            <el-form-item label="收款人">
              {{ detailInfoList.accountName }}
            </el-form-item>
            <el-form-item label="异步通知状态">
              {{ detailInfoList.notifyStatus == 0 ? '未通知' : detailInfoList.notifyStatus == 1 ? '成功' :
                detailInfoList.notifyStatus == 2 ? '通知进行中' : '超时' }}
            </el-form-item>
            <el-form-item label="通道费率">
              {{ detailInfoList.merchantRate + '%+' + parseFloat(NumberDiv(detailInfoList.merchantSingleFee,
                100)).toFixed(2) }}
            </el-form-item>
          </div>
        </div>

      </el-form>
    </el-dialog>

    <!-- 子单列表 -->
    <el-dialog v-dialogDrag title="子单列表" :visible.sync="pkCouponScopeRangeParkingStoreOpen" width="80%" append-to-body
      :close-on-click-modal="false">
      <pkCouponScopeRangeStoreList v-if="pkCouponScopeRangeParkingStoreOpen" :pkCouponStore="pkCouponStore"
        :pkCouponId="pkCouponStoreId">
      </pkCouponScopeRangeStoreList>
    </el-dialog>


    <!-- 凭证 -->
    <el-dialog v-dialogDrag :close-on-click-modal="false" title="凭证" :visible.sync="isShowDetailImg" width="40%"
      append-to-body>
      <el-form label-width="142px" :label-suffix="':'">
        <el-form-item label="凭证图片">
          <div style="display: flex;justify-content: space-around;flex-wrap: wrap;" v-if="imgCon.length">
            <div v-for="item, index in imgCon" :key="index">
              <el-image style="width: 300px; height: 200px" :src="item" @click="previewImage(item)"
                :preview-src-list="srcList">
                <div slot="placeholder">
                  <div style="margin-top: 40px">
                    加载中<i class="el-icon-loading" />
                  </div>
                </div>
              </el-image>
            </div>
          </div>
          <div v-else>
            无
          </div>
        </el-form-item>
      </el-form>
    </el-dialog>


  </div>
</template>

<script>
import { listTransferOrder, getTransferOrder, delTransferOrder, addTransferOrder, updateTransferOrder, exportTransferOrder } from "@/api/order/TransferOrder";
import { payOutOrder, common_api } from "@/api/form";
import pkCouponScopeRangeStoreList from "./pkCouponScopeRangeStoreList";
import cardMerchantOrderRefreshMixin from "@/api/cardMerchantOrderRefresh.mixin";

export default {
  name: "TransferOrder",
  dicts: ['collection_order_status'],
  components: { pkCouponScopeRangeStoreList },
  mixins: [cardMerchantOrderRefreshMixin],

  data() {
    return {
      dictCon: [
        {
          label: '全部',
          value: null,
        },
        {
          label: '待支付',
          value: 1,
        },
        {
          label: '支付成功',
          value: 2,
        },
        {
          label: '支付失败',
          value: 3,
        },
      ],
      // 所有通道
      channelAll: [],
      imgCon: [],
      // 预览
      srcList: ['https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg'],
      // 显示凭证
      isShowDetailImg: false,
      pkCouponScopeRangeParkingStoreOpen: false,
      pkCouponStore: {},
      pkCouponStoreId: '',

      // 显示详情
      isShowDetail: false,
      // 详情
      detailTitle: "",
      // 详情的数据
      detailInfoList: {},
      dateRange: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 代付订单表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNo: null,
        merchantOrderNo: null,
        cardNumber: null,
        merchantName: null,
        accountName: null,
        reqAmount: null,
        orderSource: null,
        orderStatus: null,
        platformChannelId: null,
        downstreamMerchantOrderNo: null,
        batchNo: null
      },
      showAll: [
        {
          label: '全部',
          value: null,
        },
        {
          label: '接口',
          value: 1,
        },
        {
          label: '商户提现',
          value: 2,
        },
        {
          label: '商户后台付款',
          value: 3,
        },
        {
          label: '码商提现',
          value: 4,
        },
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        orderNo: [
          { required: true, message: "平台订单号不能为空", trigger: "blur" }
        ],
        merchantOrderNo: [
          { required: true, message: "商户订单号不能为空", trigger: "blur" }
        ],
        merchantId: [
          { required: true, message: "商户id不能为空", trigger: "blur" }
        ],
        merchantNo: [
          { required: true, message: "商户编号不能为空", trigger: "blur" }
        ],
        reqAmount: [
          { required: true, message: "订单请求金额不能为空", trigger: "blur" }
        ],
        merchantFee: [
          { required: true, message: "商户手续费不能为空", trigger: "blur" }
        ],
        merchantRate: [
          { required: true, message: "商户费率不能为空", trigger: "blur" }
        ],
        merchantSingleFee: [
          { required: true, message: "商户单笔手续费不能为空", trigger: "blur" }
        ],
        decreaseAmount: [
          { required: true, message: "账户扣除的金额不能为空", trigger: "blur" }
        ],
        orderStatus: [
          { required: true, message: "订单状态: 1-待支付; 2-支付成功; 3-支付失败不能为空", trigger: "blur" }
        ],
        platformChannelId: [
          { required: true, message: "平台通道id不能为空", trigger: "blur" }
        ],
        channelCode: [
          { required: true, message: "通道代码(来自platform_channel表channel_code)不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ],
        notifyUrl: [
          { required: true, message: "异步通知地址不能为空", trigger: "blur" }
        ],
        returnUrl: [
          { required: true, message: "同步跳转地址不能为空", trigger: "blur" }
        ],
        bankName: [
          { required: true, message: "收款银行名称不能为空", trigger: "blur" }
        ],
        accountName: [
          { required: true, message: "银行卡开户名不能为空", trigger: "blur" }
        ],
        cardNumber: [
          { required: true, message: "收款卡号不能为空", trigger: "blur" }
        ],
        branchName: [
          { required: true, message: "支行名称不能为空", trigger: "blur" }
        ],
        remark: [
          { required: true, message: "付款备注不能为空", trigger: "blur" }
        ],
        bankCode: [
          { required: true, message: "银行代码(ifsc_code)不能为空", trigger: "blur" }
        ],
        notifyStatus: [
          { required: true, message: "异步通知状态(0未通知,1成功,2通知进行中,3超时)不能为空", trigger: "blur" }
        ],
        notifyFailTimes: [
          { required: true, message: "通知失败次数不能为空", trigger: "blur" }
        ],
        nextNotifyTime: [
          { required: true, message: "下次通知时间不能为空", trigger: "blur" }
        ],
        payeeRealAmount: [
          { required: true, message: "收款方实际到账金额不能为空", trigger: "blur" }
        ],
        failReason: [
          { required: true, message: "订单支付失败的原因不能为空", trigger: "blur" }
        ],
        orderSource: [
          { required: true, message: "代付订单来源;1-接口; 2-商户提现；3-商户后台付款不能为空", trigger: "blur" }
        ],
        mode: [
          { required: true, message: "模式：test|pro(测试|生产)不能为空", trigger: "blur" }
        ],
        canSplit: [
          { required: true, message: "是否可拆分为多个子单付款(1可拆,2不可拆)不能为空", trigger: "blur" }
        ],
        applicableAmount: [
          { required: true, message: "供子订单可申请的金额不能为空", trigger: "blur" }
        ],
        canRace: [
          { required: true, message: "卡商是否可进行抢单(1可抢,2不可抢)不能为空", trigger: "blur" }
        ],
        merchantFrozenAmount: [
          { required: true, message: "商户冻结金额不能为空", trigger: "blur" }
        ],
        isCommission: [
          { required: true, message: "是否已经分佣(1是，2否)不能为空", trigger: "blur" }
        ],
        batchNo: [
          { required: true, message: "批量付款批次号不能为空", trigger: "blur" }
        ],
        batchRowNo: [
          { required: true, message: "批量付款批次行号不能为空", trigger: "blur" }
        ],
        isCrypto: [
          { required: true, message: "是否加密货币不能为空", trigger: "blur" }
        ],
        recvAddr: [
          { required: true, message: "收款地址不能为空", trigger: "blur" }
        ],
        queryTime: [
          { required: true, message: "最后查询时间不能为空", trigger: "blur" }
        ]
      },
      reqAmount: null,
    };
  },
  created() {
    this.getList();
    this.init();
  },
  $autoRefresh: {
    // 刷新间隔时间
    interval: 3000 * 10,
    // 立即执行一次
    immediate: false,
    // 被回调的函数, 不保证顺序执行
    handles: ["getList"],
    /**
     * 调用 handles 后的回调函数
     * 这个字段为数组类型, 数组中的每个元素都是一个函数, 在对应索引的 handle 执行后被调用
     */
    callbacks: [],
    // 是否启用调试模式
    debug: true,
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (row.sameMark == 1) {
        return "purpleTransfer";
      }
      if (row.payeeRealAmount != row.reqAmount && row.orderStatus == 2) {
        return "greyOrder";
      }
      if (row.orderStatus == 3) {
        return "redTransfer";
      }
      // if (row.orderStatus == 1) {
      //   return "yellowTransfer";
      // }
      if (row.orderStatus == 2) {
        return "greenTransfer";
      }
    },
    init() {
      common_api.platformChannelAll().then(response => {
        for (var i = 0; i < response.data.length; i++) {
          if (response.data[i].channelType == 2) {
            this.channelAll.push(response.data[i])
          }
        }
      });
    },
    // 预览图片
    previewImage(abUrl) {
      this.srcList[0] = abUrl;
    },
    // 查看子单
    handleSonOrder(row) {
      this.pkCouponStore = row;
      this.pkCouponStoreId = row.orderNo;
      this.pkCouponScopeRangeParkingStoreOpen = true;
    },
    // 通知
    handleNotify(row) {
      this.reset()
      payOutOrder.notify(row.orderNo).then(response => {
        this.msgSuccess("操作成功");
        this.getList();
      });
    },

    // 凭证图片
    getCertificate(row) {
      this.reset()
      payOutOrder.getCertificate(row.orderNo).then(response => {
        this.isShowDetailImg = true;
        this.imgCon = response.data
      });
    },

    //qrBase64是后台传回来的base64数据
    handleDownloadQrIMg(qrBase64) {
      // 这里是获取到的图片base64编码,这里只是个例子哈，要自行编码图片替换这里才能测试看到效果
      const imgUrl = qrBase64
      // 如果浏览器支持msSaveOrOpenBlob方法（也就是使用IE浏览器的时候），那么调用该方法去下载图片
      if (window.navigator.msSaveOrOpenBlob) {
        const bstr = atob(imgUrl.split(',')[1])
        let n = bstr.length
        const u8arr = new Uint8Array(n)
        while (n--) {
          u8arr[n] = bstr.charCodeAt(n)
        }
        const blob = new Blob([u8arr])
        window.navigator.msSaveOrOpenBlob(blob, 'chart-download' + '.' + 'png')
      } else {
        // 这里就按照chrome等新版浏览器来处理
        const a = document.createElement('a')
        a.href = imgUrl
        a.setAttribute('download', 'chart-download')
        a.click()
      }
    },

    timerHandler() {
      let queryParams = {
        pageNum: this.queryParams.pageNum,
        pageSize: this.queryParams.pageSize,
        orderNo: this.queryParams.orderNo,
        merchantOrderNo: this.queryParams.merchantOrderNo,
        cardNumber: this.queryParams.cardNumber,
        merchantName: this.queryParams.merchantName,
        accountName: this.queryParams.accountName,
        reqAmount: typeof (this.reqAmount) == 'object' ? null : !this.reqAmount ? null : parseFloat(this.reqAmount),
        orderSource: this.queryParams.orderSource,
        orderStatus: this.queryParams.orderStatus,
        platformChannelId: this.queryParams.platformChannelId,
      }
      listTransferOrder(this.addSESDateRange(queryParams, this.dateRange, 'type')).then(response => {
        this.infoList = response.rows;
        this.total = Number(response.total);
      });
    },

    /** 查询代付订单列表 */
    getList(reqAmount) {
      this.loading = true;
      let queryParams = {
        pageNum: this.queryParams.pageNum,
        pageSize: this.queryParams.pageSize,
        orderNo: this.queryParams.orderNo,
        merchantOrderNo: this.queryParams.merchantOrderNo,
        cardNumber: this.queryParams.cardNumber,
        merchantName: this.queryParams.merchantName,
        accountName: this.queryParams.accountName,
        reqAmount: typeof (reqAmount) == 'object' ? null : !reqAmount ? null : parseFloat(reqAmount),
        orderSource: this.queryParams.orderSource,
        orderStatus: this.queryParams.orderStatus,
        platformChannelId: this.queryParams.platformChannelId,
        downstreamMerchantOrderNo: this.queryParams.downstreamMerchantOrderNo,
        batchNo: this.queryParams.batchNo
      }
      listTransferOrder(this.addSESDateRange(queryParams, this.dateRange, 'type')).then(response => {
        this.infoList = response.rows;
        this.total = Number(response.total);
        this.loading = false;
        this.startTimer(queryParams)
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {

      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      var reqAmount;
      this.queryParams.reqAmount ? reqAmount = this.NumberMul(this.queryParams.reqAmount, 100) : this.queryParams.reqAmount
      reqAmount = parseFloat(reqAmount)
      this.queryParams.pageNum = 1;
      reqAmount ? this.reqAmount = reqAmount : this.reqAmount = null
      reqAmount ? this.getList(reqAmount) : this.getList(null)
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加代付订单";
    },
    // 查看详情
    handleView(row) {
      const id = row.orderNo;
      getTransferOrder(id).then((response) => {
        this.detailInfoList = response.data;
        this.isShowDetail = true;
        this.detailTitle = "详情";
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTransferOrder(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改代付订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTransferOrder(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addTransferOrder(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除代付订单编号为"' + ids + '"的数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delTransferOrder(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      if (this.dateRange.length) {
        if (this.dateRange[0]) {
          this.queryParams.beginTime = this.dateRange[0][0]
          this.queryParams.endTime = this.dateRange[0][1]
        } else {
          this.queryParams.beginTime = null
          this.queryParams.endTime = null
        }
        if (this.dateRange[1]) {
          this.queryParams.updateBeginTime = this.dateRange[1][0]
          this.queryParams.updateEndTime = this.dateRange[1][1]
        } else {
          this.queryParams.updateBeginTime = null
          this.queryParams.updateEndTime = null
        }
      } else {
        this.queryParams.beginTime = null
        this.queryParams.endTime = null
        this.queryParams.updateBeginTime = null
        this.queryParams.updateEndTime = null
      }
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有代付订单数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportTransferOrder(queryParams);
      }).then(response => {
        this.download(response.msg);
      })
    }
  }
};
</script>
<style>
.greyOrder {
  background: #F4F4F5 !important;
}

.purpleTransfer {
  background: #FDF7FF !important;
}

/* #EEF6FF/#F1FAF5/#FDF7FF/#FFF6F4 */
.blueTransfer {
  background: #EEF6FF !important;
}

.yellowTransfer {
  background: #FEFEE5 !important;
}

.greenTransfer {
  background: #F1FAF5 !important;
}

.redTransfer {
  background: #FFF6F4 !important;
}
</style>
<style scoped>
.red {
  color: red !important;
}

.yellow {
  color: #F49300 !important;
}
.green{
    color: #67c23a !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>