From ecd4e0f81c47fcb4ae41e7b4377f49b8a326c0d9 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 27 九月 2023 17:33:27 +0800
Subject: [PATCH] 上架规则、库存调整模块接口联调

---
 src/views/operate/inventoryAdjustment/index.vue |  176 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 107 insertions(+), 69 deletions(-)

diff --git a/src/views/operate/inventoryAdjustment/index.vue b/src/views/operate/inventoryAdjustment/index.vue
index 9f6346e..8e9c374 100644
--- a/src/views/operate/inventoryAdjustment/index.vue
+++ b/src/views/operate/inventoryAdjustment/index.vue
@@ -4,7 +4,7 @@
       <SearchCommonView
         :add-title="addTitle"
         :show-discard="showDiscard"
-        :show-apply="true"
+        :show-apply="false"
         :placeholder="'璇疯緭鍏ヤ綅缃�/浜у搧'"
         :amount-view="false"
         @addCommonClick="addProductClick"
@@ -19,16 +19,17 @@
           :isinventory="true"
           :product-table-list="tableList"
           @inputContent="inputContent"
-          @tableRowClick="tableRowClick"
+          @selLocationClick="selLocationClick"
+          @selProductClick="selProductClick"
         >
           <template slot="tableButton">
             <el-table-column label="鎿嶄綔" width="180" fixed="right" align="center">
               <template slot-scope="scope">
-                <span @click="handleHistoryClick(scope.row)">
+                <span @click="handleHistoryClick(scope.row)" class="yes-cursor">
                   <i class="el-icon-refresh-left"></i>
                   <span>鍘嗗彶</span>
                 </span>
-                <span v-if="scope.row.isSet" @click="handleSetClick(scope)" class="margin_left_5px">
+                <!-- <span v-if="scope.row.isSet" @click="handleSetClick(scope)" class="margin_left_5px">
                   <i class="el-icon-setting"></i>
                   <span>璁剧疆</span>
                 </span>
@@ -41,7 +42,7 @@
                     <i class="el-icon-delete"></i>
                     <span>娓呴櫎</span>
                   </span>
-                </template>
+                </template> -->
               </template>
             </el-table-column>
           </template>
@@ -57,7 +58,8 @@
 <script>
 import CommonFormTableView from "@/components/makepager/CommonFormTableView"
 import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
-import { getLocationList } from "@/api/warehouseManage/warehouse"
+import { getInventoryAdjustmentList, addInventoryAdjustment } from "@/api/operate/inventoryAdjustment"
+import { currentTime } from "@/common/config/index"
 export default {
   name: "InventoryAdjustment",
   props: {},
@@ -69,23 +71,15 @@
       addTitle: "鏂板缓",
       showDiscard: false,
       tableList: {},
-      tableData: [
-        {
-          location: "HC/閿�鍞尯",
-          productName: "澶忓鐪熶笣鍚婂甫瑁�",
-          amount: "0.00",
-          unit: "浠�",
-          count: "0.00",
-          date: "2023-12-31",
-          user: "绠$悊鍛�",
-          isSet: true,
-          isEdit: true
-        }
-      ],
+      tableData: [],
       searchOptions: [],
       countId: 0,
       isNoProduct: true, // 娣诲姞鏄庣粏琛屾椂鏄惁鏈変骇鍝佹湭閫夋嫨
-      isRowClick: false
+      isRowClick: false,
+      locationId: 0,
+      productId: 0,
+      differenceAmount: 0,
+      Amount: 0
     }
   },
   created() {
@@ -98,48 +92,108 @@
         tableData: this.tableData,
         selectBox: true,
         tableColumn: [
-          { label: "浣嶇疆", prop: "location", location: true },
+          { label: "浣嶇疆", prop: "locationName", location: true },
           { label: "浜у搧", prop: "productName", product: true },
           { label: "鍦ㄥ簱鏁伴噺", prop: "amount" },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
-          { label: "璁℃暟鐨勬暟閲�", prop: "count", inputFloat: true },
-          { label: "宸紓", prop: "difference" },
-          { label: "鏃ユ湡", prop: "date", date: true },
+          { label: "璁℃暟鐨勬暟閲�", prop: "differenceAmount", inputFloat: true },
+          { label: "宸紓", prop: "adjustAmount" },
+          { label: "鏃ユ湡", prop: "createDate" },
           { label: "鐢ㄦ埛", prop: "user", user: true }
         ]
       }
     },
-    // 鎿嶄綔杈撳叆
-    inputContent(val, prop, row) {
-      this.countId = row.countId
-      this.tableData.map((item) => {
-        if (item.countId === row.countId) {
-          item[prop] = val
+    // 璇锋眰鏁版嵁
+    async getData() {
+      await getInventoryAdjustmentList({
+        page: this.pagerOptions.currPage,
+        pageSize: this.pagerOptions.pageSize
+      }).then((res) => {
+        if (res.code === 200) {
+          console.log(res)
+          const list = res.data.map((item) => {
+            return {
+              ...item,
+              isSet: false,
+              isEdit: true,
+              editable: true
+            }
+          })
+          this.tableList.tableData = list || []
+          this.tableData = list || []
+          this.pagerOptions.totalCount = res.total
         }
       })
+    },
+    // 鎿嶄綔杈撳叆
+    inputContent(val, prop, row) {
+      console.log("22222222222222")
+      console.log(val, prop, row)
+      // this.countId = row.countId
+      // this.tableData.map((item) => {
+      //   if (item.countId === row.countId) {
+      //     item[prop] = val
+      //   }
+      // })
+      this.differenceAmount = val
     },
     // 鏂板
     addProductClick() {
       console.log(this.tableData)
       this.isSel()
+      this.isSel()
       if (this.isNoProduct && this.addTitle === "鏂板缓") {
         this.addTitle = "淇濆瓨"
         this.showDiscard = true
         this.isRowClick = false
+        this.currentRowId = 0
         this.countId++
         this.tableData.push({
           countId: this.countId,
+          Amount: 0,
+          areaName: "",
+          adjustAmount: 0,
           productId: "",
-          amount: 0,
-          unit: "",
-          productName: "",
-          count: "0.00",
+          differenceAmount: 0,
+          locationId: 0,
+          createDate: this.currentTime(),
           isSet: true,
-          isEdit: false
+          isEdit: false,
+          editable: false
         })
-      } else if (this.isNoProduct && this.addTitle === "淇濆瓨") {
-        this.addTitle = "鏂板缓"
-        this.showDiscard = false
+        this.locationId = 0
+        this.subLocationId = 0
+        this.productCategoryId = 0
+        this.productId = 0
+      } else {
+        if (this.locationId === 0) {
+          this.$message.error("璇烽�夋嫨浣嶇疆")
+        } else if (this.productId === 0) {
+          this.$message.error("璇烽�夋嫨浜у搧")
+        } else {
+          this.addTitle = "鏂板缓"
+          this.showDiscard = false
+          // let requestUrl = this.currentRowId === 0 ? addInventoryAdjustment : updateListingRules
+          addInventoryAdjustment({
+            // id: this.currentRowId,
+            locationId: this.locationId,
+            Amount: this.Amount,
+            differenceAmount: this.differenceAmount,
+            productId: this.productId
+          })
+            .then((res) => {
+              console.log(res)
+              if (res.code === 200) {
+                // let tipStr = this.currentRowId === 0 ? "娣诲姞鎴愬姛" : "淇敼鎴愬姛"
+                this.$message.success("娣诲姞鎴愬姛")
+                this.getData()
+              }
+            })
+            .catch((err) => {
+              console.log(err)
+              this.getData()
+            })
+        }
       }
     },
     // 鏄惁閫夋嫨浜у搧
@@ -177,7 +231,7 @@
         console.log("鍘嗗彶")
         this.$router.push({
           name: "inventoryAdjustmentHistory",
-          params: { id: row.id }
+          params: { locationId: row.locationId, productId: row.productId }
         })
       }
     },
@@ -209,22 +263,9 @@
       this.tableData.map((item, index) => {
         if (index === rowIndex) {
           item.isEdit = false
+          item.editable = true
         } else {
           item.isEdit = true
-        }
-      })
-    },
-    // 璇锋眰鏁版嵁
-    async getData() {
-      await getLocationList({
-        keyword: this.keyword,
-        page: this.pagerOptions.currPage,
-        pageSize: this.pagerOptions.pageSize
-      }).then((res) => {
-        if (res.code === 200) {
-          const list = res.data ? res.data : []
-          this.tableList.tableInfomation = list
-          this.pagerOptions.totalCount = res.total
         }
       })
     },
@@ -234,22 +275,19 @@
       this.pagerOptions.currPage = 1
       this.getData()
     },
-    // 鏂板缓
-    addBtnClick() {
-      this.editConfig.infomation = {
-        name: "",
-        parentId: null,
-        type: 3,
-        isScrapLocation: null,
-        isReturnLocation: null,
-        replenishLocation: null,
-        countFrequency: 0,
-        recentlyCount: "",
-        nextCount: "",
-        notes: ""
-      }
-      this.editConfig.visible = true
-      this.editConfig.title = "鏂板缓"
+    // 閫夋嫨浣嶇疆鏂规硶
+    selLocationClick(item, prop) {
+      console.log(item, prop)
+      this.locationId = item.value
+    },
+    // 閫変腑浜у搧鏂规硶
+    selProductClick(item) {
+      console.log(item)
+      this.productId = item.value
+    },
+    // 鑾峰彇褰撳墠鏃堕棿
+    currentTime() {
+      return currentTime()
     }
   }
 }

--
Gitblit v1.8.0