Forráskód Böngészése

fix(bugs): 票种连续点击问题

LaveyD 3 napja
szülő
commit
d421dc54df

+ 5 - 0
src/components/PrintTemplate.vue

@@ -464,6 +464,11 @@ export default {
           let id = this.$localStore.get('defaultTemplate')
           target = this.$store.state.app.printTemplateList.find(i => i.id === id)
         }
+
+        if (!target) {
+          target = this.$store.state.app.printTemplateList.find(i => i.isDefault) || this.$store.state.app.printTemplateList[0]
+        }
+
         this.$store.commit('SET_PRINT_TEMPLATE', target ? JSON.parse(target.content) : this.printTemplate)
         this.$nextTick(async () => {
           var opts = {

+ 15 - 12
src/pages/sellManage/common/TicketList.vue

@@ -486,6 +486,8 @@ export default {
             })
             // this.changeTicket(this.tableData[0])
             this.$emit('set-batch', this.currentBatch)
+            this.currentTicket = {}
+            this.$emit('update', null)
           }
         }
       })
@@ -527,23 +529,24 @@ export default {
       }
     },
     async changeTicket (ticket) {
-      if (!ticket) {
+      if (!ticket?.id) {
         return
       }
 
       const playDate = moment(this.playDate).format('YYYY-MM-DD')
       this.$emit('changePlayDate', playDate)
-      const res = await getTicketTypeByDate({
-        ticketTypeId: ticket.id,
-        playDateBegin: playDate
-      })
-
-      if (res.code === '200') {
-        console.log(playDate, '获取票种数据成功', res.data)
-        this.currentTicket = res.data
-      } else {
-        this.currentTicket = ticket
-      }
+      // const res = await getTicketTypeByDate({
+      //   ticketTypeId: ticket.id,
+      //   playDateBegin: playDate
+      // })
+
+      // if (res.code === '200') {
+      //   console.log(playDate, '获取票种数据成功', res.data)
+      //   this.currentTicket = res.data
+      // } else {
+      //   this.currentTicket = ticket
+      // }
+      this.currentTicket = ticket
 
       this.currentTicket.playDate = playDate
 

+ 9 - 8
src/pages/sellManage/retail/FormInfo.vue

@@ -466,7 +466,7 @@ export default {
         }
       }
 
-      if (!this.currentTicket) {
+      if (!this.currentTicket?.id) {
         return this.$message.error('请选择门票')
       }
 
@@ -493,9 +493,9 @@ export default {
           this.syncTouristList()
           const { playDateBegin, playDateEnd } = this.form
           const { currentBatch } = this
-          const { id, name, checkCount, isUseDateLimit, printTemplateId } = this.currentTicket
-          const price = this.currentPrice
-          const originalPrice = this.currentPrice
+          const { id, name, checkCount, isUseDateLimit, printTemplateId, price } = this.currentTicket
+          // const price = this.currentPrice
+          const originalPrice = price
 
           if (this.isTeam) {
             if (!this.form.teamId) {
@@ -547,6 +547,7 @@ export default {
               printTemplateId
             }
           })
+          const ticketNum = tickets.length
 
           // 合并游玩日期相同的票种数据
           const existItem = this.orderItems.find(i => {
@@ -557,7 +558,7 @@ export default {
               dateIsEque = true
             }
             // 日期对象不全等
-            return i.id === id && dateIsEque && i.price === this.currentPrice
+            return i.id === id && dateIsEque && i.price === price
           })
 
           if (existItem) {
@@ -571,11 +572,11 @@ export default {
               keyId: randomString(), // 唯一标识
               id, // 票种Id
               ticketName: name,
-              count: tickets.length,
+              count: ticketNum,
               price,
               originalPrice,
               discountPrice: 0,
-              total: this.totalPrice,
+              total: ticketNum * price,
               playDateBegin: pdb,
               currentTicket: {
                 ...this.currentTicket,
@@ -639,7 +640,7 @@ export default {
         //   this.ticketAutoAddMap[this.currentTicket.id] = true
         // }
         this.addToOrder()
-      }, 500)
+      }, 600)
     })
 
     if (this.retailLockCheckStyle) {