123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>二级市场订单表-交易凭证</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <!-- 所有的 css js 资源 -->
- <link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
- <link rel="stylesheet" href="../../static/sa.css">
- <script src="../../static/kj/vue.min.js"></script>
- <script src="../../static/kj/element-ui/index.js"></script>
- <script src="../../static/kj/httpVueLoader.js"></script>
- <script src="../../static/kj/jquery.min.js"></script>
- <script src="../../static/kj/layer/layer.js"></script>
- <script src="../../static/sa.js"></script>
- <script src="../../static/kj/upload-util.js"></script>
- <!-- 引入 html2canvas 和 jsPDF -->
- <script src="../../static/kj/html2canvas.min.js"></script>
- <script src="../../static/kj/jspdf.umd.min.js"></script>
- <style type="text/css">
- .c-panel .c-label{width: 8em;}
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 90%;
- margin-top: 20px ;
- margin-left: auto;
- margin-right: auto;
- }
- th {
- border: 1px solid darkgray;
- text-align: left;
- height: 24px;
- padding: 8px;
- background-color: #dddddd;
- }
- td {
- border: 1px solid darkgray;
- text-align: left;
- padding: 8px;
- }
- </style>
- </head>
- <body>
- <div class="vue-box sbot" style="display: none;" :style="'display: block;'">
- <!-- ------- 内容部分 ------- -->
- <div class="s-body">
- <div class="c-panel" id="content-to-convert" ref="contentToConvert">
- <el-form v-if="m">
- <table>
- <tr>
- <td colspan='6' style="text-align:center;font-weight: bold;" >{{m.tradeAreaName}}交易凭证</td>
- </tr>
- <tr>
- <td colspan='6'>交易信息</td>
- </tr>
- <tr>
- <th>订单编号</th>
- <td>{{m.orderNo}}</td>
- <th>银行流水</th>
- <td>{{m.result}}</td>
- <th>交易时间</th>
- <td>{{m.payTime}}</td>
- </tr>
- <tr>
- <th>卖家</th>
- <td>{{m.leaderName}}</td>
- <th>证件号码</th>
- <td>{{m.idCard}}</td>
- <th>所属合作社(互助组)</th>
- <td>{{m.groupName}}</td>
- </tr>
- <tr>
- <th>买家</th>
- <td>{{m.purchaserName}}</td>
- <th>支付方式</th>
- <td></td>
- <th>交易金额</th>
- <td>{{m.resalePrice}}</td>
- </tr>
- <tr>
- <th>关区</th>
- <td>天保海关</td>
- <th>口岸</th>
- <td colspan='3'>{{m.tradeAreaName}}</td>
- </tr>
- <tr>
- <td colspan='6'>商品信息</td>
- </tr>
- <tr>
- <th>商品名称</th>
- <th>单价(元)</th>
- <th>数量</th>
- <th>重量</th>
- <th>单位</th>
- <th>总价(元)</th>
- </tr>
- <tr>
- <td>{{m.goodsName}}</td>
- <td>{{m.singlePrice}}</td>
- <td>{{m.buyQty}}</td>
- <td>{{m.netWet}}</td>
- <td>{{m.goodsUnit}}</td>
- <td>{{m.resalePrice}}</td>
- </tr>
- </table>
- </el-form>
- </div>
- </div>
- <!-- ------- 底部按钮 ------- -->
- <div class="s-foot">
- <el-button type="success" icon="el-icon-printer" @click="htmlToPdf()">打印凭证</el-button>
- <el-button type="primary" icon="el-icon-download" @click="downloadToPdf()">下载凭证</el-button>
- <el-button @click="sa.closeCurrIframe()">关闭</el-button>
- </div>
- </div>
- <script>
- var app = new Vue({
- components: {
- "sa-info": httpVueLoader('../../sa-frame/com/sa-info.vue')
- },
- el: '.vue-box',
- data: {
- id: sa.p('id', 0), // 获取数据ID
- m: null
- },
- methods: {
- downloadToPdf() {
- const element = document.getElementById('content-to-convert');
- html2canvas(element).then(canvas => {
- // 使用 jsPDF 将 canvas 转换成 PDF
- const imgData = canvas.toDataURL('image/png');
- const pdf = new jspdf.jsPDF({
- orientation: 'pportrait',
- unit: 'px',
- format: 'a4'
- });
- const imgProps = pdf.getImageProperties(imgData);
- const pdfWidth = pdf.internal.pageSize.getWidth();
- const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
- // 添加图片,适应页面大小
- pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
- pdf.save(Date.now()+'.pdf');
- });
- },
- htmlToPdf() {
- const element = document.getElementById('content-to-convert');
- html2canvas(element).then(canvas => {
- // 使用 jsPDF 将 canvas 转换成 PDF
- const imgData = canvas.toDataURL('image/png');
- const pdf = new jspdf.jsPDF({
- orientation: 'portrait',
- unit: 'px',
- format: 'a4'
- });
- const imgProps = pdf.getImageProperties(imgData);
- const pdfWidth = pdf.internal.pageSize.getWidth();
- const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
- // 添加图片,适应页面大小
- pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
- // 将 PDF 保存为 Blob 并处理它 这里需要处理跨域问题
- const pdfBlob = pdf.output('blob');
- var blobURL = window.URL.createObjectURL(pdfBlob);
- var newWindow = window.open(blobURL, '_blank');
- if (newWindow) {
- newWindow.focus();
- } else {
- alert('请允许弹出窗口或在新标签页中手动查看 PDF。');
- }
- });
- },
- },
- mounted: function() {
- sa.ajax('/level-two-server/TbOrders/getSubPrint?id=' + this.id, function(res) {
- this.m = res.data;
- if(res.data == null) {
- sa.alert('未能查找到 id=' + this.id + " 详细数据");
- }
- }.bind(this))
- }
- })
- </script>
- </body>
- </html>
|