From d958c09166e101483bfd845da9340ce525355815 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期三, 28 二月 2024 16:13:33 +0800
Subject: [PATCH] 新建销售子单和新建销售明细单-产品管理-添加、编辑、删除产品数据处理和保存时数据处签约实际默认设置
---
src/views/sales/subOrder/AddSubOrderDialog.vue | 123 ++++++++++++++---------
src/views/sales/salesDetails/AddSalesDetailsDialog.vue | 162 +++++++++++++++++---------------
src/views/sales/salesDetails/index.vue | 1
3 files changed, 160 insertions(+), 126 deletions(-)
diff --git a/src/views/sales/salesDetails/AddSalesDetailsDialog.vue b/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
index 290677e..a7a24a2 100644
--- a/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
+++ b/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
@@ -182,7 +182,7 @@
}
]"
>
- <!-- isAddQuatation || -->
+ <!-- isAddQuatation || -->
<div class="custom-name">
<el-autocomplete
v-model="editConfig.infomation.quotation_number"
@@ -195,14 +195,10 @@
@select="handleSelectClient('quotation', $event)"
style="width: 100%"
placeholder="璇烽�夋嫨閿�鍞姤浠峰崟"
- :disabled=" isView"
+ :disabled="isView"
></el-autocomplete>
<!-- !isAddQuatation && editConfig.infomation.sale_chance_name &&-->
- <div
- v-if=" !isView"
- class="common-select-btn"
- @click="selClientClick('quotation')"
- >
+ <div v-if="!isView" class="common-select-btn" @click="selClientClick('quotation')">
<i class="el-icon-circle-plus-outline" title="閫夋嫨"></i>
</div>
<!-- !isAddQuatation && -->
@@ -568,7 +564,7 @@
},
data() {
return {
- dialogWidth: "50%",
+ dialogWidth: "60%",
editConfig: this.editCommonConfig,
rules: {
client_name: [{ required: true, message: "璇烽�夋嫨瀹㈡埛鍚嶇О", trigger: "change" }],
@@ -644,7 +640,7 @@
},
created() {
if (this.editConfig.title !== "鏂板缓") {
- this.productTableList.tableData=[
+ this.productTableList.tableData = [
{
productId: this.productId,
id: 0,
@@ -721,61 +717,67 @@
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 === "鏂板缓") {
- getAddSalesDetails(params).then((res) => {
- console.log(res)
- this.editConfig.visible = false
- if (res.code === 200) {
- this.tableData.map((item) => {
- this.amountTotal += parseFloat(item.total)
- })
- let config = {
- amountTotal: this.amountTotal,
- id: res.data.id
- }
- this.$emit("addCollectionPlanClick", config)
- }
- })
- } else {
- getUpdateSalesDetails(params).then((res) => {
- console.log(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 === "鏂板缓") {
+ getAddSalesDetails(params).then((res) => {
+ console.log(res)
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.tableData.map((item) => {
+ this.amountTotal += parseFloat(item.total)
+ })
+ let config = {
+ amountTotal: this.amountTotal,
+ id: res.data.id
+ }
+ this.$emit("addCollectionPlanClick", config)
+ }
+ })
+ } else {
+ getUpdateSalesDetails(params).then((res) => {
+ console.log(res)
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.$message.success("缂栬緫鎴愬姛")
+ this.$parent.getData()
+ }
+ })
+ }
}
+ // } else {
+ // console.log("error submit")
+ // return false
+ // }
})
},
saveParams() {
let data = this.editConfig.infomation
+ let products = []
+ this.tableData.map((item) => {
+ if (item.number.length > 0) {
+ products.push(item)
+ }
+ })
let commonParam = {
address: data.address || "",
addressee: data.addressee || "",
@@ -785,7 +787,7 @@
memberId: data.memberId || 0,
number: data.number || "",
phone: data.phone || "",
- products: this.tableData,
+ products: products,
remark: data.remark || "",
saleChanceId: this.saleChanceId || 0,
saleType: data.saleType || 0,
@@ -828,7 +830,7 @@
if (res.code == 200) {
console.log(res)
this.quotationList = res.data.list
- this.count=res.data.count;
+ this.count = res.data.count
if (value === "鍏ㄩ儴浜у搧") {
// this.quotationList.map((item) => {
// if (item.id === this.editConfig.infomation.quotationId) {
@@ -854,13 +856,13 @@
restaurants = this.clientList
console.log(restaurants, "瀹㈡埛鍗�")
} else if (value === "chance") {
- if(this.editConfig.infomation.client_name){
+ if (this.editConfig.infomation.client_name) {
restaurants = this.saleChancelist
}
} else if (value === "subbill") {
restaurants = this.subOrderList
} else if (value === "quotation") {
- if(this.editConfig.infomation.sale_chance_name){
+ if (this.editConfig.infomation.sale_chance_name) {
restaurants = this.quotationList
}
}
@@ -930,7 +932,7 @@
if (value === "client") {
this.editSelectClientConfig.editVisible = true
} else if (value === "chance") {
- if(this.clientId){
+ if (this.clientId) {
this.editSelectChanceConfig.clientId = this.clientId
}
this.editSelectChanceConfig.editVisible = true
@@ -940,15 +942,15 @@
this.editSelCommonConfig.clientId = this.clientId
} else if (value === "quotation") {
this.editSelCommonConfig.title = "鎶ヤ环鍗�"
- if(this.saleChanceId&&this.clientId){
+ if (this.saleChanceId && this.clientId) {
this.editSelCommonConfig.clientId = this.clientId
// 姝e悜閫夋嫨瀹㈡埛 閿�鍞満浼� 鎶ヤ环鍗�
this.editSelCommonConfig.isRequest = false
- this.editSelCommonConfig.count=this.count
+ this.editSelCommonConfig.count = this.count
this.editSelCommonConfig.tableInfomation = [...this.quotationList]
- }else{
- // 鍙嶅悜閫夋嫨
- this.editSelCommonConfig.isRequest = true;
+ } else {
+ // 鍙嶅悜閫夋嫨
+ this.editSelCommonConfig.isRequest = true
}
this.editSelCommonConfig.editVisible = true
}
@@ -956,10 +958,10 @@
selClient(row, value) {
if (value === "client") {
this.editConfig.infomation.sale_chance_name = ""
- this.saleChanceId=''
+ this.saleChanceId = ""
this.editConfig.infomation.subbill_name = ""
// 娓呯┖鎶ヤ环鍗�
- this.editConfig.infomation.quotation_number =''
+ this.editConfig.infomation.quotation_number = ""
this.editConfig.infomation.client_name = row.name
this.clientId = row.id
this.getSaleChanceList(row)
@@ -970,7 +972,7 @@
this.clientId = row.client.id
this.saleChanceId = row.id
// 娓呯┖鎶ヤ环鍗�
- this.editConfig.infomation.quotation_number =''
+ this.editConfig.infomation.quotation_number = ""
this.isAddQuatation = false
this.getQuotation(row.id)
} else if (value === "subbill") {
@@ -1052,8 +1054,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: "specs" },
{ label: "鍨嬪彿", prop: "type" },
@@ -1070,9 +1073,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
}
})
@@ -1097,13 +1100,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
},
diff --git a/src/views/sales/salesDetails/index.vue b/src/views/sales/salesDetails/index.vue
index 88a2e02..d57155c 100644
--- a/src/views/sales/salesDetails/index.vue
+++ b/src/views/sales/salesDetails/index.vue
@@ -535,6 +535,7 @@
console.log(this.addConfig)
this.editConfig.infomation = {
...this.addConfig,
+ signTime: new Date().toLocaleDateString(),
currency: "浜烘皯甯�",
sale_chance_name: "",
subbill_name: "",
diff --git a/src/views/sales/subOrder/AddSubOrderDialog.vue b/src/views/sales/subOrder/AddSubOrderDialog.vue
index 198b6bb..f37f656 100644
--- a/src/views/sales/subOrder/AddSubOrderDialog.vue
+++ b/src/views/sales/subOrder/AddSubOrderDialog.vue
@@ -167,9 +167,11 @@
<div class="product-view">
<CommonFormTableView
:show-summary="showSummary"
+ :addTypeIdMultiple="true"
:product-table-list="productTableList"
@inputContent="inputContent"
@addProductClick="addProductClick"
+ @getSelectArray="getSelectArray"
@emptyProductClick="emptyProductClick"
@recalculateProductClick="recalculateProductClick"
@clearupProduct="clearupProduct"
@@ -346,53 +348,59 @@
this.$refs[formName].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("浜у搧鍚嶇О涓嶈兘涓虹┖")
+ // 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 {
+ const params = this.saveParams()
+ if (this.editConfig.title === "鏂板缓") {
+ getAddSubOrder(params).then((res) => {
+ console.log(res)
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.$message.success("娣诲姞鎴愬姛")
+ this.$parent.getData()
+ }
+ })
} else {
- const params = this.saveParams()
- if (this.editConfig.title === "鏂板缓") {
- getAddSubOrder(params).then((res) => {
- console.log(res)
- this.editConfig.visible = false
- if (res.code === 200) {
- this.$message.success("娣诲姞鎴愬姛")
- this.$parent.getData()
- }
- })
- } else {
- getUpdateSubOrder(params).then((res) => {
- console.log(res)
- this.editConfig.visible = false
- if (res.code === 200) {
- this.$message.success("缂栬緫鎴愬姛")
- this.$parent.getData()
- }
- })
- }
+ getUpdateSubOrder(params).then((res) => {
+ console.log(res)
+ this.editConfig.visible = false
+ if (res.code === 200) {
+ this.$message.success("缂栬緫鎴愬姛")
+ this.$parent.getData()
+ }
+ })
}
- } else {
- console.log("error submit")
- return false
}
+ // } else {
+ // console.log("error submit")
+ // return false
+ // }
})
},
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,
clientId: this.clientId || 0,
masterOrderId: this.masterId || 0,
memberId: data.memberId || 0,
number: data.number || "",
- product: this.tableData,
+ product: products,
codeStandID: data.ID
}
return params
@@ -515,8 +523,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 },
{ label: "浜у搧缂栧彿", prop: "number" },
{ label: "鏁伴噺", prop: "amount", inputNumber: true, isRequird: true },
@@ -528,27 +537,43 @@
},
// 浜у搧鍒楄〃杈撳叆
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
}
})
},
// 浜у搧鏂板
addProductClick() {
- this.productId++
- this.tableData.push({
- productId: this.productId,
- id: 0,
- amount: 0,
- desc: "",
- name: "",
- number: "",
- price: 0,
- total: 0,
- unit: ""
- })
+ // this.productId++
+ // this.tableData.push({
+ // productId: this.productId,
+ // id: 0,
+ // amount: 0,
+ // desc: "",
+ // name: "",
+ // number: "",
+ // price: 0,
+ // total: 0,
+ // unit: ""
+ // })
+ // this.showSummary.show = true
+ },
+ // 鏂板鏂瑰紡淇敼
+ getSelectArray(val, index) {
+ 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
},
// 浜у搧娓呯┖
--
Gitblit v1.8.0