Procházet zdrojové kódy

优化成本,添加成本导出

yuanrf před 1 rokem
rodič
revize
0ab7992a22
1 změnil soubory, kde provedl 141 přidání a 77 odebrání
  1. 141 77
      src/components/Finance/Cost.vue

+ 141 - 77
src/components/Finance/Cost.vue

@@ -240,8 +240,8 @@
                 <el-checkbox v-for="(  item, index  ) in    checkOptions  " :key="index" :title="item.tips"
                     :label="item.label" @change="(val) => { topcheckboxChange(val, item.label) }"></el-checkbox>
             </el-checkbox-group>
-            <el-table :summary-method="getSummaries" show-summary :data="tableData" :border="true" size="small"
-                row-class-name="row" cell-class-name="column" :highlight-current-row="true" :fit="true"
+            <el-table :summary-method="getSummaries" show-summary show-overflow-tooltip :data="tableData" :border="true"
+                size="small" row-class-name="row" cell-class-name="column" :highlight-current-row="true" :fit="true"
                 :height="centerheight">
                 <template v-for="(  item, index  ) in   tableLabel  ">
                     <el-table-column :key="index" :prop="item.prop" :width="item.width == 150 ? columnWidth : item.width"
@@ -278,7 +278,7 @@
                                 </el-input>
                             </div>
                             <span v-else :title="scope.row[item.prop]"><el-input placeholder="请输入内容"
-                                    v-model="scope.row[item.prop]" clearable>
+                                    v-model="scope.row[item.prop]">
                                 </el-input></span>
                         </template>
                     </el-table-column>
@@ -311,7 +311,7 @@
                                             <template slot-scope="scope">
                                                 <div v-if="itemsheetone.prop.indexOf(sheetitem.EnLabel) != -1">
                                                     <div v-if="itemsheetone.isBind">
-                                                        {{ AGroupCostParameter[itemsheetone.prop] }}
+                                                        <span>{{ AGroupCostParameter[itemsheetone.prop] }}</span>
                                                     </div>
                                                     <div v-else>
                                                         <el-input v-model="AGroupCostParameter[itemsheetone.prop]"
@@ -352,7 +352,7 @@
                                             <template slot-scope="scope">
                                                 <div v-if="itemsheetone.prop.indexOf(sheetitem.EnLabel) != -1">
                                                     <div v-if="itemsheetone.isBind">
-                                                        {{ BGroupCostParameter[itemsheetone.prop] }}
+                                                        <span>{{ BGroupCostParameter[itemsheetone.prop] }}</span>
                                                     </div>
                                                     <div v-else>
                                                         <el-input v-model="BGroupCostParameter[itemsheetone.prop]"
@@ -2052,7 +2052,8 @@ export default {
                 costTypeStartTime: [
                     { message: '请输入开始时间', trigger: 'blur', required: true, },
                 ],
-            }
+            },
+            titleText: [],
         };
     },
     watch: {
@@ -2083,6 +2084,7 @@ export default {
             const { columns, data } = param;
             const sums = [];
             const sums1 = [];
+            const texts = [];
             var prices = [];
             var thisData = data;
             var ATime = { start: that.addOneDay(that.AGroupCostParameter.costTypeStartTime, 0), end: that.addOneDay(that.AGroupCostParameter.costTypeendTime, 0) };
@@ -2180,13 +2182,28 @@ export default {
                     that.sumTopPrice.push({ name: column.property, label: column.label, Aprice: sums[index], Bprice: sums1[index] == undefined ? 0 : sums1[index] });
                 } else {
                     fliterList[0].Aprice = sums[index];
-                    fliterList[0].Bprice = sums1[index];
+                    fliterList[0].Bprice = sums1[index] == undefined ? 0 : sums1[index];
                 }
 
+                var TextfliterList = texts.filter(function (x) {
+                    return x.label == column.label;
+                })
+
+                var text = prices[index];
+                if (TextfliterList.length == 0) {
+                    texts.push({ label: column.label, text: text });
+                } else {
+                    TextfliterList.text = text;
+                }
             });
+            this.titleText = texts;
             console.log(that.sumTopPrice, 'sumTopPrice---------------');
             this.CalculatedPrice();
             //console.log(that.sumTopPrice, '------------');
+            setTimeout(() => {
+                this.setLastTitle(prices);
+            }, 1000);
+
             return prices;
         },
         handleEdit(index, row, buttonIndex) {
@@ -2729,77 +2746,85 @@ export default {
             this.clearFormVerify();
             this.loadData(this.diid);
         },
-        async save() {
-            var that = this;
-            var Data = { diid: this.diid, userid: this.userId };
-            var isTrue = await this.formVerify();
-            if (isTrue) {
-                Data.checkBoxs = this.CheckBoxListSelect.map(x => {
-                    return {
-                        diid: x.diid,
-                        cbType: x.cbType,
-                        cbValues: x.cbValues.join(',')
-                    };
-                });
+        save() {
 
-                Data.groupCosts = this.tableData;
-                Data.costTypeHotelNumbers = this.costTypeHotelNumbers.map(x => {
-                    return {
-                        id: x.id,
-                        sgr: x.sgr,
-                        tbr: x.tbr,
-                        jses: x.jses,
-                        suite: x.suite,
-                        type: x.type,
-                        diid: that.diid
-                    };
-                });
-
-                this.AGroupCostParameter.diId = this.diid;
-                this.BGroupCostParameter.diId = this.diid;
+            return new Promise(async (resolve, reject) => {
+                var that = this;
+                var Data = { diid: this.diid, userid: this.userId };
+                var isTrue = await this.formVerify();
+                if (isTrue) {
+                    Data.checkBoxs = this.CheckBoxListSelect.map(x => {
+                        return {
+                            diid: x.diid,
+                            cbType: x.cbType,
+                            cbValues: x.cbValues.join(',')
+                        };
+                    });
 
-                var Aparam = Object.assign({}, this.AGroupCostParameter);
-                var Bparam = Object.assign({}, this.BGroupCostParameter);
-                if (that.AGroupCostParameter.costTypeStartTime) {
-                    Aparam.costTypeStartTime = this.addOneDay(that.AGroupCostParameter.costTypeStartTime, 0);
-                }
-                if (that.AGroupCostParameter.costTypeendTime) {
-                    Aparam.costTypeendTime = this.addOneDay(that.AGroupCostParameter.costTypeendTime, 0);
-                }
-                if (that.BGroupCostParameter.costTypeStartTime) {
-                    Bparam.costTypeStartTime = this.addOneDay(that.BGroupCostParameter.costTypeStartTime, 0);
-                }
-                if (that.BGroupCostParameter.costTypeendTime) {
-                    Bparam.costTypeendTime = this.addOneDay(that.BGroupCostParameter.costTypeendTime, 0);
-                }
-                if (this.costTypevalue == "A") {
-                    Data.groupCostParameters = [Aparam];
-                } else {
-                    Data.groupCostParameters = [Aparam, Bparam];
-                }
+                    Data.groupCosts = this.tableData;
+                    Data.costTypeHotelNumbers = this.costTypeHotelNumbers.map(x => {
+                        return {
+                            id: x.id,
+                            sgr: x.sgr,
+                            tbr: x.tbr,
+                            jses: x.jses,
+                            suite: x.suite,
+                            type: x.type,
+                            diid: that.diid
+                        };
+                    });
 
-                console.log(Data, "save-------Data");
+                    this.AGroupCostParameter.diId = this.diid;
+                    this.BGroupCostParameter.diId = this.diid;
 
-                var that = this;
-                this.$axios.post('/api/Groups/SaveGroupCost', Data, {
-                    headers: {
-                        'Authorization': that.token,
+                    var Aparam = Object.assign({}, this.AGroupCostParameter);
+                    var Bparam = Object.assign({}, this.BGroupCostParameter);
+                    if (that.AGroupCostParameter.costTypeStartTime) {
+                        Aparam.costTypeStartTime = this.addOneDay(that.AGroupCostParameter.costTypeStartTime, 0);
+                    }
+                    if (that.AGroupCostParameter.costTypeendTime) {
+                        Aparam.costTypeendTime = this.addOneDay(that.AGroupCostParameter.costTypeendTime, 0);
+                    }
+                    if (that.BGroupCostParameter.costTypeStartTime) {
+                        Bparam.costTypeStartTime = this.addOneDay(that.BGroupCostParameter.costTypeStartTime, 0);
                     }
-                }).then(resp => {
-                    console.log(resp.data.data, '------------------------------------');
-                    if (resp.data.code == 200) {
-                        this.$message({
-                            message: '保存成功!',
-                            type: 'success'
-                        });
+                    if (that.BGroupCostParameter.costTypeendTime) {
+                        Bparam.costTypeendTime = this.addOneDay(that.BGroupCostParameter.costTypeendTime, 0);
+                    }
+                    if (this.costTypevalue == "A") {
+                        Data.groupCostParameters = [Aparam];
                     } else {
-                        this.$message.error('保存失败!' + resp.data.msg);
+                        Data.groupCostParameters = [Aparam, Bparam];
                     }
-                })
 
-            } else {
-                this.$message.error('请输入完整!');
-            }
+                    console.log(Data, "save-------Data");
+
+                    var that = this;
+                    this.$axios.post('/api/Groups/SaveGroupCost', Data, {
+                        headers: {
+                            'Authorization': that.token,
+                        }
+                    }).then(resp => {
+                        console.log(resp.data.data, '------------------------------------');
+                        if (resp.data.code == 200) {
+                            this.$message({
+                                message: '保存成功!',
+                                type: 'success'
+                            });
+                            resolve(true);
+                        } else {
+                            this.$message.error('保存失败!' + resp.data.msg);
+                            resolve(false);
+                        }
+                    })
+
+                } else {
+                    this.$message.error('请输入完整!');
+                }
+
+
+            })
+
 
         },
         TopChange() {
@@ -3782,7 +3807,7 @@ export default {
                 console.log(resp, '------------------------------------');
                 try {
                     if (resp.data.code != 200) {
-                        throw false;
+                        throw resp.data.msg;
                     }
                     var file = resp.data.data;
                     that.fileDownload(file.data, file.strFileName);
@@ -3809,7 +3834,15 @@ export default {
             }
             return new Blob([u8arr], { type });
         },
-        GetGroupCostExcel() {
+        async GetGroupCostExcel() {
+
+            console.log(this.titleText, 'this.titleText');
+
+            var isTrue = await this.save();
+            if (!isTrue) {
+                this.$message.error('请检查数据!');
+                return;
+            }
 
             var that = this;
             var group = this.options.filter(function (x) {
@@ -3823,6 +3856,7 @@ export default {
 
             var data = {
                 diid: this.diid,
+                costType: this.costTypevalue,
                 title: {
                     groupNumber: Number(this.grouptitleinfo.visitPNumber),
                     teamName: group[0].groupName,
@@ -3835,12 +3869,16 @@ export default {
                 },
                 rightInfo: {
 
+                },
+                titleModel: {
+
                 }
             };
             var leftObject = this.GetDomLeftValue();
             var rightObject = this.GetDomRightValue();
             data.leftInfo = leftObject;
             data.rightInfo = rightObject;
+            data.titleModel = this.titleText;
 
             console.log(data);
 
@@ -3850,7 +3888,12 @@ export default {
                 }
             }).then(resp => {
                 console.log(resp, '------------------------------------');
-
+                if (resp.data.code == 200) {
+                    var file = resp.data.data;
+                    that.fileDownload(file.data, file.strFileName);
+                } else {
+                    this.$message.error('操作失败!' + resp.data.msg);
+                }
             })
 
 
@@ -3869,7 +3912,12 @@ export default {
                     if (chiBoxs[j].className.indexOf(titleClassName) != -1) {
                         info.title = chiBoxs[j].querySelectorAll('thead tr th')[0].innerText;
                     } else if (chiBoxs[j].className.indexOf(bodyClassName) != -1) {
-                        info.cb = chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input').value : '0';
+                        var title = info.title;
+                        if (title.indexOf('酒店') != -1 || title.indexOf('地接') != -1 || title.indexOf('公务单人') != -1 || title.indexOf('零用金') != -1) {
+                            info.cb = chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('span') ? chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('span').innerText : '0';
+                        } else {
+                            info.cb = chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input').value : '0';
+                        }
                         info.rs = chiBoxs[j].querySelectorAll('tbody tr td')[1].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[1].querySelector('input').value : '0';
                         info.xs = chiBoxs[j].querySelectorAll('tbody tr td')[2].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[2].querySelector('input').value : '0';
                     }
@@ -3889,7 +3937,12 @@ export default {
                         if (chiBoxs[j].className.indexOf(titleClassName) != -1) {
                             info.title = chiBoxs[j].querySelectorAll('thead tr th')[0].innerText;
                         } else if (chiBoxs[j].className.indexOf(bodyClassName) != -1) {
-                            info.cb = chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input').value : '0';
+                            var title = info.title;
+                            if (title.indexOf('酒店') != -1 || title.indexOf('地接') != -1 || title.indexOf('公务单人') != -1 || title.indexOf('零用金') != -1) {
+                                info.cb = chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('span') ? chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('span').innerText : '0';
+                            } else {
+                                info.cb = chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[0].querySelector('input').value : '0';
+                            }
                             info.rs = chiBoxs[j].querySelectorAll('tbody tr td')[1].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[1].querySelector('input').value : '0';
                             info.xs = chiBoxs[j].querySelectorAll('tbody tr td')[2].querySelector('input') ? chiBoxs[j].querySelectorAll('tbody tr td')[2].querySelector('input').value : '0';
                         }
@@ -3951,6 +4004,17 @@ export default {
 
 
             return AllResult;
+        },
+        setLastTitle(list) {
+            let summaryRow = document.querySelectorAll('.el-table__footer-wrapper .cell');
+            for (var i = 0; i < summaryRow.length; i++) {
+                let summaryRowOne = summaryRow[i];
+                if (summaryRowOne.innerHTML == '总计:' || summaryRowOne.innerHTML == '——') {
+                } else {
+                    summaryRowOne.setAttribute('title', list[i]);
+                }
+            }
+
         }
 
     },
@@ -3971,10 +4035,10 @@ export default {
             })
         },
         columnWidth() {
-            if (this.CheckBoxListSelect.filter(item => item.cbType == 'Top')[0].cbValues.length < 9) {
+            if (this.CheckBoxListSelect.filter(item => item.cbType == 'Top')[0].cbValues.length < 15) {
                 return ''
             } else {
-                return 150
+                return 75
             }
         }
     }