Explorar o código

1. 优化可分配数量为最新的

MONSTER-ygh hai 9 meses
pai
achega
1c0b866c14

+ 9 - 0
src/api/schedulingMr/schedulingMr.js

@@ -109,4 +109,13 @@ export const saveCommonConfigSingleApi = (data) => {
     method: 'post',
     data: data
   })
+}
+
+// 获取渠道库存设置信息
+export const countSoldNumApi = (query) => {
+  return request({
+    url: '/merchant/merchantPerTimeStock/countSoldNum',
+    method: 'get',
+    params: query
+  })
 }

+ 34 - 11
src/views/venue/schedulingMr/dialog/addStock.vue

@@ -65,6 +65,7 @@
       <span slot="footer" class="dialog-footer">
         <el-button v-if="!loading" @click="cancel">取消</el-button>
         <el-button
+          v-if="status"
           type="primary"
           @click="submitForm"
           :loading="loading"
@@ -77,7 +78,11 @@
   </template>
   
   <script>
-  import { saveCommonConfigApi,saveCommonConfigSingleApi } from "@/api/schedulingMr/schedulingMr";
+  import { 
+    saveCommonConfigApi,
+    saveCommonConfigSingleApi,
+    countSoldNumApi } from "@/api/schedulingMr/schedulingMr";
+import { status } from "nprogress";
   export default {
     name: "stockAll",
     dicts: ['order_form_type'],
@@ -87,6 +92,7 @@
         model: "EDIT",
         open: false,
         loading: false,
+        status: 0, // 0 初始加载 1 加载后
         tableData: [], // 票务
         stock: {},
         tableId: '',
@@ -95,6 +101,8 @@
         chennelStock: [],
         sourceList: [],
         stockAllNum: 0,
+        performTimeId: null,
+        seatTypeId: null,
       };
     },
     methods: {
@@ -107,23 +115,21 @@
       async openDialog(title,data,id,allData,useStock) {
         console.log("data,id,allData====",data,id,useStock)
         this.open = true;
+        this.status = 0
+        this.loading = true
         this.tableId = id
         this.useStock = useStock
+        this.performTimeId = data.performTimeId
+        this.seatTypeId = data.seatTypeId
         this.stock = JSON.parse(JSON.stringify(data))
         this.tableData = JSON.parse(JSON.stringify(data.chennelStock))
         this.chennelStock = JSON.parse(JSON.stringify(data.chennelStock))
         this.sourceList = [];
-        this.stockAllNum = 0
-        let stockAllNum = 0
-        this.chennelStock.forEach(item=>{
-          this.sourceList.push(item.source)
-          if(item.soldNum) {
-            stockAllNum += item.soldNum
-          }
-        })
-        this.stockAllNum = this.stock.stock - stockAllNum
+        await this.countSoldNumFun()
         this.allData = JSON.parse(JSON.stringify(allData))
         this.title = title + `(可分配库存:${ this.stockAllNum })`
+        this.loading = false
+        this.status = 1
       },
       /**  票务信息  */
       async saveCommonConfigFun(value){
@@ -239,11 +245,12 @@
         this.$forceUpdate()
       },
       /**   */
-      selectSource(value,i) {
+      async selectSource(value,i) {
         console.log("value===",value,i,this.sourceList)
         this.$set(this.sourceList,i,value)
         //this.sourceList.push(value)
         this.$set(this.tableData[i],'soldNum',0)
+        
         if(value || value === 0){
           this.chennelStock.forEach((item,index)=>{
             if(value == item.source) {
@@ -252,6 +259,22 @@
           })
         }
         this.$forceUpdate()
+      },
+      async countSoldNumFun(){
+        try {
+          this.stockAllNum = 0
+          let stockAllNum = 0
+          let res = await countSoldNumApi({
+            performTimeId: this.performTimeId,
+            seatTypeId: this.seatTypeId
+          })
+          if(res.code) {
+            stockAllNum = res.data
+          }
+          this.stockAllNum = this.stock.stock - stockAllNum
+        } catch (error) {
+          
+        }
       }
     },
   };