From 3a1a63d17e21cb9c26e4515e49e9ff75f59f52a0 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期三, 06 九月 2023 17:51:57 +0800 Subject: [PATCH] 产品管理样式修改 --- src/views/supplierManage/supplier/AddNewProduct.vue | 84 ++++++++++++++++++++++++++++------------- 1 files changed, 57 insertions(+), 27 deletions(-) diff --git a/src/views/supplierManage/supplier/AddNewProduct.vue b/src/views/supplierManage/supplier/AddNewProduct.vue index 3fdb08e..d5e590c 100644 --- a/src/views/supplierManage/supplier/AddNewProduct.vue +++ b/src/views/supplierManage/supplier/AddNewProduct.vue @@ -14,6 +14,7 @@ <div class="basic-info-title">浜у搧淇℃伅</div> <div class="basic-info-view"> <CommonFormTableView + ref="productTable" :product-table-list="productTableList" :detail-enter="detailEnter" @inputContent="inputContent" @@ -60,7 +61,10 @@ productId: 1, isNoProduct: true, supplierId: this.addCommonConfig.infomation.supplierId, - detailEnter: true + detailEnter: true, + deliveryTime: this.addCommonConfig.infomation.deliveryTime, // 渚涜揣鏃堕暱 + shippingDuration: this.addCommonConfig.infomation.shippingDuration, // 鐗╂祦鏃堕暱 + purchasePrice: this.addCommonConfig.infomation.purchasePrice // 閲囪喘浠锋牸 } }, created() { @@ -75,34 +79,50 @@ }, // 淇濆瓨 saveClick() { - console.log(this.editConfig.infomation) - if (this.editConfig.title === "娣诲姞") { - createProduct({ - list: this.tableData - }).then((res) => { - console.log(res) - this.editConfig.visible = false - if (res.code === 200) { - this.$message.success("娣诲姞鎴愬姛") - this.$parent.getProductList() + this.$refs.productTable.$refs.form.validate((valid) => { + if (valid) { + console.log(this.editConfig.infomation) + for (let i = 0; i < this.tableData.length; i++) { + if (this.tableData[i].name.length === 0) { + this.isNoProduct = true + break + } else { + this.isNoProduct = false + } } - }) - } else { - 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() + if (this.isNoProduct) { + this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖") + } else { + if (this.editConfig.title === "娣诲姞") { + createProduct({ + list: this.tableData + }).then((res) => { + console.log(res) + this.editConfig.visible = false + if (res.code === 200) { + this.$message.success("娣诲姞鎴愬姛") + this.$parent.getProductList() + } + }) + } else { + 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 params = { - deliveryTime: data.deliveryTime || 0, + deliveryTime: this.deliveryTime || 0, id: data.ID || 0, maximumStock: data.maximumStock || 0, minimumStock: data.minimumStock || 0, @@ -110,9 +130,9 @@ name: data.name || "", number: data.number || "", productType: data.productType || "", - purchasePrice: data.purchasePrice || 0, + purchasePrice: this.purchasePrice || 0, remark: data.remark || "", - shippingDuration: data.shippingDuration || 0, + shippingDuration: this.shippingDuration || 0, specifications: data.specifications || "", supplierId: this.supplierId || 0, unit: data.unit || "" @@ -155,10 +175,16 @@ // 浜у搧鍒楄〃杈撳叆 inputContent(val, prop, row) { this.productId = row.productId + this.deliveryTime = row.deliveryTime + this.shippingDuration = row.shippingDuration + this.purchasePrice = row.purchasePrice this.tableData.map((item) => { if (item.productId === row.productId) { item[prop] = val item.supplierId = this.supplierId + item.deliveryTime = this.deliveryTime + item.shippingDuration = this.shippingDuration + item.purchasePrice = this.purchasePrice } }) }, @@ -172,8 +198,10 @@ desc: "", name: "", number: "", - price: 0, + purchasePrice: 0, total: 0, + deliveryTime: 0, + shippingDuration: 0, supplierId: this.supplierId }) }, @@ -188,8 +216,10 @@ desc: "", name: "", number: "", - price: 0, + purchasePrice: 0, total: 0, + deliveryTime: 0, + shippingDuration: 0, supplierId: this.supplierId } ] -- Gitblit v1.8.0