<template>
  <page-header-wrapper>
    <a-card>
      <JeepaySearchForm :searchFunc="searchFunc" :resetFunc="onReset" searchConditionNum="6">
        <a-form-item label="" class="table-search-item">
          <JeepayDateRangePicker ref="dateRangePicker" v-model:value="vdata.searchData['queryDateRange']" customDateRangeType="dateTime" />
        </a-form-item>

<!--        <JeepaySelect ref="orderKeyTypeRef" :reset="isReset">-->
<!--          <a-select v-model:value="vdata.orderKeyType" @change="orderKeyTypeChangeFunc">-->
<!--            <a-select-option v-for="item in orderKeyList" :key="item.key" :value="item.key">{{ item.desc }}</a-select-option>-->
<!--          </a-select>-->
<!--        </JeepaySelect>-->
<!--        <jeepay-text-up v-model:value="vdata.searchData[vdata.orderKeyType]" :placeholder="orderKeyList.find(item => item.key==vdata.orderKeyType)?.desc" class="table-search-item" />-->
        <a-form-item class="table-search-item">
          <a-select v-model:value="vdata.searchData['agentNo']" placeholder="请选择服务商" @change="handleChange">
            <a-select-option value="">全部</a-select-option>
            <a-select-option value="onlyOne">仅自己</a-select-option>
            <a-select-option v-for="d in vdata.agentList" :key="d.agentNo" v-model:value="d.agentNo">
              {{ d.agentName + " [ ID: " + d.agentNo + " ]" }}
            </a-select-option>
          </a-select>
        </a-form-item>

        <JeepaySearchInfoInput v-model:value="vdata.searchData['mchUserName']" placeholder="用户号/名称/手机号" :textUpStyle="true" showType="MCH" />
<!--        <jeepay-text-up v-model:value="vdata.searchData['agentName']" :placeholder="'服务商号/服务商名称'" class="table-search-item" />-->


        <jeepay-text-up v-model:value="vdata.searchData['unionOrderId']" :placeholder="'订单号'" class="table-search-item" />

        <jeepay-text-up v-model:value="vdata.searchData.mchExtNo" :placeholder="'商户名称/商户号'" />
        <jeepay-text-up v-model:value="vdata.searchData.storeInfo" :placeholder="'门店名称/门店编号'" />
        <jeepay-text-up v-model:value="vdata.searchData.ifCode" :placeholder="'支付通道'" />
        <jeepay-text-up v-model:value="vdata.searchData.isvNo" :placeholder="'渠道名称/渠道号'" />
        <jeepay-text-up v-model:value="vdata.searchData.appId" :placeholder="'应用名称/应用ID'" />

        <a-form-item label="" class="table-search-item">
          <a-select v-model:value="vdata.searchData.state" placeholder="支付状态">
            <a-select-option value="">全部</a-select-option>
            <a-select-option value="0">订单生成</a-select-option>
            <a-select-option value="1">支付中</a-select-option>
            <a-select-option value="2">支付成功</a-select-option>
            <a-select-option value="3">支付失败</a-select-option>
            <a-select-option value="4">已撤销</a-select-option>
            <a-select-option value="5">已退款</a-select-option>
            <a-select-option value="6">订单关闭</a-select-option>
            <a-select-option value="20">部分退款</a-select-option>
            <a-select-option value="21">全额退款</a-select-option>
            <a-select-option value="22">退款中</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="" class="table-search-item">
          <a-select v-model:value="vdata.searchData.wayCode" placeholder="支付方式">
            <a-select-option value="">全部</a-select-option>
            <a-select-option v-for="item in vdata.payWayList" :key="item.wayCode" :value="item.wayCode">
              {{ item.wayName }}
            </a-select-option>
          </a-select>
        </a-form-item>


        <a-form-item label="" class="table-search-item">
          <a-select v-model:value="vdata.searchData.settleType" placeholder="结算类型">
            <a-select-option value="">全部</a-select-option>
            <a-select-option value="D0">D0</a-select-option>
            <a-select-option value="D1">D1</a-select-option>
            <a-select-option value="T1">T1</a-select-option>
            <a-select-option value="定时结算">定时结算</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="" class="table-search-item">
          <a-select v-model:value="vdata.searchData.drType" placeholder="借贷标识">
            <a-select-option value="">全部</a-select-option>
            <a-select-option value="00">借记卡</a-select-option>
            <a-select-option value="01">贷记卡</a-select-option>
            <a-select-option value="02">零钱/余额</a-select-option>
            <a-select-option value="03">支付宝花呗</a-select-option>
            <a-select-option value="04">数字货币</a-select-option>
            <a-select-option value="99">其他</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="" class="table-search-item">
          <a-select v-model:value="vdata.searchData.divisionState" placeholder="分账状态">
            <a-select-option value="">全部</a-select-option>
            <a-select-option value="0">未发生分账</a-select-option>
            <a-select-option value="1">等待分账任务处理</a-select-option>
            <a-select-option value="2">分账处理中</a-select-option>
            <a-select-option value="3">分账任务已结束（状态请看分账记录）</a-select-option>
          </a-select>
        </a-form-item>

        <!-- <a-form-item label="" class="table-search-item">
          <a-select v-model:value="vdata.searchData.divisionState" placeholder="分账状态">
            <a-select-option value="">全部</a-select-option>
            <a-select-option value="0">未发生分账</a-select-option>
            <a-select-option value="1">等待分账任务处理</a-select-option>
            <a-select-option value="2">分账处理中</a-select-option>
            <a-select-option value="3">分账任务已结束（状态请看分账记录）</a-select-option>
          </a-select>
        </a-form-item> -->
      </JeepaySearchForm>

      <!-- 列表渲染 -->
      <JeepayTable
        ref="infoTable"
        :initData="true"
        :reqTableDataFunc="reqTableDataFunc"
        :tableColumns="tableColumns"
        :searchData="vdata.searchData"
        :statisticsIsShow="$access('ENT_ORDER_COUNT')"
        rowKey="payOrderId"
        :tableRowCrossColor="true"
        :tableExportFunc="tableExportFunc"
        @btnLoadClose="vdata.btnLoading=false"
      >
        <template #statistics>
          <div class="statistics-list">
            <div v-for="(item, index) in orderCountList" :key="index" class="item">
              <div v-if="item.type == 'line'" class="line" />
              <div class="title">
                {{ item.title }}
                <a-tooltip v-if="item.title == '成功金额'"
                           title="包含支付成功和已退款订单"
                ><question-circle-outlined style="padding-left: 10px"
                /></a-tooltip>
              </div>
              <div v-if="item.title" class="amount" :style="{color: item.textColor}">
                <!-- <span v-if="item.symbol" class="symbol">{{ item.symbol == 'add' ? '+' : '-' }}</span> -->
                <span class="amount-num">{{ item.content }}</span>元
              </div>
              <div v-if="item.count >= 0" class="detail">
                <span>{{ item.count + '笔' }}</span>
                <span v-if="item.detail" class="detail-text" @click="payDetail.showModal()">明细</span>
              </div>
              <div v-if="item.payCount >= 0" class="detail">
                <span>{{ item.payCount + '笔' }}</span>
                <span v-if="item.detail" class="detail-text" @click="paySucDetail.showModal()">明细</span>
              </div>

            </div>
          </div>
        </template>

        <template #headerCell="{ column }">
          <template v-if="column.key === 'settleType'">
            <Tooltip color="#3b4146">
              <template #title>
                <div style="color: #ffffff">提示内容</div>
              </template>
              <div style="cursor: pointer; width: 100%">
                结算类型
                <a-tooltip>
                  <template #title>
                    <p>T1：工作日次日到账，交易资金于周末和法定节假日次日的6点-12点自动结算至银行卡</p>
                    <p>D1：自然日次日到账，全年365天（不分节假日）的交易资金于自然日的次日6点-12点自动结算至银行卡</p>
                    <p>D0：实时到账，全年365天24小时（不分节假日）的交易资金笔笔实时秒到至银行卡，更放心更快捷</p>
                    <p>定时结算，在一天24个整点时辰，根据入账需求选择结算范围，可任意指定一个或多个结算时间点</p>
                  </template>
                  <question-circle-outlined style="padding-left: 10px"/>
                </a-tooltip>
              </div>
            </Tooltip>
          </template>
        </template>
<!--        <template #bodyCell="{column,record}">-->
<!--          <template v-if="column.key == 'amount'"><b>￥{{ record.amount/100 }}</b></template>-->
<!--          <template v-if="column.key == 'refundAmount'">￥{{ record.refundAmount/100 }}</template>-->
<!--          <template v-if="column.key == 'mchFeeAmount'">￥{{ (record.mchFeeAmount / 100).toFixed(2) }}</template>-->
<!--          <template v-if="column.key == 'mchOrderFeeAmount'">￥{{ (record.mchOrderFeeAmount / 100).toFixed(2) }}</template>-->
<!--          <template v-if="column.key == 'state'">-->
<!--            <a-tag-->
<!--              :key="record.state"-->
<!--              :color="record.state === 0?'blue':record.state === 1?'orange':record.state === 2?'green':record.state === 6?'':'volcano'"-->
<!--            >-->
<!--              {{ record.state === 0?'订单生成':record.state === 1?'支付中':record.state === 2?'支付成功':record.state === 3?'支付失败':record.state === 4?'已撤销':record.state === 5?'已退款':record.state === 6?'订单关闭':'未知' }}-->
<!--            </a-tag>-->
<!--          </template>-->
<!--          <template v-if="column.key == 'divisionState'">-->
<!--            <span v-if="record.divisionState == 0">-</span>-->
<!--            <a-tag v-else-if="record.divisionState == 1" color="orange">待分账</a-tag>-->
<!--            <a-tag v-else-if="record.divisionState == 2" color="red">分账处理中</a-tag>-->
<!--            <a-tag v-else-if="record.divisionState == 3" color="green">任务已结束</a-tag>-->
<!--            <span v-else>未知</span>-->
<!--          </template>-->
<!--          <template v-if="column.key == 'orderNo'">-->
<!--            <div class="order-list">-->
<!--              <p><span style="color:#729ED5;background:#e7f5f7">支付</span>{{ record.payOrderId }}</p>-->
<!--              <p style="margin-bottom: 0">-->
<!--                <span style="color:#56cf56;background:#d8eadf">商户</span>-->
<!--                <a-tooltip v-if="record.mchOrderNo.length > record.payOrderId.length" placement="bottom" style="font-weight: normal;">-->
<!--                  <template #title>-->
<!--                    <span>{{ record.mchOrderNo }}</span>-->
<!--                  </template>-->
<!--                  {{ changeStr2ellipsis(record.mchOrderNo, record.payOrderId.length) }}-->
<!--                </a-tooltip>-->
<!--                <span v-else style="font-weight: normal;">{{ record.mchOrderNo }}</span>-->
<!--              </p>-->
<!--              <p v-if="record.channelOrderNo" style="margin-bottom: 0;margin-top: 10px">-->
<!--                <span style="color:#fff;background:#E09C4D">渠道</span>-->
<!--                <a-tooltip v-if="record.channelOrderNo.length > record.payOrderId.length" placement="bottom" style="font-weight: normal;">-->
<!--                  <template #title>-->
<!--                    <span>{{ record.channelOrderNo }}</span>-->
<!--                  </template>-->
<!--                  {{ changeStr2ellipsis(record.channelOrderNo, record.payOrderId.length) }}-->
<!--                </a-tooltip>-->
<!--                <span v-else style="font-weight: normal;">{{ record.channelOrderNo }}</span>-->
<!--              </p>-->
<!--            </div>-->
<!--          </template>-->
<!--          <template v-if="column.key === 'ifCode'">-->
<!--            <span v-if="record.ifCode">{{ record.ifName }} ({{ record.ifCode }})</span>-->
<!--            <span v-else />-->
<!--          </template>-->

<!--          <template v-if="column.key == 'op'">-->
<!--            &lt;!&ndash; 操作列插槽 &ndash;&gt;-->
<!--            <a-button v-if="$access('ENT_PAY_ORDER_VIEW')" type="link" @click="detailFunc(record.payOrderId)">详情</a-button>-->
<!--          </template>-->
<!--        </template>-->

        <template #bodyCell="{column,record}">
          <template v-if="column.key == 'amount'">
            <!--            <a-tooltip>-->
            <!--              <template #title >-->
            <!--                <span>实付金额：￥{{ (record.findAmt / 100).toFixed(2) }}</span><br>-->
            <!--                <span>实际手续费：￥{{ (record.mchFeeAmount / 100).toFixed(2) }}</span><br>-->
            <!--                <span>收单手续费：￥{{ (record.mchOrderFeeAmount / 100).toFixed(2) }}</span><br>-->
            <!--                <span>退款金额：￥{{ (record.refundAmount / 100).toFixed(2) }}</span><br>-->
            <!--                <span v-if="record.discountScale >0">优惠折扣：{{record.discountScale}}折</span><br>-->
            <!--                <span>优惠金额：￥{{ (record.discountAmt / 100).toFixed(2) }}</span><br>-->
            <!--                <span>入账金额：￥{{ ((record.findAmt - record.extDivAmt- record.mchFeeAmount  + record.marketAmt) / 100).toFixed(2) }}</span><br>-->
            <!--                <span>补贴金额：￥{{ (record.marketAmt / 100).toFixed(2) }}</span><br>-->
            <!--              </template>-->
            <!--                <b style="color: #1890ff">￥{{ record.amount/100 }} </b>-->
            <!--            </a-tooltip>-->
            <a-popover placement="top" style="background: #0c2640 !important;">
              <template #content  style="background: #ff0 !important;">
                <p>实付金额：￥{{ (record.findAmt / 100).toFixed(2) }}</p>
                <p>实际手续费：￥{{ (record.mchFeeAmount / 100).toFixed(2) }}</p>
                <p>收单手续费：￥{{ (record.mchOrderFeeAmount / 100).toFixed(2) }}</p>
                <p>垫资手续费：￥{{ (record.cashFee / 100).toFixed(2) }}</p>
                <p>退款金额：￥{{ (record.refundAmount / 100).toFixed(2) }}</p>
                <p v-if="record.discountScale >0">优惠折扣：{{record.discountScale}}折</p>
                <p>优惠金额：￥{{ (record.discountAmt / 100).toFixed(2) }}</p>
                <p>入账金额：￥{{ ((record.findAmt - record.extDivAmt- record.mchFeeAmount - record.cashFee  + record.marketAmt) / 100).toFixed(2) }}</p>
                <p>补贴金额：￥{{ (record.marketAmt / 100).toFixed(2) }}</p>
              </template>
              <b style="color: #1890ff">￥{{ (record.amount/100).toFixed(2) }} </b>
            </a-popover>
          </template>
          <!--          <template v-if="column.key == 'refundAmount'">￥{{ record.refundAmount/100 }}</template>-->
          <!--          <template v-if="column.key == 'mchFeeAmount'">￥{{ (record.mchFeeAmount / 100).toFixed(2) }}</template>-->
          <!--          <template v-if="column.key == 'mchOrderFeeAmount'">￥{{ (record.mchOrderFeeAmount / 100).toFixed(2) }}</template>-->
          <template v-if="column.key == 'state'">
            <span v-if="record.state !== 5 ">
               <a-tag
                   :key="record.state"
                   :color="record.state === 0?'blue':record.state === 1?'orange':record.state === 2?'green':record.state === 6?'':'volcano'"
               >
                {{ record.state === 0?'订单生成':record.state === 1?'支付中':record.state === 2?'支付成功':record.state === 3?'支付失败':record.state === 4?'已撤销':record.state === 6?'订单关闭':record.state === 22?'退款中':'未知' }}

              </a-tag>
            </span>
            <span v-else-if="record.state === 5 ">
               <a-tag
                   :key="record.refundState"
                   :color="record.refundState === 0?'red':record.refundState === 1?'orange':record.refundState === 2?'red':'red'"
               >
                {{ record.refundState === 0?'':record.refundState === 1?'部分退款':record.refundState === 2?'全额退款':'未知' }}
              </a-tag>
            </span>
            <a-tag v-else></a-tag>


            <a-tooltip  title="拉卡拉通道单笔结算金额低于11元、银联云闪付交易或单笔超限交易均转为D1次日到账" v-if="record.state == 2 && record.ifCode == 'lklspay'  && record.settleType == 'D0'">
              <question-circle-outlined style="color: #FF0000;"/>
            </a-tooltip>
            <a-tooltip  :title="record.errMsg" v-if="record.state == 3">
              <info-circle-outlined style="color: #FFD080;margin-left: 10px"/>
            </a-tooltip>

            <TransactionOutlined @click="getRefund(record)" style="color: #FF0000;" v-if="record.state == 5 || record.state == 22" />

            <reload-outlined @click="getReload(record)" style="color: #1890ff;margin-left: 10px" v-if="record.state == 1" />

          </template>
          <template v-if="column.key == 'divisionState'">
            <!--            <span v-if="record.divisionState == 0">不分账</span>-->
            <a-tag v-if="record.divisionState == 0" color="orange">否</a-tag>
            <a-tag v-if="record.divisionState != 0" color="green">是</a-tag>
            <!--            <a-tag v-else-if="record.divisionState != 0" color="orange">待分账</a-tag>-->
            <!--            <a-tag v-else-if="record.divisionState == 2" color="red">分账处理中</a-tag>-->
            <!--            <a-tag v-else-if="record.divisionState == 3" color="green">任务已结束</a-tag>-->
          </template>



          <template v-if="column.key === 'isvName'">
            <a-tooltip  class="my-tooltip" overlayClassName="tooltip-box-name">
              <template #title>
                <span>渠道名称：{{record.isvName}}</span><br>
                <span>渠道号：{{record.isvNo}}</span>
              </template>
              <div class="my-tooltip-title-box"> {{record.isvName}}</div>
            </a-tooltip>
          </template>
          <template v-if="column.key === 'appId'">
            <a-tooltip  class="my-tooltip" overlayClassName="tooltip-box-name">
              <template #title>
                <span>应用名称：{{record.appName}}</span><br>
                <span>应用ID：{{record.appId}}</span>
              </template>
              <div class="my-tooltip-title-box"> {{record.appName}}</div>
            </a-tooltip>
          </template>
          <template v-if="column.key === 'mchName'">
            <a-tooltip  class="my-tooltip" overlayClassName="tooltip-box-name">
              <template #title>
                <span>商户名称：{{record.mchName}}</span><br>
                <span>商户号：{{record.mchExtNo}}</span>
              </template>
              <div class="my-tooltip-title-box"> {{record.mchName}}</div>
            </a-tooltip>
          </template>
          <template v-if="column.key === 'agentName'">
            <a-tooltip  class="my-tooltip" overlayClassName="tooltip-box-name">
              <template #title>
                <span>服务商名称：{{record.agentName}}</span><br>
                <span>服务商号：{{record.agentNo}}</span>
              </template>
              <div class="my-tooltip-title-box"> {{record.agentName}}</div>
            </a-tooltip>
          </template>
          <template v-if="column.key === 'mchUserName'">
            <a-tooltip  class="my-tooltip" overlayClassName="tooltip-box-name">
              <template #title>
                <span>用户名称：{{record.mchUserName}}</span><br>
                <span>用户手机号：{{record.mchUserPhone}}</span>
              </template>
              <div class="my-tooltip-title-box"> {{record.mchUserName}}</div>
            </a-tooltip>
          </template>
          <template v-if="column.key === 'storeName'">
            <a-tooltip  class="my-tooltip" overlayClassName="tooltip-box-name">
              <template #title>
                <span>门店名称：{{record.storeName}}</span><br>
                <span>门店编号：{{record.storeId}}</span>
              </template>
              <div class="my-tooltip-title-box"> {{record.storeName}}</div>
            </a-tooltip>
          </template>



          <template v-if="column.key == 'drType'">
            <span v-if="record.drType == '00'">借记卡</span>
            <span v-if="record.drType == '01'">贷记卡</span>
            <span v-if="record.drType == '02'">零钱/余额</span>
            <span v-if="record.drType == '03'">支付宝花呗</span>
            <span v-if="record.drType == '04'">数字货币</span>
            <span v-if="record.drType == '99'">其他</span>
            <span v-if="!record.drType">--</span>
          </template>
          <template v-if="column.key == 'ifName'">
            {{record.ifName??"--"}}
          </template>
          <template v-if="column.key == 'settleType'">
            {{record.settleType??"--"}}
          </template>
          <template v-if="column.key == 'orderNo'">

            <a-popover placement="top">
              <template #content>
                <p>平台订单号：{{ record.payOrderId??"--" }}</p>
                <p>通道订单号：{{record.channelOrderNo??"--"}}</p>
                <p>渠道订单号：{{ record.platformOrderNo??"--" }}</p>
                <p>商户订单号：{{ record.mchOrderNo ??"--"}}</p>
                <p>落单订单号：{{ record.platformMchOrderNo??"--" }}</p>
              </template>
              <b style="color: #1890ff"> {{ record.payOrderId??"--" }} </b>
            </a-popover>

            <!--            <a-tooltip  defaultVisible="true">-->
            <!--              <template #title>-->
            <!--                <div class="order-list-payOrderId">-->
            <!--                  <p>平台订单号：{{ record.payOrderId??"&#45;&#45;" }}</p>-->
            <!--                  <p>通道订单号：{{record.channelOrderNo??"&#45;&#45;"}}</p>-->
            <!--                  <p>渠道订单号：{{ record.platformOrderNo??"&#45;&#45;" }}</p>-->
            <!--                  <p>商户订单号：{{ record.mchOrderNo ??"&#45;&#45;"}}</p>-->
            <!--                  <p>落单订单号：{{ record.platformMchOrderNo??"&#45;&#45;" }}</p>-->
            <!--                </div>-->
            <!--              </template>-->
            <!--             <b style="color: #1890ff"> {{ record.payOrderId??"&#45;&#45;" }} </b>-->
            <!--            </a-tooltip>-->

            <!--            <div class="order-list">-->
            <!--              <p><span style="color:#729ED5;background:#e7f5f7">支付</span>{{ record.payOrderId }}</p>-->

            <!--              <p style="margin-bottom: 0">-->
            <!--                <span style="color:#56cf56;background:#d8eadf">商户</span>-->
            <!--                <a-tooltip v-if="record.mchOrderNo.length > record.payOrderId.length" placement="bottom" style="font-weight: normal;">-->
            <!--                  <template #title>-->
            <!--                    <span>{{ record.mchOrderNo }}</span>-->
            <!--                  </template>-->
            <!--                  {{ changeStr2ellipsis(record.mchOrderNo, record.payOrderId.length) }}-->
            <!--                </a-tooltip>-->
            <!--                <span v-else style="font-weight: normal;">{{ record.mchOrderNo }}</span>-->
            <!--              </p>-->
            <!--              <p v-if="record.channelOrderNo" style="margin-bottom: 0;margin-top: 10px">-->
            <!--                <span style="color:#fff;background:#E09C4D">渠道</span>-->
            <!--                <a-tooltip v-if="record.channelOrderNo.length > record.payOrderId.length" placement="bottom" style="font-weight: normal;">-->
            <!--                  <template #title>-->
            <!--                    <span>{{ record.channelOrderNo }}</span>-->
            <!--                  </template>-->
            <!--                  {{ changeStr2ellipsis(record.channelOrderNo, record.payOrderId.length) }}-->
            <!--                </a-tooltip>-->
            <!--                <span v-else style="font-weight: normal;">{{ record.channelOrderNo }}</span>-->
            <!--              </p>-->
            <!--            </div>-->
          </template>
          <template v-if="column.key == 'op'">
            <!-- 操作列插槽 -->

            <!--            <a-button v-if="$access('ENT_PAY_ORDER_VIEW')" type="link" @click="detailFunc(record.payOrderId)">详情</a-button>-->

            <a-button v-if="$access('ENT_PAY_ORDER_VIEW')" type="link" @click="payLogDetail.show(record)">详情</a-button>
          </template>
        </template>
      </JeepayTable>
    </a-card>
    <!-- 退款弹出框 -->
    <refund-modal ref="refundModalInfo" :callbackFunc="searchFunc" />
    <!-- 日志详情抽屉 -->
<!--    <template>-->
<!--      <a-drawer-->
<!--        v-model:visible="vdata.visible"-->
<!--        width="50%"-->
<!--        placement="right"-->
<!--        :closable="true"-->
<!--        :title="vdata.visible === true? '订单详情':''"-->
<!--        @close="onClose"-->
<!--      >-->
<!--        <a-row justify="space-between" type="flex">-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="渠道商号">-->
<!--                {{ vdata.detailData.isvNo }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="支付订单号">-->
<!--                <a-tag color="purple">-->
<!--                  {{ vdata.detailData.payOrderId }}-->
<!--                </a-tag>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="用户号">-->
<!--                {{ vdata.detailData.mchNo }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="商户订单号">-->
<!--                {{ vdata.detailData.mchOrderNo }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="用户名称">-->
<!--                {{ vdata.detailData.mchName }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="应用APPID">-->
<!--                {{ vdata.detailData.appId }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="门店名称">-->
<!--                {{ vdata.detailData.storeName }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="门店ID">-->
<!--                {{ vdata.detailData.storeId }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="订单状态">-->
<!--                <a-tag :color="vdata.detailData.state === 0?'blue':vdata.detailData.state === 1?'orange':vdata.detailData.state === 2?'green':vdata.detailData.state === 6?'':'volcano'">-->
<!--                  {{ vdata.detailData.state === 0?'订单生成':vdata.detailData.state === 1?'支付中':vdata.detailData.state === 2?'支付成功':vdata.detailData.state === 3?'支付失败':vdata.detailData.state === 4?'已撤销':vdata.detailData.state === 5?'已退款':vdata.detailData.state === 6?'订单关闭':'未知' }}-->
<!--                </a-tag>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="支付金额">-->
<!--                <a-tag color="green">-->
<!--                  {{ vdata.detailData.amount/100 }}-->
<!--                </a-tag>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions><a-descriptions-item label="实际手续费"><a-tag color="pink">{{ vdata.detailData.mchFeeAmount/100 }}</a-tag></a-descriptions-item></a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions><a-descriptions-item label="收单手续费"><a-tag color="pink">{{ vdata.detailData.mchOrderFeeAmount/100 }}</a-tag></a-descriptions-item></a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions><a-descriptions-item label="商家费率">{{ vdata.detailData.mchFeeRate }}</a-descriptions-item></a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="支付错误码">-->
<!--                {{ vdata.detailData.errCode }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="支付错误描述">-->
<!--                {{ vdata.detailData.errMsg }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="买家备注">-->
<!--                {{ vdata.detailData.buyerRemark }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="卖家备注">-->
<!--                {{ vdata.detailData.sellerRemark }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="订单失效时间">-->
<!--                {{ vdata.detailData.expiredTime }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="支付成功时间">-->
<!--                {{ vdata.detailData.successTime }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="创建时间">-->
<!--                {{ vdata.detailData.createdAt }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="更新时间">-->
<!--                {{ vdata.detailData.updatedAt }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-divider />-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="商品标题">-->
<!--                {{ vdata.detailData.subject }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="商品描述">-->
<!--                {{ vdata.detailData.body }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="接口代码">-->
<!--                {{ vdata.detailData.ifCode }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="货币代码">-->
<!--                {{ vdata.detailData.currency }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="支付方式">-->
<!--                {{ vdata.detailData.wayCode }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="客户端IP">-->
<!--                {{ vdata.detailData.clientIp }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="用户标识">-->
<!--                {{ vdata.detailData.channelUser }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="渠道订单号">-->
<!--                {{ vdata.detailData.channelOrderNo }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="异步通知地址">-->
<!--                {{ vdata.detailData.notifyUrl }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="页面跳转地址">-->
<!--                {{ vdata.detailData.returnUrl }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="退款次数">-->
<!--                {{ vdata.detailData.refundTimes }}-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="退款总额">-->
<!--                <a-tag v-if="vdata.detailData.refundAmount" color="cyan">-->
<!--                  {{ vdata.detailData.refundAmount/100 }}-->
<!--                </a-tag>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->

<!--          &lt;!&ndash; <a-divider />-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="订单分账模式">-->
<!--                <span v-if="vdata.detailData.divisionMode == 0">该笔订单不允许分账</span>-->
<!--                <span v-else-if="vdata.detailData.divisionMode == 1">支付成功按配置自动完成分账</span>-->
<!--                <span v-else-if="vdata.detailData.divisionMode == 2">商户手动分账(解冻商户金额)</span>-->
<!--                <span v-else>未知</span>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item label="分账状态">-->
<!--                <a-tag v-if="vdata.detailData.divisionState == 0" color="blue">未发生分账</a-tag>-->
<!--                <a-tag v-else-if="vdata.detailData.divisionState == 1" color="orange">待分账</a-tag>-->
<!--                <a-tag v-else-if="vdata.detailData.divisionState == 2" color="red">分账处理中</a-tag>-->
<!--                <a-tag v-else-if="vdata.detailData.divisionState == 3" color="green">任务已结束</a-tag>-->
<!--                <a-tag v-else color="#f50">未知</a-tag>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions><a-descriptions-item label="最新分账发起时间">{{ vdata.detailData.divisionLastTime }}</a-descriptions-item></a-descriptions>-->
<!--          </a-col> &ndash;&gt;-->
<!--        </a-row>-->
<!--        <a-divider />-->
<!--        <a-row justify="start" type="flex">-->
<!--          <a-col :sm="24">-->
<!--            <span style="color: black;">扩展参数:</span>-->
<!--            <a-form-item>-->
<!--              <a-input-->
<!--                v-model:value="vdata.detailData.extParam"-->
<!--                type="textarea"-->
<!--                disabled="disabled"-->
<!--                style="height: 100px;color: black;margin-top: 10px;"-->
<!--              />-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--        </a-row>-->

<!--        <a-row justify="start" type="flex">-->
<!--          <a-col :sm="12">-->
<!--            <a-descriptions>-->
<!--              <a-descriptions-item v-if="vdata.detailData.profitAmount" label="分润金额">-->
<!--                <a-tag color="green">{{ vdata.detailData.profitAmount/100 }}</a-tag>-->
<!--              </a-descriptions-item>-->
<!--            </a-descriptions>-->
<!--          </a-col>-->
<!--        </a-row>-->
<!--      </a-drawer>-->
<!--    </template>-->
    <PayLogDetail ref="payLogDetail" :countDetailList="countDetailList"  />
  </page-header-wrapper>

  <!-- 数据统计对话框 -->
  <PayDetail ref="payDetail" :countDetailList="countDetailList" />
  <PaySucDetail ref="paySucDetail"  :sucDetailList="sucDetailList" />
</template>
<script lang="ts" setup>
import RefundModal from './RefundModal.vue' // 退款弹出框
import { $getPayOrderRefresh,API_URL_PAY_ORDER_LIST, API_URL_PAYWAYS_LIST, API_URL_AGENT_LIST, req, $exportExcel, exportExcelUrl ,$payOrderCount, $getPayConfigIfcodes} from '@/api/manage'
import {ref, onMounted, reactive, getCurrentInstance} from 'vue'
import fileDownload from 'js-file-download'
import { message } from 'ant-design-vue'
import PayDetail from './PayDetail.vue' // 数据统计详情弹出框
import PayLogDetail from './PayLogDetail.vue' // 数据统计详情弹出框
import PaySucDetail from './PaySucDetail.vue' // 数据统计详情弹出框

import { useRouter, useRoute } from 'vue-router'
const routerPath = useRouter() //这是全部路由
const payDetail = ref() // 对话框
const ifCodeRef = ref()
const payLogDetail = ref()
const paySucDetail = ref()

  // 获取全局函数
const { $infoBox,$access } = getCurrentInstance()!.appContext.config.globalProperties

// const tableColumns = reactive([
//   { key: 'orderNo', title: '订单号', },
//   { key: 'amount', title: '支付金额' },
//   { key: 'refundAmount', title: '退款金额' },
//   { key: 'mchFeeAmount', title: '实际手续费', dataIndex: 'mchFeeAmount' },
//   { key: 'mchOrderFeeAmount', title: '收单手续费', dataIndex: 'mchOrderFeeAmount' },
//   { key: 'mchName', title: '用户名称', dataIndex: 'mchName', ellipsis: true, minWidth: 100 },
//   { key: 'storeName', title: '门店名称', dataIndex: 'storeName', ellipsis: true, defaultHidden: true },
//   { key: 'storeId', title: '门店ID', dataIndex: 'storeId', defaultHidden: true },
//   { key: 'ifCode', title: '支付接口'},
//   { key: 'wayName', title: '支付方式', dataIndex: 'wayName', },
//   { key: 'state', title: '支付状态',},
//   // { key: 'divisionState', title: '分账状态', align: 'center' },
//   { key: 'buyerRemark', title: '买家备注', dataIndex: 'buyerRemark', defaultHidden: true },
//   { key: 'platformMchOrderNo', title: '支付凭证商户单号', dataIndex: 'platformMchOrderNo', defaultHidden: true },
//   { key: 'platformOrderNo', title: '支付凭证交易单号', dataIndex: 'platformOrderNo', defaultHidden: true },
//   { key: 'createdAt', dataIndex: 'createdAt', title: '创建日期' },
//   { key: 'op', title: '操作',   fixed: 'right', align: 'center' }
// ])
const tableColumns = reactive([
  { key: 'orderNo', title: '订单号'},
  { key: 'mchUserName', title: '用户名称', dataIndex: 'mchUserName'},
  { key: 'agentName', title: '服务商名称', dataIndex: 'agentName' },
  { key: 'mchName', title: '商户名称', dataIndex: 'mchName' },
  { key: 'storeName', title: '门店名称', dataIndex: 'storeName' },
  { key: 'ifName', title: '支付通道', dataIndex: 'ifName',},
  { key: 'isvName', title: '所属渠道', dataIndex: 'isvName' },
  { key: 'appId', title: '应用名称', dataIndex: 'appId' },
  { key: 'amount', title: '支付金额(元)' },
  // { key: 'refundAmount', title: '退款金额' },
  // { key: 'mchFeeAmount', title: '实际手续费', dataIndex: 'mchFeeAmount' },
  // { key: 'mchOrderFeeAmount', title: '收单手续费', dataIndex: 'mchOrderFeeAmount' },
  // { key: 'payOrderId', title: '支付订单号', dataIndex: 'payOrderId' },
  // { key: 'mchOrderNo', title: '商户订单号', dataIndex: 'mchOrderNo' },
  { key: 'state', title: '支付状态',},
  { key: 'wayName', title: '支付方式', dataIndex: 'wayName',},
  { key: 'settleType', title: '结算类型', dataIndex: 'settleType', align: 'center'},
  { key: 'drType', title: '借贷标识', dataIndex: 'drType', align: 'center'},
  { key: 'divisionState', title: '分账状态', align: 'center' },
  { key: 'buyerRemark', title: '买家备注', dataIndex: 'buyerRemark', defaultHidden: true },
  { key: 'platformMchOrderNo', title: '支付凭证商户单号', dataIndex: 'platformMchOrderNo', defaultHidden: true },
  { key: 'platformOrderNo', title: '支付凭证交易单号', dataIndex: 'platformOrderNo', defaultHidden: true },
  { key: 'createdAt', dataIndex: 'createdAt', title: '创建日期' },
  { key: 'op', title: '操作',  fixed: 'right', align: 'center' }
])

const orderKeyList = ref([
  { 'key': 'payOrderId', 'desc': '支付订单号' },
  { 'key': 'mchOrderNo', 'desc': '商户订单号' },
  { 'key': 'channelOrderNo', 'desc': '渠道订单号' },
  { 'key': 'platformOrderNo', 'desc': '用户支付凭证交易单号' },
  { 'key': 'platformMchOrderNo', 'desc': '用户支付凭证商户单号' }])

    const refundModalInfo = ref()
    const infoTable = ref()
    const dateRangePicker = ref()
    const orderKeyTypeRef = ref()

    const vdata :any = reactive({
      btnLoading: false,
      tableColumns: tableColumns,
      searchData: {queryDateRange: 'today' , agentNo: ''} as any,
      visible: false,
      detailData: {} as any,
      payWayList: [] as any,
      agentList: [] as any, // 服务商下拉列表
      orderKeyType: 'payOrderId'
    })

  onMounted(()=>{
    if ($access('ENT_PAY_ORDER_SEARCH_PAY_WAY')) {
      initPayWay()
    }
    if($access('ENT_AGENT_RATE_CONFIG')){
     $getPayConfigIfcodes('AGENT', 'agentApplyment', '').then((res) => {
        vdata.ifCodeList = res
      })
    }
  })
function  getReload(data){
  return $getPayOrderRefresh(data.payOrderId).then(res => {
    infoTable.value.refTable(true)
    message.success('刷新成功')
  })
}
function getRefund(data) {
  routerPath.push({
    path:'/refund',
    query:{payOrderId:data.payOrderId}
  })
}
  let orderCountList:any = ref([]) // 数据统计数组
  let countDetailList: any = ref([]) // 数据统计明细数组
  let sucDetailList: any = ref([]) // 数据统计明细数组
  // 数据统计
  // const getOrderCount = () => {
  //   $payOrderCount(vdata.searchData).then( res => {
  //     orderCountList.value = [
  //       {title: '实际收款金额', symbol: 'add', textColor: '#1A66FF', content: ((res.allAmount - res.mchFeeAmount) / 100).toFixed(2)},
  //       {type: 'line'},
  //       {title: '成交金额', content: (res.allAmount / 100).toFixed(2), count: res.allCount, detail: true},
  //       {type: 'line'},
  //       {title: '实际手续费金额',symbol: 'sub', content: (res.mchFeeAmount / 100).toFixed(2)},
  //       {type: 'line'},
  //       {title: '退款订单', content: (res.refundAmount / 100).toFixed(2), count: res.refundCount, textColor: '#faad14'},
  //     ]
  //     countDetailList.value = [
  //       {title: '创建订单', content: (res.allPayAmount / 100).toFixed(2), count: res.allPayCount},
  //       {type: 'line'},
  //       {title: '成交订单', content: (res.allAmount / 100).toFixed(2), count: res.allCount},
  //       {type: 'line'},
  //       {title: '未付款订单', content: (res.failPayAmount / 100).toFixed(2), count: res.failPayCount},
  //     ]
  //   })
  // }
const getOrderCount = () => {
  $payOrderCount(vdata.searchData).then( res => {
    orderCountList.value = [
      {title: '订单金额', textColor: '#1A66FF', content: (res.totalAmt/ 100).toFixed(2),count: res.totalNum},
      {type: 'line'},
      {title: '成交金额', content: (res.totalSuccAmt / 100).toFixed(2),count:res.totalSuccNum,  detail: false},
      {type: 'line'},
      // {title: '入账金额',symbol: 'sub', content:  ((res.totalFindAmt - res.totalExtDivAmt- res.mchFeeAmount  + res.totalMarketAmt) / 100).toFixed(2), count: res.totalNum, detail: true},
      {title: '入账金额',symbol: 'sub', content:  ((res.totalEntryAmt) / 100).toFixed(2), count: res.totalSuccNum, detail: true},

      {type: 'line'},
      {title: '退款金额', content: (res.totalRefundAmt / 100).toFixed(2), count: res.totalRefundNum, textColor: '#faad14'},
    ]
    // orderCountList.value = [
    //   {title: '实际收款金额', symbol: 'add', textColor: '#1A66FF', content: ((res.allAmount - res.mchFeeAmount) / 100).toFixed(2)},
    //   {type: 'line'},
    //   {title: '成交订单', content: (res.allAmount / 100).toFixed(2), count: res.allCount, detail: true},
    //   {type: 'line'},
    //   {title: '实际手续费金额',symbol: 'sub', content: (res.mchFeeAmount / 100).toFixed(2)},
    //   {type: 'line'},
    //   {title: '退款订单', content: (res.refundAmount / 100).toFixed(2), count: res.refundCount, textColor: '#faad14'},
    // ]
    sucDetailList.value = [
      {title: '创建订单', content: (res.allPayAmount / 100).toFixed(2), count: res.allPayCount},
      {type: 'line'},
      {title: '成交订单', content: (res.allAmount / 100).toFixed(2), count: res.allCount},
      {type: 'line'},
      {title: '未付款订单', content: (res.failPayAmount / 100).toFixed(2), count: res.failPayCount},
    ]
    countDetailList.value = [
      [
        {title: '支付金额', content: (res.totalFinalAmt   / 100).toFixed(2), type: 1},
        {type: 'line'},
        {title: '交易手续费', content: (res.totalFeeAmt / 100).toFixed(2), type: 1},
        {type: 'line'},
        {title: '垫资手续费', content: (res.totalCashFee / 100).toFixed(2), type: 1},
      ],
      [
        {title: '退款金额', content: (res.totalRefundAmt   / 100).toFixed(2), type: 2},
        {type: 'line'},
        {title: '优惠金额', content: (res.totalDiscountAmt / 100).toFixed(2), type: 2},
        {type: 'line'},
        {title: '补贴金额', content: (res.totalMarketAmt / 100).toFixed(2), type: 2},
      ]
    ]
  })
}
  getOrderCount() // 进入页面时调用一次

    // 请求table接口数据
  function reqTableDataFunc(params){
    return req.list(API_URL_PAY_ORDER_LIST, params)
  }
  function searchFunc(){ // 点击【查询】按钮点击事件
     infoTable.value.refTable(true)
     getOrderCount() // 数据统计函数
  }

  function detailFunc(recordId) {

    req.getById(API_URL_PAY_ORDER_LIST, recordId).then(res => {
      vdata.detailData = res
    })
    vdata.visible = true
  }
  function onClose () {
    vdata.visible = false
  }
  function initPayWay () {

    req.list(API_URL_PAYWAYS_LIST, { 'pageSize': -1 }).then(res => { // 支付方式下拉列表
      vdata.payWayList = res.records
    })
  }
  function changeStr2ellipsis (orderNo, baseLength) {
    const halfLengh = baseLength / 2
    return orderNo.substring(0, halfLengh - 1) + '...' + orderNo.substring(orderNo.length - halfLengh, orderNo.length)
  }

  function tableExportFunc(){
    return $exportExcel(exportExcelUrl.payOrder, Object.assign({}, vdata.searchData, {'pageSize': -1})).then(res => {
        fileDownload(res.data, '订单列表.xlsx')
    }).catch ((error) =>{console.log(error)} )
  }

  function handleChange (value) {
    for (let i = 0; i < vdata.agentList.length; i++) {
      if (value === vdata.agentList[i]['agentNo']) {
        vdata.searchData['isvNo'] = vdata.agentList[i]['isvNo']
      }
    }
  }

  let isReset = ref(0) // 下拉搜索框是否重置
  function onReset(){
    isReset.value++ // 下拉搜索框重置
    //重置搜索内容
    dateRangePicker.value.returnSelectModel()
    vdata.searchData = { queryDateRange: 'today' }
  }

  req.list(API_URL_AGENT_LIST, { 'pageSize': -1, 'state': 1 }).then(res => { // 服务商下拉选择列表
    vdata.agentList = res.records
  })

  function orderKeyTypeChangeFunc() {
    orderKeyTypeRef.value.textupHandle()

    vdata.searchData.payOrderId = ''
    vdata.searchData.mchOrderNo = ''
    vdata.searchData.channelOrderNo = ''
    vdata.searchData.platformMchOrderNo = ''
    vdata.searchData.platformOrderNo = ''
  }
</script>
<style lang="less" scoped>

.order-list {
  -webkit-text-size-adjust:none;
  font-size: 12px;
  display: flex;
  flex-direction: column;

  p {
    white-space:nowrap;
    span {
      display: inline-block;
      font-weight: 800;
      height: 16px;
      line-height: 16px;
      width: 35px;
      border-radius: 5px;
      text-align: center;
      margin-right: 2px;
    }
  }
}
</style>
