Selaa lähdekoodia

refactor(ticketSetting): improve data fetching and UI in ticket settings

- Remove unused receipt print model call in globalData.vue
- Update ticket print template loading to fetch all records by default
- Add refresh button to ticket type group management page
- Improve robustness of ticket type group list data parsing and total count calculation
LaveyD 1 viikko sitten
vanhempi
commit
f934294543

+ 0 - 1
src/globalData.vue

@@ -14,7 +14,6 @@ export default {
   created () {
     getIp()
     // 获取打印模板
-    this.getReceiptPrintModel()
     this.getTicketPrintModelList()
 
     this.$store.dispatch('setTravelAgencyType')

+ 36 - 8
src/pages/ticketSetting/ticket/Dialog.vue

@@ -589,6 +589,19 @@
             </el-radio>
           </el-form-item>
 
+          <el-form-item
+            label="绑定打印模板"
+            prop="printTemplateId">
+            <el-select v-model="form.printTemplateId" placeholder="请选择打印模板">
+              <el-option
+                v-for="item in printTemplateList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name">
+              </el-option>
+            </el-select>
+          </el-form-item>
+
           <template v-if="form.category === 'batch' && dialogType !== 'add'">
             <div class="block-title">
               时间场次
@@ -773,7 +786,7 @@
                     <el-select
                       v-model="scope.row.scenicId">
                       <el-option
-                        v-for="item in scenicList"
+                        v-for="item in localScenicList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id"
@@ -842,7 +855,7 @@
                       v-model="scope.row.scenicId"
                       multiple>
                       <el-option
-                        v-for="item in scenicList"
+                        v-for="item in localScenicList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id"
@@ -1074,7 +1087,7 @@
                     <el-select
                       v-model="scope.row.scenicId">
                       <el-option
-                        v-for="item in scenicList"
+                        v-for="item in localScenicList"
                         :key="item.id"
                         :label="item.name"
                         :value="item.id"
@@ -1190,9 +1203,10 @@
 </template>
 
 <script>
-import { addTicket, updateTicket, queueList, batchUpdateTicketBatch, delTicketBatch } from '@/api/ticketType'
+import { addTicket, updateTicket, queueList, batchUpdateTicketBatch, delTicketBatch, getScenic } from '@/api/ticketType'
 import { getGhSubMerchantList } from '@/api/payChannel'
 import { getInvoiceSellerList } from '@/api/invoice'
+import { getTicketPrintModelList } from '@/api/printModal'
 import { getLabelName } from '@/utils'
 import { cloneDeep } from 'lodash'
 import moment from 'moment'
@@ -1243,7 +1257,8 @@ const defaultForm = {
   payGonghangTicketTypeMerchantList: [], // 工行子商户列表
   ticketTypeInvoiceSellerList: [], // 发票销售方列表
   ticketTypeScenicSplitRequests: [], // 子分账景点
-  teamIndividual: 0 // 团散:0-不限 1-散客 2-团队
+  teamIndividual: 0, // 团散:0-不限 1-散客 2-团队
+  printTemplateId: null // 绑定打印模板ID
 }
 
 export default {
@@ -1287,6 +1302,7 @@ export default {
       dialogType: 'add',
       projectName: process.env.VUE_APP_PROJECT,
       visible: false,
+      localScenicList: [],
       pickerOptions: {
         disabledDate: (theTime) => {
           let startTime = moment().format('YYYY-MM-DD') + ' 00:00:00'
@@ -1318,7 +1334,8 @@ export default {
       currGroupScenicInfo: [],
       groupScenicMap: new Map(),
       ghSubMerchantList: [], // 工行子商户列表
-      invoiceSellerList: [] // 发票销售方列表
+      invoiceSellerList: [], // 发票销售方列表
+      printTemplateList: [] // 打印模板列表
     }
   },
   watch: {
@@ -1343,7 +1360,10 @@ export default {
     }
   },
   methods: {
-    show (ticketItem, type) {
+    async show (ticketItem, type) {
+      // 每次打开时拉取最新景点列表
+      const res = await getScenic()
+      this.localScenicList = res?.data?.records || []
       // this.reset()
       this.ticketItem = ticketItem
       this.dialogType = type
@@ -1437,6 +1457,7 @@ export default {
 
       this.getGhSubMerchantList()
       this.getInvoiceSellerList()
+      this.loadPrintTemplates()
 
       this.visible = true
     },
@@ -1450,6 +1471,13 @@ export default {
       const res = await getInvoiceSellerList()
       this.invoiceSellerList = res.data || []
     },
+    async loadPrintTemplates () {
+      const res = await getTicketPrintModelList({ pageNum: 0, pageSize: -1 })
+      this.printTemplateList = res?.data?.records || []
+      if (this.printTemplateList.length > 0 && this.form.printTemplateId == null) {
+        this.form.printTemplateId = this.printTemplateList[0].id
+      }
+    },
     updateDiscountRule: function () {
       let man = parseInt(this.man)
       let jian = parseInt(this.jian)
@@ -1547,7 +1575,7 @@ export default {
       } else {
         this.currGroupScenicInfo = []
         item.scenicId.forEach(id => {
-          const scene = this.scenicList.find((scene) => scene.id === id)
+          const scene = this.localScenicList.find((scene) => scene.id === id)
 
           if (scene) {
             this.currGroupScenicInfo.push({

+ 182 - 0
src/pages/ticketSetting/ticketTypeGroup/index.vue

@@ -0,0 +1,182 @@
+<template>
+  <div class="form-wrap">
+    <div class="table-box">
+      <div class="block-title">
+        票种分组管理
+        <el-button
+          type="primary"
+          icon="el-icon-refresh"
+          :loading="loading"
+          :disabled="loading"
+          style="margin-right:10px"
+          @click="getList"
+        >
+          刷新
+        </el-button>
+        <el-button
+          type="primary"
+          style="margin-right:10px"
+          @click="showDialog('add')"
+        >
+          新增
+        </el-button>
+      </div>
+
+      <el-table
+        border
+        stripe
+        v-loading="loading"
+        :data="tableData"
+      >
+        <el-table-column
+          prop="id"
+          label="编号"
+          width="80"
+        >
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          label="分组名称"
+        >
+        </el-table-column>
+        <el-table-column
+          prop="description"
+          label="描述"
+        >
+        </el-table-column>
+        <el-table-column
+          label="票种数量"
+          width="100"
+        >
+          <template slot-scope="scope">
+            {{ scope.row.ticketTypes ? scope.row.ticketTypes.length : 0 }}
+          </template>
+        </el-table-column>
+        <el-table-column
+          prop="createTime"
+          label="创建时间"
+          width="180"
+        >
+        </el-table-column>
+        <el-table-column
+          label="操作"
+          width="220"
+        >
+          <template slot-scope="scope">
+            <el-link
+              type="primary"
+              size="small"
+              @click="showDialog('edit', scope.row)"
+            >
+              编辑
+            </el-link>
+            <el-link
+              type="primary"
+              size="small"
+              @click="assignTickets(scope.row)"
+            >
+              分配票种
+            </el-link>
+            <el-link
+              type="primary"
+              size="small"
+              @click="handleDelete(scope.row.id)"
+            >
+              删除
+            </el-link>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <el-pagination
+        background
+        :current-page.sync="form.pageNum"
+        :page-sizes="[10, 20, 50, 100]"
+        :page-size="form.pageSize"
+        @size-change="handleSizeChange"
+        layout="total, sizes, prev, pager, next, jumper"
+        @current-change="getList()"
+        :total="total">
+      </el-pagination>
+    </div>
+
+    <Dialog
+      ref="dialog"
+      @update="getList"
+    ></Dialog>
+
+    <TicketAssignDialog
+      ref="ticketAssignDialog"
+      @update="getList"
+    ></TicketAssignDialog>
+  </div>
+</template>
+
+<script>
+import { getTicketTypeGroupList, deleteTicketTypeGroup } from '@/api/ticketTypeGroup'
+import Dialog from './Dialog'
+import TicketAssignDialog from './TicketAssignDialog'
+
+export default {
+  components: {
+    Dialog,
+    TicketAssignDialog
+  },
+  data () {
+    return {
+      form: {
+        pageNum: 1,
+        pageSize: 10
+      },
+      loading: false,
+      total: 0,
+      tableData: []
+    }
+  },
+  created () {
+    this.getList()
+  },
+  methods: {
+    getList () {
+      this.loading = true
+      let params = JSON.parse(JSON.stringify(this.form))
+      getTicketTypeGroupList(params).then(res => {
+        this.tableData = Array.isArray(res?.data) ? res.data : (res?.data?.records || [])
+        this.total = res?.data?.total || this.tableData.length
+      }).finally(() => {
+        this.loading = false
+      })
+    },
+    handleSizeChange (size) {
+      this.form.pageSize = size
+      this.getList()
+    },
+    showDialog (type, row) {
+      this.$refs.dialog.show(type, row)
+    },
+    assignTickets (row) {
+      this.$refs.ticketAssignDialog.show(row)
+    },
+    handleDelete (id) {
+      this.$confirm('确认删除该分组吗?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteTicketTypeGroup([id]).then(res => {
+          this.$message.success('删除成功')
+          this.getList()
+        })
+      }).catch(() => {})
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.form-wrap {
+  .el-input,.el-select,.el-date-editor,.el-date-editor.el-input,.el-input-number {
+    width: 300px;
+  }
+}
+</style>