Przeglądaj źródła

1. 新增库存管理

MONSTER-ygh 9 miesięcy temu
rodzic
commit
7e657b4fb6

+ 2 - 2
src/views/monitor/logininfor/index.vue

@@ -112,9 +112,9 @@
         </template>
       </el-table-column>
       <el-table-column label="操作信息" align="center" prop="msg" :show-overflow-tooltip="true" />
-      <el-table-column label="登录日期" align="center" prop="loginTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
+      <el-table-column label="登录日期" align="center" prop="accessTime" sortable="custom" :sort-orders="['descending', 'ascending']" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.loginTime) }}</span>
+          <span>{{ parseTime(scope.row.accessTime) }}</span>
         </template>
       </el-table-column>
     </el-table>

+ 54 - 21
src/views/venue/schedulingMr/dialog/addStock.vue

@@ -46,7 +46,7 @@
           @click="submitForm"
           :loading="loading"
         >
-          <span v-if="loading">提交中...</span>
+          <span v-if="loading">保存中...</span>
           <span v-else>保存</span>
         </el-button>
       </span>
@@ -66,7 +66,8 @@
         loading: false,
         tableData: [], // 票务
         stock: {},
-        tableId: ''
+        tableId: '',
+        allData: {}
       };
     },
     methods: {
@@ -76,11 +77,13 @@
        * @param {any} obj
        * @returns {any}
        */
-      async openDialog(title,data,id) {
+      async openDialog(title,data,id,allData) {
+        console.log("data,id,allData====",data,id)
         this.open = true;
         this.tableId = id
         this.stock = JSON.parse(JSON.stringify(data))
         this.tableData = JSON.parse(JSON.stringify(data.chennelStock))
+        this.allData = JSON.parse(JSON.stringify(allData))
       },
       /**  票务信息  */
       async saveCommonConfigFun(value){
@@ -106,25 +109,55 @@
        * @returns {any}
        */
       async submitForm() {
-        try {
-          this.loading = true;
-          let params = JSON.parse(JSON.stringify(this.stock))
-          params.chennelStock = this.tableData
-          let res = null
-          if(this.tableId) {
-            res = await saveCommonConfigSingleApi({ stock: [{...params}] });
-          }else {
-            res = await saveCommonConfigApi({ stock: [{...params}] });
-          }
-          if (res.code === 200) {
-            this.$message.success("操作成功!");
-            this.loading = false;
-            this.$emit("getList");
-            this.cancel();
-          }
-        } catch (error) {
-          this.loading = false;
+        let count = 0
+        this.tableData.forEach((item,index)=>{
+          count = count + (item.stock?item.stock:0)
+        })
+        console.log("count====",count)
+        if(this.stock.stock < count) {
+          this.$message.error("库存总合不能大于可售库存!");
+          return
         }
+        let params = JSON.parse(JSON.stringify(this.allData))
+        this.allData.forEach((item,index)=>{
+          if(item.seatTypeId == this.stock.seatTypeId) {
+            params[index] = {
+              ...this.stock,
+              chennelStock: this.tableData
+            }
+          }
+        })
+        this.$emit("getList",params);
+        this.cancel();
+        // try {
+        //   this.loading = true;
+        //   let params = JSON.parse(JSON.stringify(this.allData))
+        //   this.allData.forEach((item,index)=>{
+        //     if(item.seatTypeId == this.stock.seatTypeId) {
+        //       params[index] = {
+        //         ...this.stock,
+        //         chennelStock: this.tableData
+        //       }
+        //     }
+        //   })
+        //   let res = null
+        //   if(this.tableId) {
+        //     res = await saveCommonConfigSingleApi({ 
+              
+        //       stock: params
+        //     });
+        //   }else {
+        //     res = await saveCommonConfigApi({ stock: params });
+        //   }
+        //   if (res.code === 200) {
+        //     this.$message.success("操作成功!");
+        //     this.loading = false;
+        //     this.$emit("getList");
+        //     this.cancel();
+        //   }
+        // } catch (error) {
+        //   this.loading = false;
+        // }
       },
     },
   };

+ 98 - 4
src/views/venue/schedulingMr/dialog/stockAll.vue

@@ -44,14 +44,24 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="cancel">取消</el-button>
+        <el-button
+          type="primary"
+          @click="submitForm"
+          :loading="loading"
+        >
+          <span v-if="loading">提交中...</span>
+          <span v-else>提交</span>
+        </el-button>
       </span>
-      <addStock ref="addStock" @getList="commonConfigAllFun" />
+      <addStock ref="addStock" @getList="updateCommonConfigAllFun" />
     </el-dialog>
   </template>
   
   <script>
   import { commonConfigAllApi,commonConfigSingleApi } from "@/api/schedulingMr/schedulingMr";
+  import { saveCommonConfigApi,saveCommonConfigSingleApi } from "@/api/schedulingMr/schedulingMr";
   import addStock from "./addStock.vue";
+  
   export default {
     name: "stockAll",
     components: { addStock },
@@ -95,7 +105,28 @@
           
 
           if(res.code == 200){
-            this.tableData = res.data.stock
+            let listCopy = []
+            res.data.stock.forEach((item,index)=>{
+              if(this.tableId) {
+                listCopy.push({
+                  id: item.id,
+                  seatTypeName: item.seatTypeName,
+                  "performTimeId": item.performTimeId,
+                  "seatTypeId": item.seatTypeId,
+                  "stock": item.stock,
+                  "chennelStock": this.setData(item.chennelStock)
+                })
+              }else {
+                listCopy.push({
+                  seatTypeName: item.seatTypeName,
+                  "seatTypeId": item.seatTypeId,
+                  "stock": item.stock,
+                  "chennelStock": this.setData(item.chennelStock)
+                })
+              }
+              
+            })
+            this.tableData = listCopy
             let stockAllNum = 0
             this.tableData.forEach((item,index)=>{
               if(item.stock){
@@ -106,10 +137,47 @@
           }
           this.loading = false;
         } catch (error) {   
+            console.error(error)
             this.loading = false;
             this.open = false
         }
       },
+      /**  初始化值  */
+      setData(list) {
+        let listCopy = []
+        list.forEach((item,index)=>{
+          if(this.tableId){
+            listCopy.push({
+              id: item.id,
+              "stockId": item.stockId,
+              "source": item.source,
+              "stock": item.stock,
+              "soldNum": item.soldNum,
+              "status": item.status
+            })
+          }else {
+            listCopy.push({
+              "source": item.source,
+              "stock": item.stock,
+              "soldNum": item.soldNum,
+              "status": item.status
+            })
+          }
+          
+        })
+        return listCopy
+      },
+      /** 更新列表  */
+      updateCommonConfigAllFun(data) {
+        this.tableData = data
+        let stockAllNum = 0
+        this.tableData.forEach((item,index)=>{
+          if(item.stock){
+            stockAllNum = stockAllNum + item.stock
+          }
+        })
+        this.stockAllNum = stockAllNum
+      },
       /**
        * 关闭弹框
        * @date 2023-11-22
@@ -121,8 +189,34 @@
       },
       /**  场次库存设置   */
       addStockFun(row) {
-        this.$refs["addStock"].openDialog('',row,this.tableId);
-      }
+        this.$refs["addStock"].openDialog('',row,this.tableId,this.tableData);
+      },
+      /**
+       * 保存
+       * @date 2023-11-22
+       * @returns {any}
+       */
+       async submitForm() {
+        try {
+          this.loading = true;
+          let res = null
+          if(this.tableId) {
+            res = await saveCommonConfigSingleApi({ 
+              "performTimeId": this.tableId,
+              stock: this.tableData
+            });
+          }else {
+            res = await saveCommonConfigApi({ stock: this.tableData });
+          }
+          if (res.code === 200) {
+            this.$message.success("操作成功!");
+            this.loading = false;
+            this.cancel();
+          }
+        } catch (error) {
+          this.loading = false;
+        }
+      },
     },
   };
   </script>