From 504e00da9a9898ac419e97f93fc66cc7c7c6f620 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期三, 28 二月 2024 14:30:25 +0800 Subject: [PATCH] 服务合同-去掉产品为空的判断增加保存时去掉未选择产品的对象 --- src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue | 106 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue b/src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue index db9ee6d..62d4db1 100644 --- a/src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue +++ b/src/views/sales/salesOpportunity/AddSalesOpportunityDialog.vue @@ -34,16 +34,14 @@ <el-input v-if=" editConfig.title == '缂栬緫' || - (editConfig.title == '鏂板缓' && - codenumer && - (explain != '' || isIdDisabled)) + (editConfig.title == '鏂板缓' && codenumer && (explain != '' || isIdDisabled)) " :disabled="editConfig.title == '缂栬緫'" v-model="editConfig.infomation.number" placeholder="璇疯緭鍏ョ紪鐮�" > </el-input> - <span v-else-if="editConfig.title == '鏂板缓'" style="color: #f56c6c" + <span v-else-if="editConfig.title == '鏂板缓'" style="color: #f56c6c" >璇蜂紭鍏堥厤缃紪鐮佽鑼� <el-button type="text" @click="numberClick"> 閰嶇疆瑙勮寖 </el-button></span > <!-- <WordInput @@ -328,13 +326,15 @@ </div> <div class="product-view"> <CommonFormTableView - :show-summary="showSummary" - :product-table-list="productTableList" - @inputContent="inputContent" - @addProductClick="addProductClick" - @emptyProductClick="emptyProductClick" - @recalculateProductClick="recalculateProductClick" - @clearupProduct="clearupProduct" + :show-summary="showSummary" + :addTypeIdMultiple="true" + :product-table-list="productTableList" + @inputContent="inputContent" + @addProductClick="addProductClick" + @getSelectArray="getSelectArray" + @emptyProductClick="emptyProductClick" + @recalculateProductClick="recalculateProductClick" + @clearupProduct="clearupProduct" /> </div> @@ -617,7 +617,7 @@ import { getCityList } from "@/api/common/address" import codeMixin from "@/components/makepager/mixin/codeMixin" import { getContactList } from "@/api/client/contacts" -import CommonFormTableView from "@/components/makepager/CommonFormTableView.vue"; +import CommonFormTableView from "@/components/makepager/CommonFormTableView.vue" export default { name: "AddSalesOpportunityDialog", mixins: [codeMixin], @@ -633,7 +633,7 @@ } } }, - components: {CommonFormTableView, SelectClientDialog, SelectContactDialog }, + components: { CommonFormTableView, SelectClientDialog, SelectContactDialog }, computed: { searchCommonHeight() { return this.$refs.searchCommonView.offsetHeight @@ -648,10 +648,10 @@ dialogWidth: "50%", editConfig: this.editCommonConfig, rules: { - number: [{ required: true, validator: this.validateCheckCode, trigger: ["blur",'change'] }], + number: [{ required: true, validator: this.validateCheckCode, trigger: ["blur", "change"] }], name: [{ required: true, message: "璇疯緭鍏ユ満浼氬悕绉�", trigger: "blur" }], - member_id: [{ required: true, message: "璇烽�夋嫨閿�鍞礋璐d汉", trigger: "change" }], + member_id: [{ required: true, validator: this.validateMemberId, trigger: "change" }], sale_stage_id: [{ required: true, message: "璇烽�夋嫨閿�鍞樁娈�", trigger: "change" }], currency: [{ required: true, message: "璇烽�夋嫨甯佺", trigger: "change" }], expected_time: [{ required: true, message: "璇烽�夋嫨棰勮鎴愪氦鏃ユ湡", trigger: "change" }], @@ -694,7 +694,7 @@ sumProp: ["Amount", "total"], mergeNumber: 2 }, - productId:1, + productId: 1 } }, created() { @@ -715,7 +715,7 @@ if (val) { this.formInfo() } - }, + } }, methods: { formInfo() { @@ -734,6 +734,14 @@ getAllData() .then((res) => { this.memberOptions = res.data.member + if (this.editConfig.title === "鏂板缓") { + let username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1") + this.memberOptions.map((item) => { + if (item.username == username) { + this.$set(this.editConfig.infomation, "member_id", item.id) + } + }) + } this.businessSourceOptions = res.data.sales_source this.businessTypeOptions = res.data.sale_type this.oldCustomerMarketOptions = res.data.regular_customers @@ -759,8 +767,8 @@ saveClick(formName) { this.$refs[formName].validate((valid) => { if (valid) { - const hasProduct = this.tableData.every(ele=>!!ele.name) - if (!hasProduct){ + const hasProduct = this.tableData.every((ele) => !!ele.name) + if (!hasProduct) { this.$message.error("浜у搧鍚嶇О涓嶈兘涓虹┖") return } @@ -773,10 +781,13 @@ this.editConfig.visible = false if (res.code === 200) { this.$message.success("娣诲姞鎴愬姛锛�") - this.$parent.getData() - // } - }else{ - this.$message.error(res.msg?res.msg:"娣诲姞澶辫触锛�") + if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation?.sourceTitle === "鎺ㄨ繘") { + this.$parent.handleClose() + } else { + this.$parent.getData() + } + } else { + this.$message.error(res.msg ? res.msg : "娣诲姞澶辫触锛�") } }) } else { @@ -785,9 +796,9 @@ this.editConfig.visible = false if (res.code === 200) { this.$message.success("缂栬緫鎴愬姛锛�") - this.$parent.getData() - }else{ - this.$message.error(res.msg?res.msg:"缂栬緫澶辫触锛�") + this.$parent?.getData() + } else { + this.$message.error(res.msg ? res.msg : "缂栬緫澶辫触锛�") } }) } @@ -836,7 +847,7 @@ detail_address: data.detail_address || "", codeStandID: data.ID, - products: this.tableData, + products: this.tableData } return params }, @@ -991,17 +1002,28 @@ }, // 浜у搧鏂板 addProductClick() { - this.productId++ - this.tableData.push({ - productId: this.productId, - id: 0, - amount: 0, - desc: "", - name: "", - number: "", - price: 0, - total: 0 - }) + // this.productId++ + // this.tableData.push({ + // productId: this.productId, + // id: 0, + // amount: 0, + // desc: "", + // name: "", + // number: "", + // price: 0, + // total: 0 + // }) + // this.showSummary.show = true + }, + // 鏂板鏂瑰紡淇敼 + getSelectArray(val) { + if (val.length > 0) { + val.map((item, index) => { + item.productId = this.tableData.length + index + 1 + }) + } + this.tableData = this.tableData.concat(val) + this.productTableList.tableData = this.tableData this.showSummary.show = true }, // 浜у搧娓呯┖ @@ -1026,6 +1048,14 @@ clearupProduct(data) { this.tableData = data this.productTableList.tableData = this.tableData + }, + // 閿�鍞礋璐d汉鑷畾涔夋牎楠岃鍒� + validateMemberId(rule, value, callback) { + if (this.editConfig.infomation?.member_id > 0) { + callback() + } else { + callback(new Error("璇烽�夋嫨閿�鍞礋璐d汉")) + } } } } -- Gitblit v1.8.0