<template>
  <ContainerQuery>
    <div slot="tip" class="page-tip-div" style="margin-top: 0">
      <i class="el-icon-info"></i>
      <span>温馨提示：</span>
      <span>1、双击列表可查看对应订单详情</span>
      <span v-if="$route.name === 'OrderQuery'">
        <span>2、订单审核后，会自动生成出库单；</span>
        <span>
          3、待审核订单是可以进行编辑金额操作的，审核后无法进行编辑金额操作！
        </span>
      </span>
      <span v-else>
        <span>2、已审核的上门自提订单会在此列表显示！</span>
        <span>3、订单出库后，可在此页面点击确认收款与确认收货操作！</span>
      </span>
      <span v-if="parseInt(printTag) === 5">
        4、当前页面按键盘【F8】可进行页面刷新
      </span>
    </div>
    <div slot="left">
      <el-dropdown
        v-if="
          $accessCheck($Access.PublishGoodsAddGoods) ||
          $accessCheck($Access.PublishGoodsAddBasicAndPublishGoods)
        "
        split-button
        type="primary"
        @click="goAddOrder"
      >
        代客下单
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <div class="dropdown-div" @click="getData(1)">导出</div>
          </el-dropdown-item>
          <el-dropdown-item>
            <div class="dropdown-div" @click="resetPage">刷新页面</div>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <div v-else>
        <el-button size="small" type="primary" plain @click="getData(1)">
          导出
        </el-button>
        <el-button
          v-if="parseInt(printTag) === 5"
          type="primary"
          plain
          size="small"
          @click="resetPage"
        >
          刷新页面
        </el-button>
      </div>
    </div>
    <el-form v-if="accessSearch" slot="more" size="small" :inline="true">
      <el-form-item>
        <el-input
          v-model="searchDate.keyword"
          clearable
          style="width: 320px"
          placeholder="请输入要搜索的内容"
          @keyup.enter.native="pageChange(1)"
          @clear="pageChange(1)"
        >
          <el-select
            slot="prepend"
            v-model="searchDate.keywordType"
            style="width: 100px"
          >
            <el-option
              v-for="item in keywordType_list"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="pageChange(1)"
          ></el-button>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="options_value"
          multiple
          style="width: 220px"
          placeholder="请选择订单状态"
          @change="pageChange(1)"
        >
          <el-option
            v-for="item in order_status"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="searchDate.Return"
          style="width: 220px"
          multiple
          placeholder="请选择退货状态"
          @change="returnstatus"
        >
          <el-option
            v-for="item in Return_status"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <SelectCustomer
          v-model="customer_name"
          @clear="customerClear"
          @change="customerSel"
        />
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="search_form.time"
          clearable
          type="datetimerange"
          value-format="timestamp"
          range-separator="-"
          start-placeholder="下单开始时间"
          end-placeholder="下单结束时间"
          @change="orderDate"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <SelectShop
          v-model="searchDate.shopId"
          width="220"
          placeholder="所属店铺"
          @clear="clearShop"
          @change="selShop"
        />
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="searchDate.payType"
          clearable
          style="width: 220px"
          placeholder="支付方式"
          @visible-change="paytypevisibleChange"
          @change="pageChange(1)"
        >
          <el-option
            v-for="(item, index) in pay_type_list"
            :key="index"
            :label="item.title"
            :value="item.signId"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="searchDate.customerType"
          clearable
          style="width: 220px"
          placeholder="客户类型"
          @change="customerTypes"
        >
          <el-option
            v-for="(item, index) in customerType"
            :key="index"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="searchDate.source"
          clearable
          style="width: 220px"
          placeholder="订单来源"
          @change="pageChange(1)"
        >
          <el-option
            v-for="(item, index) in order_from"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="searchDate.outStatus"
          clearable
          style="width: 220px"
          placeholder="出库状态"
          @change="pageChange(1)"
        >
          <el-option
            v-for="(item, index) in outStatus_list"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select
          v-model="searchDate.payStatus"
          clearable
          style="width: 220px"
          placeholder="支付状态"
          @change="pageChange(1)"
        >
          <el-option
            v-for="(item, index) in payStatus_list"
            :key="index"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <!--      <el-form-item>-->
      <!--        <el-input-->
      <!--          v-model="goods"-->
      <!--          placeholder="请输入商品名称"-->
      <!--          style="width: 220px"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="getUserList()"-->
      <!--          @clear="getUserList()"-->
      <!--        >-->
      <!--          <el-button-->
      <!--            slot="append"-->
      <!--            icon="el-icon-search"-->
      <!--            @click="getUserList()"-->
      <!--          ></el-button>-->
      <!--        </el-input>-->
      <!--      </el-form-item>-->
    </el-form>
    <!--    <el-tabs-->
    <!--      v-model="searchDate.orderStatus"-->
    <!--      type="card"-->
    <!--      @tab-click="pageChange(1)"-->
    <!--    >-->
    <!--      <el-tab-pane-->
    <!--        v-for="item in order_status"-->
    <!--        :key="item.value"-->
    <!--        :label="item.label"-->
    <!--        :name="item.value"-->
    <!--      ></el-tab-pane>-->
    <!--    </el-tabs>-->
    <el-table
      ref="orderList"
      :data="order_list"
      :row-class-name="tableRowClassName"
      @row-dblclick="goDetail"
      @selection-change="selectOrderChange"
    >
      <el-table-column
        v-if="accessAudit"
        type="selection"
        width="55"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="id"
        label="ID"
        fixed="left"
        width="70"
      ></el-table-column>
      <el-table-column
        v-if="markFlag"
        prop="no"
        label="订单号"
        min-width="180"
        fixed="left"
        :show-overflow-tooltip="true"
      >
        <template slot-scope="scope">
          <span
            v-if="accessDetail"
            class="click-div"
            @click="goDetail(scope.row)"
          >
            {{ scope.row.no }}
          </span>
          <span v-else>{{ scope.row.no }}</span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="clientFlag"
        prop="customerName"
        label="客户"
        show-overflow-tooltip
        min-width="140"
      >
        <template slot-scope="scope">
          <el-popover
            v-if="scope.row.deliveryType !== 2"
            placement="right"
            width="400"
            trigger="click"
          >
            <div>
              <p class="order-info-p">
                <span class="order-info-label">收货人：</span>
                {{ scope.row.receiveData.realName }}
              </p>
              <p class="order-info-p">
                <span class="order-info-label">联系电话：</span>
                {{ scope.row.receiveData.mobile }}
              </p>
              <p
                v-if="scope.row.receiveData && scope.row.receiveData.area"
                class="order-info-p"
              >
                <span class="order-info-label">联系地址：</span>
                {{ scope.row.receiveData.area.provinceName
                }}{{ scope.row.receiveData.area.cityName
                }}{{ scope.row.receiveData.area.districtName
                }}{{ scope.row.receiveData.address }}
              </p>
            </div>
            <span
              slot="reference"
              class="click-div"
              @click="
                $router.push(
                  `/Customer/CustomerAdmin/CustomerDetail/${scope.row.customerId}`
                )
              "
            >
              {{ scope.row.customerName }}
            </span>
          </el-popover>
          <span
            v-else
            class="click-div"
            @click="
              $router.push(
                `/Customer/CustomerAdmin/CustomerDetail/${scope.row.customerId}`
              )
            "
          >
            {{ scope.row.customerName }}
          </span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="moneyFlag"
        prop="payAmount"
        label="订单金额"
        min-width="120"
      >
        <template slot-scope="scope">
          {{ $_common.formattedNumber(scope.row.payAmount) }}
        </template>
      </el-table-column>
      <el-table-column
        v-if="commodityFlag"
        prop="payAmount"
        label="商品"
        min-width="90"
      >
        <template slot-scope="scope">
          <span class="click-div" @click="showGoods(scope.row)">商品明细</span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="indentFlag"
        prop="orderMsg"
        label="订单状态"
        min-width="100"
      >
        <template slot-scope="scope">
          <span
            :class="[
              scope.row.orderMsg === '待审核'
                ? 'warning-status'
                : scope.row.orderMsg === '已关闭'
                ? 'info-status'
                : scope.row.orderMsg === '已出库'
                ? 'primary-status'
                : scope.row.orderMsg === '已完成'
                ? 'success-status'
                : scope.row.orderMsg === '待出库'
                ? 'danger-status'
                : 'primary-status',
            ]"
          >
            {{ scope.row.orderMsg }}
          </span>
        </template>
      </el-table-column>
      <el-table-column v-if="paymentFlag" label="付款状态" min-width="100">
        <template slot-scope="scope">
          <span
            :class="[
              parseInt(scope.row.payStatus) === 4
                ? 'danger-status'
                : parseInt(scope.row.payStatus) === 5
                ? 'success-status'
                : parseInt(scope.row.payStatus) === 5
                ? 'warning-status'
                : 'warning-status',
            ]"
          >
            {{
              parseInt(scope.row.payStatus) === 4
                ? "未支付"
                : parseInt(scope.row.payStatus) === 5
                ? "已支付"
                : parseInt(scope.row.payStatus) === 6
                ? "已退款"
                : parseInt(scope.row.payStatus) === 7
                ? "部分退款"
                : "部分支付"
            }}
          </span>
        </template>
      </el-table-column>
      <el-table-column prop="returnStatus" label="退货状态" min-width="100">
        <template slot-scope="scope">
          <span
            :class="[
              scope.row.returnStatus === 1
                ? 'warning-status'
                : scope.row.returnStatus === 2
                ? 'primary-status'
                : 'success-status',
            ]"
          >
            {{
              scope.row.returnStatus === 1
                ? "部分退货"
                : scope.row.returnStatus === 2
                ? "全部退货"
                : "未退货"
            }}
          </span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="auditFlag"
        prop="auditStatus"
        label="审核状态"
        min-width="100"
      >
        <template slot-scope="scope">
          <span
            :class="[
              parseInt(scope.row.auditStatus) === 1
                ? 'warning-status'
                : parseInt(scope.row.auditStatus) === 2
                ? 'success-status'
                : parseInt(scope.row.auditStatus) === 3
                ? 'danger-status'
                : parseInt(scope.row.auditStatus) === 4
                ? 'warning-status'
                : 'warning-status',
            ]"
          >
            {{
              parseInt(scope.row.auditStatus) === 1
                ? "待审核"
                : parseInt(scope.row.auditStatus) === 2
                ? "已审核"
                : parseInt(scope.row.auditStatus) === 3
                ? "已驳回"
                : parseInt(scope.row.auditStatus) === 4
                ? "审核中"
                : "其他"
            }}
          </span>
        </template>
      </el-table-column>

      <el-table-column
        v-if="distributionFlag"
        prop="deliveryMsg"
        label="配送方式"
        min-width="100"
      >
        <!--        <template slot-scope="scope">-->
        <!--          {{-->
        <!--            parseInt(scope.row.deliveryType) === 1-->
        <!--              ? "快递"-->
        <!--              : parseInt(scope.row.deliveryType) === 3-->
        <!--              ? "物流"-->
        <!--              : parseInt(scope.row.deliveryType) === 2-->
        <!--              ? "上门自提"-->
        <!--              : "其他"-->
        <!--          }}-->
        <!--          <p style="font-weight: bold; color: #67c23a">-->
        <!--            {{ scope.row.verifyCode }}-->
        <!--          </p>-->
        <!--        </template>-->
      </el-table-column>
      <el-table-column
        v-if="payFlag"
        prop="payType"
        label="支付方式"
        min-width="100"
      >
        <template slot-scope="scope">
          {{ scope.row.payTypeMsg }}
        </template>
      </el-table-column>
      <el-table-column
        v-if="staffFlag"
        prop="salesman"
        label="业务员"
        min-width="110"
      >
        <template slot-scope="scope">
          {{ scope.row.salesManName || "未分配" }}
          <el-button
            v-if="!scope.row.salesManName"
            type="text"
            icon="el-icon-edit"
            @click="saleFn(scope.row.id, scope.row.customerId)"
          ></el-button>
        </template>
      </el-table-column>
      <el-table-column
        v-if="sourceFlag"
        prop="source"
        label="订单来源"
        min-width="110"
      >
        <template slot-scope="scope">
          {{
            parseInt(scope.row.source) === 1
              ? "ios"
              : parseInt(scope.row.source) === 2
              ? "安卓"
              : parseInt(scope.row.source) === 3
              ? "微信小程序"
              : parseInt(scope.row.source) === 4
              ? "后台创建"
              : parseInt(scope.row.source) === 5
              ? "H5页面"
              : parseInt(scope.row.source) === 8
              ? "字节跳动小程序"
              : parseInt(scope.row.source) === 6
              ? "pc页面"
              : "其他"
          }}
        </template>
      </el-table-column>
      <el-table-column
        v-if="timeFlag"
        prop="createTime"
        label="创建时间"
        min-width="140"
      >
        <template slot-scope="scope">
          {{ $_common.formatDate(scope.row.createTime) }}
        </template>
      </el-table-column>

      <el-table-column
        v-if="shopFlag"
        prop="shopName"
        label="商铺"
        min-width="120"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <!--<el-table-column
        v-if="parseInt(printTag) === 5"
        prop="printingNum"
        label="打印次数"
        min-width="80"
      ></el-table-column>-->

      <el-table-column label="操作" fixed="right" width="260">
        <template slot="header" slot-scope="scope">
          <span v-if="false">{{ scope.$index }}</span>
          <span class="operation">操作</span>
          <el-popover popper-class="custom-table-checkbox" trigger="click">
            <el-checkbox-group v-model="checkList">
              <el-checkbox
                v-for="(item, index) in columns"
                :key="index"
                :label="item.label"
                @change="change"
              ></el-checkbox>
            </el-checkbox-group>
            <el-button
              slot="reference"
              icon="el-icon-setting"
              type="text"
            ></el-button>
          </el-popover>
        </template>
        <template slot-scope="scope">
          <!--          部分退货-->
          <div v-if="scope.row.returnStatus === 1">
            <el-button
              v-if="accessDetail"
              type="text"
              @click="goDetail(scope.row)"
            >
              查看
            </el-button>
            <el-button
              v-if="accessAudit"
              type="text"
              @click="returnOrder(scope.row)"
            >
              退单
            </el-button>
            <el-popover
              v-if="accessDetail"
              placement="top-start"
              title="请选择打印类型"
              width="300"
              trigger="click"
            >
              <el-button slot="reference" type="text">打印</el-button>
              <el-button-group>
                <el-button type="primary" @click="toPrint(scope.row)">
                  小票打印
                </el-button>
                <el-button type="primary" @click="tagPrint(scope.row)">
                  标签打印
                </el-button>
                <el-button type="primary" @click="openUrl(scope.row)">
                  网页打印
                </el-button>
              </el-button-group>
            </el-popover>
            <el-button
              v-if="parseInt(scope.row.payStatus) === 5"
              type="text"
              @click="logisticsInformation(scope.row)"
            >
              物流
            </el-button>
            <el-button
              v-if="parseInt(scope.row.payStatus) === 5"
              type="text"
              @click="expressInformation(scope.row)"
            >
              快递
            </el-button>
          </div>
          <!-- 全部退货-->
          <div v-else-if="scope.row.returnStatus === 2">
            <el-button
              v-if="accessDetail"
              type="text"
              @click="goDetail(scope.row)"
            >
              查看
            </el-button>
            <el-popover
              v-if="accessDetail"
              placement="top-start"
              title="请选择打印类型"
              width="300"
              trigger="click"
            >
              <el-button slot="reference" type="text">打印</el-button>
              <el-button-group>
                <el-button type="primary" @click="toPrint(scope.row)">
                  小票打印
                </el-button>
                <el-button type="primary" @click="tagPrint(scope.row)">
                  标签打印
                </el-button>
                <el-button type="primary" @click="openUrl(scope.row)">
                  网页打印
                </el-button>
              </el-button-group>
            </el-popover>
          </div>
          <div v-else-if="scope.row.orderMsg === '待审核'">
            <el-button
              v-if="$accessCheck($Access.newOrderListEdit)"
              type="text"
              @click="
                $router.push(
                  `/order/manageO/OrderEdit/${scope.row.userCenterId}/${scope.row.id}`
                )
              "
            >
              编辑
            </el-button>
            <el-button
              v-if="accessAudit && parseInt(scope.row.payStatus) !== 3"
              type="text"
              :disabled="
                scope.row.payType === '9' &&
                scope.row.payStatus === 4 &&
                parseInt(scope.row.payStatus) === 4
              "
              @click="updateAuditStatus(scope.row)"
            >
              审核
            </el-button>
            <el-button
              v-if="
                scope.row.payType === '9' &&
                scope.row.orderMsg === '待审核' &&
                parseInt(scope.row.payStatus) === 4
              "
              type="text"
              @click="payment(scope.row)"
            >
              收款
            </el-button>
            <el-button
              v-if="$accessCheck($Access.orderQueryUpdateOrderStatus)"
              type="text"
              @click="updateOrderStatus(scope.row)"
            >
              取消
            </el-button>
            <el-dropdown v-if="accessDetail">
              <span class="el-dropdown-link">
                更多
                <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <div class="dropdown-div">
                    <el-popover
                      placement="top-start"
                      title="请选择打印类型"
                      width="300"
                      trigger="click"
                    >
                      <div slot="reference">打印</div>
                      <el-button-group>
                        <el-button type="primary" @click="toPrint(scope.row)">
                          小票打印
                        </el-button>
                        <el-button type="primary" @click="tagPrint(scope.row)">
                          标签打印
                        </el-button>
                        <el-button type="primary" @click="openUrl(scope.row)">
                          网页打印
                        </el-button>
                      </el-button-group>
                    </el-popover>
                  </div>
                </el-dropdown-item>
                <el-dropdown-item>
                  <div class="dropdown-div" @click="goDetail(scope.row)">
                    查看
                  </div>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <div v-else-if="scope.row.orderMsg === '待出库'">
            <el-button
              v-if="accessDetail"
              type="text"
              @click="goDetail(scope.row)"
            >
              查看
            </el-button>
            <el-button
              v-if="accessAudit"
              type="text"
              @click="deAudit(scope.row)"
            >
              驳回
            </el-button>
            <el-popover
              v-if="accessDetail"
              placement="top-start"
              title="请选择打印类型"
              width="300"
              trigger="click"
            >
              <el-button slot="reference" type="text">打印</el-button>
              <el-button-group>
                <el-button type="primary" @click="toPrint(scope.row)">
                  小票打印
                </el-button>
                <el-button type="primary" @click="tagPrint(scope.row)">
                  标签打印
                </el-button>
                <el-button type="primary" @click="openUrl(scope.row)">
                  网页打印
                </el-button>
              </el-button-group>
            </el-popover>
          </div>
          <div v-else-if="scope.row.orderMsg === '部分出库'">
            <el-button type="text" @click="reStockOut(scope.row)">
              再次出库
            </el-button>
            <el-button type="text" @click="retAmount(scope.row)">
              {{
                parseInt(scope.row.payStatus) === 5 ? "一键退款" : "一键完结"
              }}
            </el-button>
            <el-dropdown v-if="accessDetail">
              <span class="el-dropdown-link">
                更多
                <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <div class="dropdown-div">
                    <el-popover
                      placement="top-start"
                      title="请选择打印类型"
                      width="300"
                      trigger="click"
                    >
                      <div slot="reference">打印</div>
                      <el-button-group>
                        <el-button type="primary" @click="toPrint(scope.row)">
                          小票打印
                        </el-button>
                        <el-button type="primary" @click="tagPrint(scope.row)">
                          标签打印
                        </el-button>
                        <el-button type="primary" @click="openUrl(scope.row)">
                          网页打印
                        </el-button>
                      </el-button-group>
                    </el-popover>
                  </div>
                </el-dropdown-item>
                <el-dropdown-item>
                  <div class="dropdown-div" @click="goDetail(scope.row)">
                    查看
                  </div>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <!--          scope.row.returnStatus === 1 -->
          <div v-else-if="scope.row.orderMsg === '已出库'">
            <el-button
              v-if="accessDetail"
              type="text"
              @click="goDetail(scope.row)"
            >
              查看
            </el-button>
            <el-button
              v-if="accessAudit"
              type="text"
              @click="returnOrder(scope.row)"
            >
              退单
            </el-button>
            <el-popover
              v-if="accessDetail"
              placement="top-start"
              title="请选择打印类型"
              width="300"
              trigger="click"
            >
              <el-button slot="reference" type="text">打印</el-button>
              <el-button-group>
                <el-button type="primary" @click="toPrint(scope.row)">
                  小票打印
                </el-button>
                <el-button type="primary" @click="tagPrint(scope.row)">
                  标签打印
                </el-button>
                <el-button type="primary" @click="openUrl(scope.row)">
                  网页打印
                </el-button>
              </el-button-group>
            </el-popover>
            <el-button
              v-if="parseInt(scope.row.deliveryType) === 3"
              type="text"
              @click="logisticsInformation(scope.row)"
            >
              物流
            </el-button>
            <el-button
              v-if="parseInt(scope.row.deliveryType) === 1"
              type="text"
              @click="expressInformation(scope.row)"
            >
              快递
            </el-button>
          </div>
          <div v-else-if="scope.row.orderMsg === '待取消'">
            <el-button
              v-if="accessDetail"
              type="text"
              @click="goDetail(scope.row)"
            >
              查看
            </el-button>
            <el-button type="text" @click="cancelOrderAdit(scope.row)">
              取消审核
            </el-button>
          </div>
          <div v-else-if="['已完成', '已关闭'].includes(scope.row.orderMsg)">
            <el-button
              v-if="accessAudit && scope.row.orderMsg === '已完成'"
              type="text"
              @click="returnOrder(scope.row)"
            >
              退单
            </el-button>
            <el-button
              v-if="accessDetail"
              type="text"
              @click="goDetail(scope.row)"
            >
              查看
            </el-button>
            <el-popover
              v-if="accessDetail"
              placement="top-start"
              title="请选择打印类型"
              width="300"
              trigger="click"
            >
              <el-button slot="reference" type="text">打印</el-button>
              <el-button-group>
                <el-button type="primary" @click="toPrint(scope.row)">
                  小票打印
                </el-button>
                <el-button type="primary" @click="tagPrint(scope.row)">
                  标签打印
                </el-button>
                <el-button type="primary" @click="openUrl(scope.row)">
                  网页打印
                </el-button>
              </el-button-group>
            </el-popover>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <FooterPage
      :page-size="pageSize"
      :total-page.sync="total"
      :current-page.sync="page"
      @pageChange="pageChange"
      @sizeChange="sizeChange"
    >
      <div v-if="accessAudit" slot="btn-div" class="foot-btn-div">
        <span class="batch-checkbox">
          <el-checkbox
            v-model="checkedAll"
            @change="checkAllChange"
          ></el-checkbox>
        </span>
        <el-button
          :loading="batch_audit_load"
          size="mini"
          @click="batchUpdateAuditStatus"
        >
          批量审核
        </el-button>
        <el-button size="mini" @click="batchPrinting">批量打印</el-button>
      </div>
    </FooterPage>
    <staffListModal
      v-if="staff_show"
      :is-show="staff_show"
      :is-check="false"
      @cancel="staff_show = false"
      @confirm="staffSel"
    />
    <el-dialog
      v-if="is_show_goods"
      title="商品明细"
      :visible.sync="is_show_goods"
    >
      <el-table :data="goodsDataD">
        <el-table-column
          property="goodsName"
          label="商品名称"
          show-overflow-tooltip
          min-width="140"
        ></el-table-column>
        <el-table-column
          property="goodsCode"
          label="商品编码"
          min-width="140"
        ></el-table-column>
        <el-table-column property="unitName" label="规格" min-width="140">
          <template slot-scope="prop">
            {{ prop.row.unitName }}；
            <span v-for="(item, index) in prop.row.specGroup" :key="index">
              {{ item.specValueName }}；
            </span>
          </template>
        </el-table-column>

        <el-table-column property="price" label="单价" min-width="100">
          <template slot-scope="scope">
            {{ $_common.formattedNumber(scope.row.price) }}
          </template>
        </el-table-column>
        <el-table-column property="buyNum" label="购买数量" min-width="140">
          <template slot-scope="scope">
            {{ $_common.formatNub(scope.row.buyNum) }}
            <span v-if="scope.row.isEq === 5">
              <span v-if="!!scope.row.u_1_buy">
                （{{ scope.row.u_1_buy }}{{ scope.row.u_1 }}）
              </span>
              <span v-else>
                （{{ $_common.formatNub(scope.row.otherNum) }}）
              </span>
            </span>
          </template>
        </el-table-column>
        <el-table-column property="totalMoney" label="商品总价" min-width="120">
          <template slot-scope="scope">
            {{ $_common.formattedNumber(scope.row.totalMoney) }}
          </template>
        </el-table-column>
        <el-table-column property="deliverNum" label="发货数量" min-width="100">
          <template slot-scope="scope">
            {{ $_common.formatNub(scope.row.deliverNum) }}
          </template>
        </el-table-column>
        <el-table-column
          property="barCode"
          label="商品条码"
          min-width="120"
        ></el-table-column>
        <el-table-column
          property="storage"
          label="货架编码"
          min-width="120"
        ></el-table-column>
      </el-table>
    </el-dialog>
    <OrderOut
      v-if="show_out"
      :receive-data="received_data"
      :out-id="out_id"
      :is-show="show_out"
      @cancel="show_out = false"
      @confirm="orderAuditConfirm"
    ></OrderOut>
    <LogisticsData
      v-if="logisticsFlag"
      :show="logisticsFlag"
      :num="false"
      :type="5"
      :order-id="logisticsList.id"
      :user-center-id="logisticsList.userCenterId"
      @cancel="logisticsFlag = false"
    ></LogisticsData>
    <tagPrint
      v-if="print_show"
      v-model="print_show"
      :order-id="print_order_id"
      :user-center-id="print_user_center_id"
      @close="print_show = false"
    ></tagPrint>
    <vxe-modal
      v-model="balanceAdjustment"
      title="收款"
      width="500"
      min-height="400"
      resize
      remember
      @close="closeBalanceAdjustment('formData')"
    >
      <template #default>
        <el-form
          ref="formData"
          :model="formData"
          :rules="rules1"
          label-width="100px"
        >
          <el-form-item label="商品总额:">
            {{ formData.payAmount }}
          </el-form-item>
          <el-form-item label="收款账户:">
            <el-input
              v-model="formData.accountName"
              readonly
              style="width: 300px"
              size="small"
              placeholder="结算账户"
            >
              <i
                slot="suffix"
                class="el-input__icon el-icon-search"
                @click="account_show = true"
              ></i>
            </el-input>
          </el-form-item>
          <el-form-item label="收款金额:" prop="money">
            <el-input-number
              v-model="formData.money"
              :controls="false"
              style="width: 300px"
              :min="0"
              placeholder="请输入收款金额"
            ></el-input-number>
          </el-form-item>
          <el-form-item label="优惠金额:">
            <el-input-number
              v-model="formData.discountMoney"
              :controls="false"
              style="width: 300px"
              :min="0"
              placeholder="请输优惠入金额"
            ></el-input-number>
          </el-form-item>

          <el-form-item>
            <el-button @click="closeBalanceAdjustment('formData')">
              取 消
            </el-button>
            <el-button type="primary" @click="addReceived">确 定</el-button>
          </el-form-item>
        </el-form>
      </template>
    </vxe-modal>
    <vxe-modal v-model="cancel_tip" width="500" title="取消订单审核">
      <template #default>
        <p style="line-height: 30px">客户发起取消订单:{{ cancel_reason }}</p>
        <p style="line-height: 30px">
          是否同意客户取消订单，如果拒绝，请输入拒绝原因
        </p>
        <vxe-input
          v-model="cancelRejectReason"
          style="width: 100%"
          placeholder="拒绝原因"
        ></vxe-input>
        <div slot="footer" style="text-align: right; padding-top: 20px">
          <el-button type="danger" @click="cancelReject">拒绝</el-button>
          <el-button type="primary" @click="cancelConfirm">同意</el-button>
        </div>
      </template>
    </vxe-modal>
    <AccountType
      v-if="account_show"
      :is-check="false"
      :is-show="account_show"
      :is-mem="1"
      @cancel="account_show = false"
      @confirm="accountsel"
    />
  </ContainerQuery>
</template>

<script>
  import { getCustomerInfo } from "@/api/Customer";
  import staffListModal from "@/component/common/staffListModal";
  import OrderOut from "@/views/order/components/OrderOut.vue";
  import tagPrint from "../components/tagPrint";
  import LogisticsData from "../components/LogisticsData";
  import { mapGetters } from "vuex";
  import {
    getOrderInfoById,
    getAllOrder,
    exportGetAllOrder,
    updateOrderStatus,
    updateAuditStatus,
    setSalesMan,
    revokeAudit,
    reStockOut,
    retAmount,
    batchUpdateAuditStatus,
    exportKeywordSearch,
    keywordSearch,
  } from "@/api/Order";
  import { getAllCustomerSource, getAllPayment } from "@/api/System";
  import { addReceived } from "@/api/Finance";
  import { toPrint } from "@/api/common";
  import SelectShop from "@/component/goods/SelectShop.vue";
  import SelectCustomer from "@/component/common/SelectCustomer.vue";
  import AccountType from "../../Finance/AccountType";

  export default {
    name: "NewOrderList",
    components: {
      staffListModal,
      SelectShop,
      SelectCustomer,
      OrderOut,
      LogisticsData,
      tagPrint,
      AccountType,
    },

    data() {
      return {
        cancel_reason: "",
        order_item: {},
        cancelRejectReason: "", // 拒绝取消审核原因
        account_show: false,
        cancel_tip: false,
        formData: {
          customerId: "",
          customerName: "",
          shopId: "",
          shopName: "",
          id: "",
          no: "",
          payAmount: "",
          discountMoney: "",
          money: "",
          accountId: "",
          accountNumber: "",
          accountName: "",
        },
        rules1: {
          money: [
            { required: true, message: "请输入收款金额", trigger: "blur" },
          ],
        },
        Return_status: [
          {
            label: "未退货",
            value: 0,
          },
          {
            label: "部分退货",
            value: 1,
          },
          {
            label: "全部退货",
            value: 2,
          },
        ],
        print_user_center_id: "",
        print_order_id: "",
        goods: "",
        print_show: false,
        options_value: [],
        received_data: {},
        customerType: [],
        batch_audit_load: false,
        checkedAll: false,
        is_show_goods: false,
        selected_order: [],
        staff_show: false,
        order_list: [],
        goodsDataD: [],
        order_from: [
          {
            label: "ios",
            value: 1,
          },

          {
            label: "安卓",
            value: 2,
          },
          {
            label: "微信小程序",
            value: 3,
          },
          {
            label: "后台创建",
            value: 4,
          },
          {
            label: "H5页面",
            value: 5,
          },
          {
            label: "pc页面",
            value: 6,
          },
          {
            label: "字节跳动小程序",
            value: 8,
          },
        ],
        pay_type_list: [],
        order_status: [
          // {
          //   label: "全部",
          //   value: "all",
          // },
          {
            label: "待审核", // 新订单】
            value: "waitAudit",
          },
          {
            label: "待出库", // 等待出库
            value: "waitOutStock",
          },
          {
            label: "已出库", // 已出库
            value: "hasOutStock",
          },
          {
            label: "已完成", // 已收货
            value: "finish",
          },
          {
            label: "已关闭", // 已取消
            value: "close",
          },
        ],
        region_options: [],
        total: 0,
        page: 1,
        pageSize: 10,
        search_form: {
          time: [],
          region: [],
          user: "",
          order_type: "",
          shopId: "",
          money_type: "",
          customType: "",
          staff: "",
        },
        customer_name: "",
        searchDate: {
          Return: "",
          keyword: "",
          orderStatus: "all",
          payType: "",
          provinceCode: "",
          cityCode: "",
          districtCode: "",
          start: "",
          end: "",
          customerId: "",
          customerType: "",
          salesManId: "",
          source: "",
          shopId: "",
          keywordType: 1,
          outStatus: "",
          payStatus: "",
        },
        payStatus_list: [
          {
            label: "未支付",
            value: 4,
          },
          {
            label: "已支付",
            value: 5,
          },
        ],
        salesManId: "",
        receiveData: [],
        deliveryType: "",
        auditStatus: "",
        // 权限
        accessAdd: true,
        accessAudit: true,
        accessSearch: true,
        accessDetail: true,
        isserch: true,
        order_id: "",
        checkList: [
          "创建时间",
          "客户",
          "订单金额",
          "商品",
          "订单状态",
          "付款状态",
          "审核状态",
          "配送方式",
          "支付方式",
          "所属员工",
          "订单来源",
          "订单号",
          "商铺",
        ],
        columns: [
          {
            label: "创建时间",
          },
          {
            label: "客户",
          },
          {
            label: "订单金额",
          },
          {
            label: "商品",
          },
          {
            label: "订单状态",
          },
          {
            label: "付款状态",
          },
          {
            label: "审核状态",
          },
          {
            label: "配送方式",
          },
          {
            label: "支付方式",
          },
          {
            label: "所属员工",
          },
          {
            label: "订单来源",
          },
          {
            label: "订单号",
          },
          {
            label: "商铺",
          },
        ],
        timeFlag: true,
        clientFlag: true,
        moneyFlag: true,
        commodityFlag: true,
        indentFlag: true,
        paymentFlag: true,
        auditFlag: true,
        distributionFlag: true,
        payFlag: true,
        staffFlag: true,
        sourceFlag: true,
        markFlag: true,
        shopFlag: true,
        logisticsFlag: false,
        rules: {
          freight_information: [
            { required: true, message: "请输入货车车牌", trigger: "blur" },
          ],
          van_phone: [
            { required: true, message: "请输入货车电话", trigger: "blur" },
          ],
        },
        show_out: false,
        out_id: "",
        out_detail: {},
        logisticsList: {},
        loading: false,
        balanceAdjustment: false,
        keywordType_list: [
          {
            label: "单据编号",
            value: 1,
          },
          {
            label: "自提码",
            value: 2,
          },
          {
            label: "商品名称",
            value: 3,
          },
          {
            label: "商品编码",
            value: 4,
          },
          {
            label: "收货人",
            value: 5,
          },
          {
            label: "电话",
            value: 6,
          },
          {
            label: "业务员",
            value: 7,
          },
          {
            label: "详细地址",
            value: 8,
          },
        ],
        outStatus_list: [
          {
            label: "未出库",
            value: 4,
          },
          {
            label: "已出库",
            value: 5,
          },
          {
            label: "部分出库",
            value: 6,
          },
        ],
      };
    },
    computed: {
      ...mapGetters({
        printTag: "MUser/printTag",
      }),
    },
    async mounted() {
      this.deliveryType = parseInt(this.$route.query.type) || "";
      if (this.$route.name === "NewOrderList") {
        this.auditStatus = 1;
        this.accessAdd = this.$accessCheck(this.$Access.newOrderListAddOrder);
        this.accessAudit = this.$accessCheck(
          this.$Access.newOrderLitUpdateAuditStatus
        );
        this.accessSearch = this.$accessCheck(this.$Access.newOrderLitSearch);
      } else if (this.$route.name === "OrderQuery") {
        this.auditStatus = 2;
        this.accessAdd = this.$accessCheck(this.$Access.orderQueryAddOrder);
        this.accessAudit = this.$accessCheck(
          this.$Access.orderQueryUpdateAuditStatus
        );
        this.accessSearch = this.$accessCheck(this.$Access.orderQuerySearch);
      }
      this.accessDetail = this.$accessCheck(
        this.$Access.newOrderLitGetOrderInfoById
      );
      // 到期提示
      this.enterExpireTime();
      await this.getAllOrder();
      await this.getAllPayment();
      await this.getAllCustomerSource();
    },
    activated() {
      if (this.$_isInit()) return;
      this.getData();
    },
    methods: {
      async showGoods(row) {
        const { data } = await getOrderInfoById(row.userCenterId, {
          orderId: row.id,
        });

        this.is_show_goods = true;
        this.goodsDataD = data.goodsData;
      },
      returnOrder(row) {
        const allowReturn = row.allowReturn;
        const allowReturnDay = row.allowReturnDay;
        if (allowReturn === 4) {
          this.$confirm(
            `已经超过${allowReturnDay}天,建议不能退货, 是否确定强制退货?`,
            "提醒",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }
          ).then(() => {
            this.$message({
              type: "error",
              message: "你已确定强制退货!",
            });
          });
          this.$router.push(
            `/order/manageO/AddWareOrder?userCenterId=${row.userCenterId}&orderId=${row.id}`
          );
        } else {
          this.$router.push(
            `/order/manageO/AddWareOrder?userCenterId=${row.userCenterId}&orderId=${row.id}`
          );
        }
      },
      // 客户类型
      async getAllCustomerSource() {
        if (this.customerType.length) {
          return;
        }
        const data = await getAllCustomerSource({
          page: 1,
          pageSize: 999,
        });

        this.customerType = data.data;
      },
      customerTypes(val) {
        this.searchDate.customerType = val;
        this.pageChange(1);
      },
      clearShop() {
        this.searchDate.shopId = "";
        this.pageChange(1);
      },
      selShop(val) {
        this.pageChange(1);
      },
      // 获取列表
      async getAllOrder(exports) {
        let search = {};
        if (this.deliveryType) {
          search.deliveryType = 2;
        }
        // if (this.$route.name === "NewOrderList") {
        //   this.searchDate.orderStatus = "waitAudit";
        //   search.auditStatus = 1;
        // }
        // if (this.$route.name === "OrderQuery") {
        //   search.auditStatus = 2;
        // }
        let params = {
          page: this.page,
          pageSize: this.pageSize,
          search: search,
        };
        if (exports) {
          params.export = 1;
          const target = await exportGetAllOrder({
            ...params,
            state: this.options_value,
          });
        } else {
          const data = await getAllOrder({
            ...params,
            state: this.options_value,
          });

          this.order_list = data.data;
          this.total = data.pageTotal;
        }
      },
      // 支付方式展开
      paytypevisibleChange(val) {
        if (val && !this.pay_type_list.length) {
          this.getAllPayment();
        }
      },
      // 获取支付方式
      async getAllPayment() {
        if (this.pay_type_list.length) {
          return;
        }
        const data = await getAllPayment({
          page: 1,
          pageSize: 20,
        });

        this.pay_type_list = data.data;
      },
      // 订单搜索searchOrder
      async keywordSearch(exports) {
        const params = {
          keywordType: this.searchDate.keywordType,
          keyword: this.searchDate.keyword,
          payType: this.searchDate.payType,
          shopId: this.searchDate.shopId,
          startTime: this.searchDate.start,
          endTime: this.searchDate.end,
          customerId: this.searchDate.customerId,
          customerType: this.searchDate.customerType,
          source: this.searchDate.source,
          page: this.page,
          pageSize: this.pageSize,
          returnStatus: this.searchDate.Return,
          state: this.options_value,
          outStatus: this.searchDate.outStatus,
          payStatus: this.searchDate.payStatus,
        };
        if (this.deliveryType) {
          params.deliveryType = 2;
        }
        if (exports) {
          const target = await exportKeywordSearch({
            ...params,
            export: 1,
          });
        } else {
          const data = await keywordSearch({
            ...params,
          });
          this.order_list = data.data;
          this.total = data.pageTotal;
        }
      },
      //  判断
      getData(exports) {
        const obj = {
          keyword: this.searchDate.keyword,
          payType: this.searchDate.payType,
          shopId: this.searchDate.shopId,
          startTime: this.searchDate.start,
          endTime: this.searchDate.end,
          customerId: this.searchDate.customerId,
          customerType: this.searchDate.customerType,
          source: this.searchDate.source,
          returnStatus: this.searchDate.Return,
          outStatus: this.searchDate.outStatus,
          payStatus: this.searchDate.payStatus,
        };
        const isKey = this.$_common.isSerch(obj);
        if (isKey) {
          this.keywordSearch(exports);
        } else {
          this.getAllOrder(exports);
        }
      },
      // 选择员工
      staffSel(val) {
        const row = val[0];
        this.$confirm("确定要分配给该业务员吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          this.setSalesMan(row.id, row.staffName);
        });
      },
      // 清除员工输入框
      staffClear() {
        this.searchDate.salesManId = "";
        this.search_form.staff = "";
        this.pageChange(1);
      },
      // 选择客户
      customerSel(val, list) {
        this.searchDate.customerId = list[0].id;
        this.pageChange(1);
      },
      customerClear() {
        this.searchDate.customerId = "";
        this.customer_name = "";
        this.pageChange(1);
      },
      //退货状态
      returnstatus() {
        this.pageChange(1);
      },
      //  选择区域region
      regionChange(val) {
        if (val && val.length) {
          this.searchDate.provinceCode = val[0];
          this.searchDate.cityCode = val[1];
          this.searchDate.districtCode = val[2];
        } else {
          this.searchDate.provinceCode = "";
          this.searchDate.cityCode = "";
          this.searchDate.districtCode = "";
        }
        this.pageChange(1);
      },
      //  订单时间
      orderDate(val) {
        if (val && val.length) {
          this.searchDate.start = parseInt(val[0] / 1000);
          this.searchDate.end = parseInt(val[1] / 1000);
        } else {
          this.searchDate.start = "";
          this.searchDate.end = "";
        }
        this.pageChange(1);
      },
      // 切页
      pageChange(val) {
        this.page = val;
        this.getData();
      },
      // 每页数据大小改变
      sizeChange(val) {
        this.pageSize = val;
        this.pageChange(1);
      },
      goAddOrder() {
        this.$router.push({
          path: "/order/manageO/OrderAdd",
        });
      },
      goDetail(row) {
        if (!this.accessDetail) {
          return;
        }
        this.$router.push({
          path: `/order/manageO/OrderDetails/${row.userCenterId}/${row.id}`,
        });
      },
      openUrl(row) {
        // const params = { userCenterId: row.userCenterId, id: row.id }
        let routeData = this.$router.resolve({
          path: `/OrderPrinting/${row.userCenterId}/${row.id}`,
        });
        window.open(routeData.href, "_blank");
      },
      // 单据小票打印
      async toPrint(row) {
        const data = await toPrint({
          objectId: row.id,
          objectType: 1, // 销售单
        });

        this.$message({
          type: "success",
          message: "操作成功",
        });
      },
      // 取消订单
      async updateOrderStatus(row) {
        this.$prompt("请输入取消订单原因", "取消订单", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        }).then(async ({ value }) => {
          const data = await updateOrderStatus(row.userCenterId, {
            orderId: row.id,
            orderStatus: 6,
            cancelReason: value,
          });
          this.$message({
            type: "success",
            message: "取消订单成功,您的取消原因是: " + value,
          });
          this.pageChange(1);
        });
        // this.$confirm("确定要取消该订单吗?", "提示", {
        //   confirmButtonText: "确定",
        //   cancelButtonText: "取消",
        //   type: "warning",
        // }).then(async () => {
        //   const data = await updateOrderStatus(row.userCenterId, {
        //     orderId: row.id,
        //   });
        //
        //   this.$message({
        //     type: "success",
        //     message: "操作成功",
        //   });
        //   this.getData();
        // });
      },
      // 批量选择订单
      selectOrderChange(val) {
        this.checkedAll = val.length === this.order_list.length;
        this.selected_order = val;
      },
      // 批量审核订单
      batchUpdateAuditStatus() {
        let flag = false;
        this.selected_order.forEach((item) => {
          if (item.payType === "4" && !item.extends) {
            flag = true;
            this.$message.warning("银行打款需要上传支付凭证才可以审核！");
            return;
            if (item.payType === "4" && item.extends.bankData.length === 0) {
              flag = true;
              this.$message.warning("银行打款需要上传支付凭证才可以审核！");
              return;
            }
          }
        });
        if (flag) {
          // this.$message.warning("银行打款需要上传支付凭证才可以审核！");
          return;
        }
        if (!this.selected_order.length) {
          this.$message.warning("请选择要审核的订单");
          return;
        }
        this.$confirm("是否要批量审核订单吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          this.batch_audit_load = true;
          try {
            const orderIds = this.selected_order.map((item) => {
              return item.id;
            });
            const data = await batchUpdateAuditStatus({
              orderIds: orderIds,
              audit: this.userName,
              auditStatus: 2,
            });
            this.batch_audit_load = false;
            this.$message.success("审核成功");
            this.getData();
          } finally {
            this.batch_audit_load = false;
          }
        });
      },
      // 批量打印
      batchPrinting() {
        if (!this.selected_order.length) {
          this.$message.warning("请选择要打印的订单");
          return;
        }
        const ids = this.selected_order.map((item) => item.id);
        let routeData = this.$router.resolve({
          path: `/OrderPrintingBetch?ids=${ids}`,
        });
        window.open(routeData.href, "_blank");
      },
      // 标签打印
      tagPrint(row) {
        this.print_order_id = row.id;
        this.print_user_center_id = row.userCenterId;
        this.print_show = true;
      },
      // 审核订单
      async updateAuditStatus(row) {
        if (row.payType === "4" && !row.extends) {
          this.$message.warning("银行打款需要上传支付凭证才可以审核！");
          return;
        }
        if (row.payType === "4" && row.extends.bankData.length === 0) {
          this.$message.warning("银行打款需要上传支付凭证才可以审核！");
          return;
        }
        this.$confirm("确定要审核通过该订单吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          const data = await updateAuditStatus(row.userCenterId, {
            orderId: row.id,
            auditStatus: 2,
            audit: this.userName,
          });

          this.getData();
          this.$confirm("订单审核成功，是否前去打印?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            this.openUrl(row);
          });
        });
      },
      // 驳回订单
      async deAudit(row) {
        this.$confirm("确定要驳回该订单吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          const data = await revokeAudit(row.id);
          this.$message.success("订单驳回成功！");
          this.getData();
        });
      },
      checkAllChange() {
        this.$refs.orderList.toggleAllSelection();
      },
      async saleFn(id, cutomerid) {
        if (id) {
          this.order_id = id;
        }
        await this.getCustomerInfo(cutomerid);
      },

      //  客户详情 getCustomerInfo
      async getCustomerInfo(cutomerid) {
        const { data } = await getCustomerInfo(cutomerid);
        if (data.salesManId) {
          await this.setSalesMan(data.salesManId, data.salesManName, 5);
        } else {
          this.staff_show = true;
        }
      },

      async setSalesMan(id, salesManName, ifSalesMan) {
        const data = await setSalesMan({
          orderId: this.order_id,
          salesManName: salesManName,
          salesManId: id,
          ifSalesMan: ifSalesMan || 4,
        });
        this.$message.success("分配成功！");
        this.getData();
      },
      tableRowClassName({ row, rowIndex }) {
        if (parseInt(this.printTag) === 5 && row.printingNum > 0) {
          return "print-row";
        }
        return "";
      },
      // 刷新页面
      resetPage() {
        this.getData();
      },
      change() {
        this.timeFlag = this.checkList.some((item) => item === "创建时间");
        this.clientFlag = this.checkList.some((item) => item === "客户");
        this.moneyFlag = this.checkList.some((item) => item === "订单金额");
        this.commodityFlag = this.checkList.some((item) => item === "商品");
        this.indentFlag = this.checkList.some((item) => item === "订单状态");
        this.paymentFlag = this.checkList.some((item) => item === "付款状态");
        this.auditFlag = this.checkList.some((item) => item === "审核状态");
        this.distributionFlag = this.checkList.some(
          (item) => item === "配送方式"
        );
        this.payFlag = this.checkList.some((item) => item === "支付方式");
        this.staffFlag = this.checkList.some((item) => item === "所属员工");
        this.sourceFlag = this.checkList.some((item) => item === "订单来源");
        this.markFlag = this.checkList.some((item) => item === "订单号");
        this.shopFlag = this.checkList.some((item) => item === "商铺");
      },
      // 再次出库
      async reStockOut(row) {
        this.$confirm("是否确认订单再次出库?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(async () => {
          const { data } = await reStockOut(row.id);
          this.$message.success("再次出库成功");
          this.getData();
        });
      },
      expressInformation(row) {
        this.out_id = row.id;
        this.out_detail = row;

        this.received_data = {
          ...row.receiveData,
          orderId: row.id,
          deliveryNo: row.deliveryNo,
          expressId: row.expressId,
          expressName: row.expressName,
          page: "order",
        };
        this.show_out = true;
      },
      orderAuditConfirm() {
        this.getData();
        this.show_out = false;
      },
      logisticsInformation(row) {
        if (row.orderMsg === "待出库" || row.orderMsg === "待审核") {
          this.$message("请先审核");
          return;
        }
        this.logisticsFlag = true;
        this.logisticsList = row;
      },
      // 一键退款
      retAmount(row) {
        this.$confirm(
          `确定${parseInt(row.payStatus) === 5 ? "一键退款" : "一键完结"}吗?`,
          "提示",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        ).then(async () => {
          const { data } = await retAmount({
            orderId: row.id,
          });
          this.$message({
            type: "success",
            message: data,
          });
          this.getData();
        });
      },
      payment(row) {
        this.balanceAdjustment = true;
        this.formData = {
          customerId: row.customerId,
          customerName: row.customerName,
          shopId: row.shopId,
          shopName: row.shopName,
          id: row.id,
          no: row.no,
          payAmount: row.payAmount,
          discountMoney: "",
          money: "",
          accountId: "",
          accountNumber: "",
          accountName: "",
        };
      },
      accountsel(val) {
        this.formData.accountId = val[0].id;
        this.formData.accountNumber = val[0].accountNumber;
        this.formData.accountName = val[0].name;
      },
      closeBalanceAdjustment(formData) {
        this.balanceAdjustment = false;
        this.formData = {
          customerId: "",
          customerName: "",
          shopId: "",
          shopName: "",
          id: "",
          no: "",
          payAmount: "",
          discountMoney: "",
          money: "",
          accountId: "",
          accountNumber: "",
          accountName: "",
        };
        this.$refs[formData].resetFields();
        this.pageChange(1);
      },
      async addReceived() {
        if (!this.formData.accountId) {
          this.$message.warning("请选择收款账户");
          return;
        }
        if (!this.formData.money) {
          this.$message.warning("请输入收款金额");
          return;
        }
        const { data } = await addReceived({
          accountList: [
            {
              accountId: this.formData.accountId,
              accountName: this.formData.accountName,
              accountNumber: this.formData.accountNumber,
              discountMoney: this.formData.discountMoney,
              money: this.formData.money,
              finalMoney: this.formData.money - this.formData.discountMoney,
              payWay: "",
              remark: "",
            },
          ],
          createTime: "",
          currentAccountName: this.userName,
          customerId: this.formData.customerId,
          customerName: this.formData.customerName,
          financeTypeId: 2,
          financeType: "销售收款",
          receiptTime: new Date().getTime() / 1000,
          shopId: this.formData.shopId,
          shopName: this.formData.shopName,
          sourceNo: this.formData.no,
          sourceId: this.formData.id,
          originId: this.formData.id,
          originNo: this.formData.no,
          sourceNoMoney: "",
        });
        this.$message.success("收款单创建成功！");
        this.closeBalanceAdjustment("formData");
      },
      // 取消订单审核
      cancelOrderAdit(row) {
        this.order_item = row;
        this.cancel_reason = row.extends.cancelReason;
        this.cancel_tip = true;
      },
      async cancelReject() {
        if (!this.cancelRejectReason) {
          this.$message({
            type: "warning",
            message: "请输入拒绝原因",
          });
          return;
        }
        const data = await updateOrderStatus(this.order_item.userCenterId, {
          orderId: this.order_item.id,
          orderStatus: 7,
          cancelRejectReason: this.cancelRejectReason,
        });
        this.$message({
          type: "success",
          message:
            "您已拒绝客户的取消订单申请,原因是: " + this.cancelRejectReason,
        });
        this.cancel_tip = false;
        this.pageChange(this.page);
      },
      async cancelConfirm() {
        const data = await updateOrderStatus(this.order_item.userCenterId, {
          orderId: this.order_item.id,
          orderStatus: 6,
          cancelReason: "工作人员同意客户主动的发起取消订单",
        });
        this.cancel_tip = false;
        this.$message({
          type: "success",
          message: "操作成功",
        });
        this.pageChange(this.page);
      },
    },
  };
</script>
<style scoped lang="scss">
  .custom-table-checkbox {
    .el-checkbox {
      display: block !important;
      margin: 0 0 $base-padding/4 0;
    }
  }
  .el-dropdown-link {
    color: $base-color-blue;
    margin-left: 10px;
    cursor: pointer;
  }
</style>
