From d07ef537be9cc30e40aeecff097b393e52cbf41e Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期三, 29 十一月 2023 17:32:10 +0800 Subject: [PATCH] 采购详情的采购状态枚举值修改 --- src/views/supplierManage/supplier/AddNewProduct.vue | 155 +++++++++++++++++++++++++++++++++------------------ 1 files changed, 100 insertions(+), 55 deletions(-) diff --git a/src/views/supplierManage/supplier/AddNewProduct.vue b/src/views/supplierManage/supplier/AddNewProduct.vue index f1d305e..4ebb1bc 100644 --- a/src/views/supplierManage/supplier/AddNewProduct.vue +++ b/src/views/supplierManage/supplier/AddNewProduct.vue @@ -14,11 +14,14 @@ <div class="basic-info-title">浜у搧淇℃伅</div> <div class="basic-info-view"> <CommonFormTableView + ref="productTable" :product-table-list="productTableList" + :detail-enter="detailEnter" @inputContent="inputContent" @addProductClick="addProductClick" @emptyProductClick="emptyProductClick" @clearupProduct="clearupProduct" + @selCommonName="selCommonName" /> </div> </div> @@ -31,7 +34,7 @@ </template> <script> -// import { getAddContact, getUpdateContact } from "@/api/client/contacts" +import { createProduct, updateProduct } from "@/api/productManage/product" import CommonFormTableView from "@/components/makepager/CommonFormTableView" export default { name: "AddNewProduct", @@ -51,12 +54,17 @@ computed: {}, data() { return { - dialogWidth: "80%", + dialogWidth: "60%", editConfig: this.addCommonConfig, productTableList: {}, tableData: [], productId: 1, - isNoProduct: true + isNoProduct: true, + supplierId: this.addCommonConfig.infomation.supplierId, + detailEnter: true, + deliveryTime: this.addCommonConfig.infomation.deliveryTime, // 渚涜揣鏃堕暱 + shippingDuration: this.addCommonConfig.infomation.shippingDuration, // 鐗╂祦鏃堕暱 + purchasePrice: this.addCommonConfig.infomation.purchasePrice // 閲囪喘浠锋牸 } }, created() { @@ -71,53 +79,73 @@ }, // 淇濆瓨 saveClick() { - console.log(this.editConfig.infomation) - const params = this.saveParams() - console.log(params) - if (this.editConfig.title === "娣诲姞") { - // getAddContact(params).then((res) => { - // console.log(res) - // this.editConfig.visible = false - // if (res.code === 200) { - // this.$message.success("娣诲姞鎴愬姛") - // this.$parent.getData() - // } - // }) - } else { - // getUpdateContact(params).then((res) => { - // console.log(res) - // this.editConfig.visible = false - // if (res.code === 200) { - // this.$message.success("缂栬緫鎴愬姛") - // this.$parent.getData() - // } - // }) - } + 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 + } + } + 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() + } + }) + .catch((e) => { + console.log(e) + }) + } 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 = { - id: this.editConfig.title === "娣诲姞" ? 0 : data.id, - birthday: data.birthday || "", - city_id: data.city_id || 0, - client_id: this.clientId || 0, - country_id: data.country_id || 0, - desc: data.desc || "", - email: data.email || "", - is_first: data.is_first || false, - member_id: data.member_id || 0, + deliveryTime: this.deliveryTime || 0, + id: data.ID || 0, + maximumStock: data.maximumStock || 0, + minimumStock: data.minimumStock || 0, + modelNumber: data.modelNumber || "", name: data.name || "", number: data.number || "", - phone: data.phone || "", - position: data.position || "", - province_id: data.province_id || 0, - region_id: data.region_id || 0, - wechat: data.wechat || "" + productType: data.productType || "", + purchasePrice: this.purchasePrice || 0, + remark: data.remark || "", + shippingDuration: this.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, @@ -127,34 +155,40 @@ 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, tableColumn: [ - { label: "浜у搧鍚嶇О", prop: "name", productName: true, isRequird: true }, + { label: "浜у搧鍚嶇О", prop: "name", productName: true, isRequird: true, width: 250 }, { label: "浜у搧缂栫爜", prop: "number" }, - { label: "璁¢噺鍗曚綅", prop: "number" }, - { label: "瑙勬牸鍨嬪彿", prop: "number" }, - { label: "閲囪喘浠锋牸", prop: "amount", inputFloat: true, isRequird: true }, - { label: "渚涜揣鏃堕暱", prop: "price", inputNumber: true, isRequird: true }, - { label: "鐗╂祦鏃堕暱", prop: "total", inputNumber: true, isRequird: true } + { label: "璁¢噺鍗曚綅", prop: "unit" }, + { label: "瑙勬牸鍨嬪彿", prop: "specifications" }, + { label: "閲囪喘浠锋牸", prop: "purchasePrice", inputFloat: true, isRequird: true }, + { label: "渚涜揣鏃堕暱", prop: "deliveryTime", inputNumber: true, isRequird: true }, + { label: "鐗╂祦鏃堕暱", prop: "shippingDuration", inputNumber: true, isRequird: true } ] } }, // 浜у搧鍒楄〃杈撳叆 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 } }) }, @@ -168,8 +202,11 @@ desc: "", name: "", number: "", - price: 0, - total: 0 + purchasePrice: 0, + total: 0, + deliveryTime: 0, + shippingDuration: 0, + supplierId: this.supplierId }) }, // 浜у搧娓呯┖ @@ -183,8 +220,11 @@ desc: "", name: "", number: "", - price: 0, - total: 0 + purchasePrice: 0, + total: 0, + deliveryTime: 0, + shippingDuration: 0, + supplierId: this.supplierId } ] this.productTableList.tableData = this.tableData @@ -193,6 +233,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