<!--
 * @Description: 
 * @Author: gcz
 * @Date: 2025-02-21 14:56:50
 * @LastEditors: gcz
 * @LastEditTime: 2025-02-21 17:37:41
 * @FilePath: \great_webui\src\views\windowTicketSales\rebook.vue
 * @Copyright: Copyright (c) 2016~2025 by gcz, All Rights Reserved. 
-->

<template>
  <div class="app-container app-container-scheduling">
    <div class="app-container_flex_auto">
      <!-- 搜索区域 -->
      <div class="app-container_form">
        <el-form :model="queryParams" size="small" ref="queryForm" :inline="true">
          <el-form-item label="订单号" prop="orderId">
            <el-input v-model="queryParams.orderId" placeholder="请输入订单号" clearable />
          </el-form-item>
          <el-form-item label="购票人手机号" prop="memberMobile">
            <el-input v-model="queryParams.memberMobile" placeholder="请输入手机号" clearable />
          </el-form-item>
          <el-form-item label="身份证号码" prop="idcard">
            <el-input v-model="queryParams.idcard" placeholder="请输入身份证号码" clearable />
          </el-form-item>
          <el-form-item label="票务名称" prop="goodsName">
            <el-input v-model="queryParams.goodsName" placeholder="请输入票务名称" clearable />
          </el-form-item>
          <el-form-item label="订单状态" prop="status">
            <el-select v-model="queryParams.status" placeholder="请选择订单状态" clearable>
              <el-option
                v-for="dict in dict.type.order_status_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
      
      <div class="app-container_table" :class="showSearch ? 'mt15' : ''">
        <el-row :gutter="10" class="mb8" style="margin-left: 0;">
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <div class="app-container_table_main">
          <!-- 数据列表 -->
          <el-table v-loading="loading" :data="rebookList" height="100%">
            <el-table-column label="序号" type="index" width="50" align="center" />
            <el-table-column label="姓名" align="center" prop="memberName" />
            <el-table-column label="身份证号码" align="center" prop="idcard" width="150" />
            <el-table-column label="购票人手机号" align="center" prop="mobile" width="150" />
            <el-table-column label="订单号" align="center" prop="orderId" width="170" />
            <el-table-column label="剧目名称" align="center" prop="performName" width="150" />
            <el-table-column label="票务名称" align="center" prop="goodsName" width="150" />
            <el-table-column label="票档" align="center" prop="seatTypeName" />
            <el-table-column label="座位信息" align="center" prop="seatNames" width="160" />
            <el-table-column label="日期" align="center" prop="performDate" width="140" />
            <el-table-column label="场次" align="center" prop="performInterval" width="140" />
            <el-table-column label="下单时间" align="center" prop="createTime" width="180" />
            <el-table-column label="支付方式" align="center" prop="payWay">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.pay_way_type" :value="scope.row.payWay"/>
              </template>
            </el-table-column>
            <el-table-column label="支付金额" align="center" prop="realPrice" />
            <el-table-column label="购票渠道" align="center" prop="channelType">
              <template slot-scope="scope">
                  <dict-tag :options="dict.type.channel_type" :value="scope.row.channelType" />
              </template>
            </el-table-column>
            <el-table-column label="订单状态" align="center" prop="status">
              <template slot-scope="scope">
                  <dict-tag :options="dict.type.order_status_type" :value="scope.row.status" />
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <el-button 
                type="primary" 
                size="small"
                @click="handleUpgrade(scope.row)"
                v-if="hasPermi('windowTicketSales:rebook:rebook') && scope.row.allowReSubmit == 1 && scope.row.status == 3 && scope.row.channelType != 'group'"
                >升舱</el-button>
                <el-button 
                type="primary" 
                size="small"
                @click="handleRebook(scope.row)"
                v-if="hasPermi('windowTicketSales:rebook:rebook') && scope.row.allowReSubmit == 1 && scope.row.status == 3"
                >改签</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        
      </div>
      <div class="app-container_table_page">
        <!-- 分页组件 -->
        <pagination
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
    <!-- 改签 -->
    <rebookBox ref="rebookBox" @getList="getList" />
    <!-- 改签 -->
    <upgradeBox ref="upgradeBox" @getList="getList" />
  </div>
</template>

<script>
import { reSubmitPageList } from '@/api/windowTicketSales/rebook'
import rebookBox from './model/rebookBox.vue';
import upgradeBox from "./model/upgradeBox.vue"
import auth from '@/plugins/auth'
export default {
  name: 'Rebook',
  dicts: ['order_status_type', 'channel_type','pay_way_type'],
  components: { rebookBox,upgradeBox },
  data() {
    return {
      loading: false,
      showSearch: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      // 改签列表数据
      rebookList: [],
      // 总条数
      total: 0
    }
  },
  created() {
    this.$set(this.queryParams,'orderId',this.$route.query.id ? this.$route.query.id : '')
    this.getList()
  },
  methods: {
    hasPermi(value){
      return auth.hasPermi(value)
    },
    getList() {
      this.loading = true
      reSubmitPageList(this.queryParams).then(response => {
        this.rebookList = response.data.rows
        this.total = response.data.total
        this.loading = false
      })
    },
    handleQuery() {
      this.getList()
    },
    resetQuery() {
      this.$refs.queryForm.resetFields()
      this.queryParams = {
        pageNum: 1,
        pageSize: this.queryParams.pageSize
      }  // 重置时将页码重置为1
      this.handleQuery()
    },
    handleRebook(row){
      this.$refs.rebookBox.initData(row)
    },
    handleUpgrade(row) {
      this.$refs.upgradeBox.initData(row)
    }
  }
}
</script>

<style scoped>
.tip-box {
  padding: 10px;
  background-color: #f8f8f8;
  margin-bottom: 20px;
}
.tip-box p {
  color: #E6A23C;
  margin: 0;
}
.pay-status {
  text-align: center;
  font-size: 16px;
}
.success-info {
  text-align: center;
  font-size: 16px;
}
.interval-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.interval-list .el-button {
  margin: 0;
}
</style>
