From 563c60ab9d465e275bf18b57fde7b51c4bc020da Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期三, 29 十一月 2023 15:32:56 +0800
Subject: [PATCH] 出入库明细单打印功能调整,新引入三方库:html2Canvas,jsPdf,vue-office

---
 src/views/productManage/productCategory/AddProductCategoryDialog.vue |  101 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/src/views/productManage/productCategory/AddProductCategoryDialog.vue b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
index 841d7b4..b4330aa 100644
--- a/src/views/productManage/productCategory/AddProductCategoryDialog.vue
+++ b/src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -1,14 +1,14 @@
 <template>
   <div class="add-common">
     <el-dialog
-      :title="editCommonConfig.title + '浜у搧绫诲埆'"
+      :title="modalTitle + '浜у搧绫诲埆'"
       :visible.sync="editConfig.visible"
       :width="dialogWidth"
       :before-close="handleClose"
     >
       <!-- 澶� -->
       <div slot="title" class="dialog-header">
-        <span>{{ editCommonConfig.title + "浜у搧绫诲埆" }}</span>
+        <span>{{ modalTitle + "浜у搧绫诲埆" }}</span>
         <div class="header_btns">
           <!-- <span class="btn">
             <i class="el-icon-printer"></i>
@@ -36,10 +36,14 @@
         label-position="right"
         label-width="110px"
         size="mini"
-        style="height: 290px; overflow-x: hidden"
       >
         <div class="basic-info">
-          <FormBtnsView :showProduct="true" @productClick="productClick" />
+          <FormBtnsView
+            :showProduct="true"
+            :countObject="statisticsMap"
+            @productClick="productClick"
+            @listingRulesClick="listingRulesClick"
+          />
           <div class="basic-info-view">
             <!-- <el-row> -->
             <!-- <el-col :span="24">
@@ -161,9 +165,9 @@
         </div>
       </el-form>
       <!-- 灏� -->
-      <div v-if="showFooter" slot="footer" class="dialog-footer">
+      <div slot="footer" class="dialog-footer">
         <!-- <el-button type="primary" size="small" @click="editConfig.visible = false">淇濆苟鎻愪氦瀹℃壒</el-button> -->
-        <el-button type="primary" size="small" @click="saveClick('form')">淇濆瓨</el-button>
+        <el-button type="primary" size="small" @click="saveClick('form')" :disabled="!showFooter">淇濆瓨</el-button>
         <el-button size="small" @click="editConfig.visible = false">鍙栨秷</el-button>
       </div>
     </el-dialog>
@@ -174,6 +178,7 @@
 import { addProductCategory, updateProductCategory, deleteProductCategory } from "@/api/product/productCategory"
 
 import { getDataByType } from "@/api/data"
+import { getProductList } from "@/api/product/product"
 export default {
   name: "AddProductCategoryDialog",
   props: {
@@ -183,7 +188,8 @@
         return {
           visible: false,
           title: "鏂板缓",
-          infomation: { type: [] }
+          infomation: { type: [] },
+          autoEdit: false
         }
       }
     },
@@ -195,7 +201,17 @@
     }
   },
   components: {},
-  computed: {},
+  computed: {
+    modalTitle() {
+      if (this.editConfig.title === "缂栬緫" && this.editConfig.autoEdit) {
+        return "缂栬緫"
+      } else if (this.editConfig.title === "缂栬緫") {
+        return !this.showEdit ? "缂栬緫" : "鏌ョ湅"
+      } else {
+        return "鏂板缓"
+      }
+    }
+  },
   data() {
     return {
       dialogWidth: "50%",
@@ -213,13 +229,65 @@
       showButton: true,
       showEdit: false, // 鏄惁鏄剧ず缂栬緫鎸夐挳
       isDelClick: false, // 鍒犻櫎鎸夐挳鏄惁鍙偣鍑�
-      showFooter: false // 鏄惁鏄剧ず鍙栨秷淇濆瓨
+      showFooter: false, // 鏄惁鏄剧ず鍙栨秷淇濆瓨,
+      statisticsMap: {
+        product: 0 // 浜у搧鏁伴噺
+      }
     }
   },
   created() {
     this.setBottonView()
+    this.getProductCount()
+    if (this.editConfig.autoEdit) {
+      this.editClick()
+    }
+    this.setOptionalFieldsToEmpty()
   },
   methods: {
+    /**
+     * 闈炲繀濉」鍚庣杩斿洖鐨勬槸鏁板瓧 0,琛ㄥ崟闇�瑕佺┖涓叉墠鑳借涓烘湭閫夋嫨鍥炴樉
+     */
+    setOptionalFieldsToEmpty() {
+      let arr = ["parentId", "costingMethod", "inventoryValuation", "forceRemovalStrategy"]
+      arr
+        .filter((filed) => this.editConfig.infomation[filed] === 0)
+        .forEach((filed) => {
+          this.editConfig.infomation[filed] = ""
+        })
+    },
+    /**
+     * 鍚庣鍙帴鍙楁暟瀛楀舰寮�, 淇濆瓨鏃惰繕寰楀啀杞洖鍘�
+     */
+    unsetFieldsToNumber() {
+      let arr = ["parentId", "costingMethod", "inventoryValuation", "forceRemovalStrategy"]
+      arr
+        .filter((filed) => this.editConfig.infomation[filed] === "")
+        .forEach((filed) => {
+          this.editConfig.infomation[filed] = 0
+        })
+    },
+    // 鑾峰彇浜у搧鏁伴噺
+    getProductCount() {
+      if (this.editConfig.title !== "鏂板缓") {
+        getProductList({
+          keyWord: "",
+          categoryId: this.editConfig.title === "鏂板缓" ? null : this.editConfig.infomation.id,
+          page: 1,
+          pageSize: 1
+        })
+          .then((res) => {
+            if (res.code === 200) {
+              this.statisticsMap.product = res?.total ?? 0
+            } else {
+              this.statisticsMap.product = 0
+            }
+          })
+          .catch((err) => {
+            console.error(err)
+            this.statisticsMap.product = 0
+          })
+      }
+    },
     // 璁剧疆鍒犻櫎/鎵撳嵃/缂栬緫鏄惁鏄剧ず
     setBottonView() {
       if (this.editConfig.title === "鏂板缓") {
@@ -255,6 +323,7 @@
       this.showFooter = true
     },
     saveParams() {
+      this.unsetFieldsToNumber()
       let data = JSON.parse(JSON.stringify(this.editConfig.infomation))
 
       let params = {
@@ -316,6 +385,20 @@
           })
         }
       })
+    },
+    // 涓婃灦瑙勫垯
+    listingRulesClick() {
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          this.$router.push({
+            path: "/warehouseManage/listingRules",
+            query: {
+              categoryName: this.editConfig.infomation.name,
+              id: this.editConfig.title === "鏂板缓" ? "" : this.editConfig.infomation.id
+            }
+          })
+        }
+      })
     }
   }
 }

--
Gitblit v1.8.0