From 05159702c718d8661eb457f1362b115beeaa421d Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期五, 03 十一月 2023 09:51:26 +0800
Subject: [PATCH] 新增补货页面,库存报表列表状态修改

---
 src/views/warehouseManage/listingRules/index.vue      |    2 
 src/views/reportForm/inboundOutboundDetail/index.vue  |   14 +
 src/router/operate/index.js                           |    9 +
 src/views/operate/orderPoint/index.vue                |  445 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/components/layout/components/appsidebar/index.vue |    1 
 src/api/product/reorderRules.js                       |    8 +
 6 files changed, 478 insertions(+), 1 deletions(-)

diff --git a/src/api/product/reorderRules.js b/src/api/product/reorderRules.js
index f2c9a6f..2ddd9e9 100644
--- a/src/api/product/reorderRules.js
+++ b/src/api/product/reorderRules.js
@@ -39,3 +39,11 @@
     data
   })
 }
+// 鑾峰彇浣嶇疆鍒楄〃
+export function getLocationList(data) {
+  return request({
+    url: "/api-wms/v1/location/getLocationList",
+    method: "post",
+    data
+  })
+}
diff --git a/src/components/layout/components/appsidebar/index.vue b/src/components/layout/components/appsidebar/index.vue
index 7ed14e4..64216ba 100644
--- a/src/components/layout/components/appsidebar/index.vue
+++ b/src/components/layout/components/appsidebar/index.vue
@@ -41,6 +41,7 @@
           <el-menu-item index="/operate/inventoryAdjustment">搴撳瓨璋冩暣</el-menu-item>
           <el-menu-item index="/operate/allot">搴撳瓨璋冩嫧</el-menu-item>
           <el-menu-item index="/operate/scrap">搴撳瓨鎶ュ簾</el-menu-item>
+          <el-menu-item index="/operate/orderPoint">琛ヨ揣</el-menu-item>
         </el-submenu>
         <el-submenu index="4">
           <template slot="title">
diff --git a/src/router/operate/index.js b/src/router/operate/index.js
index 5aa40ab..68088c6 100644
--- a/src/router/operate/index.js
+++ b/src/router/operate/index.js
@@ -2,6 +2,7 @@
 
 const allot = (resolve) => require(["@/views/operate/allot/index"], resolve) // 璋冩嫧
 const scrap = (resolve) => require(["@/views/operate/scrap/index"], resolve) // 鎶ュ簾
+const orderPoint = (resolve) => require(["@/views/operate/orderPoint/index"], resolve) // 鎶ュ簾
 const inventoryAdjustment = (resolve) => require(["@/views/operate/inventoryAdjustment/index"], resolve) // 搴撳瓨璋冩暣
 const inventoryAdjustmentHistory = (resolve) =>
   require(["@/views/operate/inventoryAdjustment/inventoryAdjustmentHistory"], resolve) // 搴撳瓨璋冩暣鍘嗗彶
@@ -24,6 +25,14 @@
     }
   },
   {
+    path: "/operate/orderPoint",
+    name: "orderPoint",
+    component: orderPoint,
+    meta: {
+      title: "琛ヨ揣"
+    }
+  },
+  {
     path: "/operate/inventoryAdjustment",
     name: "inventoryAdjustment",
     component: inventoryAdjustment,
diff --git a/src/views/operate/orderPoint/index.vue b/src/views/operate/orderPoint/index.vue
new file mode 100644
index 0000000..eb8596f
--- /dev/null
+++ b/src/views/operate/orderPoint/index.vue
@@ -0,0 +1,445 @@
+<template>
+  <div class="rightContent">
+    <div class="top">
+      <SearchCommonView :add-title="addTitle" :show-discard="showDiscard" :show-apply="false" :placeholder="'璇疯緭鍏ヤ綅缃�/浜у搧'"
+        :amount-view="false" @addCommonClick="addProductClick" @searchClick="getList"
+        @discardBtnClick="discardBtnClick" />
+    </div>
+    <div class="content_wrap">
+      <div class="con_left">
+          <p>浣嶇疆</p>
+          <div class="stash">
+            <template>
+              <el-tree :data="datas" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
+            </template>
+          </div>
+      </div>
+      <div class="list-view">
+        <div class="table">
+          <CommonFormTableView ref="tablelistRef" :isReorder="true" :product-table-list="tableList"
+            @inputContent="inputContent" @selLocationClick="selLocationClick" @selProductClick="selProductClick"
+            @tableRowClick="tableRowClick" @selRouteClick="selRouteClick">
+            <template slot="tableButton">
+              <el-table-column label="鎿嶄綔" width="180" align="center">
+                <template slot-scope="scope">
+                  <span v-if="scope.row.isEdit && scope.row.isView" @click.stop="handleOrderOnceClick(scope.row)"
+                    class="yes-cursor">
+                    <i class="el-icon-truck"></i>
+                    <span>璁㈣喘涓�娆�</span>
+                  </span>
+                </template>
+              </el-table-column>
+            </template>
+          </CommonFormTableView>
+        </div>
+        <div class="btn-pager">
+          <PagerView class="page" :pager-options="pagerOptions" v-on="pagerEvents" />
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import CommonFormTableView from "@/components/makepager/CommonFormTableView"
+import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
+import { getReorderRuleList, addReorderRule, updateReorderRule, orderAgain,getLocationList } from "@/api/product/reorderRules"
+import { currentTime } from "@/common/config/index"
+export default {
+  name: "ReorderRules",
+  props: {},
+  components: { CommonFormTableView },
+  mixins: [pageMixin],
+  computed: {},
+  data() {
+    return {
+      datas:[],
+      // datas: [{
+      //     label: '涓�绾� 1',
+      //     children: [{
+      //       label: '浜岀骇 1-1',
+      //       children: [{
+      //         label: '涓夌骇 1-1-1'
+      //       }]
+      //     }]
+      //   }, {
+      //     label: '涓�绾� 2',
+      //     children: [{
+      //       label: '浜岀骇 2-1',
+      //       children: [{
+      //         label: '涓夌骇 2-1-1'
+      //       }]
+      //     }, {
+      //       label: '浜岀骇 2-2',
+      //       children: [{
+      //         label: '涓夌骇 2-2-1'
+      //       }]
+      //     }]
+      //   }, {
+      //     label: '涓�绾� 3',
+      //     children: [{
+      //       label: '浜岀骇 3-1',
+      //       children: [{
+      //         label: '涓夌骇 3-1-1'
+      //       }]
+      //     }, {
+      //       label: '浜岀骇 3-2',
+      //       children: [{
+      //         label: '涓夌骇 3-2-1'
+      //       }]
+      //     }]
+      // }],
+      defaultProps: {
+        children: 'children',
+        label: 'jointName'
+      },
+      addTitle: "鏂板缓",
+      showDiscard: false,
+      tableList: {},
+      tableData: [],
+      searchOptions: [],
+      countId: 0,
+      isNoProduct: true, // 娣诲姞鏄庣粏琛屾椂鏄惁鏈変骇鍝佹湭閫夋嫨
+      isRowClick: false,
+      locationId: 0,
+      productId: 0,
+      amount: 0,
+      operationId: 0,
+      minInventory: 0,
+      maxInventory: 0,
+      orderNumber: 0,
+      unit: "",
+      reorderId: 0
+    }
+  },
+  created() {
+    this.setTable()
+    this.getData()
+    this.getLocationList()
+  },
+  methods: {
+    setTable() {
+      this.tableList = {
+        tableData: this.tableData,
+        selectBox: false,
+        selectIndex: true,
+        tableColumn: [
+          { label: "浜у搧", prop: "productName", product: true },
+          { label: "浣嶇疆", prop: "locationName", defaultLocation: true },
+          { label: "鍦ㄥ簱鏁伴噺", prop: "amount" },
+          { label: "棰勬祴鏁伴噺", prop: "prediction" },
+          { label: "棣栭�夎矾绾�", prop: "route", route: true },
+          { label: "鏈�灏忔暟閲�", prop: "minInventory", inputFloat: true },
+          { label: "鏈�澶ф暟閲�", prop: "maxInventory", inputFloat: true },
+          { label: "璁㈣喘鏁伴噺", prop: "orderNumber", inputFloat: true },
+          { label: "璁¢噺鍗曚綅", prop: "unit" }
+        ]
+      }
+    },
+    // 璇锋眰鏁版嵁
+    async getData() {
+      await getReorderRuleList({
+        page: this.pagerOptions.currPage,
+        pageSize: this.pagerOptions.pageSize
+      }).then((res) => {
+        if (res.code === 200) {
+          console.log(res)
+          const list = res.data.map((item) => {
+            let orderNum = 0
+            if (parseFloat(item.minInventory) - parseFloat(item.prediction) > 0) {
+              orderNum = this.caculateOrderNumber(
+                parseFloat(item.minInventory),
+                parseFloat(item.maxInventory),
+                parseFloat(item.prediction)
+              )
+            }
+            return {
+              ...item,
+              productName: item.product.name,
+              locationName: item.location.name,
+              isSet: false,
+              isEdit: true,
+              editable: true,
+              isOrder: true,
+              isView: item?.minInventory - item?.prediction > 0 ? true : false,
+              orderNumber: orderNum
+            }
+          })
+          this.tableList.tableData = list || []
+          this.tableData = list || []
+          this.pagerOptions.totalCount = res.total
+        }
+      })
+    },
+    // 鎶�鏈璐暟閲�
+    caculateOrderNumber(minInventory, maxInventory, prediction) {
+      return maxInventory > minInventory ? maxInventory - prediction : minInventory - prediction
+    },
+    // 鎿嶄綔杈撳叆
+    inputContent(val, prop, row) {
+      console.log(val, prop, row)
+      if (prop === "minInventory") {
+        this.minInventory = val
+        if (parseFloat(this.minInventory) - parseFloat(this.prediction) > 0) {
+          this.orderNumber = this.caculateOrderNumber(
+            parseFloat(this.minInventory),
+            parseFloat(this.maxInventory),
+            parseFloat(this.prediction)
+          )
+        }
+      } else if (prop === "maxInventory") {
+        this.maxInventory = val
+        if (parseFloat(this.minInventory) - parseFloat(this.prediction) > 0) {
+          this.orderNumber = this.caculateOrderNumber(
+            parseFloat(this.minInventory),
+            parseFloat(this.maxInventory),
+            parseFloat(this.prediction)
+          )
+        }
+      } else if (prop === "orderNumber") {
+        this.orderNumber = val
+      }
+    },
+    // 鏂板
+    addProductClick() {
+      console.log(this.addTitle)
+      this.isSel()
+      if (this.isNoProduct && this.addTitle === "鏂板缓") {
+        this.$refs.tablelistRef.getProductList()
+        this.$refs.tablelistRef.getLocationList()
+        this.addTitle = "淇濆瓨"
+        this.showDiscard = true
+        this.isRowClick = false
+        this.operationId = 0
+        this.currentRowId = 0
+        this.countId++
+        this.tableData.unshift({
+          countId: this.countId,
+          amount: 0,
+          minInventory: 0,
+          productId: "",
+          maxInventory: 0,
+          orderNumber: 0,
+          prediction: 0,
+          locationId: 0,
+          createDate: this.currentTime(),
+          isSet: true,
+          isEdit: false,
+          editable: false,
+          isOrder: true
+        })
+        this.locationId = 0
+        this.productId = 0
+      } else {
+        this.addTitle = "鏂板缓"
+        this.showDiscard = false
+        let requestUrl = this.currentRowId === 0 ? addReorderRule : updateReorderRule
+        let params = this.saveParams()
+        requestUrl(params)
+          .then((res) => {
+            console.log(res)
+            if (res.code === 200) {
+              let tipStr = this.currentRowId === 0 ? "娣诲姞鎴愬姛" : "淇敼鎴愬姛"
+              this.$message.success(tipStr)
+              this.getData()
+            }
+          })
+          .catch((err) => {
+            console.log(err)
+            this.getData()
+          })
+        // }
+      }
+    },
+    saveParams() {
+      return {
+        id: this.reorderId,
+        amount: this.amount,
+        locationId: this.locationId,
+        maxInventory: this.maxInventory,
+        minInventory: this.minInventory,
+        orderNumber: this.orderNumber,
+        prediction: this.prediction,
+        operationId: this.operationId,
+        productId: this.productId,
+        route: this.route,
+        unit: this.unit
+      }
+    },
+    // 鏄惁閫夋嫨浜у搧
+    isSel() {
+      for (let i = 0; i < this.tableData.length; i++) {
+        if (this.tableData[i].productName?.length === 0) {
+          this.isNoProduct = false
+          break
+        } else {
+          this.isNoProduct = true
+        }
+      }
+    },
+    // 鍙栨秷
+    discardBtnClick() {
+      this.getData()
+      this.addTitle = "鏂板缓"
+      this.showDiscard = false
+    },
+    // 璁㈣喘涓�娆�
+    handleOrderOnceClick(row) {
+      let params = {
+        ...row
+      }
+      orderAgain(params).then((res) => {
+        if (res.code === 200) {
+          this.$message.success("璁㈣喘鎴愬姛")
+          this.getData()
+        }
+      })
+    },
+    // 琛岀偣鍑�
+    tableRowClick(row, rowIndex) {
+      this.locationId = row.locationId
+      this.rowIndex = rowIndex
+      this.reorderId = row.id
+      this.isSel()
+      if (!this.isNoProduct && this.currentRowId === 0) {
+        this.$message.error("璇峰畬鎴愬綋鍓嶆柊寤烘垨鍙栨秷鏂板缓")
+      } else {
+        this.currentRowId = row.id
+        this.addTitle = "淇濆瓨"
+        this.showDiscard = true
+        this.isRowClick = true
+        if (!this.isNoProduct) {
+          this.tableData.splice(this.tableData.length - 1, 1)
+        }
+        this.tableData.map((item, index) => {
+          if (index === rowIndex) {
+            item.isEdit = false
+            item.editable = true
+            item.isOrder = true
+          } else {
+            item.isEdit = true
+          }
+        })
+        this.minInventory = row.minInventory
+        this.amount = row.amount
+        this.productId = row.productId
+        this.maxInventory = row.maxInventory
+        this.orderNumber = row.orderNumber
+        this.prediction = row.prediction
+        this.locationId = row.locationId
+      }
+    },
+    // 鎼滅储
+    getList(val) {
+      this.keyword = val
+      this.pagerOptions.currPage = 1
+      this.getData()
+    },
+    // 閫変腑浣嶇疆鏂规硶
+    selLocationClick(item, prop) {
+      console.log(item, prop)
+      this.locationId = item?.value ?? item?.id
+    },
+    // 閫変腑浜у搧鏂规硶
+    selProductClick(item) {
+      this.productId = item.value
+      this.unit = item.unit
+    },
+    // 閫変腑璺嚎鏂规硶
+    selRouteClick(item, prop) {
+      console.log(item, prop)
+      this.route = item.label
+    },
+    // 鑾峰彇褰撳墠鏃堕棿
+    currentTime() {
+      return currentTime()
+    },
+    //鏍戠偣鍑�
+    handleNodeClick(data) {
+      console.log(data,"sss");
+      getReorderRuleList({
+        locationId:data.id,
+        page:1,
+        pageSize:15,
+        type:"",
+        keyWord:data.jointName,
+      }).then((res)=>{
+        console.log(res,"res999")
+        if (res.code === 200) {
+          console.log(res)
+          const list = res.data.map((item) => {
+            let orderNum = 0
+            if (parseFloat(item.minInventory) - parseFloat(item.prediction) > 0) {
+              orderNum = this.caculateOrderNumber(
+                parseFloat(item.minInventory),
+                parseFloat(item.maxInventory),
+                parseFloat(item.prediction)
+              )
+            }
+            return {
+              ...item,
+              productName: item.product.name,
+              locationName: item.location.name,
+              isSet: false,
+              isEdit: true,
+              editable: true,
+              isOrder: true,
+              isView: item?.minInventory - item?.prediction > 0 ? true : false,
+              orderNumber: orderNum
+            }
+          })
+          this.tableList.tableData = list || []
+          this.tableData = list || []
+          this.pagerOptions.totalCount = res.total
+        }
+      })
+    },
+    async getLocationList(){
+      await getLocationList({
+        categoryId:"",
+        keyWord:"",
+        // page:1,
+        // pageSize:,
+      }).then((res)=>{
+        this.datas=res.data
+        console.log(res,"res666")
+      })
+    }
+  }
+}
+</script>
+
+<!-- Add "scoped" attribute to limit CSS to this component only -->
+<style lang="scss" scoped>
+::v-deep {
+  .el-table {
+    border-top-left-radius: 12px;
+    border-top-right-radius: 12px;
+    overflow: auto;
+  }
+  .content_wrap {
+  height: calc(100% - 0px);
+  display: flex;
+  justify-content: space-between;
+  .con_left {
+    width: 200px;
+    .el-checkbox-group {
+      width:100%;
+      display: flex;
+      flex-direction: column;
+    }
+    .stash {
+      display: flex;
+      flex-direction: column;
+      .el-tree{
+        background-color: #E6ECF2;
+      }
+    }
+  }
+  .list-view {
+    flex: 1;
+  }
+}
+  
+}
+</style>
diff --git a/src/views/reportForm/inboundOutboundDetail/index.vue b/src/views/reportForm/inboundOutboundDetail/index.vue
index a38bdc0..c6ee050 100644
--- a/src/views/reportForm/inboundOutboundDetail/index.vue
+++ b/src/views/reportForm/inboundOutboundDetail/index.vue
@@ -212,6 +212,20 @@
           pageSize: this.pagerOptions.pageSize
         }).then((res) => {
           if (res.code === 200) {
+            // let arr=[]
+            res.data.map((item)=>{
+              if(item.baseOperationType===1){
+                item.baseOperationType="鏀惰揣"
+              }else if(item.baseOperationType===2){
+                item.baseOperationType="浜よ揣"
+              }else if(item.baseOperationType===3){
+                item.baseOperationType="鍐呴儴璋冩嫧"
+              }else if(item.baseOperationType===4){
+                item.baseOperationType="鎶ュ簾"
+              }else if(item.baseOperationType===5){
+                item.baseOperationType="搴撳瓨鐩樼偣"
+              }
+            })
             this.tableList.tableInfomation = res.data
             this.pagerOptions.totalCount = res.total
           }
diff --git a/src/views/warehouseManage/listingRules/index.vue b/src/views/warehouseManage/listingRules/index.vue
index b7be896..6e0c9d6 100644
--- a/src/views/warehouseManage/listingRules/index.vue
+++ b/src/views/warehouseManage/listingRules/index.vue
@@ -221,7 +221,7 @@
     isSel() {
       for (let i = 0; i < this.tableData.length; i++) {
         if (this.tableData[i].productName.length === 0) {
-          this.isNoProduct = true
+          this.isNoProduct = true // 鏆傛椂淇敼涓簍rue锛屽鏋滀骇鍝佷互鍚庢槸蹇呭~锛屾敼涓篺alse灏辫
           break
         } else {
           this.isNoProduct = true

--
Gitblit v1.8.0