From 6e84763437df97e194f8c833feca8bdcb90e7103 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期一, 28 八月 2023 14:48:49 +0800 Subject: [PATCH] 产品相关接口联调 --- src/views/supplierManage/supplier/AddNewProduct.vue | 98 ++++++++++++++++++++++++++++--------------------- 1 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/views/supplierManage/supplier/AddNewProduct.vue b/src/views/supplierManage/supplier/AddNewProduct.vue index b9a1812..431779a 100644 --- a/src/views/supplierManage/supplier/AddNewProduct.vue +++ b/src/views/supplierManage/supplier/AddNewProduct.vue @@ -15,10 +15,12 @@ <div class="basic-info-view"> <CommonFormTableView :product-table-list="productTableList" + :detail-enter="detailEnter" @inputContent="inputContent" @addProductClick="addProductClick" @emptyProductClick="emptyProductClick" @clearupProduct="clearupProduct" + @selCommonName="selCommonName" /> </div> </div> @@ -31,7 +33,7 @@ </template> <script> -// import { createProduct, updateProduct } from "@/api/productManage/product" +import { createProduct, updateProduct } from "@/api/productManage/product" import CommonFormTableView from "@/components/makepager/CommonFormTableView" export default { name: "AddNewProduct", @@ -56,7 +58,9 @@ productTableList: {}, tableData: [], productId: 1, - isNoProduct: true + isNoProduct: true, + supplierId: this.addCommonConfig.infomation.supplierId, + detailEnter: true } }, created() { @@ -72,49 +76,52 @@ // 淇濆瓨 saveClick() { console.log(this.editConfig.infomation) - const params = this.saveParams() - console.log(params) if (this.editConfig.title === "娣诲姞") { - // createProduct(params).then((res) => { - // console.log(res) - // this.editConfig.visible = false - // if (res.code === 200) { - // this.$message.success("娣诲姞鎴愬姛") - // this.$parent.getData() - // } - // }) + createProduct({ + list: this.tableData + }).then((res) => { + console.log(res) + this.editConfig.visible = false + if (res.code === 200) { + this.$message.success("娣诲姞鎴愬姛") + this.$parent.getProductList() + } + }) } else { - // updateProduct(params).then((res) => { - // console.log(res) - // this.editConfig.visible = false - // if (res.code === 200) { - // this.$message.success("缂栬緫鎴愬姛") - // this.$parent.getData() - // } - // }) + const params = this.saveParams() + updateProduct(params).then((res) => { + console.log(res) + this.editConfig.visible = false + if (res.code === 200) { + this.$message.success("缂栬緫鎴愬姛") + this.$parent.getProductList() + } + }) } }, saveParams() { - // let data = this.editConfig.infomation + let data = this.editConfig.infomation let params = { - deliveryTime: 0, - id: 0, - maximumStock: 0, - minimumStock: 0, - name: "string", - number: "string", - productType: "string", - purchasePrice: 0, - remark: "string", - shippingDuration: 0, - specifications: "string", - supplierId: 0, - unit: "string" + deliveryTime: data.deliveryTime || 0, + id: data.ID || 0, + maximumStock: data.maximumStock || 0, + minimumStock: data.minimumStock || 0, + modelNumber: data.modelNumber || "", + name: data.name || "", + number: data.number || "", + productType: data.productType || "", + purchasePrice: data.purchasePrice || 0, + remark: data.remark || "", + shippingDuration: data.shippingDuration || 0, + specifications: data.specifications || "", + supplierId: this.supplierId || 0, + unit: data.unit || "" } return params }, setTableForm() { - if (this.editConfig.title === "娣诲姞" || this.editConfig.infomation.products.length === 0) { + if (this.editConfig.title === "娣诲姞") { + this.detailEnter = false this.tableData = [ { productId: this.productId, @@ -124,14 +131,13 @@ name: "", number: "", price: 0, - total: 0 + total: 0, + supplierId: this.supplierId } ] } else { - this.tableData = this.editConfig.infomation.products - this.tableData.map((item, index) => { - item.productId = index + 1 - }) + this.tableData = [{ ...this.editConfig.infomation }] + this.detailEnter = true } this.productTableList = { tableData: this.tableData, @@ -152,6 +158,7 @@ this.tableData.map((item) => { if (item.productId === row.productId) { item[prop] = val + item.supplierId = this.supplierId } }) }, @@ -166,7 +173,8 @@ name: "", number: "", price: 0, - total: 0 + total: 0, + supplierId: this.supplierId }) }, // 浜у搧娓呯┖ @@ -181,7 +189,8 @@ name: "", number: "", price: 0, - total: 0 + total: 0, + supplierId: this.supplierId } ] this.productTableList.tableData = this.tableData @@ -190,6 +199,11 @@ clearupProduct(data) { this.tableData = data this.productTableList.tableData = this.tableData + }, + selCommonName(row) { + console.log("1133") + console.log(row) + this.editConfig.infomation = row } } } -- Gitblit v1.8.0