From 0026b3725127be9b0ec5ab2ec6b05181ccb2997f Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 28 二月 2024 15:49:16 +0800
Subject: [PATCH] 报价单-产品管理-添加、删除、编辑等产品数据处理和保存产品校验和数据处理
---
src/views/sales/quotation/AddQuotationDialog.vue | 120 +++++++++++++++++++++++++++++++++---------------------------
1 files changed, 66 insertions(+), 54 deletions(-)
diff --git a/src/views/sales/quotation/AddQuotationDialog.vue b/src/views/sales/quotation/AddQuotationDialog.vue
index 543a115..241096a 100644
--- a/src/views/sales/quotation/AddQuotationDialog.vue
+++ b/src/views/sales/quotation/AddQuotationDialog.vue
@@ -515,50 +515,50 @@
saveClick(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
+ // 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 {
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 {
- for (let i = 0; i < this.tableData.length; i++) {
- if (this.tableData[i].cost) {
- let reg =/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
- if (!reg.test(this.tableData[i].cost)) {
- this.$message.error("鎴愭湰鍗曚环闇�瑕佸~鍐欏ぇ浜�0鐨�2浣嶅皬鏁帮紒")
- return true
- }
+ if (this.tableData[i].cost) {
+ let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
+ if (!reg.test(this.tableData[i].cost)) {
+ this.$message.error("鎴愭湰鍗曚环闇�瑕佸~鍐欏ぇ浜�0鐨�2浣嶅皬鏁帮紒")
+ return true
}
}
- const params = this.saveParams()
- if (this.editConfig.title === "鏂板缓") {
- getAddQuotation(params).then((res) => {
- console.log(res)
- this.editConfig.visible = false
- if (res.code === 200) {
- this.$message.success("娣诲姞鎴愬姛")
- this.$parent.getData()
- }
- })
- } else {
- getUpdateQuotation(params).then((res) => {
- this.editConfig.visible = false
- if (res.code === 200) {
- this.$message.success("缂栬緫鎴愬姛")
- this.$parent.getData()
- }
- })
- }
}
- } else {
- console.log("error submit")
- return false
+ const params = this.saveParams()
+ if (this.editConfig.title === "鏂板缓") {
+ getAddQuotation(params).then((res) => {
+ console.log(res)
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.$message.success("娣诲姞鎴愬姛")
+ this.$parent.getData()
+ }
+ })
+ } else {
+ getUpdateQuotation(params).then((res) => {
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.$message.success("缂栬緫鎴愬姛")
+ this.$parent.getData()
+ }
+ })
+ }
}
+ // } else {
+ // console.log("error submit")
+ // return false
+ // }
})
},
/**
@@ -573,6 +573,12 @@
},
saveParams() {
let data = this.editConfig.infomation
+ let products = []
+ this.tableData.map((item) => {
+ if (item.number.length > 0) {
+ products.push(item)
+ }
+ })
let params = {
id: this.editConfig.title === "鏂板缓" ? 0 : data.id,
quotationName: data.quotationName || "",
@@ -583,7 +589,7 @@
quotation_status_id: data.quotation_status_id || 0,
sale_chance_id: this.saleChanceId || 0,
validity_date: data.validity_date || "",
- products: this.tableData,
+ products: products,
codeStandID: data.ID,
client_id: this.clientId || 0
}
@@ -617,8 +623,8 @@
this.getSaleChanceList(item)
} else if (value === "chance") {
this.saleChanceId = item.id
- this.productTableList.tableData = item.products?item.products:[]
- this.tableData = item.products?item.products:[]
+ this.productTableList.tableData = item.products ? item.products : []
+ this.tableData = item.products ? item.products : []
} else {
this.contactId = item.id
}
@@ -640,11 +646,11 @@
this.contactId = row.id
} else if (value === "chance") {
this.editConfig.infomation.sale_chance_name = row.name
- this.editConfig.infomation.client_name=row.client.name
+ this.editConfig.infomation.client_name = row.client.name
this.clientId = row.client.id
this.saleChanceId = row.id
- this.productTableList.tableData = row.products?row.products:[]
- this.tableData = row.products?row.products:[]
+ this.productTableList.tableData = row.products ? row.products : []
+ this.tableData = row.products ? row.products : []
} else {
this.editConfig.infomation.client_name = row.name
this.clientId = row.id
@@ -711,8 +717,9 @@
}
this.productTableList = {
tableData: this.tableData,
+ isReturn: true,
tableColumn: [
- { label: "#", prop: "productId", width: 40 },
+ // { label: "#", prop: "productId", width: 40 },
{ label: "浜у搧鍚嶇О", prop: "name", productName: true, isRequird: true, min: 110 },
{ label: "浜у搧缂栧彿", prop: "number" },
{ label: "鍗曚綅", prop: "unit" },
@@ -727,9 +734,9 @@
},
// 浜у搧鍒楄〃杈撳叆
inputContent(val, prop, row) {
- this.productId = row.productId
+ // this.productId = row.productId
this.tableData.map((item) => {
- if (item.productId === row.productId) {
+ if (item.number === row.number) {
item[prop] = val
}
})
@@ -754,13 +761,18 @@
// this.showSummary.show = true
},
// 鏂板鏂瑰紡淇敼
- getSelectArray(val) {
- if (val.length > 0) {
- val.map((item, index) => {
- item.productId = this.tableData.length + index + 1
- })
+ getSelectArray(val, index) {
+ if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
+ this.tableData = []
}
- this.tableData = this.tableData.concat(val)
+ 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
},
--
Gitblit v1.8.0