<template>
  <div>
    <crud-template ref="crudRef" class="as-weight" :home-data="field" :tableData="tableData" @btnSearch="btnSearch"
      @CurrentChange="handleCurrentChange" @refreshLeft="refreshLeft" @pageSizeChange="(val) => {
      field.paging.currentPage = 1
      field.paging.pageSize = val
      getList()
    }">
      <template #search>
        <el-input maxlength="60" v-trim clearable v-model="searchForm.orderNo" style="width: 200px"
          placeholder="请输入单号" />
        <el-input maxlength="60" v-trim clearable v-model="searchForm.customerIdnum" style="width: 200px"
          placeholder="请输入证件号" />
        <el-input maxlength="60" v-trim clearable v-model="searchForm.customerTel" style="width: 200px"
          placeholder="请输入用户手机号" />
        <el-input maxlength="60" v-trim clearable v-model="searchForm.productName" style="width: 200px"
          placeholder="请输入产品名称" />
        <el-input maxlength="60" v-trim clearable v-model="searchForm.vehiclePlate" placeholder="请输入车牌号"
          :style="{ width: '320px', margin: '0 10px 10px 0' }">
          <template #append>
            <el-select clearable v-model="searchForm.vehiclePlateColor" placeholder="请选择车牌颜色" style="width: 150px;">
              <el-option :label="item.label" :key="item.label" :value="item.value" v-for="item in VEHICLE_COLOR_TYPE" />
            </el-select>
          </template>
        </el-input>
        <el-select clearable v-model="searchForm.artificialStatus" style="width: 200px" placeholder="请选择审核类型">
          <el-option v-for="item in artificialStatusList" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
        <el-select clearable v-model="searchForm.vanType" style="width: 200px" placeholder="请选择车辆类型">
          <el-option v-for="item in vehicleTypes" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
        <el-select clearable v-model="searchForm.promotionModes" style="width: 200px" placeholder="请选择办理方式">
          <el-option v-for="item in PATTERN_TYPE" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
        <el-select clearable @change="deviceTypeChange" v-model="searchForm.deviceType" style="width: 200px"
          placeholder="请选择设备类型">
          <el-option v-for="item in CSMSN_DEVICE_TYPE" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
        <!-- <el-select clearable v-model="searchForm.orderTypes" multiple style="width: 200px" placeholder="请选择订单类型">
          <el-option v-for="item in newOrderTypeList" :key="item.value" :label="item.label" :value="item.value" />
        </el-select> -->
        <!-- <div class="date-label">创建时间:</div> -->
        <el-date-picker unlink-panels v-model="searchForm.time" type="datetimerange" range-separator="到"
          start-placeholder="订单创建开始日期" end-placeholder="订单创建结束日期" format="YYYY-MM-DD HH:mm:ss"
          value-format="YYYY-MM-DDTHH:mm:ss" />
      </template>
      <template #searchCustomButton>
        <el-button v-if="IsPermission(route, 'DELIVERY_INFORMATION_ENTRY')" type="warning" icon="Download"
          @click="templateDownload" class="btn">
          模板下载
        </el-button>
        <el-upload v-if="IsPermission(route, 'DELIVERY_INFORMATION_ENTRY')"
          style="display: inline-block; margin: 0 10px" ref="upload" :data="data" :action="uploadUrl"
          @success="onSuccess($event)" accept=".xls, .xlsx" :limit="1" :on-exceed="handleExceed" :show-file-list="false"
          :multiple="false">
          <el-button type="primary" class="btn" icon="Upload">批量发货导入</el-button>
        </el-upload>
        <el-button v-if="IsPermission(route, 'DELIVERY_INFORMATION_EXPORT')" type="success" icon="Download"
          @click="download" class="btn">
          发货信息导出
        </el-button>
      </template>
      <template #button2>
        <el-tabs @tab-click="handleClick" v-model="activeName">
          <el-tab-pane v-for="(item, index) in tageList" :key="index" :label="item.label"
            :name="item.name"></el-tab-pane>
        </el-tabs>
      </template>

      <template #operation="{ scope }">
        <!-- 审核转移到订单领取审核 -->
        <!-- <el-button style="margin: 10px 5px;"
          v-if="'6' == scope.row.orderStep && scope.row.orderStatus != 99999 && IsPermission(route, 'AUDIT_LIST') && channelOperationAuthority(scope.row.agencyId)"
          type="success" size="small" @click="audit(scope.$index, scope.row, true)">
          审核
        </el-button> -->
        <el-button style="margin: 10px 5px;" v-if="IsPermission(route, 'INFO_LIST')" type="warning" size="small"
          @click="audit(scope.$index, scope.row, false)">
          详情
        </el-button>
        <el-button style="margin: 10px 5px;" v-if="(scope.row.orderStep < 9 || scope.row.orderStep == '26' || scope.row.orderStep == '27') && scope.row.orderStatus == '0' && IsPermission(route, 'CANCEL_ORDER_LIST') && channelOperationAuthority(scope.row.agencyId)
      " type="danger" size="small" @click="showData(scope.row, 1)">
          取消订单
        </el-button>
        <el-button style="margin: 10px 5px;" v-if="scope.row.orderStep == 8 && scope.row.orderStatus == 0 &&
      IsPermission(route, 'DELIVER_GOODS_LIST') && channelOperationAuthority(scope.row.agencyId)
      " type="primary" size="small" @click="showData(scope.row, 3)">
          订单发货
        </el-button>
        <el-button style="margin: 10px 5px;" v-if="(scope.row.orderStep == 9 || scope.row.orderStep == 10) && scope.row.orderStatus != 99999 &&
      IsPermission(route, 'RETURN_GOODS_LIST') && channelOperationAuthority(scope.row.agencyId)
      " type="danger" size="small" @click="showData(scope.row, 4)">
          退货
        </el-button>
        <el-button style="margin: 10px 5px;" v-if="(scope.row.orderStep == 9 || scope.row.orderStep == 10) && scope.row.orderStatus != 99999 &&
      IsPermission(route, 'CHANGE_GOODS_LIST') && channelOperationAuthority(scope.row.agencyId)
      " type="danger" size="small" @click="showData(scope.row, 5)">
          换货
        </el-button>
        <el-button style="margin: 10px 5px;" v-if="(scope.row.orderStep == 32 || scope.row.orderStep == 34) && scope.row.orderStatus != 99999 && channelOperationAuthority(scope.row.agencyId)
      " type="primary" size="small" @click="showData(scope.row, 8)">
          确认收货
        </el-button>
        <el-button style="margin: 10px 5px;" v-if="(scope.row.securityDeposit == 1) && IsPermission(route, 'MARGIN_INQUIRY_LIST')
      " type="success" size="small" @click="showData(scope.row, 6)">
          保证金查询
        </el-button>
        <el-button style="margin: 10px 5px;" type="success" size="small" v-if="IsPermission(route, 'BIDDING_PROCESS')"
          @click="showData(scope.row, 7)">
          申办记录
        </el-button>
        <!-- <el-button
          v-if="((scope.row.orderStep == 13) && scope.row.orderStatus != 99999) && IsPermission(route, 'COMPLETE_RETURN')"
          size="small" type="success" @click="audit(scope.$index, scope.row, 0)">完成退货</el-button> -->
        <el-popover
          v-if="(scope.row.orderStep == 14 && scope.row.orderStatus != 99999 && scope.row.updateTime && -timesDiff((scope.row.updateTime).replaceAll('T', ' ')).days <= 30) && IsPermission(route, 'REUSE_LIST') && channelOperationAuthority(scope.row.agencyId)"
          style="margin: 10px 5px;" trigger="click" :visible="scope.row.visible2" placement="top" :width="160">
          <div>
            <div style="margin-bottom: 10px">
              <span>确认再次使用?</span>
            </div>
            <div class="as-layout-horizontal">
              <el-button type="default" @click="scope.row.visible2 = false" style="width: 100%">取消</el-button>
              <el-button type="primary" @click="completeReturn(scope.$index, scope.row, 2)"
                style="color: #fff; margin-right: 10px">确认</el-button>
            </div>
          </div>
          <template #reference>
            <el-button size="small" type="success" @click="scope.row.visible2 = true">再次使用</el-button>
          </template>
        </el-popover>
        <el-popover
          v-if="((scope.row.orderStep == 10 || scope.row.orderStep == 9) && scope.row.orderStatus != 99999 && scope.row.insertTime && -timesDiff((scope.row.insertTime).replaceAll('T', ' ')).days > 30) && IsPermission(route, 'CLOSE_ORDER_LIST') && channelOperationAuthority(scope.row.agencyId)"
          style="margin: 10px 5px;" trigger="click" :visible="scope.row.visible3" placement="top" :width="160">
          <div>
            <div style="margin-bottom: 10px">
              <span>确认结束订单?</span>
            </div>
            <div class="as-layout-horizontal">
              <el-button type="default" @click="scope.row.visible3 = false" style="width: 100%">取消</el-button>
              <el-button type="primary" @click="completeReturn(scope.$index, scope.row, 3)"
                style="color: #fff; margin-right: 10px">确认</el-button>
            </div>
          </div>
          <template #reference>
            <el-button size="small" type="danger" @click="scope.row.visible3 = true">结束订单</el-button>
          </template>
        </el-popover>
      </template>
    </crud-template>

    <!-- 详情弹窗 -->
    <el-dialog class="detail-dialog" :title="detailDialogTitle" v-model="visible">
      <div v-if="detailDialogTitle == '订单详情'">
        <div style="position: absolute; top: 0; right: 100px" v-if="visiinfoDatable">
          <!-- <el-affix v-if="9 > visiinfoDatable.orderStep" :offset="offset">
          <el-button type="danger" size="small" @click="showData(visiinfoDatable, 1)">
            取消订单
          </el-button>
        </el-affix> -->
          <el-affix v-if="6 == visiinfoDatable.orderStep && autdisButton" :offset="offset + 50">
            <el-button type="danger" size="small" @click="showData(visiinfoDatable, 2)">
              审核
            </el-button>
          </el-affix>
          <!-- <el-affix v-if="8 == visiinfoDatable.orderStep" :offset="offset + 100">
          <el-button type="danger" size="small" @click="showData(visiinfoDatable, 3)">
            订单发货
          </el-button>
        </el-affix> -->
          <!-- <el-affix v-if="visiinfoDatable.orderStep == 9 || visiinfoDatable.orderStep == 10
          " :offset="offset + 50">
          <el-button type="danger" size="small" @click="showData(visiinfoDatable, 4)">
            退货
          </el-button>
        </el-affix> -->
          <!-- <el-affix v-if="visiinfoDatable.orderStep == 9 || visiinfoDatable.orderStep == 10
          " :offset="offset + 100">
          <el-button type="danger" size="small" @click="showData(visiinfoDatable, 5)">
            换货
          </el-button>
        </el-affix> -->
        </div>
        <orderInfo :infoData="visiinfoDatable"></orderInfo>
      </div>
      <div v-else-if="detailDialogTitle == '保证金详情'">
        <el-descriptions direction="vertical" border :column="3">
          <el-descriptions-item label="保证金(元)" :span="1"> {{ handleAmount(earnestMoneyObj?.amount) ?? '-'
            }}</el-descriptions-item>
          <el-descriptions-item label="支付状态" :span="1"> {{ earnestMoneyObj?.payType == 0 ? '未支付' :
            earnestMoneyObj?.payType == 1 ? '已支付' : '-' }}</el-descriptions-item>
          <el-descriptions-item label="支付时间" :span="1"> {{ earnestMoneyObj?.payTime ?? '-' }}</el-descriptions-item>
          <el-descriptions-item label="退款状态" :span="1"> {{ earnestMoneyObj?.refundType == 0 ? '未退款' :
            earnestMoneyObj?.payType == 1 ? '已退款' : '-' }}</el-descriptions-item>
          <el-descriptions-item label="退款时间" :span="1"> {{ earnestMoneyObj?.refundTime ?? '-' }}</el-descriptions-item>
        </el-descriptions>
      </div>
    </el-dialog>

    <!-- 简单操作弹窗(取消订单,退货,换货) -->
    <el-dialog v-model="dialogVisible" :width="startTitle === '申办记录' ? '40%' : '30%'" :title="startTitle">
      <div v-if="startTitle !== '申办记录'">
        <el-input v-trim clearable type="textarea" v-model="content" :placeholder="startTitle + `原因`"
          maxlength="200" show-word-limit></el-input>
      </div>
      <template #footer v-if="startTitle !== '申办记录'">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="operation()">确 定</el-button>
      </template>
      <div v-if="startTitle === '申办记录'" v-loading="biddingProcessLoading">
        <el-steps style="max-width: 600px" :active="biddingProcessList.length" align-center>
          <el-step v-for="item in biddingProcessList" :key="item.serviceType" :title="item.serviceType">
            <template v-slot:description>
              <div>
                {{ item.operateTime }}
              </div>
              <div @click="biddingProcessInfoFn(item.type)"
                v-if="item.type === 'APPLYRETURN' || item.type === 'APPLYREPLACEMENT' || item.type === 'PAYEND'"
                class="user-content">
                查看详情
              </div>
            </template>
          </el-step>
        </el-steps>
      </div>
    </el-dialog>

    <!-- 订单发货 -->
    <el-dialog v-model="deliverGoods" width="40%" title="订单发货" @close="deliverClose">
      <el-form ref="form" :rules="rules" :model="sizeForm" label-width="120px">
        <el-form-item label="收件人姓名">
          <el-input v-trim clearable disabled v-model="sizeForm.orderInfoExt.consignee"
            placeholder="请输入收件人姓名"></el-input>
        </el-form-item>
        <el-form-item label="收件人电话">
          <el-input v-trim clearable disabled v-model="sizeForm.orderInfoExt.consigneeTel"
            placeholder="请输入收件人电话"></el-input>
        </el-form-item>
        <el-form-item label="收货地区">
          <el-input v-trim clearable disabled v-model="sizeForm.orderInfoExt.region" placeholder="请输入收货地址"></el-input>
        </el-form-item>
        <el-form-item label="详细地址">
          <el-input v-trim clearable disabled v-model="sizeForm.orderInfoExt.address" placeholder="请输入详细地址"></el-input>
        </el-form-item>
        <el-form-item label="邮政编码">
          <el-input v-trim clearable disabled v-model="sizeForm.orderInfoExt.postalCode"
            placeholder="请输入邮政编码"></el-input>
        </el-form-item>
        <el-form-item label="卡号" :prop="beanData.orderType === 'OFFICAL_SUPPLEMENT_OBU' ? '' : 'cardId'">
          <el-input v-trim clearable :disabled="cardIdDisabled" type="number"
            oninput="if(value.length>20)value=value.slice(0,20)" v-model="sizeForm.cardId" placeholder="卡号"></el-input>
        </el-form-item>
        <el-form-item label="OBU号" prop="obuId">
          <el-input v-trim clearable :disabled="obuIdDisabled" type="number"
            oninput="if(value.length>16)value=value.slice(0,16)" v-model="sizeForm.obuId" placeholder="OBU号"></el-input>
        </el-form-item>
        <el-form-item label="物流公司" prop="courierCompany">
          <el-select @change="courierCompanyChange" clearable v-model="sizeForm.courierCompany" placeholder="请选择物流公司">
            <el-option :label="item.label" :key="item.value" :value="item.value"
              v-for="item in EXPRESS_DELIVERY_COMPANY" />
          </el-select>
        </el-form-item>
        <el-form-item label="物流单号" prop="trackingNumber">
          <el-input v-trim clearable maxlength="60" :disabled="trackingNumberDisabled" v-model="sizeForm.trackingNumber"
            placeholder="物流单号"></el-input>
        </el-form-item>
      </el-form>

      <template #footer>
        <el-button @click="deliverGoods = false">取 消</el-button>
        <el-button type="primary" @click="submitForm(form)">确 定</el-button>
      </template>
    </el-dialog>
    <!-- 订单换货 -->
    <el-dialog v-model="exchangeInformationDialog" width="40%" title="订单换货" @close="exchangeInformationClose">
      <el-form ref="exchangeInformationRef" :rules="exchangeInformationRules" :model="exchangeInformationForm"
        label-width="120px">
        <el-form-item label="换货类型" prop="applyType">
          <el-select clearable v-model="exchangeInformationForm.applyType" placeholder="请选择换货类型">
            <el-option :label="item.label" :key="item.value" :value="item.value" v-for="item in applyTypeList" />
          </el-select></el-form-item>
        <!-- <el-form-item label="损坏方式">
          <el-radio-group v-model="exchangeInformationForm.damageMode">
            <el-radio label="1">自然损坏</el-radio>
            <el-radio label="0">人为损坏</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="上传图片">
          <el-upload ref="uploadImg" v-model:file-list="fileList" list-type="picture-card" :data="data"
            :action="uploadUrl">
            <el-icon>
              <Plus />
            </el-icon>
          </el-upload>
        </el-form-item> -->
        <el-form-item style="font-weight: 900;" label="邮寄方式"></el-form-item>
        <el-form-item label="是否需要邮寄" prop="sendStatus">
          <el-radio-group v-model="exchangeInformationForm.sendStatus">
            <el-radio label="1">邮寄</el-radio>
            <el-radio label="0">不邮寄</el-radio>
          </el-radio-group>
        </el-form-item>
        <div v-if="exchangeInformationForm.sendStatus == '1'">
          <el-form-item label="收件人姓名" prop="consignee">
            <el-input maxlength="60" v-trim clearable v-model="exchangeInformationForm.consignee"
              placeholder="请输入收件人姓名"></el-input>
          </el-form-item>
          <el-form-item label="收件人电话" prop="consigneeTel">
            <el-input maxlength="60" v-trim clearable v-model="exchangeInformationForm.consigneeTel"
              placeholder="请输入收件人电话"></el-input>
          </el-form-item>
          <el-form-item label="收货地区" prop="region">
            <el-cascader v-model="exchangeInformationForm.region" placeholder="请选择收货地址" :options="pcaText" />
          </el-form-item>
          <el-form-item label="详细地址" prop="address">
            <el-input maxlength="60" v-trim clearable v-model="exchangeInformationForm.address"
              placeholder="请输入详细地址"></el-input>
          </el-form-item>
          <el-form-item label="邮政编码" prop="postalCode">
            <el-input maxlength="60" v-trim clearable v-model="exchangeInformationForm.postalCode"
              placeholder="请输入邮政编码"></el-input>
          </el-form-item>
        </div>
        <el-form-item style="font-weight: 900;" label="收货方式"></el-form-item>
        <el-form-item label="收货方式" prop="receiveMethod">
          <el-radio-group v-model="exchangeInformationForm.receiveMethod">
            <el-radio label="1">线上</el-radio>
            <el-radio label="0">线下</el-radio>
          </el-radio-group>
        </el-form-item>
        <div v-if="exchangeInformationForm.receiveMethod == '1'">
          <el-form-item label="物流公司" prop="courierCompany">
            <el-select clearable v-model="exchangeInformationForm.courierCompany" placeholder="请选择物流公司">
              <el-option :label="item" :key="item" :value="item" v-for="item in logisticsCompanyList" />
            </el-select>
          </el-form-item>
          <el-form-item label="物流单号" prop="courierOrderId">
            <el-input maxlength="60" v-trim clearable v-model="exchangeInformationForm.courierOrderId"
              placeholder="请输入物流单号"></el-input>
          </el-form-item>
        </div>
        <el-form-item label="更换原因" prop="applyRes">
          <el-input v-trim clearable type="textarea" maxlength="100" show-word-limit
            v-model="exchangeInformationForm.applyRes" placeholder="请输入更换原因"></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="exchangeInformationDialog = false">取 消</el-button>
        <el-button type="primary" @click="exchangeInformationsubmitForm(exchangeInformationRef)">确 定</el-button>
      </template>
    </el-dialog>
    <!-- 审核接口 -->
    <el-dialog v-model="check" width="30%" title="审核">
      <el-form ref="form" :model="autdis"
        :rules="{ reason: [{ required: true, message: '驳回类型不能为空', trigger: 'change' }] }" label-width="80px">
        <el-form-item label="">
          <el-radio-group v-model="autdis.auditStatus">
            <el-radio label="true">审核通过</el-radio>
            <el-radio label="false">审核不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="autdis.auditStatus != 'true'" label="审核原因" prop="reason">
          <el-select clearable @change="autdisReasonChange" v-model="autdis.reason" placeholder="请选择审核原因类型">
            <el-option :label="item.label" :key="item.value" :value="item.value"
              v-for="item in NEW_CSMSN_APPLY_REASON" />
          </el-select>
        </el-form-item>
        <el-form-item v-if="autdisReasonType == '8' && autdis.auditStatus != 'true'" label="其他原因" prop="reason1">
          <el-input v-trim clearable type="textarea" v-model="autdis.reason1" :placeholder="`审核不通过原因`"
            maxlength="200" show-word-limit></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="check = false">取 消</el-button>
        <el-button type="primary" @click="checkForm(form)">确 定</el-button>
      </template>
    </el-dialog>
    <!-- 完成退货，已加入业务审核该地方不使用 -->
    <!-- <returnInformation v-model="CompleteTeturnDialog" @completeReturn="getList()" :infoData="visiinfoDatable">
    </returnInformation> -->
    <!-- 申办查看详情 -->
    <el-dialog v-model="biddingProcessDialog" width="50%" :title="biddingProcessTypeTitle">
      <biddingProcessInfo :infoData="biddingProcessInfoData" :biddingProcessType="biddingProcessType"
        v-loading="biddingProcessInfoLoading">
      </biddingProcessInfo>
    </el-dialog>
  </div>
</template>

<!-- 订单管理 -->
<script setup lang="ts">
  import { ref, reactive, onMounted, computed } from 'vue'
  import { useRoute } from 'vue-router'
  // @ts-ignore crudFrom模板
  import CrudTemplate from '@/crud/index.vue'
  import $storeinitData from '@/store/initData' //引入tab vuex
  import BaseService from '@/utils/baseService' //引入接口请求
  import { ElMessage, ElMessageBox, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus' //提示
  import { getCache } from '@/utils/cache'
  // @ts-ignore crudFrom模板
  import orderInfo from '@/components/orderInfo/index.vue'
  import returnInformation from './returnInformation.vue'
  import { timesDiff } from '@/utils/utils'
  import biddingProcessInfo from './biddingProcessInfo.vue'
  import { pcaTextArr } from 'element-china-area-data'
  const pcaText: any = pcaTextArr
  import {
    getOrderInfo,
    salesReturnAffirm,
    cancellationOfOrder,
    getOrderList,
    deliverGoodsOrder,
    exchangeGoods,
    salesReturn,
    getAudit,
  } from '@/api/onlineBusinessHall/orderManagement'
  import { IsPermission } from '@/router/routerUtil'
  import { channelOperationAuthority } from '@/utils/channelOperationAuthority'
  import moment from 'moment'
  import handleAmount from '@/utils/handleAmount'
  import { exportFn, importFn } from '@/views/settlement/exportFn'
  const uploadUrl = '/minIo/upload'
  const data = { bucket: 'default-bucket' }
  const fileList = ref([])
  //或取路由传入过来的对象数据
  const route = useRoute()
  const crudRef = ref()
  let offset = ref(150)
  let cacheAccessToken = getCache(
    'cacheAccessToken',
    { isSessionStorage: false },
    {}
  )
  let openId = cacheAccessToken['openId']
  let visible = ref(false)
  let dialogVisible = ref(false)
  let deliverGoods = ref(false)
  let check = ref(false) //审核弹窗
  let orderStep = ref('')
  const orderStatus = ref()
  let content = ref('')
  let form = ref()
  let startTitle = ref('取消订单') //取消订单 换货 退货
  let visiinfoDatable: any = reactive({})
  let activeName = null
  let sizeForm: any = ref({ orderInfoExt: {} }) //发货对象
  const autdis: any = reactive({ auditStatus: 'true', reason: '', reason1: '' }) //审核对象
  const detailDialogTitle = ref('订单详情')
  const exchangeInformationDialog = ref(false) // 换货弹框
  const CompleteTeturnDialog = ref()
  let rules = ref({
    cardId: [{ required: true, message: '不能为空且卡号为20位', trigger: 'blur', min: 20, max: 20 }],
    obuId: [{ required: true, message: '不能为空且OBU号为16位', trigger: 'blur', min: 16, max: 16 }],
    courierCompany: [{ required: true, message: '不能为空', trigger: 'blur' }],
    trackingNumber: [{ required: true, message: '不能为空', trigger: 'blur' }],
  })
  let exchangeInformationRules = ref({
    sendStatus: [{ required: true, message: '不能为空', trigger: 'change' }],
    consignee: [{ required: true, message: '不能为空', trigger: 'blur' }],
    consigneeTel: [{ required: true, message: '不能为空', trigger: 'blur' }, {
      pattern:
        /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/, //正则校验不用字符串
      message: '请填写正确的手机号码',
      trigger: 'blur',
    },],
    region: [{ required: true, message: '不能为空', trigger: 'blur' }],
    address: [{ required: true, message: '不能为空', trigger: 'blur' }],
    receiveMethod: [{ required: true, message: '不能为空', trigger: 'change' }],
    courierCompany: [{ required: true, message: '不能为空', trigger: 'blur' }],
    courierOrderId: [{ required: true, message: '不能为空', trigger: 'blur' }],
    applyRes: [{ required: true, message: '不能为空', trigger: 'blur' }],
    applyType: [{ required: true, message: '不能为空', trigger: 'change' }]
  })
  const exchangeInformationForm = reactive<any>({
    sendStatus: '1',
    consignee: '',
    consigneeTel: '',
    region: '',
    address: '',
    postalCode: '',
    receiveMethod: '1',
    courierCompany: '',
    courierOrderId: '',
    applyRes: '',
    applyType: '',
    // damageMode: '1'
  })
  const artificialStatusList = [
    {
      label: '系统审核',
      value: '2'
    },
    {
      label: '人工审核',
      value: '1'
    },
  ]
  //订单阶段
  const ORDER_STAGE_TYPE = computed(() => {
    return $storeinitData.state.dictData['ORDER_STAGE_TYPE'] || []
  })
  const EXPRESS_DELIVERY_COMPANY = computed(() => {
    return $storeinitData.state.dictData['EXPRESS_DELIVERY_COMPANY'] || []
  })
  const CSMSN_DEVICE_TYPE = computed(() => {
    return $storeinitData.state.dictData['CSMSN_DEVICE_TYPE'] || []
  })
  //订单状态
  const ORDER_TYPE = computed(() => {
    return $storeinitData.state.dictData['ORDER_TYPE'] || []
  })
  //车牌颜色
  const VEHICLE_COLOR_TYPE = computed(() => {
    return $storeinitData.state.dictData['VEHICLE_COLOR_TYPE'] || []
  })

  // 车辆类型
  const vehicleTypes = computed(() => {
    return $storeinitData.state.dictData['VAN_TYPE'] || []
  })

  //产品类型
  const PRODUCT_TYPE = computed(() => {
    return $storeinitData.state.dictData['PRODUCT_TYPE_NEW'] || []
  })

  //办理模式
  const PATTERN_TYPE = computed(() => {
    return $storeinitData.state.dictData['PATTERN_TYPE'] || []
  })

  //订单状态
  const ORDER_STATUS = computed(() => {
    return $storeinitData.state.dictData['ORDER_STATUS'] || []
  })

  const NEW_CSMSN_APPLY_REASON = computed(() => {
    return $storeinitData.state.dictData['NEW_CSMSN_APPLY_REASON'] || []
  })

  const CERTIFICATE_TYPE = computed(() => {
    return $storeinitData.state.dictData["CERTIFICATE_TYPE"] ?? [];
  }); //用户证件类型

  const autdisReasonType = ref()
  function autdisReasonChange(value) {
    autdisReasonType.value = value
  }
  const applyTypeList = [
    {
      label: '换卡',
      value: 'CARD'
    },
    {
      label: '换签',
      value: 'OBU'
    },
    {
      label: '换卡签',
      value: 'ALL'
    },
  ] // 换货类型
  const logisticsCompanyList = ref([])
  function getLogisticsCompanyList() {
    BaseService.post('/managew/order/couriercompanyselect', {}).then((res: any) => {
      if (res && res.statusCode === 0) {
        logisticsCompanyList.value = res?.data ? res.data : []
      } else {
        ElMessage.error(res.message)
      }
    })
  }
  const newOrderTypeList = ref([])
  function deviceTypeChange(value) {
    console.log(value, 'value')
    if (value === 'TYMY9901') {
      newOrderTypeList.value = ORDER_TYPE.value.filter(item => {
        // 新办发行 更换卡 更换签 更换卡签
        return (item.value == 'ISSUE' || item.value == 'EXCHANGE_OBU' || item.value == 'EXCHANGE_CARD' || item.value == 'EXCHANGE_ALL' || item.value == 'FILL_CARD' || item.value == 'FILL_OBU')
      })
    } else {
      newOrderTypeList.value = ORDER_TYPE.value
      console.log(newOrderTypeList.value, 'newOrderTypeList.value')
    }
  }

  function getLabel(item, selectedValue) {
    let data = item.value
    let selectedLabel = ''
    for (var i = 0; i < data.length; i++) {
      if (data[i].code == selectedValue) {
        selectedLabel = data[i].name
        break
      }
    }
    return selectedLabel
  }

  // 物流单号
  const trackingNumberDisabled = ref(false)
  function courierCompanyChange(value) {
    if (value == '99') {
      sizeForm.value.trackingNumber = '000000'
      trackingNumberDisabled.value = true
    } else {
      sizeForm.value.trackingNumber = ''
      trackingNumberDisabled.value = false
    }
  }

  let tageList = [
    {
      label: '全部',
      name: null,
      value: ''
    },
    {
      label: '待签约',
      name: '3',
      value: 'NORMAL'
    },
    {
      label: '待审核',
      name: '6',
      value: 'NORMAL'
    },
    {
      label: '待发货',
      name: '8',
      value: 'NORMAL'
    },
    {
      label: '待收货',
      name: '9',
      value: 'NORMAL'
    },
    {
      label: '待激活',
      name: '10',
      value: 'NORMAL'
    },
    {
      label: '换货',
      name: '12',
      value: 'NORMAL'
    },
    {
      label: '退货',
      name: '13',
      value: 'NORMAL'
    },
    // {
    //   label: '异地换货',
    //   name: '34',
    //   value: 'NORMAL'
    // },
    // {
    //   label: '异地退货',
    //   name: '32',
    //   value: 'NORMAL'
    // },
    {
      label: '已完成',
      name: '11',
      value: 'ACTIVE'
    },
    {
      label: '已结束',
      name: '14',
      value: 'CANCEL'
    },
    {
      label: '审核不通过',
      name: '7',
      value: 'NORMAL'
    },
    {
      label: '待支付',
      name: '4',
      value: 'NORMAL'
    },
    {
      label: '已取消',
      name: '',
      value: 'CANCEL'
    },
    {
      label: '已封存',
      name: ' ',
      value: 'SEAL'
    },
  ]
  //查询参数
  const searchForm = ref({
    artificialStatus: '',
    orderNo: '',
    productName: '',
    vehiclePlate: '',
    vanType: '',
    orderTypes: '',
    orderStep: '',
    time: '',
    vehiclePlateColor: '',
    promotionModes: '',
    customerIdnum: '',
    customerTel: '',
    deviceType: '',
  })
  let tableData: any = ref([])

  onMounted(() => {
    getList()
    getLogisticsCompanyList()
  })

  // 搜索按钮
  function btnSearch() {
    field.value.paging.currentPage = 1
    getList()
  }

  //标签分页
  function handleClick(tab, event) {
    orderStep.value = tab.props.name
    orderStatus.value = tageList[tab.index].value
    getList()
  }

  //分页
  function handleCurrentChange(val: number) {
    field.value.paging.currentPage = val
    getList()
  }

  // 搜索重置
  function refreshLeft() {
    searchForm.value = {
      artificialStatus: '',
      orderNo: '',
      productName: '',
      vehiclePlate: '',
      vanType: '',
      orderTypes: '',
      orderStep: '',
      time: '',
      vehiclePlateColor: '',
      promotionModes: '',
      customerIdnum: '',
      customerTel: '',
      deviceType: '',
    }
    newOrderTypeList.value = ORDER_TYPE.value
    field.value.paging.currentPage = 1
    getList()
  }

  function deliverClose() {
    if (form.value) form.value.resetFields()
  }
  const uploadImg = ref()
  const exchangeInformationRef = ref()
  function exchangeInformationClose() {
    if (exchangeInformationRef.value) exchangeInformationRef.value.resetFields()
    if (uploadImg.value) uploadImg.value.clearFiles()
    exchangeInformationForm.sendStatus = '1',
      exchangeInformationForm.consignee = '',
      exchangeInformationForm.consigneeTel = '',
      exchangeInformationForm.region = '',
      exchangeInformationForm.address = '',
      exchangeInformationForm.postalCode = '',
      exchangeInformationForm.receiveMethod = '1',
      exchangeInformationForm.courierCompany = '',
      exchangeInformationForm.courierOrderId = '',
      exchangeInformationForm.applyRes = '',
      exchangeInformationForm.applyType = ''
      // exchangeInformationForm.damageMode = '1'
  }

  //订单发货
  let timer1: any = null
  function submitForm(formEl) {
    if (timer1) return
    timer1 = setTimeout(() => {
      formEl.validate((valid: any, fields: any) => {
        if (valid) {
          delete sizeForm.value.type
          sizeForm.value.opId = openId
          console.log(sizeForm.value)
          //订单发货
          BaseService.postN('/iaw/issue/order/orderDeliverGoods', sizeForm.value).then((res: any) => {
            if (res && res.code === 0) {
              deliverGoods.value = false
              ElMessage.success(res.message)
              getList() //页面数据刷新
            } else {
              ElMessage.error(res.message)
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
      timer1 = null
    }, 1000)
  }
  // 订单换货
  let timerExchange: any = null
  function exchangeInformationsubmitForm(exchangeInformationRef) {
    if (timerExchange) return
    let params: any = {
      orderId: beanData.orderId,
      applyType: exchangeInformationForm.applyType,
      returnReason: exchangeInformationForm.applyRes,
      // damageMode: exchangeInformationForm.damageMode
    }
    // params.fileUrl = fileList.value.map((item: any) => {
    //   return '/default-bucket/' + item?.response?.data?.ossFilePath
    // }).join()
    timerExchange = setTimeout(() => {
      exchangeInformationRef.validate((valid: any, fields: any) => {
        if (valid) {
              if (exchangeInformationForm.sendStatus == '0') {
                exchangeInformationForm.consignee = ''
                exchangeInformationForm.consigneeTel = ''
                exchangeInformationForm.region = ''
                exchangeInformationForm.address = ''
                exchangeInformationForm.postalCode = ''
              }
              if (exchangeInformationForm.receiveMethod == '0') {
                exchangeInformationForm.courierCompany = ''
                exchangeInformationForm.courierOrderId = ''
              }
              if (exchangeInformationForm.region && exchangeInformationForm.region.length !== 0) {
                exchangeInformationForm.region = exchangeInformationForm.region.join('')
              }
              let searchFormList = { ...exchangeInformationForm }
              for (let key in searchFormList) {
                if (searchFormList[key]) {
                  params[key] = searchFormList[key]
                }
              }
          BaseService.post('/iaw/issue/order/replaceGoodsFill', params).then((res: any) => {
            if (res && res.statusCode === 0) {
                  exchangeInformationDialog.value = false
                  ElMessage.success(res.message)
            } else {
              ElMessage.error(res.message)
            }
          })
        } else {
          return false
        }
      })
      timerExchange = null
    }, 1000)
  }

  let timer3: any = null
  const completeReturn = (index, row, type) => {
    if (timer3) return
    timer3 = setTimeout(() => {
      let api = ''
      let params = {}
      if (type == 2) {
        api = '/managew/order/orderreuse'
        params = { orderId: row.orderId, orderSource: 'WEB' }
      } else if (type == 3) {
        api = '/managew/order/orderend'
        params = { orderId: row.orderId, orderSource: 'WEB' }
      }
      BaseService.post(api, params).then((res: any) => {
        if (res && res.statusCode === 0) {
          ElMessage.success('操作完成')
          getList()
        } else {
          ElMessage.error(res.message)
        }
        if (type == 1) {
          row.visible1 = false
        } else if (type == 2) {
          row.visible2 = false
        } else if (type == 3) {
          row.visible3 = false
        }
      })
      timer3 = null
    }, 1000)
  }

  let timer2: any = null
  //审核提交
  function checkForm(formEl) {
    if (timer2) return
    timer2 = setTimeout(() => {
      formEl.validate((valid: any, fields: any) => {
        if (valid) {
          if (autdisReasonType.value == '8' && autdis.reason1) {
            autdis.reason = autdis.reason1
          }
          if (autdis.auditStatus == 'true') {
            autdisReasonType.value = ''
            autdis.reason = ''
            autdis.reason1 = ''
          }
          BaseService.postN('/iaw/issue/order/orderManualVerify', autdis).then((res: any) => {
            if (res && res.code === 0) {
              ElMessage.success(res.message)
              check.value = false
              visible.value = false
              getList()
            } else {
              ElMessage.error(res.message)
            }
          })
        } else {
          return false
        }
      })
      timer2 = null
    }, 1000)
  }

  //审核弹窗
  const autdisButton = ref(false)
  function audit(idx: number, data: any, type) {
    beanData = data
    if (type !== 0) {
      detailDialogTitle.value = '订单详情'
      autdisButton.value = type
      offset.value = 150
    }
    visiinfoDatable = {}
    BaseService.postN('/iaw/issue/order/orderDetailQuery', { id: data.id }).then((res: any) => {
      if (res && res.code === 0) {
        try {
          visiinfoDatable = res.data.data
        } catch (e) {
          console.log(e)
          ElMessage.error('未知错误')
        } //渲详情数据
        if (visiinfoDatable) {
          if (type !== 0) {
            autdis.orderId = visiinfoDatable.orderNo
            visible.value = true
          } else {
            CompleteTeturnDialog.value = true
          }
        } else {
          ElMessage.error('没有查到详情数据')
        }
      } else {
        ElMessage.error(res.message)
      }
    })
  }
  const biddingProcessInfoData = ref([])
  const biddingProcessDialog = ref(false)
  const biddingProcessType = ref()
  const biddingProcessTypeTitle = ref()
  const biddingProcessInfoLoading = ref(false)
  // 申办详情
  function biddingProcessInfoFn(type) {
    let api = ''
    biddingProcessDialog.value = true
    biddingProcessType.value = type
    biddingProcessInfoLoading.value = true
    if (type === 'APPLYRETURN') { // 退货
      api = '/managew/api/generalAudit/verificationquery'
      biddingProcessTypeTitle.value = '退货详情'
    } else if (type === 'APPLYREPLACEMENT') { // 换货
      api = '0dff04ef1e8648e6a5cddfb1eae1ee4b'
      biddingProcessTypeTitle.value = '换货详情'
    } else if (type === 'PAYEND') { // 支付
      api = '/managew/api/generalAudit/paymentdetails'
      biddingProcessTypeTitle.value = '支付详情'
    }
    BaseService.post(api, { orderId: beanData.orderId }).then((res: any) => {
      if (res && res.statusCode === 0) {
        const data = res.data ?? []
        biddingProcessInfoData.value = data
      } else {
        ElMessage.error(res.message)
      }
      biddingProcessInfoLoading.value = false
    })
  }

  let beanData: any = {}
  let operationStart
  const earnestMoneyObj = ref<any>()
  const cardIdDisabled = ref(false)
  const obuIdDisabled = ref(false)
  //显示内容 1 取消订
  function showData(data: any, start: number) {
    beanData = data
    operationStart = start
    content.value = '' //进入清空
    if (start == 1) {
      //取消订单
      dialogVisible.value = true
      startTitle.value = '取消订单'
    } else if (start == 2) {
      //审核
      autdisReasonType.value = ''
      autdis.auditStatus = 'true'
      autdis.reason = ''
      autdis.reason1 = ''
      check.value = true
    } else if (start == 3) {
      //订单发货
      //数据内容赋值（先查详情）
      sizeForm.value = { orderInfoExt: {} }
      BaseService.postN('/iaw/issue/order/orderDetailQuery', { id: data.id }).then((res: any) => {
        if (res && res.code === 0) {
          const data = res.data.data
          cardIdDisabled.value = data.cardId ? true : false
          obuIdDisabled.value = data.obuId ? true : false
          sizeForm.value = Object.assign(sizeForm.value, data)
          sizeForm.value.courierCompany = ''
          sizeForm.value.trackingNumber = ''
          sizeForm.value.orderId = data.orderNo
          deliverGoods.value = true
        } else {
          ElMessage.error(res.message)
        }
      })
    } else if (start == 4) {
      //退货
      dialogVisible.value = true
      startTitle.value = '退货'
    } else if (start == 5) {
      //换货
      exchangeInformationDialog.value = true
    } else if (start == 6) {
      detailDialogTitle.value = '保证金详情'
      BaseService.post('/managew/query/userdeposit', { orderId: data.orderId }).then((res: any) => {
        if (res && res.statusCode === 0) {
          earnestMoneyObj.value = res.data //渲详情数据
          if (earnestMoneyObj.value) {
            visible.value = true
          } else {
            ElMessage.error('没有查到数据')
          }
        } else {
          ElMessage.error(res.message)
        }
      })
    } else if (start == 7) {
      // 申办记录
      dialogVisible.value = true
      startTitle.value = '申办记录'
      biddingProcessLoading.value = true
      getBiddingProcess(data)
    } else if (start == 8) {
      // 确认收货
      ElMessageBox.confirm('确认收货吗?', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          BaseService.post('6ffed187cf4c493cbe7772f6153b7eef', {
            orderId: beanData.orderId,
            orderStep: beanData.orderStep,
          }).then((res: any) => {
            dialogVisible.value = false
            ElMessage.success(res.message)
            getList()
          })
        })
        .catch(() => { })
    }
  }
  // 
  const biddingProcessLoading = ref(false)
  const biddingProcessList: any = ref([])
  function getBiddingProcess(row) {
    biddingProcessList.value = []
    BaseService.post('/managew/api/generalAudit/biddingprocess', {
      orderId: row.orderId,
    }).then((res: any) => {
      if (res && res.statusCode === 0) {
        biddingProcessLoading.value = false
        biddingProcessList.value = res?.data ?? []
        console.log(biddingProcessList.value, 'biddingProcessList.value')
      } else {
        biddingProcessLoading.value = false
      }
    }).catch(() => {
      biddingProcessLoading.value = false
    })
  }

  //审核(no)  取消订单(已完成)
  let timer: any = null
  function operation() {
    if (timer) return
    timer = setTimeout(() => {
      let ifCode: string = '0'
      let params: any = {
        id: beanData.id,
        orderId: beanData.orderId,
        reason: content.value,
        returnReason: content.value,
        returnNetworkId: '52010106004',
        orderSource: 'WEB',
        returnNetworkName: '黔通智联自营网点',
        examineRes: content.value, //换货申请原因
        returnMode: 'OFFLINE', //线下
        source: 'WEB',
        opId: openId,
      }
      //取消订单
      if (operationStart == 1) {
        ifCode = '/iaw/issue/order/orderCancel'
        startTitle.value = '取消订单'
      } else if (operationStart == 4) {
        //退货
        ifCode = '/iaw/issue/order/refundGoodsApply'
      } else {
        timer = null
        return
      }
      if (!content.value) {
        ElMessage.error(startTitle.value + '原因不能为空!')
        timer = null
        return
      }
      BaseService.post(ifCode, params).then((res: any) => {
        if (res && res.statusCode === 0) {
          // //退货
          // ElMessageBox.confirm('确认退货吗?', '提示', {
          //   confirmButtonText: '确认',
          //   cancelButtonText: '取消',
          //   type: 'warning',
          // })
          //   .then(() => {
          //     BaseService.post(salesReturnAffirm, {
          //       id: beanData.id,
          //       opId: openId,
          //     }).then((res: any) => {
          //       dialogVisible.value = false
          //       ElMessage.success(res.message)
          //       getList()
          //     })
          //   })
          //   .catch(() => { })
          dialogVisible.value = false
          ElMessage.success(res.message)
          getList()
        } else {
          crudRef.value.tableLoding = false
          ElMessage.error(res.message)
        }
      })
      timer = null
    }, 1000)
  }

  function dateChange(time) {
    if (time) {
      time = moment(time).format('YYYY-MM-DDTHH:mm:ss')
    }
    return time
  }
  function getParams() {
    let params: any = {
      methods: 'page',
      pageNo: field.value.paging.currentPage,
      pageSize: field.value.paging.pageSize,
      tabIndex: 0,
      orderStep: orderStep.value,
      opId: '54623263cb4d4a289dccbc983b22a4af',
      source: 'WEB',
    }
    if (orderStatus.value) {
      params.orderStatus = orderStatus.value
    }
    //赋值查询参数
    let searchFormList = { ...searchForm.value }
    for (let key in searchFormList) {
      if (searchFormList[key]) {
        params[key] = searchFormList[key]
      }
    }
    if (params.time) {
      params.startTime = dateChange(params.time[0])
      params.endTime = dateChange(params.time[1])
    }
    return params
  }

  //获取列表
  function getList() {
    crudRef.value.tableLoding = true
    BaseService.postN('/iaw/issue/order/queryPage', getParams()).then((res: any) => {
      if (res && res.code === 0) {
        //数据转换
        let bizContent = res.data
        let data = bizContent.data || []
        console.log(data, 'data')
        //数据渲染
        tableData.value = data
        crudRef.value.tableLoding = false
        newOrderTypeList.value = ORDER_TYPE.value
        //分页总数
        field.value.paging.total = bizContent.totalCount
      } else {
        crudRef.value.tableLoding = false
        ElMessage.error(res.message)
      }
    })
  }
  // 发货导出
  function download() {
    exportFn('/managew/api/order/deliverGoodsExport', getParams(), '发货信息')
  }
  // 发货导入
  const upload = ref<UploadInstance>()
  function onSuccess(response: any) {
    const { ossFilePath, originalFileName } = response.data
    const url = data.bucket + '/' + ossFilePath
    console.log(ossFilePath, originalFileName)
    BaseService.post('/managew/api/order/deliverGoodsImport', { path: url, }).then((res: any) => {
      if (res && res.statusCode === 0) {
        getList && getList();
        console.log(res.bizContent, 'res')
        const errUrl = JSON.parse(res.bizContent)?.url ?? ''
        if (errUrl) {
          ElMessage.error("导入失败，请查看下载到本地文件的具体错误信息");
          BaseService.getDownload(
            import.meta.env.VITE_APP_UPLOAD_URL + errUrl,
            '错误信息文件'
          )
        } else {
          ElMessage.success("导入成功");
        }
      } else {
        ElMessage.error("导入失败，" + res.message);
      }
    });
  }
  const handleExceed: UploadProps['onExceed'] = (files) => {
    upload.value!.clearFiles()
    const file = files[0] as UploadRawFile
    file.uid = genFileId()
    upload.value!.handleStart(file)
    upload.value!.submit()
  }
  // 下载模板
  const templateDownload = () => {
    BaseService.getDownload(
      import.meta.env.VITE_APP_UPLOAD_URL + 'default-bucket/发货信息.xlsx',
      '发货信息录入模板'
    )
  }
  //表单数据配置
  let field = ref({
    border: true, //是否添加边框(默认false)
    searchShow: IsPermission(route, 'QUERY_BASE'), //搜索展示
    crudShow: false, //是否显示添加功能等
    paginStart: true, //是否显示分页查询
    operateWidth: '250px', //操作栏宽度
    operateFixed: true,
    operateTitle: '操作', //操作栏标题(默认为"")
    operate: {
      edit: false, //是否编辑(默认true)
      delete: false, //是否删除(默认true)
      remark: false, // 详情
      announcement: false, // 公告
      forbidden: false, // 禁用
      enable: false, // 启用
      authorization: false, // 授权
      cancel: false, // 取消订单
    },
    tableSize: -1,
    isPageSizes: true,
    pageLayout: 'total, sizes, prev, pager, next',
    paging: {
      pageSize: 10,
      currentPage: 1,
      total: 0,
    },
    extend: [
      {
        label: '序号',
        type: 'index',
        width: '80px',
      },
    ],
    field: [
      {
        prop: 'orderId',
        label: '单号',
      },
      {
        prop: 'productName',
        label: '产品名称',
      },
      {
        prop: 'productType',
        label: '产品类型',
        listData: PRODUCT_TYPE
      },
      {
        prop: 'promotionModes',
        label: '办理方式',
        listData: PATTERN_TYPE
      },
      {
        prop: 'isValueCard',
        label: '卡类型',
        funRuleStarts: true,
        funRule: (money: any) => {
          //1-储值卡 2-记账卡
          return money == '1' ? '储值卡' : '记账卡'
        },
      },
      {
        prop: 'type',
        label: '车辆类型',
        listData: vehicleTypes
      },
      {
        prop: 'userType',
        label: '用户类型', //PERSONAL_USER - 个人用户 UNIT_USER - 单位用户
        funRuleStarts: true,
        funRule: (money: any) => {
          return money === 'PERSONAL_USER' ? '个人用户' : '单位用户'
        },
      },
      {
        prop: 'customerTel',
        label: '手机号',
      },
      {
        prop: 'customerIdtype',
        label: '证件类型',
        listData: CERTIFICATE_TYPE,
      },
      {
        prop: 'cusotmerIdnum',
        label: '证件号',
      },
      {
        prop: 'vehiclePlate',
        label: '车牌号',
      },
      {
        prop: 'vehiclePlateColor',
        label: '车牌颜色',
        listData: VEHICLE_COLOR_TYPE
      },
      {
        prop: 'cardId',
        label: '卡号',
      },
      {
        prop: 'obuId',
        label: '签号',
      },
      {
        prop: 'amount',
        label: '订单金额',
        funRuleStarts: true,
        funRule: (money: any) => {
          return !money || money === 0 ? '---' : money / 100 + ' 元'
        },
      },
      {
        prop: 'isMigrateData',
        label: '系统来源',
        funRuleStarts: true,
        funRule: (isMigrateData: any) => {
          return (isMigrateData == '0' ? '新系统订单' : '老系统订单')
        },
      },
      {
        prop: 'orderStatus', //1 - 已取消 0 - 正常
        label: '订单状态',
        listData: ORDER_STATUS
        // funRuleStarts: true,
        // funRule: (money: any) => {
        //   return money === '0' ? '正常' : '已取消'
        // },
      },
      {
        width: '180px',
        prop: 'orderStep', //
        label: '订单阶段',
        funRuleStarts: true,
        funRule: (money: any) => {
          return getLabel(ORDER_STAGE_TYPE, money)
        },
      },
      {
        width: '180px',
        prop: 'orderType', //
        label: '订单类型',
        funRuleStarts: true,
        funRule: (money: any) => {
          return getLabel(ORDER_TYPE, money)
        },
      },
      {
        prop: 'selfMark',
        label: '是否自提',
        funRuleStarts: true,
        funRule: (money: any) => {
          return money == '1' ? '是' : '否'
        },
      },
      {
        width: '180px',
        prop: 'artificialStatus', //
        label: '审核类型',
        funRuleStarts: true,
        funRule: (value: any) => {
          return value == '1' ? '人工审核' : (value == '2' ? '系统审核' : '---')
        },
      },
      {
        width: '180px',
        prop: 'auditPerson', //
        label: '审核人',
      },
      {
        width: '150px',
        prop: 'insertTime',
        label: '创建时间',
        funRuleStarts: true,
        funRule: (money: any) => {
          return money ? money.replace('T', ' ') : '---'
        },
      },
    ],
  })
</script>

<style lang="scss" scoped>
.my-custom-class .el-dialog__wrapper {
  overflow: hidden;
}

.my-custom-class .el-dialog__body::-webkit-scrollbar {
  display: none;
}

.my-custom-class .el-dialog__body {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE 10+ */
  overflow: -moz-scrollbars-none;
  /* Firefox */
}

::v-deep .el-steps {
  flex-flow: wrap;
  overflow: hidden
}

::v-deep .el-step.is-center .el-step__description {
  padding-left: 10px;
  padding-right: 10px;
}

::v-deep .el-step.is-horizontal {
  margin-bottom: 20px;
}

::v-deep .el-step__title {
  line-height: 25px;
}

// ::v-deep .el-dialog__headerbtn {
//   position: fixed;
//   top: 10px;
//   right: 40px;
//   z-index: 10;
// }

// ::v-deep .el-dialog__headerbtn .el-dialog__close {
//   font-size: 30px;
// }

::v-deep .el-step.is-horizontal {
  // flex-basis: 20% !important;
  // max-width: 20% !important
  min-width: 20%;
}
</style>
