MONSTER-ygh 1 місяць тому
батько
коміт
0501e1cd4e

+ 29 - 17
src/components/seatBox/index.vue

@@ -13,7 +13,7 @@
                             v-for="(item,index) in seatTypeList"
                             style="margin-left: 10px;align-items: center;"
                             >
-                                <span :style="{color: item.color?item.color:'none'}">{{item.name ? (item.name+'(剩余:'+ (item.num||0) +')') : '暂未命名'}}</span>
+                                <span :style="{color: item.color?item.color:'none'}">{{item.name ? (item.name+'('+ (item.num||0) +')') : '暂未命名'}}</span>
                             </div>
                         </div>
                     </div>
@@ -107,15 +107,25 @@
   <script>
   
  import moment from "moment"
- import { pageList as getSeatType } from '@/api/seatTypeMr/seatTypeMr'
  import selectListMixin from "./mixins/selectList"
  export default {
     name: "TicketingSales1",
     mixins: [selectListMixin],
     props: {
+        // 是否限制只能选择同一种类型
         isOccupyStatus: {
             type: [Boolean],
             default: true
+        },
+        /**
+         * 限制座位类型选择数量
+         * 
+         */
+        seatTypeLimit: {
+            type: [Object],
+            default: ()=>{
+                return {}
+            }
         }
     },
     data() {
@@ -144,7 +154,7 @@
         width: 0,
         justifyContent: false,
         activeName: 'first',
-        seatTypeList: [],   
+        seatTypeList: [], 
         
         // 限购条件
         ifRealUser: 0,// 散客是否实名:0-否 1-是
@@ -165,7 +175,7 @@
       };
     },
     created() {
-        this.getSeatTypeList()
+        //this.getSeatTypeList()
     },
     mounted() {
     
@@ -173,12 +183,15 @@
     methods: {
         moment,
         /**  获取座位  */
-        async querySeatListFun(type,list,list1){
+        async querySeatListFun(type,list,list1,seatTypeList){
             try {
                 this.loading = true
                 this.performId = ''
                 this.screenTop = 0
                 this.scrollLeft = 0
+
+                this.seatTypeList = seatTypeList
+
                 if(type) { // 是否清除已选
                     this.seatSelectList = []
                     this.seatSelectListNo = []
@@ -291,7 +304,7 @@
         },
         // 座位点击事件
         seatClick(row) {
-            console.log("是的发给我大是个的风格====",row)
+            console.log("是的发给我大是个的风格====",row,this.seatTypeLimit)
             if(row.isDisabled || row.status == 2){
                 return false
             }
@@ -303,6 +316,16 @@
                 this.$message.error('此座已被锁定,请先解锁!!!');
                 return
             }
+            let seatTypeNum = 0
+            this.seatSelectList.forEach((item,index)=>{
+                if(item.seatTypeId == row.seatTypeId) {
+                    seatTypeNum++
+                }
+            })
+            if( seatTypeNum >= this.seatTypeLimit['seatNum_'+row.seatTypeId].stockTotal-this.seatTypeLimit['seatNum_'+row.seatTypeId].stockYes ) {
+                this.$message.error('选择的座位类型已超过库存!!!');
+                return
+            }
             if(row.occupyStatus == 0){
                 // console.log("weqwrwerewrer")
                 // this.$confirm('此座已被锁定,请先解锁', '提示', {
@@ -377,17 +400,6 @@
         /**  选择tab */
         handleClickTab(){
 
-        },
-        /** 获取座位类型 说明 */
-        getSeatTypeList() {
-            getSeatType({
-                pageNum: 1,
-                pageSize: 999,
-            })
-            .then(response => {
-                this.seatTypeList = response.data.rows;
-                }
-            );
         },
         /**   显示座位类型  */
         setSeatTypeShow(value){

+ 4 - 2
src/views/order/orderMr/dialog/details.vue

@@ -171,7 +171,8 @@
             </div>
             <div style="margin-top: 5px; margin-left: 30px;display: flex;">
               <div style="flex-shrink: 0;">
-                已勾选:{{ seatSelectList.length }}个座位
+                已勾选:{{ form.quantity || form.quantity == 0 ?
+              form.quantity : '' }}个座位
               </div>
             </div>
           </div>
@@ -346,12 +347,13 @@ export default {
       }
     },
     setIsSelect(item) {
+      console.log("item===",item)
       if (!this.seatSelectList || this.seatSelectList.length == 0) {
         return false
       }
       let flog = false
       this.seatSelectList.forEach((item1, index1) => {
-        if (item.id == item1.seatId) {
+        if (item1.seatIds.indexOf(item.id) != -1 ) {
           flog = true
         }
       })

+ 153 - 16
src/views/ticket/InventoryTemplate/dialog/addAndEdit.vue

@@ -82,16 +82,23 @@
                   <el-table ref="tables" v-loading="loading" :data="form.chennelListForm[chennelAtion].seatTypeList" border>
                     <el-table-column label="序号" align="center" type="index" width="60"></el-table-column>
                     <el-table-column label="座位类型" align="center" prop="seatTypeName" />
-                    <el-table-column label="可配置数量" align="center" prop="stock"></el-table-column>
+                    <el-table-column label="可配置数量" align="center" prop="stock">
+                      <template slot-scope="scope">
+                        <span> {{ configStockNumObj['seatNum_'+scope.row.seatTypeId].stockTotal - configStockNumObj['seatNum_'+scope.row.seatTypeId].stockYes }} </span>
+                      </template>
+                    </el-table-column>
                     <el-table-column label="配置数量" align="center">
                       <template slot-scope="scope">
-                        <el-input 
+                        <!--  :max="configStockNumObj['seatNum_'+scope.row.seatTypeId].stockTotal - configStockNumObj['seatNum_'+scope.row.seatTypeId].stockYes"  -->
+                        <el-input-number
+                        style="width: 200px;"
                         v-model="form.chennelListForm[chennelAtion].seatTypeList[scope.$index].stockNum" 
-                        type="number" 
                         clearable 
+                        :min="0"
                         placeholder="请输入数量"
-                        @input="(value)=>countNum(value,scope.$index)"
-                        ></el-input>
+                        @change="(value)=>countNum(value,scope)"
+                        :max="configStockNumObj['seatNum_'+scope.row.seatTypeId].stockTotal - configStockNumObj['seatNum_'+scope.row.seatTypeId].stockYes"
+                        ></el-input-number>
                       </template>
                     </el-table-column>
                   </el-table>
@@ -100,6 +107,7 @@
                   <seatBox 
                   ref="seatBox" 
                   :isOccupyStatus="false"
+                  :seatTypeLimit="configStockNumObj"
                   @selectSeat="selectSeat"
                   />
                 </div>
@@ -151,6 +159,7 @@
 import { saveAndEdit, getSelectById,countBySeatTyp,channelType } from '@/api/ticketMr/InventoryTemplate'
 import { getSelectById as getSeatSelectByIdApi } from "@/api/performanceHallMr/performanceHallMr";
 import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
+ import { pageList as getSeatType } from '@/api/seatTypeMr/seatTypeMr'
 import seatBox from '@/components/seatBox/index.vue';
 export default {
   name: "addAndEdit",
@@ -204,13 +213,33 @@ export default {
 
       seatNum: '',
       configStockNum: 0, // 已分配的座位
+
+      // 总的座位类型已分配数量
+      configStockNumObj: {},
+
+      seatTypeListAll: [], // 总的获取座位类型
     };
   },
   created() {
     this.getList()// 演出厅
     this.channelTypeFun() // 渠道
+    this.getSeatTypeAllList()
   },
   methods: {
+    /** 获取座位类型 说明 */
+    async getSeatTypeAllList() {
+      try {
+        let res = await getSeatType({
+          pageNum: 1,
+          pageSize: 999,
+        })
+        if(res.code == 200) {
+          this.seatTypeListAll = res.data.rows || [];
+        }
+      } catch (error) {
+                
+      }   
+    },
     /** 演出厅列表 */
     getList() {
       merchantPageList({pageNum: 1, pageSize: 100})
@@ -235,7 +264,7 @@ export default {
         this.chennelAtion = null
         this.open = true
         this.activeName = '01';
-        
+        this.configStockNumObj = {}
         if(this.channelTypeList.length<0) {
           await this.channelTypeFun()
         }
@@ -330,7 +359,7 @@ export default {
         list1.push({
           "seatTypeId": item1.seatTypeId,
           "seatTypeName": item1.seatTypeName,
-          "stockNum": '',
+          "stockNum": undefined,
           "stock": item1.stock,
         })
         if(obj.stockType == 0 && data.chennelList && data.chennelList.length>0) {
@@ -484,7 +513,7 @@ export default {
       this.open = false;
       this.chennelAtion = null
     },
-    /** 获取座位可用数量  */
+    /** 获取座位类型  */
     async countBySeatTypFun(value,type) {
       console.log("vlaue===",value)
       try {
@@ -497,7 +526,17 @@ export default {
           num = num + item.stock
         })
         this.seatNum = num
-        this.countBySeatTypList = res.data
+        this.countBySeatTypList = res.data ? res.data : []
+        let obj = {}
+        this.countBySeatTypList.forEach((item,index)=>{
+          obj['seatNum_'+item.seatTypeId] = {
+            stockTotal: item.stock,
+            stockSelect: item.stock,
+            stockYes: 0,
+            stockNo: 0,
+          }
+        })
+        this.configStockNumObj = obj
         if(!type) {
           this.form.chennelListForm = this.setDataTree({})
           this.setDictLabel(this.form.chennelListForm[0],0)
@@ -520,19 +559,95 @@ export default {
       this.chennelAtion = index
       if(obj.stockType == 1) {
         this.getSeatSelectById()
+      }else {
+        this.countStockNum()
       }
     },
     // 计算可分配数量
     countStockNum() {
+      let stockNum = 0
+      let stockTotal= 0
+      let flog = false
+      let obj = {}
+      this.countBySeatTypList.forEach((item,index)=>{
+        obj['seatNum_'+item.seatTypeId] = {
+          stockTotal: item.stock,
+          stockSelect: item.stock,
+          stockYes: 0,
+          stockNo: 0,
+        }
+      })
       this.form.chennelListForm.forEach((item,index)=>{
-
+        stockNum = 0
+        if(!item.stockType && item.seatTypeList && item.seatTypeList.length>0) {
+          item.seatTypeList.forEach((item1,index1)=>{
+            if(item1.stockNum) {
+              stockNum = stockNum + item1.stockNum
+              stockTotal = stockTotal + item1.stockNum
+              // if(!flog) {
+              //   obj['seatNum_'+item1.seatTypeId].stockYes = item1.stockNum
+              //   flog = true
+              // }else {
+              //   obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes + item1.stockNum
+              // }
+              obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes + item1.stockNum
+            }
+            if(item1.stockNum && this.chennelAtion == index){
+              // if(!flog) {
+              //   obj['seatNum_'+item1.seatTypeId].stockYes = 0 - item1.stockNum
+              //   flog = true
+              // }else {
+              //   obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes - item1.stockNum
+              // }
+              obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes - item1.stockNum
+            }
+          })
+        }else if(item.stockType == 1 && item.chennelSeatList){
+          Object.keys(item.chennelSeatList).forEach((item1,index1)=>{
+            if(item.chennelSeatList[item1]) {
+              stockNum = stockNum + item.chennelSeatList[item1].length
+              stockTotal = stockTotal + item.chennelSeatList[item1].length
+              console.log("item1====",item1,item1.replace('seat_',''))
+              // if(!flog) {
+              //   obj[item1.replace('seat_','seatNum_')].stockYes = item.chennelSeatList[item1].length
+              //   flog = true
+              // }else {
+              //   obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes + item.chennelSeatList[item1].length
+              // }
+              obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes + item.chennelSeatList[item1].length
+            }
+            
+            if(this.chennelAtion == index && item.chennelSeatList[item1]){
+              // if(!flog) {
+              //   obj[item1.replace('seat_','seatNum_')].stockYes = 0 - item.chennelSeatList[item1].length
+              //   flog = true
+              // }else {
+              //   obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes - item.chennelSeatList[item1].length
+              // }
+              obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes - item.chennelSeatList[item1].length
+            }
+          })
+        }
+        this.form.chennelListForm[index].stockNum = stockNum
       })
+      console.log("this.configStockNumObj====",this.configStockNumObj)
+      console.log("this.form====",this.form)
+      this.configStockNumObj = obj
+      this.configStockNum = stockTotal
     },
     // 选择模式
     setStockType(value) {
+      console.log('选择模式===',value)
+      this.form.chennelListForm[this.chennelAtion].stockNum = 0
       if(value == 1) {
+        this.form.chennelListForm[this.chennelAtion].seatTypeList.forEach((item,index)=>{
+          this.form.chennelListForm[this.chennelAtion].seatTypeList[index].stockNum = undefined
+        })
         this.getSeatSelectById()
+      }else {
+        this.form.chennelListForm[this.chennelAtion].chennelSeatList = null
       }
+      
     },
     /**  获取座位  */
     async getSeatSelectById() {
@@ -579,8 +694,18 @@ export default {
         })
       }
       console.log("dfsdfdsfdsf====",list,this.form.chennelListForm[this.chennelAtion].chennelSeatList)
+      let list3 = []
+      this.countBySeatTypList.forEach((item,index)=>{
+        list3.push(item.seatTypeId)
+      })
+      let list4 = []
+      this.seatTypeListAll.forEach((item,index)=>{
+        if(list3.includes(item.id)) {
+          list4.push({...item})
+        }
+      })
       this.$nextTick(() =>{
-        this.$refs.seatBox.querySeatListFun(true,this.dataList,list)
+        this.$refs.seatBox.querySeatListFun(true,this.dataList,list,list4)
       })
     },
     /** 选择座位  */
@@ -595,11 +720,23 @@ export default {
       console.log("已选择的====",list,this.form.chennelListForm[this.chennelAtion].chennelSeatList)
     },
     /**  计算可分配座位 */
-    countNum(value,index) {
-      console.log("value,index=====",value,index)
-      if(value>this.form.chennelListForm[this.chennelAtion].seatTypeList[index],'stock',this.form.chennelListForm[this.chennelAtion].seatTypeList[index].stock) {
-        
-      }
+    countNum(value,scope) {
+      console.log("value,index=====",value,scope)
+      let stockNum = 0
+      let stockTotal= 0
+      this.form.chennelListForm.forEach((item,index)=>{
+        stockNum = 0
+        if(item.seatTypeList && item.seatTypeList.length>0) {
+          item.seatTypeList.forEach((item1,index1)=>{
+            if(item1.stockNum) {
+              stockNum = stockNum + item1.stockNum
+              stockTotal = stockTotal + item1.stockNum
+            }
+          })
+        }
+        this.form.chennelListForm[index].stockNum = stockNum
+      })
+      this.configStockNum = stockTotal
     }
   },
 };