<template>
<el-dialog :visible.sync="visibleDelivery" append-to-body title="附件(對賬單明細表)" width="950px">
<div id="out-daying1" ref="print" style="overflow: auto;" v-loading="loading">
<YgstCanteenStatementObjInfo :detailObjData="detailObjData"></YgstCanteenStatementObjInfo>
<div class="row-title">
<div>對賬單明細 </div>
<div class="check-right">
<el-checkbox v-model="checked" @change="showDetails ">顯示賬單明細</el-checkbox>
</div>
</div>
<table class="table-box" style="width:100%; line-height: 2.8em;" cellpadding="0" cellspacing="0">
<tr class="conname">
<th align="center">驗收單號</th>
<th align="center">驗收日期</th>
<th align="center">驗收品種數(shù)</th>
<th align="center">核磅人</th>
<th align="center">核磅總金額</th>
</tr>
<tbody class="conbody" v-for="(item,index) in deliveryTable" :key="index">
<tr style="background-color:#DDDDDD;text-align:center">
<td style="width:40%" align="center"> <div>{{ item.id }}</div> </td>
<td style="width:20%" align="center"> <div>{{ item.poundTime }}</div> </td>
<td style="width:20%" align="center"> <div>{{ item.poundCount }}</div> </td>
<td style="width:10%" align="center"> <div>{{ item.poundUser }}</div> </td>
<td style="width:10%" align="center"> <div>{{ item.poundPrice }}元</div> </td>
</tr>
<!-- 嵌套開始 -->
<tr class="child-row123 child-head-background" v-show="checked" style="text-align:center" >
<th>品種名稱(品牌/指標說明/保質期)</th>
<th>品種數(shù)量(單位)</th>
<th>核磅單價</th>
<th style="text-align:right;">核磅金額</th>
</tr>
<tr
v-show="checked"
class="child-row123 child-background"
v-for="(every,index) in item.deliveryDetailsList"
:key="index"
style="text-align:center"
>
<td style="width:260px">
<span style="color:orange;">[{{every.salesItemName}}]</span>
{{every.salesSubItemName}}({{every.brandName}}/{{every.indicatorDescription}}/
<span
v-show="every.shelfLifeUnit != 0"
>{{every.shelfLife}}</span>
<span v-if="every.shelfLifeUnit==1">年</span>
<span v-if="every.shelfLifeUnit==2">個月</span>
<span v-if="every.shelfLifeUnit==3">天</span>
)
</td>
<td>{{every.shipNumber}}{{every.itemUnit}}</td>
<td>{{every.poundUnitPrice}}元/{{every.itemUnit}}</td>
<td style="text-align:right;">{{every.poundTotalPrice}}元</td>
</tr>
<!-- 嵌套結束 -->
</tbody>
<tr class="contail" style="background-color:#DDDDDD;">
<td style="width:40%" align="center" >合計</td>
<td style="width:20%" align="center"></td>
<td style="width:20%" align="center"></td>
<td style="width:10%" align="center"></td>
<td style="width:10%" align="center">{{ totalAllPrice }}元</td>
</tr>
</table>
<YgstCanteenStatementSign/>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visibleDelivery = false">關閉</el-button>
<el-button type="warning" @click="exportFun">導出</el-button>
<el-button type="success" @click="onPrint">打印</el-button>
</span>
</el-dialog>
</template>
<script>
import ExcelJS from "exceljs";
import XLSX from 'xlsx';
import FileSaver from 'file-saver'
import YgstCanteenStatementApi from "@/service/ygst-api/ygst-canteen-statement-api";
import YgstCanteenStatementSign from "./YgstCanteenStatementSign.vue";
import YgstCanteenStatementObjInfo from "./YgstCanteenStatementObjInfo.vue";
export default {
components: {
YgstCanteenStatementSign,
YgstCanteenStatementObjInfo
},
name: "YgstCanteenStatementDeliveryDetailsDialog",
data() {
return {
visibleDelivery: false,
detailObjData: {},
deliveryTable:[],
totalAllPrice:"",
chinesePrice:"",
checked:false,
loading:true
}
},
mounted() {
},
// Delivery
methods: {
showDetails(){
console.log(this.checked)
},
openDeliveryDetail(rowData) {
this.visibleDelivery = true;
this.detailObjData = rowData;
this.getDeliveryData(rowData)
},
getDeliveryData(rowData){
YgstCanteenStatementApi.DeliveryList(rowData.id).then(value => {
console.log(value)
this.deliveryTable = value;
var sum = 0;
this.deliveryTable.forEach(function (value) {
sum += value.poundPrice;
});
this.totalAllPrice = sum;
})
.finally(() => {
this.loading = false;
})
},
exportFun(){
var xlsxParam = { raw: true };//轉換成excel時,使用原始的格式
// /* generate workbook object from table */
var wb = XLSX.utils.table_to_book(document.querySelector('#out-daying1'),xlsxParam)
/* get binary string as output */
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: true, type: 'array'})
try {
FileSaver.saveAs(new Blob([wbout], {type: 'application/octet-stream'}), this.detailObjData.canteenName + '“陽光食堂”食材采購結算附件(對賬單明細)' + (new Date()).getTime() + '.xlsx')
} catch (e) {
if (typeof console !== 'undefined') console.log(e, wbout)
}
return wbout
},
onPrint() {
this.$print(this.$refs.print);
},
}
}
</script>
<style scoped>
.row-title {
display: flex;
align-items: center;
font-size: 14px;
margin: 30px 0px;
}
.check-right {
cursor: pointer;
margin-left: 160px;
}
.child-row123 th {
-webkit-box-sizing: border-box;
box-sizing: border-box;
text-overflow: ellipsis;
vertical-align: middle;
position: relative;
text-align: center;
border-bottom: 1px solid #ebeef5;
}
.table-box td{
border-bottom: 1px solid #ebeef5;
}
</style>
vue2的導出exal
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
相關閱讀更多精彩內(nèi)容
- 實現(xiàn)思路:在Vue中實際是把頁面利用canvas[https://so.csdn.net/so/search?q=...
- 下載canvas方法截圖方法https://gitee.com/qiweiii/abcd/blob/master/...
- jquery.wordexport.js依賴jquery;首先npm i jquery file-saver --...
- 1 安裝依賴 npm install xlsx npm install file-saver 2 創(chuàng)建export...