浏览代码

成本代码优化

yuanrf 9 月之前
父节点
当前提交
0943b02e55
共有 1 个文件被更改,包括 96 次插入168 次删除
  1. 96 168
      src/components/Finance/Cost.vue

+ 96 - 168
src/components/Finance/Cost.vue

@@ -3348,20 +3348,20 @@ export default {
 
                     if (column.label == 'B' || column.label == 'L' || column.label == 'D' || column.label == 'EF' || column.label == 'TE' || column.label == 'T/G T' || column.label == 'P/C' || column.label == 'DRV T' || column.label == 'DRV T') {
                         that.lableSetPrice(column.label, (sums[index] * that.peopleNumber).toFixed(2), (sums[index]).toFixed(2));
-                        prices[index] = '共' + (sums[index] * that.peopleNumber).toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index]).toFixed(2) + " " + this.getCurr //sums[index] + '(' + this.getCurr + ')' + '  人均(' + sums[index] + ')';
+                        prices[index] = '共' + (sums[index] * that.peopleNumber).toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index]).toFixed(2) + " " + this.getCurr; //sums[index] + '(' + this.getCurr + ')' + '  人均(' + sums[index] + ')';
                     }
                     else if (column.label == 'SGR' || column.label == 'JS/ES' || column.label == 'SUITE' || column.label == 'TBR') {
                         if (column.label == 'TBR') {
                             that.lableSetPrice(column.label, (sums[index]).toFixed(2), (sums[index] / 2).toFixed(2));
-                            prices[index] = '共' + (sums[index]).toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index] / 2).toFixed(2) + " " + this.getCurr
+                            prices[index] = '共' + (sums[index]).toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index] / 2).toFixed(2) + " " + this.getCurr;
                         } else {
                             that.lableSetPrice(column.label, (sums[index]).toFixed(2), (sums[index]).toFixed(2));
-                            prices[index] = '共' + (sums[index]).toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index]).toFixed(2) + " " + this.getCurr
+                            prices[index] = '共' + (sums[index]).toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index]).toFixed(2) + " " + this.getCurr;
                         }
                     }
                     else {
                         that.lableSetPrice(column.label, sums[index].toFixed(2), (sums[index] / that.peopleNumber).toFixed(2));
-                        prices[index] = '共' + sums[index].toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index] / that.peopleNumber).toFixed(2) + " " + this.getCurr //sums[index] + '(' + this.getCurr + ')' + '  人均(' + sums[index] + ')';
+                        prices[index] = '共' + sums[index].toFixed(2) + ' ' + this.getCurr + '\r\n人均' + (sums[index] / that.peopleNumber).toFixed(2) + " " + this.getCurr;//sums[index] + '(' + this.getCurr + ')' + '  人均(' + sums[index] + ')';
                         sums[index] = parseFloat((sums[index] / that.peopleNumber).toFixed(2));
                     }
 
@@ -4436,7 +4436,7 @@ export default {
             if (isNaN(sum)) {
                 sum = 0.00;
             }
-            return sum.toFixed(2);;
+            return sum.toFixed(2);
         },
         BcalculateZBJ(EnLabelParam) {
             if (EnLabelParam == undefined) {
@@ -4690,6 +4690,53 @@ export default {
                 { name: "头等舱SUITE", index: 7, lable: "头等舱 SUITE" },
                 { name: "经济舱JSES", index: 8, lable: "经济舱 JS/ES" }
             ];
+            const paramArr = [
+                {
+                    costPerson: ['sgrcb', 'jjccb'],
+                    singleQuote: ['jjc', 'sgr'],
+                    index: 1,
+                },
+                {
+                    costPerson: ['tbrcb', 'jjccb'],
+                    singleQuote: ['jjc', 'tbr'],
+                    index: 0,
+                },
+                {
+                    costPerson: ['suitecb', 'jjccb'],
+                    singleQuote: ['jjc', 'suite'],
+                    index: 5,
+                },
+                {
+                    costPerson: ['suitecb', 'gwccb'],
+                    singleQuote: ['gwc', 'suite'],
+                    index: 4,
+                },
+                {
+                    costPerson: ['sgrcb', 'gwccb'],
+                    singleQuote: ['gwc', 'sgr'],
+                    index: 2,
+                },
+                {
+                    costPerson: ['jsescb', 'gwccb'],
+                    singleQuote: ['gwc', 'jses'],
+                    index: 3,
+                },
+                {
+                    costPerson: ['jsescb', 'tdccb'],
+                    singleQuote: ['tdc', 'jses'],
+                    index: 6,
+                },
+                {
+                    costPerson: ['suitecb', 'tdccb'],
+                    singleQuote: ['tdc', 'suite'],
+                    index: 7,
+                },
+                {
+                    costPerson: ['jsescb', 'jjccb'],
+                    singleQuote: ['jjc', 'jses'],
+                    index: 8,
+                },
+            ];
             if (this.costTypevalue == 'B') {
 
                 let BhotelRooms = {
@@ -4743,55 +4790,33 @@ export default {
                 this.BGroupCostParameter.suitecb = BSUITEsum;
 
                 var BleftSum = this.BOtherCost();
-                let BJJCSGR = (BleftSum + Number(this.BGroupCostParameter.sgrcb) + Number(this.BGroupCostParameter.jjccb));
-                let BJJCTBR = BleftSum + (Number(this.BGroupCostParameter.tbrcb) / 2) + Number(this.BGroupCostParameter.jjccb);
-                let BJJCSUITE = BleftSum + Number(this.BGroupCostParameter.suitecb) + Number(this.BGroupCostParameter.jjccb);
-                let BGWCSUITE = (BleftSum + Number(this.BGroupCostParameter.suitecb) + Number(this.BGroupCostParameter.gwccb)).toFixed(2);
-                let BGWCSGR = BleftSum + Number(this.BGroupCostParameter.sgrcb) + Number(this.BGroupCostParameter.gwccb);
-                let BGWCJSES = BleftSum + Number(this.BGroupCostParameter.jsescb) + Number(this.BGroupCostParameter.gwccb);
-
-                //头等舱金额计算
-                let BTDCJSES = (BleftSum + Number(this.BGroupCostParameter.jsescb) + Number(this.BGroupCostParameter.tdccb)).toFixed(2);
-                let BTDCSUITES = (BleftSum + Number(this.BGroupCostParameter.suitecb) + Number(this.BGroupCostParameter.tdccb)).toFixed(2);
-                let BJJCJSES = (BleftSum + Number(this.BGroupCostParameter.jsescb) + Number(this.BGroupCostParameter.jjccb)).toFixed(2);
-
-                BJJCSGR = BJJCSGR.toFixed(2);
-
                 var BrightSum = 0;
                 this.OtherCostPropertyBJ.forEach((x) => {
                     BrightSum += Number(that.BcalculateDRBJ(x));
                 })
 
-                let BJJCSGRDRBJ = (BrightSum + Number(that.BcalculateDRBJ('jjc')) + Number(that.BcalculateDRBJ('sgr'))).toFixed(2);
-                let BJJCTBRDRBJ = BrightSum + (Number(that.BcalculateDRBJ('tbr')) / 2) + Number(that.BcalculateDRBJ('jjc'));
-                let BJJCSUITEDRBJ = BrightSum + Number(that.BcalculateDRBJ('suite')) + Number(that.BcalculateDRBJ('jjc'));
-                let BGWCSUITEDRBJ = BrightSum + Number(that.BcalculateDRBJ('suite')) + Number(that.BcalculateDRBJ('gwc'));
-                let BGWCSGRDRBJ = BrightSum + Number(that.BcalculateDRBJ('sgr')) + Number(that.BcalculateDRBJ('gwc'));
-                let BGWCJSESDRBJ = BrightSum + Number(that.BcalculateDRBJ('jses')) + Number(that.BcalculateDRBJ('gwc'));
-                //头等舱单人报价
-                let BTDCJSESDRBJ = (BrightSum + Number(that.BcalculateDRBJ('jses')) + Number(that.BcalculateDRBJ('tdc'))).toFixed(2);
-                let BTDCSUITEDRBJ = (BrightSum + Number(that.BcalculateDRBJ('suite')) + Number(that.BcalculateDRBJ('tdc'))).toFixed(2);
-                let BJJCJSESDRBJ = (BrightSum + Number(that.BcalculateDRBJ('jses')) + Number(that.BcalculateDRBJ('jjc'))).toFixed(2);
-
-
-                this.BcabinDatal[0].sheetInfo[0].costPerson = BJJCTBR;
-                this.BcabinDatal[0].sheetInfo[0].singleQuote = BJJCTBRDRBJ;
-                this.BcabinDatal[1].sheetInfo[0].costPerson = BJJCSGR;
-                this.BcabinDatal[1].sheetInfo[0].singleQuote = BJJCSGRDRBJ;
-                this.BcabinDatal[2].sheetInfo[0].costPerson = BGWCSGR;
-                this.BcabinDatal[2].sheetInfo[0].singleQuote = BGWCSGRDRBJ;
-                this.BcabinDatal[3].sheetInfo[0].costPerson = BGWCJSES;
-                this.BcabinDatal[3].sheetInfo[0].singleQuote = BGWCJSESDRBJ;
-                this.BcabinDatal[4].sheetInfo[0].costPerson = BGWCSUITE;
-                this.BcabinDatal[4].sheetInfo[0].singleQuote = BGWCSUITEDRBJ;
-                this.BcabinDatal[5].sheetInfo[0].costPerson = BJJCSUITE;
-                this.BcabinDatal[5].sheetInfo[0].singleQuote = BJJCSUITEDRBJ;
-                this.BcabinDatal[6].sheetInfo[0].costPerson = BTDCJSES;
-                this.BcabinDatal[6].sheetInfo[0].singleQuote = BTDCJSESDRBJ;
-                this.BcabinDatal[7].sheetInfo[0].costPerson = BTDCSUITES;
-                this.BcabinDatal[7].sheetInfo[0].singleQuote = BTDCSUITEDRBJ;
-                this.BcabinDatal[8].sheetInfo[0].costPerson = BJJCJSES;
-                this.BcabinDatal[8].sheetInfo[0].singleQuote = BJJCJSESDRBJ;
+                for (var i = 0; i < paramArr.length; i++) {
+                    var costPersonPrice = 0;
+                    var singleQuotePrice = 0;
+                    for (var j = 0; j < paramArr[i].costPerson.length; j++) {
+                        var costPersonKey = paramArr[i].costPerson[j];
+                        var price = Number(that.BGroupCostParameter[costPersonKey]);
+                        if (costPersonKey.indexOf('tbr') != -1) {
+                            price = price / 2;
+                        }
+                        costPersonPrice += price;
+                    }
+                    for (var k = 0; k < paramArr[i].singleQuote.length; k++) {
+                        var singleQuoteKey = paramArr[i].singleQuote[k];
+                        var price = Number(that.BcalculateDRBJ(singleQuoteKey));
+                        if (singleQuoteKey.indexOf('tbr') != -1) {
+                            price = price / 2;
+                        }
+                        singleQuotePrice += price;
+                    }
+                    that.BcabinDatal[paramArr[i].index].sheetInfo[0].costPerson = (BleftSum + costPersonPrice).toFixed(2);
+                    that.BcabinDatal[paramArr[i].index].sheetInfo[0].singleQuote = (BrightSum + singleQuotePrice).toFixed(2);
+                }
             }
 
             for (var i = 0; i < airByHotelType.length; i++) {
@@ -4812,53 +4837,6 @@ export default {
                 }
             }
 
-
-
-            // var txtJJCSGRRS = (result.hasOwnProperty("经济舱SGR") ? result["经济舱SGR"] : 0)
-            // var lblGWCSGRRS = (result.hasOwnProperty("公务舱SGR") ? result["公务舱SGR"] : 0)
-            // var txtJJCTBRRS = (result.hasOwnProperty("经济舱TBR") ? result["经济舱TBR"] * 2 : 0)
-            // var txtGWCJSESRS = (result.hasOwnProperty("公务舱JSES") ? result["公务舱JSES"] : 0)
-            // var JJCSUITERS = (result.hasOwnProperty("经济舱SUITE") ? result["经济舱SUITE"] : 0)
-            // var txtGWCSUITERS = (result.hasOwnProperty("公务舱SUITE") ? result["公务舱SUITE"] : 0)
-
-            // //头等舱人数判断
-            // var txtTDCJSESRS = (result.hasOwnProperty("头等舱JSES") ? result["头等舱JSES"] : 0)
-            // var txtTDCSUITERS = (result.hasOwnProperty("头等舱SUITE") ? result["头等舱SUITE"] : 0)
-
-            // var txtJJCJSESRS = (result.hasOwnProperty("经济舱JSES") ? result["经济舱JSES"] : 0)
-            // //console.log(txtJJCSGRRS, lblGWCSGRRS, txtJJCTBRRS, txtGWCJSESRS, JJCSUITERS, txtGWCSUITERS, 'test');
-
-            // if (txtJJCSGRRS > 0) {
-            //     rightCheckArr.push('经济舱 SGR');
-            // }
-            // if (lblGWCSGRRS > 0) {
-            //     rightCheckArr.push('公务舱 SGR');
-            // }
-            // if (txtJJCTBRRS > 0) {
-            //     rightCheckArr.push('经济舱 TBR');
-            // }
-            // if (txtGWCJSESRS > 0) {
-            //     rightCheckArr.push('公务舱 JS/ES');
-            // }
-            // if (JJCSUITERS > 0) {
-            //     rightCheckArr.push('经济舱 SUITE');
-            // }
-            // if (txtGWCSUITERS > 0) {
-            //     rightCheckArr.push('公务舱 SUITE');
-            // }
-
-            // //头等舱人数判断
-            // if (txtTDCJSESRS > 0) {
-            //     rightCheckArr.push('头等舱 JS/ES');
-            // }
-            // if (txtTDCSUITERS > 0) {
-            //     rightCheckArr.push('头等舱 SUITE');
-            // }
-
-            // if (txtJJCJSESRS > 0) {
-            //     rightCheckArr.push('经济舱 JS/ES');
-            // }
-
             rightCheckArr.push('团组预算明细');
             rightCheckArr = [...new Set(rightCheckArr)];
 
@@ -4867,18 +4845,6 @@ export default {
                 this.CheckBoxListSelect.filter(item => item.cbType == 'Right')[0].cbValues = rightCheckArr;
             } catch (e) { }
 
-            // this.cabinDatal[0].sheetInfo[0].toll = txtJJCTBRRS;
-            // this.cabinDatal[1].sheetInfo[0].toll = txtJJCSGRRS;
-            // this.cabinDatal[2].sheetInfo[0].toll = lblGWCSGRRS;
-            // this.cabinDatal[3].sheetInfo[0].toll = txtGWCJSESRS;
-            // this.cabinDatal[4].sheetInfo[0].toll = txtGWCSUITERS;
-            // this.cabinDatal[5].sheetInfo[0].toll = JJCSUITERS;
-            // //头等舱人数
-            // this.cabinDatal[6].sheetInfo[0].toll = txtTDCJSESRS;
-            // this.cabinDatal[7].sheetInfo[0].toll = txtTDCSUITERS;
-
-            // this.cabinDatal[8].sheetInfo[0].toll = txtJJCJSESRS;
-
             this.AGroupCostParameter.djcb = Djsum;
             this.AGroupCostParameter.gwcb = GWsum;
             this.AGroupCostParameter.lyjcb = LYJsum;
@@ -4888,56 +4854,33 @@ export default {
             this.AGroupCostParameter.suitecb = SUITEsum;
 
             var leftSum = this.OtherCost();
-            let JJCSGR = (leftSum + Number(this.AGroupCostParameter.sgrcb) + Number(this.AGroupCostParameter.jjccb)).toFixed(2);
-            let JJCTBR = (leftSum + (Number(this.AGroupCostParameter.tbrcb) / 2) + Number(this.AGroupCostParameter.jjccb)).toFixed(2);
-            let JJCSUITE = (leftSum + Number(this.AGroupCostParameter.suitecb) + Number(this.AGroupCostParameter.jjccb)).toFixed(2);
-            let GWCSUITE = (leftSum + Number(this.AGroupCostParameter.suitecb) + Number(this.AGroupCostParameter.gwccb)).toFixed(2);
-            let GWCSGR = (leftSum + Number(this.AGroupCostParameter.sgrcb) + Number(this.AGroupCostParameter.gwccb)).toFixed(2);
-            let GWCJSES = (leftSum + Number(this.AGroupCostParameter.jsescb) + Number(this.AGroupCostParameter.gwccb)).toFixed(2);
-            //头等舱金额计算
-            let TDCJSES = (leftSum + Number(this.AGroupCostParameter.jsescb) + Number(this.AGroupCostParameter.tdccb)).toFixed(2);
-            let TDCSUITES = (leftSum + Number(this.AGroupCostParameter.suitecb) + Number(this.AGroupCostParameter.tdccb)).toFixed(2);
-
-            let JJCJSES = (leftSum + Number(this.AGroupCostParameter.jsescb) + Number(this.AGroupCostParameter.jjccb)).toFixed(2);
-            ////////console.log(JJCSGR, JJCTBR, JJCSUITE, GWCSUITE, GWCSGR, GWCJSES, '666--------------------------');
-
             var rightSum = 0;
             this.OtherCostPropertyBJ.forEach((x) => {
                 rightSum += Number(that.calculateDRBJ(x));
             })
 
-            let JJCSGRDRBJ = (rightSum + Number(that.calculateDRBJ('jjc')) + Number(that.calculateDRBJ('sgr'))).toFixed(2);
-            let JJCTBRDRBJ = (rightSum + (Number(that.calculateDRBJ('tbr')) / 2) + Number(that.calculateDRBJ('jjc'))).toFixed(2);
-            let JJCSUITEDRBJ = (rightSum + Number(that.calculateDRBJ('suite')) + Number(that.calculateDRBJ('jjc'))).toFixed(2);
-            let GWCSUITEDRBJ = (rightSum + Number(that.calculateDRBJ('suite')) + Number(that.calculateDRBJ('gwc'))).toFixed(2);
-            let GWCSGRDRBJ = (rightSum + Number(that.calculateDRBJ('sgr')) + Number(that.calculateDRBJ('gwc'))).toFixed(2);
-            let GWCJSESDRBJ = (rightSum + Number(that.calculateDRBJ('jses')) + Number(that.calculateDRBJ('gwc'))).toFixed(2);
-            //头等舱单人报价
-            let TDCJSESDRBJ = (rightSum + Number(that.calculateDRBJ('jses')) + Number(that.calculateDRBJ('tdc'))).toFixed(2);
-            let TDCSUITEDRBJ = (rightSum + Number(that.calculateDRBJ('suite')) + Number(that.calculateDRBJ('tdc'))).toFixed(2);
-
-            let JJCJSESDRBJ = (rightSum + Number(that.calculateDRBJ('jses')) + Number(that.calculateDRBJ('jjc'))).toFixed(2);
-
-            this.cabinDatal[0].sheetInfo[0].costPerson = JJCTBR;
-            this.cabinDatal[0].sheetInfo[0].singleQuote = JJCTBRDRBJ;
-            this.cabinDatal[1].sheetInfo[0].costPerson = JJCSGR;
-            this.cabinDatal[1].sheetInfo[0].singleQuote = JJCSGRDRBJ;
-            this.cabinDatal[2].sheetInfo[0].costPerson = GWCSGR;
-            this.cabinDatal[2].sheetInfo[0].singleQuote = GWCSGRDRBJ;
-            this.cabinDatal[3].sheetInfo[0].costPerson = GWCJSES;
-            this.cabinDatal[3].sheetInfo[0].singleQuote = GWCJSESDRBJ;
-            this.cabinDatal[4].sheetInfo[0].costPerson = GWCSUITE;
-            this.cabinDatal[4].sheetInfo[0].singleQuote = GWCSUITEDRBJ;
-            this.cabinDatal[5].sheetInfo[0].costPerson = JJCSUITE;
-            this.cabinDatal[5].sheetInfo[0].singleQuote = JJCSUITEDRBJ;
-            //头等舱费用信息
-            this.cabinDatal[6].sheetInfo[0].costPerson = TDCJSES;
-            this.cabinDatal[6].sheetInfo[0].singleQuote = TDCJSESDRBJ;
-            this.cabinDatal[7].sheetInfo[0].costPerson = TDCSUITES;
-            this.cabinDatal[7].sheetInfo[0].singleQuote = TDCSUITEDRBJ;
-
-            this.cabinDatal[8].sheetInfo[0].costPerson = JJCJSES;
-            this.cabinDatal[8].sheetInfo[0].singleQuote = JJCJSESDRBJ;
+            for (var i = 0; i < paramArr.length; i++) {
+                var costPersonPrice = 0;
+                var singleQuotePrice = 0;
+                for (var j = 0; j < paramArr[i].costPerson.length; j++) {
+                    var costPersonKey = paramArr[i].costPerson[j];
+                    var price = Number(that.AGroupCostParameter[costPersonKey]);
+                    if (costPersonKey.indexOf('tbr') != -1) {
+                        price = price / 2;
+                    }
+                    costPersonPrice += price;
+                }
+                for (var k = 0; k < paramArr[i].singleQuote.length; k++) {
+                    var singleQuoteKey = paramArr[i].singleQuote[k];
+                    var price = Number(that.calculateDRBJ(singleQuoteKey));
+                    if (singleQuoteKey.indexOf('tbr') != -1) {
+                        price = price / 2;
+                    }
+                    singleQuotePrice += price;
+                }
+                that.cabinDatal[paramArr[i].index].sheetInfo[0].costPerson = (leftSum + costPersonPrice).toFixed(2);
+                that.cabinDatal[paramArr[i].index].sheetInfo[0].singleQuote = (rightSum + singleQuotePrice).toFixed(2);
+            }
 
             let groupCosts = 0;
             let gtroupQuotes = 0;
@@ -4972,21 +4915,6 @@ export default {
             cabinDatalLast[0].sheetInfo[0]['groupCosts'] = groupCosts;
             cabinDatalLast[0].sheetInfo[0]['gtroupQuotes'] = gtroupQuotes;
             cabinDatalLast[0].sheetInfo[0]['groupProfit'] = groupProfit;
-
-
-            //costTypeHotelNumbers{
-            //     "sgr": 0,
-            //     "tbr": 0,
-            //     "jses": 0,
-            //     "suite": 0,
-            //     "type": "Default",
-            //     "diid": 0,
-            //     id: 0,
-            // }
-
-
-            ////////console.log(groupCosts, gtroupQuotes, groupProfit, 'groupCosts, gtroupQuotes, groupProfit');
-
         },
         OtherCost() {
             // txtVisaCost.Text +txtHCPCB.Text + txtCPCB.Text