<template>
  <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="订单管理" name="first">
      <div style="display: inline-block;">
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>状态：</span>
          <el-select
            v-model="status"
            style="width:150px;margin-left: 10px;"
            @change="animeDat2(status)"
          >
            <el-option
              v-for="item in taskstates"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option> </el-select
          >&nbsp;&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>订单类型：</span>
          <el-select
            v-model="orderType"
            style="width:150px;margin-left: 10px;"
            @change="animeDat2(orderType)"
          >
            <el-option
              v-for="item in orderTypes"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option> </el-select
          >&nbsp;&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>配送状态：</span>
          <el-select
            v-model="reservationFlag"
            style="width:150px;margin-left: 10px;"
            @change="animeDat2(reservationFlag)"
          >
            <el-option
              v-for="item in reservationFlags"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option> </el-select
          >&nbsp;&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>跑腿订单状态：</span>
          <el-select
            v-model="indentStatus"
            style="width:150px;margin-left: 10px;"
            @change="animeDat2(indentStatus)"
          >
            <el-option
              v-for="item in indentStatuss"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option> </el-select
          >&nbsp;&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>订单号:</span>
          <el-input
            style="width: 200px;"
            @keydown.enter.native="phoneSelect"
            placeholder="请输入订单号"
            v-model="orderNumber"
          ></el-input
          >&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>商户单号:</span>
          <el-input
            style="width: 200px;"
            @keydown.enter.native="phoneSelect"
            placeholder="请输入商户单号"
            v-model="transactionId"
          ></el-input
          >&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>商铺名称:</span>
          <el-input
            style="width: 200px;"
            @keydown.enter.native="phoneSelect"
            @input="phoneSelect"
            placeholder="请输入商户名称"
            v-model="shopName"
          >
          </el-input
          >&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>商铺类型：</span>
          <el-select
            v-model="spEarningTypeId"
            style="width:200px;"
            @change="phoneSelect"
            :clearable="true"
          >
            <el-option
              v-for="item in spEarnings"
              :key="item.id"
              :label="item.shopTypeName"
              :value="item.id"
            >
            </el-option> </el-select
          >&nbsp;&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>优惠券类型：</span>
          <el-select
            v-model="couponType"
            style="width:200px;"
            @change="phoneSelect"
            :clearable="true"
          >
            <el-option label="平台" :value="0"> </el-option>
            <el-option label="商家" :value="1"> </el-option> </el-select
          >&nbsp;&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>手机号:</span>
          <el-input
            style="width: 200px;"
            @keydown.enter.native="phoneSelect"
            placeholder="请输入手机号"
            v-model="phone"
          >
          </el-input
          >&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>骑手所在站点:</span>
          <el-select
            @change="phoneSelect"
            :clearable="true"
            v-model="stationName"
            placeholder="请选择骑手所在站点"
          >
            <el-option
              :label="i.stationName"
              :value="i.id"
              :key="i.id"
              v-for="i in stationData"
            ></el-option> </el-select
          >&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block; margin: 3px;">
          <span>骑手电话：</span>
          <el-input
            style="width: 200px;"
            @keydown.enter.native="phoneSelect"
            placeholder="请输入骑手电话"
            v-model="riderPhone"
          >
          </el-input
          >&nbsp;&nbsp;
        </div>
        <div style="position: relative;display: inline-block;margin: 3px;">
          <span>昵称:</span>
          <el-input
            style="width: 200px;"
            @keydown.enter.native="phoneSelect"
            placeholder="请输入昵称"
            v-model="userName"
          >
          </el-input
          >&nbsp;&nbsp;
        </div>
        <div style="margin:5px;display: inline-block;">
          <!-- <span>订单创建开始时间：</span> -->
          <!-- <el-date-picker
            style="width: 160px;margin-left: 10px;"
            v-model="startTime"
            align="right"
            type="datetime"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间"
          >
          </el-date-picker> -->
          <span>订单创建时间：</span>
          <el-date-picker
            v-model="startTime"
            type="datetimerange"
            unlink-panels
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
          >
          </el-date-picker>
          &nbsp;&nbsp;&nbsp;
        </div>
        <!-- <div style="margin:5px;display: inline-block;">
          <span>订单创建截止时间：</span>
          <el-date-picker
            style="width: 160px;margin-left: 10px;"
            v-model="endTime"
            align="right"
            type="datetime"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择截止时间"
          >
          </el-date-picker>
        </div> -->

        <div style="margin:5px;display: inline-block;">
          <!-- <span>支付开始时间：</span> -->
          <!-- <el-date-picker
            style="width: 160px;margin-left: 10px;"
            v-model="payStartTime"
            align="right"
            type="datetime"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择开始时间"
          >
          </el-date-picker> -->
          <span>支付时间：</span>
          <el-date-picker
            v-model="payStartTime"
            type="datetimerange"
            unlink-panels
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
          ></el-date-picker>
          &nbsp;&nbsp;&nbsp;
        </div>
        <!-- <div style="margin:5px;display: inline-block;">
          <span>支付截止时间：</span>
          <el-date-picker
            style="width: 160px;margin-left: 10px;"
            v-model="payEndTime"
            align="right"
            type="datetime"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择截止时间"
          >
          </el-date-picker>
        </div> -->
        <div v-if="status == 14" style="margin:5px;display: inline-block;">
          <!-- <span>退款开始时间：</span> -->
          <!-- <el-date-picker
            style="width: 200px;margin-left: 10px;"
            v-model="refundStartTime"
            align="right"
            type="datetime"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择开始时间"
          >
          </el-date-picker> -->
          <span>退款时间：</span>
          <el-date-picker
            v-model="refundStartTime"
            type="datetimerange"
            unlink-panels
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
          ></el-date-picker>
          &nbsp;&nbsp;&nbsp;
        </div>
        <!-- <div v-if="status == 14" style="margin:5px;display: inline-block;">
          <span>退款结束时间：</span>
          <el-date-picker
            style="width: 200px;margin-left: 10px;"
            v-model="refundEndTime"
            align="right"
            type="datetime"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="选择结束时间"
          >
          </el-date-picker>
        </div> -->
        <el-button
          style="margin-left:15px;"
          size="mini"
          type="primary"
          icon="document"
          @click="phoneSelect"
          >查询
        </el-button>
        <el-button
          style="margin-left:15px;"
          size="mini"
          type="primary"
          icon="document"
          @click="cleans2"
          >重置</el-button
        >
        <el-button
          style="margin-left:15px;"
          size="mini"
          type="warning"
          icon="document"
          @click="exportList"
        >
          导出Excel
        </el-button>
        <!-- <div style="margin:5px 15px;display: inline-block;" v-if="shopName">
          <span style="font-size:18px;">店铺订单总金额：{{ shopMoney }}</span>
        </div> -->
      </div>
      <div style="color: orange;">
        *
        导出订单提示：导出订单前请进行时间或者状态等筛选，否则导出订单量过多易出现卡顿或系统崩溃
      </div>
      <el-table v-loading="tableDataLoading" :data="tableData2.list">
        <el-table-column
          fixed
          prop="orderId"
          label="编号"
          width="80"
        ></el-table-column>
        <el-table-column fixed prop="userName" label="下单用户">
          <template slot-scope="scope">
            <span
              style="color: #4f9dec;cursor: pointer;"
              @click="updates(scope.row.userId)"
            >
              {{ scope.row.userName ? scope.row.userName : "未绑定" }}
            </span>
          </template>
        </el-table-column>
        <el-table-column fixed prop="userName" label="用户头像">
          <template slot-scope="scope">
            <img
              v-if="scope.row.avatar"
              :src="scope.row.avatar"
              width="60"
              height="60"
            />
            <span v-else>
              <img src="../../assets/img/avatar.png" width="60" height="60" />
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="phone" label="手机号"></el-table-column>
        <el-table-column prop="shopTypeName" label="商铺类型"></el-table-column>
        <el-table-column prop="shopName" label="商铺信息" width="300">
          <template slot-scope="scope">
            <div>店铺名称：{{ scope.row.shopName }}</div>
            <div>店铺电话：{{ scope.row.shopPhone }}</div>
            <div>店铺地址：{{ scope.row.detailedAddress }}</div>
          </template>
        </el-table-column>
        <el-table-column prop="orderTypeExtra" label="订单类型">
          <template slot-scope="scope">
            <div>
              {{
                scope.row.orderTypeExtra == 1
                  ? "到店取餐"
                  : scope.row.orderTypeExtra == 2
                  ? "骑手配送"
                  : scope.row.orderTypeExtra == 3
                  ? "商家配送"
                  : ""
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="reservationFlag" label="配送状态">
          <template slot-scope="scope">
            <div>
              {{
                scope.row.reservationFlag == 1
                  ? "预约订单"
                  : scope.row.reservationFlag == 0
                  ? "即时订单"
                  : ""
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="expectDeliveryTime"
          label="预约送达时间"
        ></el-table-column>
        <el-table-column prop="address" label="配送信息" width="300">
          <template slot-scope="scope">
            <div v-if="scope.row.orderType == 2">
              <div>订餐人：{{ scope.row.address.userName }}</div>
              <div>订餐人电话：{{ scope.row.address.userPhone }}</div>
              <div>
                订餐地址：{{ scope.row.address.address }}({{
                  scope.row.address.addressDetail
                }})
              </div>
            </div>
            <div v-else style="text-align: center;width: 100%;">-</div>
          </template>
        </el-table-column>
        <el-table-column prop="riderNickName" label="骑手昵称" width="120">
          <template slot-scope="scope">
            <div
              style="color: #4f9dec;cursor: pointer;"
              @click="updates(scope.row.riderUserId)"
            >
              {{ scope.row.riderNickName }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="riderPhone"
          label="骑手电话"
          width="200"
        ></el-table-column>
        <el-table-column
          prop="stationName"
          label="骑手所在站点"
          width="200"
        ></el-table-column>
        <el-table-column prop="orderSequence" label="序号"></el-table-column>
        <el-table-column
          prop="transactionId"
          label="商户单号"
          width="160"
        ></el-table-column>
        <el-table-column prop="orderNumber" label="订单号" width="180">
          <template slot-scope="scope">
            <span style="cursor: pointer;" @click="orderSkip(scope.row)">{{
              scope.row.orderNumber
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="content" label="内容" width="300">
          <template slot-scope="scope">
            <div>
              <div
                v-for="(item, index) in scope.row.orderGoodsList"
                :key="index"
              >
                <span>{{ index + 1 }}. 商品名：{{ item.goodsName }},</span
                ><span>数量：{{ item.goodsNum }},</span
                ><span>规格：{{ item.skuMessage }}</span>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="goodsPriceZ" label="商品总价(元)" width="100">
        </el-table-column>
        <el-table-column
          prop="couponMoney"
          label="优惠券优惠金额(元)"
          width="100"
        >
          <template slot-scope="scope">
            <div>
              <div>
                <span
                  >{{
                    scope.row.couponMoney ? scope.row.couponMoney : "0"
                  }}元</span
                >
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="activityTitle"
          label="活动名称"
          width="160"
        ></el-table-column>
        <el-table-column
          prop="couponTypeRemark"
          label="优惠券类型"
          width="100"
        ></el-table-column>
        <el-table-column prop="" label="活动优惠金额(元)" width="100">
          <template slot-scope="scope">
            <div>
              <div>
                <span
                  >{{
                    scope.row.activityDiscountAmount
                      ? scope.row.activityDiscountAmount
                      : "0"
                  }}元</span
                >
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="packMoney"
          label="打包费(元/个 具体按照数量计算)"
          width="100"
        >
          <template slot-scope="scope">
            <div>{{ scope.row.packMoney }}元/个</div>
          </template>
        </el-table-column>
        <el-table-column prop="errandMoney" label="跑腿费(元)" width="100">
          <template slot-scope="scope">
            <div>
              {{ scope.row.orderType == 1 ? "0" : scope.row.errandMoney }}元
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="payMoney" label="支付金额(元)" width="100">
        </el-table-column>
        <el-table-column
          prop="errandMoneyIsShop"
          label="跑腿费说明"
          width="150"
        >
        </el-table-column>
        <el-table-column prop="remark" label="订单备注" width="150">
        </el-table-column>

        <el-table-column prop="createTime" label="创建时间" width="100"></el-table-column>
        <el-table-column prop="payTime" label="支付时间" width="100"></el-table-column>
        <el-table-column prop="receivingTime" label="接单时间" width="100"></el-table-column>
        <el-table-column prop="finishTime" label="订单完成时间" width="120"></el-table-column>
        <el-table-column prop="payType" label="支付方式" width="100">
          <template slot-scope="scope">
            <span v-if="scope.row.payType === 1">微信</span>

            <span v-if="scope.row.payType === 2">余额</span>
            <span v-if="scope.row.payType === 3">其他</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="orderCode"
          label="取餐号"
          width="110"
        ></el-table-column>
        <!-- <el-table-column
          fixed="right"
          prop="shopReceivingTime"
          label="首次接单时间"
        ></el-table-column> -->
        <el-table-column fixed="right" prop="status" label="状态" width="100">
          <template slot-scope="scope">
            <span style="color: #4f9dec;" v-if="scope.row.status === 0"
              >待结算</span
            >
            <span
              style="color: #4f9dec;"
              v-if="scope.row.status === 1 || scope.row.status === 2"
              >待支付</span
            >

            <span style="color: #4f9dec;" v-if="scope.row.status === 3">
              {{ scope.row.orderType == 1 ? "待取餐" : "待配送" }}
            </span>
            <span style="color: #4f9dec;" v-if="scope.row.status === 4"
              >已完成</span
            >
            <span style="color: #999;" v-if="scope.row.status === 5"
              >已取消</span
            >
            <span style="color: #999;" v-if="scope.row.status === 6"
              >制作中</span
            >
            <span style="color: #999;" v-if="scope.row.status === 7"
              >商家待接单</span
            >
            <span style="color: #999;" v-if="scope.row.status === 8"
              >商家已拒单</span
            >
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          prop="isPrint"
          label="小票打印状态"
          width="80"
        >
          <template slot-scope="scope">
            <span v-if="scope.row.isPrint === 0 || scope.row.isPrint === ''"
              >未打印</span
            >
            <span v-if="scope.row.isPrint === 1">已打印</span>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          prop="indentState"
          label="跑腿订单状态"
          width="100"
        >
          <template slot-scope="scope">
            <span style="color: #4f9dec;" v-if="scope.row.indentState === 0"
              >已下单未支付</span
            >
            <span style="color: #4f9dec;" v-if="scope.row.indentState === 1"
              >超时关闭未支付订单</span
            >
            <span style="color: #4f9dec;" v-if="scope.row.indentState === 2"
              >已支付</span
            >

            <span style="color: #4f9dec;" v-if="scope.row.indentState === 3">
              骑手已接单
            </span>
            <span style="color: #4f9dec;" v-if="scope.row.indentState === 4"
              >骑手已取货/购买</span
            >
            <span style="color: #999;" v-if="scope.row.indentState === 6"
              >订单已完成</span
            >
            <span style="color: #999;" v-if="scope.row.indentState === 8"
              >用户取消订单</span
            >
            <span style="color: #999;" v-if="scope.row.indentState === 9"
              >骑手取消订单</span
            >
            <span style="color: #999;" v-if="scope.row.indentState === 10"
              >平台下架订单
            </span>
            <span style="color: #999;" v-if="scope.row.indentState === 11"
              >外卖订单下单后生成跑腿订单，只参与群聊，无法被接单
            </span>
          </template>
        </el-table-column>
        <el-table-column
          prop="isRider"
          label="是否是转单"
          fixed="right"
          width="80"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.isRider == 1">是</div>
            <div v-if="scope.row.isRider == 2">否</div>
          </template>
        </el-table-column>
        <!-- <el-table-column
          fixed="right"
          prop="updateTime"
          label="完成时间"
        >
          <template slot-scope="scope">
              <div v-if="scope.row.status == 4">{{ scope.row.updateTime }}</div>
          </template>
        </el-table-column> -->
        <el-table-column fixed="right" prop="status" label="操作" width="250">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              v-if="scope.row.status === 6"
              :disabled="!isAuth('mission:qucan')"
              @click="wancheng(scope.row)"
              >制作已完成</el-button
            >
            <el-button
              size="mini"
              type="danger"
              :disabled="!isAuth('mission:tuikuan')"
              style="margin: 10px;"
              v-if="
                scope.row.status === 3 ||
                  scope.row.status === 6 ||
                  scope.row.status === 7
              "
              @click="tuikuan(scope.row)"
              >退款</el-button
            >
            <el-button
              size="mini"
              type="primary"
              v-if="scope.row.status === 3"
              :disabled="!isAuth('mission:qucan')"
              @click="wancheng(scope.row)"
              style="margin: 5px 0;"
              >{{ scope.row.orderType == 1 ? "餐品已完成" : "餐品已完成" }}
            </el-button>
            <el-button
              size="mini"
              type="primary"
              v-if="
                scope.row.status == 3 ||
                  scope.row.status === 4 ||
                  scope.row.status === 6
              "
              :disabled="!isAuth('mission:qucan')"
              @click="dayin(scope.row)"
              style="margin: 3px;"
              >打印小票</el-button
            >
            <el-button
              size="mini"
              type="primary"
              v-if="
                scope.row.status == 3 ||
                  scope.row.status === 4 ||
                  scope.row.status === 6
              "
              :disabled="!isAuth('mission:mingxi')"
              @click="detailClick(scope.row)"
              style="margin: 3px;"
              >打印小票明细</el-button
            >
            <el-button
              size="mini"
              type="primary"
              @click="complainDetails(scope.row)"
              style="margin: 3px;"
              >聊天内容</el-button
            >
            <el-button
              size="mini"
              type="primary"
              v-if="scope.row.status == 3"
              :disabled="!isAuth('orderCenterRun:zhuandan')"
              @click="zhuandan(scope.row)"
              style="margin: 3px;"
              >转单</el-button
            >
            <el-button
              size="mini"
              type="primary"
              v-if="scope.row.orderTypeExtra == 2"
              :disabled="!isAuth('mission:qishoumingxi')"
              @click="riderDetail(scope.row)"
              style="margin: 3px;"
              >骑手明细</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div
        style="color: #B94A48;font-size: 20px;margin-top: 10px;"
        v-if="totalMoney"
      >
        本页累计交易统计：{{ totalMoney }}元
      </div>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination
          @size-change="handleSizeChange3"
          @current-change="handleCurrentChange3"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="limit"
          :current-page="page"
          layout="total,sizes, prev, pager, next"
          :total="tableData2.totalCount"
        >
        </el-pagination>
      </div>
    </el-tab-pane>
    <!-- 导出限制 -->
    <el-dialog
      custom-class="export"
      :visible.sync="exportVisible"
      center
      :title="exportTitle"
      :close-on-click-modal="false"
    >
      <div class="con" v-show="exportFlag == 1">
        <img src="../../assets/img/error.png" alt="" />
        <span
          style="font-size:20px;color: #000;font-weight: 800;margin: 18px 0 5px;"
          >当前导出条数超过50000条，暂不支持导出</span
        >
        <span style="font-size:14px;color: #808080;"
          >（注：数据中的图片、附件只能以链接的形式导出）</span
        >
      </div>
      <div class="con" v-show="exportFlag == 2">
        <img class="gundong" src="../../assets/img/loading.png" alt="" />
        <span
          style="font-size:20px;color: #000;font-weight: 800;margin: 18px 0 5px;"
          >导出中...</span
        >
        <span style="font-size:14px;color: #808080;"
          >（注：请到个人导出记录查看并下载）</span
        >
      </div>
      <div class="con" v-show="exportFlag == 3">
        <img src="../../assets/img/success.png" alt="" />
        <span
          style="font-size:20px;color: #000;font-weight: 800;margin: 18px 0 5px;"
          >导出成功</span
        >
        <span style="font-size:14px;color: #808080;"
          >（注：请到个人导出记录查看并下载）</span
        >
      </div>
      <div class="con" v-show="exportFlag == 4">
        <img class="gundong" src="../../assets/img/loading.png" alt="" />
        <span
          style="font-size:20px;color: #000;font-weight: 800;margin: 18px 0 5px;"
          >版本迭代中，导出暂时无法使用</span
        >
      </div>
      <div class="btn">
        <el-button type="primary" @click="exportAffirm">确定</el-button>
      </div>
    </el-dialog>
    <!-- 任务拒绝弹框 -->
    <el-dialog title="任务拒绝" :visible.sync="dialogFormVisible7" center>
      <div style="margin-bottom: 10px;">
        <span style="width: 200px;display: inline-block;text-align: right;"
          >拒绝理由：</span
        >
        <el-input
          style="width:50%;"
          v-model="content"
          type="text"
          placeholder="请输入拒绝理由"
        ></el-input>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible7 = false">取 消</el-button>
        <el-button type="primary" @click="refuseto()">确 定</el-button>
      </div>
    </el-dialog>
    <!--    图片展示-->
    <el-dialog
      title="图片"
      :visible.sync="dialogVisible"
      width="35%"
      :before-close="handleClose"
    >
      <span
        v-if="imageUrl.length > 0"
        v-for="(item, index) in imageUrl"
        :key="index"
        style="width: 100px;
      height: 100px;display:inline-block;"
      >
        <!--      <el-image style = "width: 100px; height: 100px" :src = "item" :preview-src-list="imageUrl"></el-image>-->
        <img :src="item" alt="" style="width: 100px; height: 100px" />
      </span>
      <span v-else>暂无图片</span>
    </el-dialog>
    <!-- 聊天内容 -->
    <el-dialog title="聊天内容" :visible.sync="dialogFormVisible" center>
      <!-- <div style="margin:2% 0;display: inline-block;">
        <span>内容:</span>
        <el-input style="width: 150px;" @keydown.enter.native="select1" clearable placeholder="请输入聊天内容"
          v-model="content">
        </el-input>
      </div>
      <div style="display: inline-block;">
        <el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="select1">查询</el-button>
        <el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="cleans1">重置</el-button>
      </div> -->
      <el-table v-loading="tableDataLoading1" :data="userData.list">
        <el-table-column prop="chatContentId" label="编号" width="80">
        </el-table-column>
        <el-table-column prop="userName" label="用户昵称">
          <template slot-scope="scope">
            <div v-if="scope.row.shopId">
              {{ scope.row.shopName }}
            </div>
            <div
              v-else
              style="color: #4f9dec;cursor: pointer;"
              @click="details(scope.row)"
            >
              {{
                scope.row.userName ? scope.row.userName : scope.row.riderName
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="title" label="用户头像">
          <template slot-scope="scope">
            <!-- <div v-if="scope.row.avatar == null || scope.row.avatar == ''">
              暂无图片
            </div> -->
            <div>
              <el-popover placement="top-start" title="" trigger="hover">
                <img
                  style="width: 50px; height: 50px"
                  :src="
                    scope.row.shopCover
                      ? scope.row.shopCover
                      : scope.row.riderAvatar
                      ? scope.row.riderAvatar
                      : scope.row.userAvatar
                  "
                  alt=""
                  slot="reference"
                />
                <img
                  style="width: 200px; height: 200px"
                  :src="
                    scope.row.shopCover
                      ? scope.row.shopCover
                      : scope.row.riderAvatar
                      ? scope.row.riderAvatar
                      : scope.row.userAvatar
                  "
                  alt=""
                />
              </el-popover>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="content" label="信息内容" width="280">
          <template slot-scope="scope">
            <div v-if="scope.row.messageType == 1">{{ scope.row.content }}</div>
            <div v-if="scope.row.messageType == 2">
              <el-popover placement="top-start" title="" trigger="hover">
                <img
                  style="width: 50px; height: 50px"
                  :src="scope.row.content"
                  alt=""
                  slot="reference"
                />
                <img
                  style="width: 200px; height: 200px"
                  :src="scope.row.content"
                  alt=""
                />
              </el-popover>
            </div>
            <div v-if="scope.row.messageType == 3">
              <audio
                :src="scope.row.content"
                type="audio/wav"
                controls="controls"
              ></audio>
            </div>
            <div v-if="scope.row.messageType == 4">
              <el-popover placement="top-start" title="" trigger="hover">
                <img
                  style="width: 50px; height: 50px"
                  :src="
                    'https://mxys.chuanghai-tech.com/emoji/' + scope.row.content
                  "
                  alt=""
                  slot="reference"
                />
                <img
                  style="width: 200px; height: 200px"
                  :src="
                    'https://mxys.chuanghai-tech.com/emoji/' + scope.row.content
                  "
                  alt=""
                />
              </el-popover>
            </div>

            <!-- <div  v-if="scope.row.messageType==4">
              <el-popover placement="top-start" title="" trigger="hover">
                <img style="width: 50px; height: 50px" :src="'https://mxys.chuanghai-tech.com/emoji/'+scope.row.content" alt="" slot="reference">
                <img style="width: 200px; height: 200px" :src="'https://mxys.chuanghai-tech.com/emoji/'+scope.row.content" alt="">
              </el-popover>
            </div> -->
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="150">
        </el-table-column>

        <el-table-column
          prop="createTime"
          label="操作"
          width="100"
          fixed="right"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="danger"
              :disabled="!isAuth('userList:delete')"
              @click="deleteuser(scope.row)"
            >
              删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination
          @size-change="handleSizeChange1"
          @current-change="handleCurrentChange1"
          :page-sizes="[10, 20, 30, 50, 100]"
          :page-size="limit1"
          :current-page="page1"
          layout="total,sizes, prev, pager, next"
          :total="userData.totalCount"
        >
        </el-pagination>
      </div>
    </el-dialog>
    <!-- 骑手列表 -->
    <el-dialog title="骑手列表" :visible.sync="dialogFormVisibleP" center>
      <div style="margin:2% 0;display: inline-block;">
        <span>手机号:</span>
        <el-input
          style="width: 150px;"
          @keydown.enter.native="selectU"
          clearable
          placeholder="请输入手机号"
          v-model="phoneU"
        ></el-input>
      </div>
      &emsp;&emsp;
      <div style="margin:2% 0;display: inline-block;">
        <span>昵称:</span>
        <el-input
          style="width: 150px;"
          @keydown.enter.native="selectU"
          clearable
          placeholder="请输入昵称"
          v-model="campus"
        ></el-input>
      </div>
      &emsp;&emsp;
      <div style="display: inline-block;">
        <el-button
          style="margin-left:15px;"
          size="mini"
          type="primary"
          icon="document"
          @click="selectU"
          >查询
        </el-button>
        <el-button
          style="margin-left:15px;"
          size="mini"
          type="primary"
          icon="document"
          @click="cleansU"
          >重置
        </el-button>
      </div>
      <el-table v-loading="tableDataLoadingU" :data="userData.list">
        <el-table-column prop="userId" label="编号" width="80">
        </el-table-column>
        <el-table-column prop="nickName" label="用户昵称" width="120">
          <template slot-scope="scope">
            <span
              style="color: #4f9dec;cursor: pointer;"
              @click="updatesvideo(scope.row)"
              v-text="scope.row.nickName"
            ></span>
          </template>
        </el-table-column>
        <el-table-column prop="avatar" label="用户头像" width="100">
          <template slot-scope="scope">
            <img
              v-if="scope.row.avatar && scope.row.avatar != ''"
              :src="scope.row.avatar"
              width="40"
              height="40"
            />
            <span v-else>暂无图片</span>
          </template>
        </el-table-column>
        <el-table-column prop="phone" label="手机号"> </el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="180">
        </el-table-column>
        <el-table-column
          label="操作"
          prop="id"
          width="100"
          fixed="right"
          align="center"
        >
          <template slot-scope="scope">
            <el-button size="mini" type="primary" @click="userBtns(scope.row)"
              >确认
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination
          @size-change="handleSizeChangeU"
          @current-change="handleCurrentChangeU"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="limit1"
          :current-page="page1"
          layout="total,sizes, prev, pager, next,jumper"
          :total="userData.totalCount"
        >
        </el-pagination>
      </div>
    </el-dialog>

    <!-- 骑手明细 -->
    <el-dialog
      custom-class="riderDetail"
      title="本单骑手记录"
      :visible.sync="dialogFormVisibleQS"
      center
    >
      <el-table v-loading="tableDataLoadingQS" :data="riderData">
        <el-table-column type="index" label="序号" width="80">
        </el-table-column>
        <el-table-column prop="userName" label="骑手姓名"> </el-table-column>
        <el-table-column prop="userPhone" label="骑手手机号"> </el-table-column>
        <el-table-column prop="payTime" label="订单支付时间"></el-table-column>
        <el-table-column prop="receveTime" label="接单时间"></el-table-column>
        <el-table-column prop="stationName" label="所在站点"></el-table-column>
      </el-table>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination
          @size-change="handleSizeChangeQS"
          @current-change="handleCurrentChangeQS"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="limitQS"
          :current-page="pageQS"
          layout="total,sizes, prev, pager, next,jumper"
          :total="totalCountQS"
        >
        </el-pagination>
      </div>
    </el-dialog>

    <!-- 打印小票明细 -->
    <el-dialog
      custom-class="detail"
      :visible.sync="detailVisible"
      center
      title="小票明细"
      :close-on-click-modal="false"
    >
      <el-table v-loading="detailLoading" :data="detailData.list">
        <el-table-column fixed prop="id" label="打印编号"></el-table-column>
        <el-table-column
          fixed
          prop="orderStatus"
          label="打印时订单状态"
        ></el-table-column>
        <el-table-column
          fixed
          prop="isAppend"
          label="打印状态是否补打"
        ></el-table-column>
        <el-table-column prop="createTime" label="打印时间"> </el-table-column>
      </el-table>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination
          @size-change="detailSizeChange"
          @current-change="detailCurrentChange"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="detailLimit"
          :current-page="detailPage"
          layout="total,sizes, prev, pager, next"
          :total="detailData.totalCount"
        >
        </el-pagination>
      </div>
      <!-- <div class="btn">
        <el-button type="primary" @click="exportAffirm">确定</el-button>
      </div> -->
    </el-dialog>
  </el-tabs>
</template>

<script>
import dayjs from "dayjs";
export default {
  data() {
    return {
      dialogVisible: false,
      stationData: [], // 骑手站点数据
      stationName: "",
      spEarnings: [], // 商铺类型数据
      couponType: "", // 优惠券类型
      spEarningTypeId: "",
      imageUrl: [],
      limit: 10,
      page: 1,
      totalMoney: 0,
      phone: "",
      userName: "",
      orderNumber: "",
      transactionId: "", // 商户单号
      status: "",
      describes: "",
      token: "",
      taskNum: "",
      taskMoney: "",
      statesnum: [
        {
          label: "全部",
          value: 0
        },
        {
          label: "待接单",
          value: 2
        },
        {
          label: "制作中",
          value: 6
        },
        {
          label: "待送达",
          value: 3
        },
        {
          label: "已完成",
          value: 4
        },
        {
          label: "已下架",
          value: 5
        }
      ],
      taskstates: [
        {
          label: "全部",
          value: ""
        },
        {
          label: "待结算",
          value: 0
        },
        {
          label: "待支付",
          value: 1
        },
        {
          label: "已支付",
          value: 15
        },
        {
          label: "已退款",
          value: 14
        },
        {
          label: "商家待接单",
          value: 7
        },
        {
          label: "制作中",
          value: 6
        },
        {
          label: "待取餐/待配送", //待取餐、派送中
          value: 3
        },
        {
          label: "已完成",
          value: 4
        },
        {
          label: "已取消",
          value: 5
        },
        {
          label: "商家已拒单",
          value: 8
        }
      ],
      orderType: "",
      orderTypes: [
        {
          label: "全部",
          value: ""
        },
        {
          label: "到店取餐",
          value: 1
        },
        {
          label: "骑手配送",
          value: 2
        },
        {
          label: "商家配送",
          value: 3
        }
      ],
      reservationFlag: "",
      reservationFlags: [
        {
          label: "全部",
          value: ""
        },
        {
          label: "即时订单",
          value: 0
        },
        {
          label: "预约订单",
          value: 1
        }
      ],
      indentStatus: "",
      indentStatuss: [
        {
          label: "全部",
          value: ""
        },
        {
          label: "已下单未支付",
          value: 0
        },
        {
          label: "超时关闭未支付订单",
          value: 1
        },
        {
          label: "已支付",
          value: 2
        },
        {
          label: "骑手已接单",
          value: 3
        },
        {
          label: "骑手已取货/购买",
          value: 4
        },
        {
          label: "订单已完成",
          value: 6
        },
        {
          label: "用户取消订单",
          value: 8
        },
        {
          label: "骑手取消订单",
          value: 9
        },
        {
          label: "骑手取消订单",
          value: 10
        },
        {
          label: "外卖订单下单后生成跑腿订单，只参与群聊，无法被接单",
          value: 11
        }
      ],
      shopId: "",
      shopName: "",
      shopList: "",
      sort: 10,
      id: "",
      btnChangeEnable: true,
      helpTakeId: "",
      helpMaintainId: "",
      content: "",
      classifyIcon: "",
      classifyId: "",
      classifyUrl: "",
      classifyName: "",
      classifyDeatilsName: "",
      formLabelWidth: "200px",
      activeName: "first",
      tableDataLoading: false,
      tableDataLoading1: false,
      dialogFormVisible: false,
      dialogFormVisible1: false,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      dialogFormVisible4: false,
      dialogFormVisible5: false,
      dialogFormVisible6: false,
      dialogFormVisible7: false,
      dialogFormVisible8: false,

      tableData: [],
      tableData2: {},
      shopMoney: "", // 店铺总交易
      form: {
        id: "",
        classifyName: "",
        classifyUrl: "",
        classifyIcon: "",
        describes: ""
      },
      form2: {
        id: "",
        classifyDeatilsName: "",
        classifyUrl: "",
        classifyIcon: "",
        taskNum: "",
        taskMoney: ""
      },
      protectjieData: [],
      protectpaiData: [],
      helpTaskData: [],
      safeguardData: [],
      classifyData: [],
      checkBoxData: [], //多选框选择的值
      checkBoxData2: [], //多选框选择的值
      chatConversationId: "",
      userData: {},
      limit1: 10,
      page1: 1,
      riderPhone: "",
      // ····
      userData: {},
      phoneU: "",
      campus: "",
      ordersId: "",
      limit1: 10,
      page1: 1,
      dialogFormVisibleP: false,
      tableDataLoadingU: false,
      // info: {
      // 	stockDate: this.getNowTime(), //日期
      // },
      // info2: {
      // 	stockDate2: this.getNowTime2(), //日期
      // },
      // info3: {
      // 	stockDate3: this.getNowTime3(), //日期
      // },
      startTime: "",
      endTime: "",
      payStartTime: [
          dayjs()
            .subtract(6, "day").startOf('day')
            .format("YYYY-MM-DD HH:mm:ss"),
          dayjs().endOf('day').format("YYYY-MM-DD HH:mm:ss")
        ], //支付开始时间
      payEndTime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
      refundStartTime: "",
      refundEndTime: "",

      // 导出限制
      exportTitle: "导出错误",
      exportVisible: false,
      exportFlag: 1, //1 超出限制  2导出中

      // 打印小票明细
      detailVisible: false,
      detailLoading: false,
      detailData: {},
      detailId: "",
      detailLimit: 10,
      detailPage: 1,

      // 骑手明细
      dialogFormVisibleQS: false,
      tableDataLoadingQS: false,
      riderData: [],
      orderIdQS: "",
      pageQS: 1,
      limitQS: 10,
      totalCountQS: 8
    };
  },
  methods: {
    // 站点下拉框
    stationList() {
      this.$http({
        url: this.$http.adornUrl("admin/riderStation/stationList"),
        method: "get",
        params: this.$http.adornParams({})
      }).then(({ data }) => {
        console.log(data, "站点下拉框");
        this.stationData = data.data;
      });
    },
    shopTypeList() {
      this.$http({
        url: this.$http.adornUrl("admin/shoptype/selectShopTypeList"),
        method: "get",
        params: this.$http.adornParams({
          page: 1,
          limit: 1000
        })
      }).then(({ data }) => {
        console.log(data, "商铺类型");

        let returnData = data.data.list;
        this.spEarnings = returnData;
      });
    },
    // 订单跳转到短信界面
    orderSkip(row) {
      console.log(row.indentId);
      console.log(row.orderTypeExtra, "2 骑手配送，3 商家配送");
      if (row.indentId) {
        // 2 骑手配送
        if (row.orderTypeExtra == 2) {
          this.$router.push({
            path: "/duanxinlistRun",
            query: {
              indentId: row.indentId
            }
          });
        }
        // 3 商家配送
        else if (row.orderTypeExtra == 3) {
          this.$router.push({
            path: "/shopduanxinlistRun",
            query: {
              indentId: row.indentId
            }
          });
        } else {
          // 到店取餐无短信记录
          this.$message({
            message: "无短信记录",
            type: "warning",
            duration: 1500
          });
        }
      } else {
        // 到店取餐无短信记录
        this.$message({
          message: "无短信记录",
          type: "warning",
          duration: 1500
        });
      }
    },
    // 详情跳转
    updates(userId) {
      this.$router.push({
        path: "/userDetail",
        query: {
          userId: userId
        }
      });
    },
    // 详情跳转
    details(row) {
      if (!row.shopId) {
      }
      let userId = row.userId ? row.userId : row.riderId;
      this.$router.push({
        path: "/userDetail",
        query: {
          userId: userId
        }
      });
    },
    // 图标上传一级分类
    handleAvatarSuccess(file) {
      this.classifyIcon = file.data;
    },
    // 图标上传一级分类编辑
    handleAvatarSuccess2(file) {
      this.form.classifyIcon = file.data;
    },
    // 多选
    changeFun(val) {
      this.checkBoxData = val;
    },
    // 多选
    changeFun2(val) {
      this.checkBoxData2 = val;
    },
    handleSizeChange(val) {
      this.limit = val;
      this.dataSelect();
    },
    handleCurrentChange(val) {
      this.page = val;
      this.dataSelect();
    },
    handleSizeChange2(val) {
      this.limit = val;
      this.classifySelect();
    },
    handleCurrentChange2(val) {
      this.page = val;
      this.classifySelect();
    },
    handleSizeChange3(val) {
      this.limit = val;
      this.taskdataSelect();
    },
    handleCurrentChange3(val) {
      this.page = val;
      this.taskdataSelect();
    },
    handleSizeChange1(val) {
      this.limit1 = val;
      this.neirongSelect(this.chatConversationId);
    },
    handleCurrentChange1(val) {
      this.page1 = val;
      this.neirongSelect(this.chatConversationId);
    },
    // tabs切换
    handleClick(tab, event) {
      if (tab._props.label == "订单管理") {
        this.page = 1;
        this.limit = 10;
        this.taskdataSelect();
      }
    },
    // 下架
    soldClick(row) {
      this.$confirm(`确定要下架此任务?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl(
              `help/outHelpOrder/?helpOrderId=${row.id}`
            ),
            method: "post",
            data: this.$http.adornData({})
          }).then(({ data }) => {
            if (data.code == 0) {
              this.$message({
                message: "操作成功",
                type: "success",
                duration: 1500,
                onClose: () => {
                  this.dataSelect();
                }
              });
            } else {
              this.$message({
                message: data.msg,
                type: "error",
                duration: 1500,
                onClose: () => {
                  this.dataSelect();
                }
              });
            }
          });
        })
        .catch(() => {});
    },
    //查看照片
    refund(e) {
      this.imageUrl = [];
      if (e.image != null) {
        let img = e.image.split(",");
        if (img.length != 0) {
          this.imageUrl = img;
        }
      }
      this.dialogVisible = true;
    },
    handleClose(done) {
      // this.$confirm('确认关闭？')
      //   .then(_ => {
      done();
      // })
      // .catch(_ => {});
    },
    // 添加一级分类弹框
    classifyStair() {
      this.dialogFormVisible = true;
    },
    // 添加一级分类确定
    StairNoticeTo() {
      if (this.classifyName == "") {
        this.$notify({
          title: "提示",
          duration: 1800,
          message: "请输入分类名称",
          type: "warning"
        });
        return;
      }
      // if (this.classifyUrl == '') {
      //     this.$notify({
      //         title: '提示',
      //         duration: 1800,
      //         message: '请输入分类链接',
      //         type: 'warning'
      //     });
      //     return
      // }
      if (this.describes == "") {
        this.$notify({
          title: "提示",
          duration: 1800,
          message: "请输入分类描述",
          type: "warning"
        });
        return;
      }
      if (this.classifyIcon == "") {
        this.$notify({
          title: "提示",
          duration: 1800,
          message: "请上传分类图标",
          type: "warning"
        });
        return;
      }
      this.$http({
        url: this.$http.adornUrl("helpClassify/saveHelpClassify"),
        method: "post",
        data: this.$http.adornData({
          classifyName: this.classifyName,
          state: this.state,
          sort: this.sort,
          classifyIcon: this.classifyIcon,
          classifyUrl: this.classifyUrl,
          describes: this.describes
        })
      }).then(({ data }) => {
        this.dialogFormVisible = false;
        this.$message({
          message: "一级分类添加成功",
          type: "success",
          duration: 1500,
          onClose: () => {
            this.classifyUrl = "";
            this.classifyName = "";
            this.classifyIcon = "";
            this.describes = "";
            this.classifySelect();
          }
        });
      });
    },
    // 修改一级分类
    compile(index, rows) {
      this.dialogFormVisible2 = true;
      this.form.id = rows.id;
      this.form.classifyName = rows.classifyName;
      this.form.classifyUrl = rows.classifyUrl;
      this.form.classifyIcon = rows.classifyIcon;
      this.form.describes = rows.describes;
    },
    // 修改一级分类确定
    CompileNoticeTo() {
      if (this.form.classifyName == "") {
        this.$notify({
          title: "提示",
          duration: 1800,
          message: "请输入分类名称",
          type: "warning"
        });
        return;
      }
      if (this.form.describes == "") {
        this.$notify({
          title: "提示",
          duration: 1800,
          message: "请输入分类描述",
          type: "warning"
        });
        return;
      }
      if (this.form.classifyIcon == "") {
        this.$notify({
          title: "提示",
          duration: 1800,
          message: "请上传分类图标",
          type: "warning"
        });
        return;
      }
      this.$http({
        url: this.$http.adornUrl("helpClassify/updateHelpClassify"),
        method: "post",
        data: this.$http.adornData({
          id: this.form.id,
          classifyName: this.form.classifyName,
          classifyUrl: this.form.classifyUrl,
          classifyIcon: this.form.classifyIcon,
          describes: this.form.describes
        })
      }).then(({ data }) => {
        this.dialogFormVisible2 = false;
        this.$message({
          message: "操作成功",
          type: "success",
          duration: 1500,
          onClose: () => {
            this.classifySelect();
          }
        });
      });
    },
    //删除一级
    deleteStair(row) {
      let delid = row.id;
      this.$confirm(`确定删除此条信息?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl(
              `helpClassify/deleteClassifyById/?id=${delid}`
            ),
            method: "post",
            data: this.$http.adornData({})
          }).then(({ data }) => {
            this.$message({
              message: "删除成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.name = "";
                this.classifySelect();
              }
            });
          });
        })
        .catch(() => {});
    },
    // 手机号搜索
    phoneSelect() {
      this.page = 1;
      this.limit = 10;
      this.taskdataSelect();
    },
    // 重置
    cleans2() {
      // const data=this.$route.query;
      // if(data.refund){
      //     delete this.$router.push({query:{}}) // 删除页面参数
      // }

      this.page = 1;
      this.phone = "";
      this.riderPhone = "";
      this.userName = "";
      this.orderNumber = "";
      this.transactionId = "";
      this.status = "";
      this.shopName = "";
      this.reservationFlag = "";
      this.indentStatus = "";
      this.orderType = "";
      this.startTime = "";
      this.endTime = "";
      this.refundStartTime = "";
      this.refundEndTime = "";
      this.payStartTime = [
          dayjs()
            .subtract(6, "day").startOf('day')
            .format("YYYY-MM-DD HH:mm:ss"),
          dayjs().endOf('day').format("YYYY-MM-DD HH:mm:ss")
        ];
      this.payEndTime = dayjs().format("YYYY-MM-DD");
      this.stationName = "";
      this.spEarningTypeId = "";
      this.couponType = "";
      this.taskdataSelect();
    },
    // 查询
    select() {
      this.page = 1;
      this.limit = 10;
      this.dataSelect();
    },
    // 重置
    cleans() {
      this.phone = "";
      this.status = 0;
      this.content = "";
      this.dataSelect();
    },
    // select选择事件
    animeDat(state) {
      this.dataSelect();
    },
    animeDat2(state) {
      // this.$router.replace({ refund: '' })
      this.page = 1;
      this.taskdataSelect();
    },
    // 获取派单数据列表
    dataSelect() {
      this.tableDataLoading = true;
      this.$http({
        url: this.$http.adornUrl("help/selectStatusHelpOrder"),
        method: "get",
        params: this.$http.adornParams({
          page: this.page,
          limit: this.limit,
          phone: this.phone,
          status: this.status,
          content: this.content
        })
      }).then(({ data }) => {
        this.tableDataLoading = false;
        let returnData = data.data;
        this.tableData = returnData;
      });
    },
    // 获取数据列表
    taskdataSelect() {
      console.log(this.refundStartTime);

      this.totalMoney = 0;
      this.tableDataLoading = true;
      this.$http({
        url: this.$http.adornUrl("admin/order/selectAllOrderAdmin"),
        method: "get",
        params: this.$http.adornParams({
          page: this.page,
          limit: this.limit,
          phone: this.phone,
          userName: this.userName,
          orderNumber: this.orderNumber,
          transactionId: this.transactionId,
          status: this.status,
          shopName: this.shopName,
          orderType: this.orderType,
          reservationFlag: this.reservationFlag,
          indentStatus: this.indentStatus,
          riderPhone: this.riderPhone,
          startTime: this.startTime ? this.startTime[0] : "",
          endTime: this.startTime ? this.startTime[1] : "",
          refundStartTime: this.refundStartTime ? this.refundStartTime[0] : "",
          refundEndTime: this.refundStartTime ? this.refundStartTime[1] : "",
          payStartTime: this.payStartTime ? this.payStartTime[0] : "",
          payEndTime: this.payStartTime ? this.payStartTime[1] : "",
          riderStationId: this.stationName,
          shopTypeId: this.spEarningTypeId,
          couponType: this.couponType
        })
      }).then(({ data }) => {
        console.log(data, "订单中心");
        if (data.code == 0) {
          this.tableDataLoading = false;
          let returnData = data.data;
          this.tableData2 = returnData;
          console.log(this.tableData2, "hhhhh");
          for (var i in this.tableData2.list) {
            this.tableData2.list[i].goodsPriceZ = 0;
            this.totalMoney =
              Number(this.totalMoney) +
              Number(this.tableData2.list[i].payMoney);
            if (this.tableData2.list[i].address) {
              this.tableData2.list[i].address = JSON.parse(
                this.tableData2.list[i].address
              );
            }

            for (var j in this.tableData2.list[i].orderGoodsList) {
              this.tableData2.list[i].orderGoodsList[j].goodsPriceZ =
                this.tableData2.list[i].orderGoodsList[j].goodsPrice *
                this.tableData2.list[i].orderGoodsList[j].goodsNum;

              this.tableData2.list[i].goodsPriceZ =
                this.tableData2.list[i].goodsPriceZ +
                this.tableData2.list[i].orderGoodsList[j].goodsPriceZ;
            }
          }
          this.totalMoney = this.totalMoney.toFixed(2);
          console.log(data.data.totalCount, "此时间段暂无数据");
          if (!data.data.totalCount) {
            this.$message({
              message: "此时间段暂无数据",
              type: "success",
              duration: 1500,
              onClose: () => {}
            });
          }
        } else {
          this.$message({
            message: data.msg,
            type: "error",
            duration: 1500,
            onClose: () => {}
          });
        }
      });
      // this.$http({
      //   url: this.$http.adornUrl("admin/order/selectAllOrderTotalPrice"),
      //   method: "get",
      //   params: this.$http.adornParams({
      //     page: this.page,
      //     limit: this.limit,
      //     phone: this.phone,
      //     userName: this.userName,
      //     orderNumber: this.orderNumber,
      //     status: this.status,
      //     shopName: this.shopName,
      //     orderType: this.orderType,
      //     reservationFlag: this.reservationFlag,
      //     indentStatus: this.indentStatus,
      //     riderPhone: this.riderPhone,
      //     startTime: this.startTime,
      //     endTime: this.endTime,
      //     payStartTime: this.payStartTime,
      //     payEndTime: this.payEndTime,
      //     riderStationId: this.stationName,
      //     shopTypeId:this.spEarningTypeId,
      //     couponType:this.couponType
      //   })
      // }).then(({ data }) => {
      //   this.shopMoney=data.data
      //   console.log(data,'店铺总交易金额');
      // })
    },
    // 商铺列表
    classifySelect() {
      this.tableDataLoading = true;
      this.$http({
        url: this.$http.adornUrl("admin/goods/selectAllShopList"),
        method: "get",
        params: this.$http.adornParams({})
      }).then(({ data }) => {
        this.tableDataLoading = false;
        let returnData = data.data;
        this.shopList = returnData;
      });
    },
    // 餐品完成
    wancheng(row) {
      if (row.status == 3) {
        var status1 = 4;
      }
      if (row.status == 6) {
        var status1 = 3;
      }
      this.$http({
        url: this.$http.adornUrl("admin/order/updateOrder"),
        method: "post",
        data: this.$http.adornData({
          status: status1,
          orderId: row.orderId,
          orderNumber: row.orderNumber
        })
      }).then(({ data }) => {
        if (data.code == 0) {
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
            onClose: () => {
              this.taskdataSelect();
            }
          });
        } else {
          this.$message({
            message: data.msg,
            type: "warning",
            duration: 1500,
            onClose: () => {}
          });
        }
      });
    },
    // 退款
    tuikuan(row) {
      console.log("退款");
      this.$confirm(`确定要退款?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          console.log("取定");
          this.$http({
            url: this.$http.adornUrl("admin/order/adminCancelOrder"),
            method: "post",
            params: this.$http.adornParams({
              orderId: row.orderId
            })
          }).then(({ data }) => {
            if (data.code == 0) {
              this.$message({
                message: "操作成功",
                type: "success",
                duration: 1500,
                onClose: () => {
                  this.taskdataSelect();
                }
              });
            } else {
              this.$message({
                message: data.msg,
                type: "error",
                duration: 1500,
                onClose: () => {}
              });
            }
          });
        })
        .catch(() => {
          console.log("取消");
        });
    },
    // 打印小票
    dayin(row) {
      this.$http({
        url: this.$http.adornUrl("admin/order/print"),
        method: "post",
        params: this.$http.adornParams({
          orderId: row.orderId,
          isAppend: 1 // 1 默认补打
        })
      }).then(({ data }) => {
        if (data.code == 0) {
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
            onClose: () => {
              this.taskdataSelect();
            }
          });
        } else {
          this.$message({
            message: data.msg,
            type: "warning",
            duration: 1500,
            onClose: () => {}
          });
        }
      });
    },
    // 聊天内容
    complainDetails(row) {
      this.chatConversationId = row.orderId;
      this.neirongSelect(this.chatConversationId);
      this.dialogFormVisible = true;
    },
    select1() {
      this.page1 = 1;
      this.neirongSelect(this.chatConversationId);
    },
    // 重置
    cleans1() {
      this.content = "";
      this.page1 = 1;
      this.neirongSelect(this.chatConversationId);
    },
    // 获取聊天内容列表
    neirongSelect(chatConversationId) {
      this.tableDataLoading1 = true;
      this.$http({
        url: this.$http.adornUrl("shop/ordersChat/selectGameChatDetails"),
        method: "get",
        params: this.$http.adornParams({
          page: this.page1,
          limit: this.limit1,
          ordersId: this.chatConversationId,
          content: this.content
        })
      }).then(({ data }) => {
        this.tableDataLoading1 = false;
        let returnData = data.data;
        this.userData = returnData;
      });
    },
    //删除聊天
    deleteuser(row) {
      // let delid = row.userId
      this.$confirm(`确定删除此条信息?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl(
            "shop/ordersChat/deleteOrdersChat?chatContentId=" +
              row.chatContentId
          ),
          method: "post",
          params: this.$http.adornParams({})
        }).then(({ data }) => {
          if (data.code == 0) {
            this.$message({
              message: "删除成功",
              type: "success",
              duration: 1500,
              onClose: () => {
                this.neirongSelect(this.chatConversationId);
              }
            });
          } else {
            this.$message({
              message: data.msg,
              type: "warning",
              duration: 1500,
              onClose: () => {}
            });
          }
        });
      });
    },
    handleSizeChangeU(val) {
      this.limit1 = val;
      this.dataSelectUser()();
    },
    handleCurrentChangeU(val) {
      this.page1 = val;
      this.dataSelectUser();
    },
    // 转单弹框
    zhuandan(row) {
      this.ordersId = row.indentId;
      this.page1 = 1;
      this.phoneU = "";
      this.campus = "";
      this.dataSelectUser();
      this.dialogFormVisibleP = true;
    },
    // 确认选择
    userBtns(row) {
      this.$http({
        url: this.$http.adornUrl("admin/tbindent/transferOfOrder"),
        method: "post",
        params: this.$http.adornParams({
          riderUserId: row.userId,
          indentId: this.ordersId
        })
      }).then(({ data }) => {
        if (data.code == 0) {
          this.$message({
            message: "操作成功",
            type: "success",
            duration: 1500,
            onClose: () => {
              this.taskdataSelect();
              this.dialogFormVisibleP = false;
            }
          });
        } else {
          if (data.msg == "订单状态发生变更，请刷新后重试！") {
            this.$message({
              message: "当前订单状态不支持转单",
              type: "warning",
              duration: 1500,
              onClose: () => {}
            });
          } else {
            this.$message({
              message: data.msg,
              type: "warning",
              duration: 1500,
              onClose: () => {}
            });
          }
        }
      });
    },
    // 获取数据列表
    dataSelectUser() {
      this.tableDataLoadingU = true;
      this.$http({
        url: this.$http.adornUrl("user/selectUserList"),
        method: "get",
        params: this.$http.adornParams({
          page: this.page1,
          limit: this.limit1,
          // 'member': this.member,
          phone: this.phoneU,
          nickName: this.campus,
          type: 2,
          isVip: "",
          platform: "",
          shopAdminFlag: this.shopAdminFlag
        })
      }).then(({ data }) => {
        this.tableDataLoadingU = false;
        let returnData = data.data;
        this.userData = returnData;
      });
    },
    // 查询
    selectU() {
      this.page = 1;
      this.dataSelectUser();
    },
    // 重置
    cleansU() {
      this.page1 = 1;
      this.campus = "";
      this.phoneU = "";
      this.dataSelectUser();
    },

    // 打印小票明细  (-------------------------------------------------------)
    detailClick(row) {
      this.detailVisible = true;
      this.detailLoading = true;
      this.detailId = row ? row.orderId : this.detailId;
      this.$http({
        url: this.$http.adornUrl("admin/printInfo/getOrderPrintDetailList"),
        method: "get",
        params: this.$http.adornParams({
          page: this.detailPage,
          limit: this.detailLimit,
          orderId: this.detailId
        })
      }).then(({ data }) => {
        console.log(data, "打印小票明细");
        this.detailLoading = false;
        let returnData = data.data;
        this.detailData = returnData;
      });
    },
    detailSizeChange(val) {
      this.detailLimit = val;
      this.detailClick();
    },
    detailCurrentChange(val) {
      this.detailPage = val;
      this.detailClick();
    },

    // 骑手明细  (-------------------------------------------------------)
    riderListData() {
      this.dialogFormVisibleQS = true;
      this.$http({
        url: this.$http.adornUrl("admin/transferRecord/queryTransferRecords"),
        method: "get",
        params: this.$http.adornParams({
          page: this.pageQS,
          limit: this.limitQS,
          orderId: this.orderIdQS
        })
      }).then(({ data }) => {
        console.log(data, "骑手明细");
        this.tableDataLoadingQS = false;
        this.riderData = data.data.list;
        this.totalCountQS = data.data.totalCount;
      });
    },
    riderDetail(row) {
      this.orderIdQS = row.orderId;
      this.riderListData();
    },
    handleSizeChangeQS(val) {
      this.limitQS = val;
      this.riderListData();
    },
    handleCurrentChangeQS(val) {
      this.pageQS = val;
      this.riderListData();
    },

    // 导出
    // exportBtn() {
    //   var userId = this.$cookie.get('userId')
    //   this.$http({
    //     url: this.$http.adornUrl("admin/export/excelOrder"),
    //     method: "get",
    //     // responseType: "blob",
    //     params: this.$http.adornParams({
    //       // 'page': page,
    //       // 'size': this.size,
    //       userId:userId,
    //       phone: this.phone,
    //       userName: this.userName,
    //       orderNumber: this.orderNumber,
    //       status: this.status,
    //       shopName: this.shopName,
    //       orderSequence: this.orderSequence,
    //       orderType: this.orderType,
    //       reservationFlag: this.reservationFlag,
    //       indentStatus: this.indentStatus,
    //       riderPhone: this.riderPhone,
    //       startTime: this.startTime,
    //       endTime: this.endTime,
    //       payStartTime: this.payStartTime,
    //       payEndTime: this.payEndTime
    //     })
    //   }).then(({ data }) => {
    //     console.log(data, "导出");
    //     // let blob = new Blob([data], {
    //     //   type:
    //     //     "application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    //     // });
    //     // if (window.navigator.msSaveOrOpenBlob) {
    //     //   navigator.msSaveBlob(blob);
    //     // } else {
    //     //   let url = window.URL.createObjectURL(blob);
    //     //   let elink = document.createElement("a");
    //     //   elink.download = "订单列表.xlsx";
    //     //   elink.style.display = "none";
    //     //   elink.href = url;
    //     //   document.body.appendChild(elink);
    //     //   elink.click();
    //     //   document.body.removeChild(elink);
    //     // }
    //   });
    // },
    exportList() {
      console.log(this.tableData2.totalCount, "导出条数");
      this.exportTitle = "导出";
      // this.exportFlag = 4;
      this.exportVisible = true;
      if (this.tableData2.totalCount >= 50000) {
        this.exportTitle = "导出错误";
        this.exportFlag = 1;
      } else {
        this.exportTitle = "导出";
        this.exportFlag = 2;
        this.exportVisible = true;
        var userId = this.$cookie.get("userId");
        this.$http({
          url: this.$http.adornUrl("admin/export/excelOrder"),
          method: "get",
          // responseType: "blob",
          params: this.$http.adornParams({
            // 'page': page,
            // 'size': this.size,
            userId: userId,
            phone: this.phone,
            userName: this.userName,
            orderNumber: this.orderNumber,
            transactionId: this.transactionId,
            status: this.status,
            shopName: this.shopName,
            orderSequence: this.orderSequence,
            orderType: this.orderType,
            reservationFlag: this.reservationFlag,
            indentStatus: this.indentStatus,
            riderPhone: this.riderPhone,
            startTime: this.startTime ? this.startTime[0] : "",
            endTime: this.startTime ? this.startTime[1] : "",
            payStartTime: this.payStartTime ? this.payStartTime[0] : "",
            payEndTime: this.payStartTime ? this.payStartTime[1] : "",
            refundStartTime: this.refundStartTime
              ? this.refundStartTime[0]
              : "",
            refundEndTime: this.refundStartTime ? this.refundStartTime[1] : "",
            riderStationId: this.stationName,
            shopTypeId: this.spEarningTypeId,
            couponType: this.couponType
          })
        }).then(({ data }) => {
          console.log(data, "导出");
          if (data.code == 0) {
            this.exportTitle = "导出成功";
            this.exportFlag = 3;
          }
          // let blob = new Blob([data], {
          //   type:
          //     "application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
          // });
          // if (window.navigator.msSaveOrOpenBlob) {
          //   navigator.msSaveBlob(blob);
          // } else {
          //   let url = window.URL.createObjectURL(blob);
          //   let elink = document.createElement("a");
          //   elink.download = "订单列表.xlsx";
          //   elink.style.display = "none";
          //   elink.href = url;
          //   document.body.appendChild(elink);
          //   elink.click();
          //   document.body.removeChild(elink);
          // }
        });
      }
    },
    exportAffirm() {
      this.exportVisible = false;
    },
    getPath() {
      console.log("监控路由获取参数", this.$route.params);
      if (this.$route.params.type == "platform") {
        console.log(this.$route.params, "平台-钩子中获取参数");
        if (this.$route.params.refund == 14) {
          this.status = this.$route.params.refund;
          this.payStartTime = "";
          // this.payEndTime = "";
          this.refundStartTime = [this.$route.params.dayId + " " + "00:00:00",this.$route.params.dayId + " " + "23:59:59"];
          // this.refundEndTime = this.$route.params.dayId + " " + "23:59:59";
          this.taskdataSelect();
        } else if (this.$route.params.refund == 15) {
          this.status = this.$route.params.refund;
          this.payStartTime = [this.$route.params.dayId + " " + "00:00:00",this.$route.params.dayId + " " + "23:59:59"];
          // this.payEndTime = this.$route.params.dayId + " " + "23:59:59";
          this.refundStartTime = "";
          // this.refundEndTime = "";
          this.taskdataSelect();
        } else {
          this.status = "";
          this.refundStartTime = "";
          // this.refundEndTime = "";
          this.payStartTime = "";
          // this.payEndTime = "";
          this.taskdataSelect();
        }
      } else if (this.$route.params.type == "shop") {
        if (this.$route.params.refund == 14) {
          console.log(this.$route.params, "商家-钩子中获取参数");
          this.status = this.$route.params.refund;
          this.payStartTime = "";
          // this.payEndTime = "";
          this.shopName = this.$route.params.shopName;
          this.refundStartTime = [this.$route.params.dayId + " " + "00:00:00",this.$route.params.dayId + " " + "23:59:59"];
          // this.refundEndTime = this.$route.params.dayId + " " + "23:59:59";
          this.taskdataSelect();
        }
      } else {
        this.status = "";
        this.shopName = "";
        this.refundStartTime = "";
        // this.refundEndTime = "";
        this.payStartTime = [
          dayjs()
            .subtract(6, "day").startOf('day')
            .format("YYYY-MM-DD HH:mm:ss"),
          dayjs().endOf('day').format("YYYY-MM-DD HH:mm:ss")
        ];
        // this.payEndTime = dayjs().format("YYYY-MM-DD");
        // this.taskdataSelect();
      }
    }
  },
  watch: {
    $route: "getPath"
  },
  beforeMount() {},

  mounted() {
    // this.classifySelect()
    // this.taskdataSelect();
    this.stationList();
    this.shopTypeList();
    // let endTime=dayjs().format('YYYY-MM-DD')
    // let startTime=dayjs().subtract(6, 'day').format('YYYY-MM-DD')
    // console.log(startTime,endTime);

    this.$nextTick(() => {
      if (this.$route.params.type == "platform") {
        console.log(this.$route.params, "平台-钩子中获取参数");
        if (this.$route.params.refund == 14) {
          this.status = this.$route.params.refund;
          this.payStartTime = "";
          // this.payEndTime = "";
          this.refundStartTime = [this.$route.params.dayId + " " + "00:00:00",this.$route.params.dayId + " " + "23:59:59"];
          // this.refundStartTime = this.$route.params.dayId + " " + "00:00:00";
          // this.refundEndTime = this.$route.params.dayId + " " + "23:59:59";
          this.taskdataSelect();
        } else if (this.$route.params.refund == 15) {
          this.status = this.$route.params.refund;
          this.payStartTime = [this.$route.params.dayId + " " + "00:00:00",this.$route.params.dayId + " " + "23:59:59"];
          // this.payStartTime = this.$route.params.dayId + " " + "00:00:00";
          // this.payEndTime = this.$route.params.dayId + " " + "23:59:59";
          this.refundStartTime = "";
          // this.refundEndTime = "";
          this.taskdataSelect();
        } else {
          this.status = "";
          this.refundStartTime = "";
          // this.refundEndTime = "";
          this.payStartTime = "";
          // this.payEndTime = "";
          this.taskdataSelect();
        }
      } else if (this.$route.params.type == "shop") {
        if (this.$route.params.refund == 14) {
          console.log(this.$route.params, "商家-钩子中获取参数");
          this.status = this.$route.params.refund;
          this.payStartTime = "";
          // this.payEndTime = "";
          this.shopName = this.$route.params.shopName;
          this.refundStartTime =[ this.$route.params.dayId + " " + "00:00:00",this.$route.params.dayId + " " + "23:59:59"];
          // this.refundStartTime = this.$route.params.dayId + " " + "00:00:00";
          // this.refundEndTime = this.$route.params.dayId + " " + "23:59:59";
          this.taskdataSelect();
        }
      } else {
        this.status = "";
        this.shopName = "";
        this.refundStartTime = "";
        // this.refundEndTime = "";
        this.payStartTime = [
          dayjs()
            .subtract(6, "day").startOf('day')
            .format("YYYY-MM-DD HH:mm:ss"),
          dayjs().endOf('day').format("YYYY-MM-DD HH:mm:ss")
        ];
        // this.payEndTime = dayjs().format("YYYY-MM-DD");
        this.taskdataSelect();
      }
    });
  }
};
</script>

<style scoped>
/* 导出限制 */
.el-tabs >>> .export {
  width: 500px;
}
.el-tabs >>> .export .con {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 20px;
}
.el-tabs >>> .export .con .gundong {
  animation: gundong 3s linear infinite;
}
@keyframes gundong {
  /* from表示动画的开始位置，也可以使用0%来表示。 */
  from {
    transform: rotate(0deg);
  }
  /* to表示动画的结束位置，也可以使用100%来表示。 */
  to {
    transform: rotate(360deg);
  }
}
.el-tabs >>> .export img {
  width: 70px;
}
.el-tabs >>> .export .btn {
  display: flex;
  flex-direction: row-reverse;
}

/* 打印小票明细 */
.el-tabs >>> .detail {
  width: 700px;
}
.el-tabs >>> .detail .btn {
  margin-top: 15px;
  display: flex;
  flex-direction: row-reverse;
}

/* 打印小票明细 */
.el-tabs >>> .riderDetail {
  width: 900px;
}
</style>
