From eed27d3000e127c433fd45609d0d5e5d06b7868c Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期二, 26 十二月 2023 11:14:28 +0800 Subject: [PATCH] Merge branch 'dev' of http://192.168.5.5:10010/r/web/crm-web into dev --- src/views/other/payment/collectionPlan/AddCollectionPlan.vue | 308 +++++++++++++++++++-------------------------------- 1 files changed, 116 insertions(+), 192 deletions(-) diff --git a/src/views/other/payment/collectionPlan/AddCollectionPlan.vue b/src/views/other/payment/collectionPlan/AddCollectionPlan.vue index 64b634c..25b144d 100644 --- a/src/views/other/payment/collectionPlan/AddCollectionPlan.vue +++ b/src/views/other/payment/collectionPlan/AddCollectionPlan.vue @@ -13,8 +13,8 @@ <div class="collection-view"> <div class="label">鏀舵璁″垝绫诲瀷</div> <el-select v-model="editConfig.infomation.collectionType" size="mini"> - <el-option label="璁″垝鏀舵鏃ユ湡" value="1"></el-option> - <el-option label="椤圭洰鐘舵��" value="2"></el-option> + <el-option label="璁″垝鏀舵鏃ユ湡" :value="1"></el-option> + <el-option label="椤圭洰鐘舵��" :value="2"></el-option> </el-select> </div> <div class="collection-view"> @@ -25,14 +25,14 @@ </div> <div class="collection-view"> <div class="label">閲戦</div> - <div>{{ editConfig.infomation.amount }}</div> + <div>{{ editConfig.infomation.amountTotal }}</div> </div> <div class="collection-view"> <div class="label">鏈鍒掗噾棰�</div> - <div>{{ editConfig.infomation.amount }}</div> + <div>{{ editConfig.infomation.amountTotal }}</div> </div> <div class="collection-view"> - <div class="label">鏀舵璁″垝璐熻矗浜�</div> + <div class="label"><span style="color: #f56c6c">*</span>鏀舵璁″垝璐熻矗浜�</div> <el-select v-model="editConfig.infomation.principalId" placeholder="璇烽�夋嫨" @@ -51,6 +51,7 @@ :data="tableData.tableInfomation" tooltip-effect="dark" style="width: 100%" + max-height="375" :header-cell-style="{ background: '#ECF4FF', color: '#666' }" > <el-table-column @@ -73,7 +74,7 @@ style="width: 100%; margin-right: 5px" @change=" (val) => { - commonInputChange(val, item.prop, scope.row) + commonInputChange(val, item.prop, scope) } " ></el-input-number> @@ -106,7 +107,13 @@ " ></el-input> <div v-else-if="item.date"> - <el-date-picker v-model="scope.row[item.prop]" type="date" size="mini" style="width: 130px"> + <el-date-picker + v-model="scope.row[item.prop]" + type="date" + value-format="yyyy-MM-dd" + size="mini" + style="width: 130px" + > </el-date-picker> </div> <div v-else @click="delClick(scope.row)"><i class="el-icon-delete"></i></div> @@ -124,6 +131,9 @@ <el-option label="1" :value="1"></el-option> <el-option label="2" :value="2"></el-option> <el-option label="3" :value="3"></el-option> + <el-option label="5" :value="5"></el-option> + <el-option label="8" :value="8"></el-option> + <el-option label="10" :value="10"></el-option> </el-select> <span> 鏈�, </span> </div> @@ -142,7 +152,7 @@ </div> <div class="btn-view"> <el-button type="primary" size="small" @click="saveClick">淇濆瓨</el-button> - <el-button size="small" @click="editConfig.visible = false">鍙栨秷</el-button> + <el-button size="small" @click="droppedClick">鍙栨秷</el-button> </div> </div> </el-dialog> @@ -182,31 +192,52 @@ mergeNumber: 7 }, tableData: [], - productId: 1, addProductArr: [], memberOptions: [], allTerms: 3, amount: 130, sourceType: this.editCommonConfig.sourceType, // 婧愬崟绫诲瀷 1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁� sourceId: this.editCommonConfig.infomation.id, - principalId: 0, + principalId: '', planAmount: 0, // 璁″垝閲戦 - firstDate: this.getCurrentDate(1) + firstDate: this.getCurrentDate(1), + collectionType: 1, + tableInfomation: [], + allPercent: 0 } }, created() { - console.log(this.editCommonConfig.sourceType) + console.log(this.editCommonConfig) this.setData() - this.setTableForm() this.getCommonData() }, methods: { + getCookie(cookieName) { + var cookieValue = null; + if (document.cookie && document.cookie !== '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = cookies[i].trim(); + // 蹇界暐涓嶅畬鏁寸殑cookie + if (cookie.startsWith(cookieName + '=')) { + cookieValue = cookie.substring(cookieName.length + 1, cookie.length); + break; + } + } + } + return cookieValue; + }, // 璁剧疆鍒濆鍊� setData() { + this.amount = + typeof this.editCommonConfig.infomation.amountTotal == "string" + ? parseInt(this.editCommonConfig.infomation.amountTotal) + : this.editCommonConfig.infomation.amountTotal this.editConfig.infomation = { - collectionType: "1", + collectionType: this.collectionType, moneyType: "浜烘皯甯�", - amount: this.amount.toFixed(2) + amountTotal: this.editCommonConfig.infomation.amountTotal, + principalId:'' } }, getCommonData() { @@ -215,7 +246,15 @@ console.log(res) if (res.code === 200) { this.memberOptions = res.data.member + let username =this.getCookie('username') + this.memberOptions.map((item) => { + if (item.username == username) { + this.$set(this.editConfig.infomation, "principalId", item.id) + } + }) + this.principalId=this.editConfig.infomation.principalId } + this.setTableForm() }) .catch((err) => { console.log(err) @@ -224,11 +263,16 @@ // 淇濆瓨 saveClick() { this.sumTotalAmount() + console.log(this.amount) if (this.editConfig.title === "鏂板缓") { if (this.principalId === 0) { this.$message.error("璇烽�夋嫨鏀舵璁″垝璐熻矗浜�") + } else if (this.amount === 0) { + this.$message.error("鏀舵閲戦涓嶈兘涓�0") } else if (this.amount !== this.planAmount) { this.$message.error("鏀舵璁″垝鍜屾湭璁″垝閲戦涓嶄竴鑷达紝璇烽噸绠�") + } else if (this.allPercent > 100) { + this.$message.error("鏀舵姣斾緥(%)鎬诲拰澶т簬100锛岃閲嶆柊杈撳叆") } else { const params = this.saveParams() addCollectionPlan(params).then((res) => { @@ -241,6 +285,10 @@ }) } } + }, + droppedClick() { + this.editConfig.visible = false + this.$parent.getData() }, // 璁$畻璁″垝鎬婚 sumTotalAmount() { @@ -259,65 +307,12 @@ }, handleClose() { this.editConfig.visible = false + this.$parent.getData() }, setTableForm() { + this.setTableInfomation(this.allTerms, this.firstDate) this.tableData = { - tableInfomation: [ - { - amount: this.amount, - amountReceivable: this.amount * 0.3, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.getCurrentDate(1), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 30, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 1 - }, - { - amount: this.amount, - amountReceivable: this.amount * 0.5, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.getCurrentDate(2), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 50, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 2 - }, - { - amount: this.amount, - amountReceivable: this.amount * 0.2, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.getCurrentDate(3), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 20, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 3 - } - ], + tableInfomation: this.tableInfomation, tableColumn: [ { label: "鎿嶄綔", prop: "operate", width: 60 }, { label: "鏈熸", prop: "term", inputNumber: true, width: 90 }, @@ -328,129 +323,44 @@ ] } }, + // 鏀舵璁″垝鍒楄〃鍐呭璁$畻 + setTableInfomation(allTerms, date) { + let arr = [] + for (let i = 0; i < allTerms; i++) { + let ratio = 1 + if (allTerms == 3) { + ratio = i == 0 ? 30 : i == 1 ? 50 : 20 + } else { + ratio = 100 / allTerms + } + let data = { + amount: this.amount, + amountReceivable: (this.amount * ratio) / 100, + amountReceived: 0, + amountTotal: this.amount, + collectionDate: this.setDate(date, i), + collectionType: this.editConfig.infomation.collectionType, + fileId: 0, + id: 0, + moneyType: "浜烘皯甯�", + percent: ratio, + principalId: Number(this.principalId), + remark: "", + sourceId: this.sourceId, + sourceType: this.sourceType, + status: 1, + term: i + 1 + } + arr.push(data) + } + this.tableInfomation = [...arr] + }, // 閲嶇畻 recalculateClick() { console.log(this.allTerms) this.tableData.tableInfomation = [] - if (this.allTerms === 1) { - console.log("aaa") - this.tableData.tableInfomation = [ - { - amount: this.amount, - amountReceivable: this.amount, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.setDate(this.firstDate, 0), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 100, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 1 - } - ] - } else if (this.allTerms === 2) { - this.tableData.tableInfomation = [ - { - amount: this.amount, - amountReceivable: this.amount * 0.5, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.setDate(this.firstDate, 0), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 50, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 1 - }, - { - amount: this.amount, - amountReceivable: this.amount * 0.5, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.setDate(this.firstDate, 1), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 50, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 2 - } - ] - } else if (this.allTerms === 3) { - this.tableData.tableInfomation = [ - { - amount: this.amount, - amountReceivable: this.amount * 0.3, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.setDate(this.firstDate, 0), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 30, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 1 - }, - { - amount: this.amount, - amountReceivable: this.amount * 0.5, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.setDate(this.firstDate, 1), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 50, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 2 - }, - { - amount: this.amount, - amountReceivable: this.amount * 0.2, - amountReceived: 0, - amountTotal: 0, - collectionDate: this.setDate(this.firstDate, 2), - collectionType: 0, - fileId: 0, - id: 0, - moneyType: "浜烘皯甯�", - percent: 20, - principalId: this.principalId, - remark: "", - sourceId: this.sourceId, - sourceType: this.sourceType, - status: 1, - term: 3 - } - ] - } + this.setTableInfomation(this.allTerms, this.firstDate) + this.tableData.tableInfomation = this.tableInfomation }, delClick(row) { console.log(row) @@ -462,6 +372,11 @@ commonInputChange(val, prop, row) { console.log(val, prop) console.log(row) + const array = this.tableData.tableInfomation + array.map((item) => { + this.allPercent += item.percent + }) + console.log(this.allPercent) }, // 鑾峰彇褰撳墠鏃ユ湡 getCurrentDate(monthNumber) { @@ -473,15 +388,24 @@ }, // 鏃ユ湡澶勭悊 setDate(str, monthNumber) { + console.log(str) console.log(str.split("-")) let dateArr = str.split("-") - let year = parseInt(dateArr[0]) - let month = parseInt(dateArr[1]) + monthNumber + // 鏈堜唤鍜� + let monthCount = parseInt(dateArr[1]) + monthNumber + // 骞� + let year = monthCount > 12 ? parseInt(dateArr[0]) + 1 : parseInt(dateArr[0]) + // 鏈� + let month = monthCount > 12 ? monthCount - 12 : monthCount + // 鏃� let day = parseInt(dateArr[2]) + return year + "-" + month + "-" + day }, principalClick(val) { this.principalId = val + this.setTableInfomation(this.allTerms, this.firstDate) + this.tableData.tableInfomation = this.tableInfomation } } } -- Gitblit v1.8.0