diff --git a/src/components/shop-cloud/shop-cloud.vue b/src/components/shop-cloud/shop-cloud.vue index 7c00bb8cd96f3586662a32e9b1d699f868659653..0f3ef5049a778470e298e39989e99dcd595b3a3e 100644 --- a/src/components/shop-cloud/shop-cloud.vue +++ b/src/components/shop-cloud/shop-cloud.vue @@ -1056,29 +1056,31 @@ export default { let a_deductions = 0; if (this.activeName == "0") { a_deductions = this.deductions; - if (this.formNew.cpu == "8") { - if (this.formNew.memory == "16") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 8 && item.memory == 16; - }); - sumCM += Number(priceObj.price); - } else if (this.formNew.memory == "32") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 8 && item.memory == 32; - }); - sumCM += Number(priceObj.price); - } - } else if (this.formNew.cpu == "16") { - if (this.formNew.memory == "32") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 16 && item.memory == 32; - }); - sumCM += Number(priceObj.price); - } else if (this.formNew.memory == "64") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 16 && item.memory == 64; - }); - sumCM += Number(priceObj.price); + if (this.cpu_memory && this.cpu_memory.length != 0) { + if (this.formNew.cpu == "8") { + if (this.formNew.memory == "16") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 8 && item.memory == 16; + }); + sumCM += Number(priceObj.price); + } else if (this.formNew.memory == "32") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 8 && item.memory == 32; + }); + sumCM += Number(priceObj.price); + } + } else if (this.formNew.cpu == "16") { + if (this.formNew.memory == "32") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 16 && item.memory == 32; + }); + sumCM += Number(priceObj.price); + } else if (this.formNew.memory == "64") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 16 && item.memory == 64; + }); + sumCM += Number(priceObj.price); + } } } sumCM = sumCM * Number(this.formNew.appDuration); @@ -1087,11 +1089,13 @@ export default { this.formNew.perDataDisk >= 1 && this.formNew.appDuration >= 1 ) { - sumDisk += - Number(this.formNew.dataDisk) * - Number(this.formNew.perDataDisk) * - Number(this.formNew.appDuration) * - Number(this.hard_disk[0].price); + if (this.hard_disk && this.hard_disk.length != 0) { + sumDisk += + Number(this.formNew.dataDisk) * + Number(this.formNew.perDataDisk) * + Number(this.formNew.appDuration) * + Number(this.hard_disk[0].price); + } this.jifeiList1[2] = { name: "数据盘", num: `${this.formNew.dataDisk}个数据盘,每个数据盘${this.formNew.perDataDisk}GB`, @@ -1116,29 +1120,31 @@ export default { }个月`; } else if (this.activeName == "1") { a_deductions = this.deductions; - if (this.formOld.cpu == "8") { - if (this.formOld.memory == "16") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 8 && item.memory == 16; - }); - sumCM += Number(priceObj.price); - } else if (this.formOld.memory == "32") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 8 && item.memory == 32; - }); - sumCM += Number(priceObj.price); - } - } else if (this.formOld.cpu == "16") { - if (this.formOld.memory == "32") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 16 && item.memory == 32; - }); - sumCM += Number(priceObj.price); - } else if (this.formOld.memory == "64") { - let priceObj = this.cpu_memory.find((item) => { - return item.cpu == 16 && item.memory == 64; - }); - sumCM += Number(priceObj.price); + if (this.cpu_memory && this.cpu_memory.length != 0) { + if (this.formOld.cpu == "8") { + if (this.formOld.memory == "16") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 8 && item.memory == 16; + }); + sumCM += Number(priceObj.price); + } else if (this.formOld.memory == "32") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 8 && item.memory == 32; + }); + sumCM += Number(priceObj.price); + } + } else if (this.formOld.cpu == "16") { + if (this.formOld.memory == "32") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 16 && item.memory == 32; + }); + sumCM += Number(priceObj.price); + } else if (this.formOld.memory == "64") { + let priceObj = this.cpu_memory.find((item) => { + return item.cpu == 16 && item.memory == 64; + }); + sumCM += Number(priceObj.price); + } } } sumCM = sumCM * Number(this.formOld.appDuration); @@ -1147,11 +1153,13 @@ export default { this.formOld.perDataDisk >= 1 && this.formOld.appDuration >= 1 ) { - sumDisk += - Number(this.formOld.dataDisk) * - Number(this.formOld.perDataDisk) * - Number(this.formOld.appDuration) * - Number(this.hard_disk[0].price); + if (this.hard_disk && this.hard_disk.length != 0) { + sumDisk += + Number(this.formOld.dataDisk) * + Number(this.formOld.perDataDisk) * + Number(this.formOld.appDuration) * + Number(this.hard_disk[0].price); + } this.jifeiList1[2] = { name: "数据盘", num: `${this.formOld.dataDisk}个数据盘,每个数据盘${this.formOld.perDataDisk}GB`, @@ -1176,7 +1184,9 @@ export default { }个月`; } // console.log(sumCM, sumDisk) - this.amounts_payable = Number((Number(sumCM) + Number(sumDisk)).toFixed(2)); + this.amounts_payable = Number( + (Number(sumCM) + Number(sumDisk)).toFixed(2) + ); // this.total_money = sumCM + sumDisk - a_deductions; return this.amounts_payable; }, @@ -1689,7 +1699,9 @@ export default { disks: [ { disk_num: this.formNew.dataDisk ? this.formNew.dataDisk : 0, - disk_cap: this.formNew.perDataDisk ? this.formNew.perDataDisk : 0, + disk_cap: this.formNew.perDataDisk + ? this.formNew.perDataDisk + : 0, store_type: "nfs-client", }, ], @@ -1741,11 +1753,11 @@ export default { ], remove_disks: this.delDataDiskList.map((item) => item.id), payment: { - // total_money: this.total_money, - disk_single_money: String(this.disk_single_money), - eci_single_money: String(this.eci_single_money), - total_money: String(this.amounts_payable), - }, + // total_money: this.total_money, + disk_single_money: String(this.disk_single_money), + eci_single_money: String(this.eci_single_money), + total_money: String(this.amounts_payable), + }, }; this.$api.serviceShop.updateCloud(query).then((response) => { if (response.data.success == 1) {