From 9b7020d0fe83aa848e92551c5252add6e05c2c5b Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 13 三月 2024 10:34:25 +0800
Subject: [PATCH] 状态就绪问题修改
---
src/views/supplierManage/supplier/AddNewProduct.vue | 142 ++++++++++++++++++++++++++++-------------------
1 files changed, 85 insertions(+), 57 deletions(-)
diff --git a/src/views/supplierManage/supplier/AddNewProduct.vue b/src/views/supplierManage/supplier/AddNewProduct.vue
index 0478e65..5c73f04 100644
--- a/src/views/supplierManage/supplier/AddNewProduct.vue
+++ b/src/views/supplierManage/supplier/AddNewProduct.vue
@@ -14,13 +14,18 @@
<div class="basic-info-title">浜у搧淇℃伅</div>
<div class="basic-info-view">
<CommonFormTableView
+ ref="productTable"
+ :addTypeIdMultiple="true"
:product-table-list="productTableList"
:detail-enter="detailEnter"
+ :isOperate="isOperate"
@inputContent="inputContent"
@addProductClick="addProductClick"
+ @getSelectArray="getSelectArray"
@emptyProductClick="emptyProductClick"
@clearupProduct="clearupProduct"
@selCommonName="selCommonName"
+ @handleProduct="handleProduct"
/>
</div>
</div>
@@ -61,6 +66,7 @@
isNoProduct: true,
supplierId: this.addCommonConfig.infomation.supplierId,
detailEnter: true,
+ isOperate: true,
deliveryTime: this.addCommonConfig.infomation.deliveryTime, // 渚涜揣鏃堕暱
shippingDuration: this.addCommonConfig.infomation.shippingDuration, // 鐗╂祦鏃堕暱
purchasePrice: this.addCommonConfig.infomation.purchasePrice // 閲囪喘浠锋牸
@@ -78,47 +84,55 @@
},
// 淇濆瓨
saveClick() {
- 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()
+ 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()
+ }
+ })
+ .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 = {
deliveryTime: this.deliveryTime || 0,
- id: data.ID || 0,
+ id: data.id || 0,
maximumStock: data.maximumStock || 0,
minimumStock: data.minimumStock || 0,
modelNumber: data.modelNumber || "",
@@ -133,6 +147,9 @@
unit: data.unit || ""
}
return params
+ },
+ handleProduct(item, row) {
+ this.editConfig.infomation.id = row.id
},
setTableForm() {
if (this.editConfig.title === "娣诲姞") {
@@ -156,8 +173,9 @@
}
this.productTableList = {
tableData: this.tableData,
+ isReturn: true,
tableColumn: [
- { label: "浜у搧鍚嶇О", prop: "name", productName: true, isRequird: true },
+ { label: "浜у搧鍚嶇О", prop: "name", productName: true, isRequird: true, width: 250 },
{ label: "浜у搧缂栫爜", prop: "number" },
{ label: "璁¢噺鍗曚綅", prop: "unit" },
{ label: "瑙勬牸鍨嬪彿", prop: "specifications" },
@@ -169,36 +187,46 @@
},
// 浜у搧鍒楄〃杈撳叆
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) {
+ if (item.number === row.number) {
item[prop] = val
- item.supplierId = this.supplierId
- item.deliveryTime = this.deliveryTime
- item.shippingDuration = this.shippingDuration
- item.purchasePrice = this.purchasePrice
+ item.supplierId = Number(this.supplierId)
}
})
},
// 浜у搧鏂板
addProductClick() {
- this.productId++
- this.tableData.push({
- productId: this.productId,
- id: 0,
- amount: 0,
- desc: "",
- name: "",
- number: "",
- purchasePrice: 0,
- total: 0,
- deliveryTime: 0,
- shippingDuration: 0,
- supplierId: this.supplierId
- })
+ // this.productId++
+ // this.tableData.push({
+ // productId: this.productId,
+ // id: 0,
+ // amount: 0,
+ // desc: "",
+ // name: "",
+ // number: "",
+ // purchasePrice: 0,
+ // total: 0,
+ // deliveryTime: 0,
+ // shippingDuration: 0,
+ // supplierId: this.supplierId
+ // })
+ },
+ // 鏂板鏂瑰紡淇敼
+ getSelectArray(val, index) {
+ console.log(val, "ddd99999")
+ if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
+ this.tableData = []
+ }
+ if (index < this.tableData.length) {
+ this.tableData.splice(index, 1)
+ val.map((item, ind) => {
+ this.tableData.splice(index + ind, 0, item)
+ })
+ } else {
+ this.tableData = this.tableData.concat(val)
+ }
+ this.productTableList.tableData = this.tableData
+ // this.showSummary.show = true
},
// 浜у搧娓呯┖
emptyProductClick() {
--
Gitblit v1.8.0