采购合同查询:导出
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// 导出Excel方法(表格id,不加扩展名的文件名,sheet名)
|
||||
export function exportExcelMethod(tableId, fileName, sheetName) {
|
||||
tableToExcel(tableId, fileName, sheetName)
|
||||
}
|
||||
const tableToExcel = (function() {
|
||||
const uri = 'data:application/vnd.ms-excel;base64,'
|
||||
// 设置导出表格的单元格默认高度/宽度/边框样式/字体颜色/背景颜色/居中,网页显示表格宽度建议1240,tr/td视情况而定
|
||||
const template = `<html xmlns:x="urn:schemas-microsoft-com:office:excel"><head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><meta charset="UTF-8"><style type="text/css">table td {border: 2px solid #000000;width:100px;text-align: center;color: #000000;}</style></head><body><table>{table}</table></body></html>`
|
||||
const base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
|
||||
const format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p] }) }
|
||||
return function(table, filename, sheetname) {
|
||||
if (!table.nodeType) table = document.getElementById(table)
|
||||
const ctx = { worksheet: sheetname || 'Worksheet', table: table.innerHTML }
|
||||
const aTag = document.createElement('a')
|
||||
aTag.href = uri + base64(format(template, ctx))
|
||||
aTag.download = filename
|
||||
aTag.click()
|
||||
}
|
||||
})()
|
||||
@@ -46,6 +46,11 @@
|
||||
icon="el-icon-search"
|
||||
style="margin-left:10px"
|
||||
@click="total1=0;pageCurrent1=1;pageSize1=10;searchTable1()">查询</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
size="small"
|
||||
icon="el-icon-download"
|
||||
@click="download()">导出</el-button>
|
||||
</el-card>
|
||||
|
||||
<el-card>
|
||||
@@ -126,49 +131,52 @@
|
||||
</div>
|
||||
<div style="width:900px;margin: 0 auto">
|
||||
<el-card>
|
||||
<table id="1" cellspacing="0px" align="center" border width="100%" style="">
|
||||
<tr style="height: 40px">
|
||||
<td colspan="1" align="center" style="font-weight: bold">GAOJING</td>
|
||||
<td colspan="3" align="center" style="font-weight: bold">产品销售合同</td>
|
||||
</tr>
|
||||
<tr style="height: 40px">
|
||||
<td colspan="1" align="center">需方</td>
|
||||
<td colspan="1" align="center">江苏高精机电装备有限公司</td>
|
||||
<td colspan="1" align="center">合同编号</td>
|
||||
<td colspan="1" align="center">{{ contract }}</td>
|
||||
</tr>
|
||||
<tr style="height: 40px">
|
||||
<td colspan="1" align="center">供方</td>
|
||||
<td colspan="1" align="center">{{ supplier }}</td>
|
||||
<td colspan="1" align="center">签订地点</td>
|
||||
<td colspan="1" align="center">江苏盐城</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div>一、 产品名称、型号、数量、单价、品牌:</div>
|
||||
<table id="2" cellspacing="0px" align="center" border width="100%" style="">
|
||||
<tbody id="4">
|
||||
<tr id="tableHead" style="height: 40px">
|
||||
<td colspan="1" align="center">物料名称</td>
|
||||
<td colspan="1" align="center">物料规格</td>
|
||||
<td colspan="1" align="center">物料型号</td>
|
||||
<td colspan="1" align="center">发货天数</td>
|
||||
<td colspan="1" align="center">数量</td>
|
||||
<td colspan="1" align="center">单价</td>
|
||||
<td colspan="1" align="center">总价</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<div id="print" style="width:860px;">
|
||||
<table id="1" cellspacing="0px" align="center" border width="100%">
|
||||
<tr style="height: 40px">
|
||||
<td colspan="6">运费:</td>
|
||||
<td colspan="1" align="center">{{ freight }}</td>
|
||||
<td colspan="1" align="center" style="font-weight: bold">GAOJING</td>
|
||||
<td colspan="4" align="center" style="font-weight: bold">产品销售合同</td>
|
||||
<td colspan="2" rowspan="3" align="center" style="width: 100px"/>
|
||||
</tr>
|
||||
<tr style="height: 40px">
|
||||
<td colspan="6">总价: (人民币){{ RMB }}(含0.17增值税) </td>
|
||||
<td colspan="1" align="center">{{ TotalAmount }}</td>
|
||||
<td colspan="1" align="center">需方</td>
|
||||
<td colspan="2" align="center">江苏高精机电装备有限公司</td>
|
||||
<td colspan="1" align="center">合同编号</td>
|
||||
<td colspan="1" align="center">{{ contract }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div id="23"/>
|
||||
<tr style="height: 40px">
|
||||
<td colspan="1" align="center">供方</td>
|
||||
<td colspan="2" align="center">{{ supplier }}</td>
|
||||
<td colspan="1" align="center">签订地点</td>
|
||||
<td colspan="1" align="center">江苏盐城</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div>一、 产品名称、型号、数量、单价、品牌:</div>
|
||||
<table id="2" cellspacing="0px" align="center" border width="100%" style="">
|
||||
<tbody id="4">
|
||||
<tr id="tableHead" style="height: 40px">
|
||||
<td colspan="1" align="center">物料名称</td>
|
||||
<td colspan="1" align="center">物料规格</td>
|
||||
<td colspan="1" align="center">物料型号</td>
|
||||
<td colspan="1" align="center">发货天数</td>
|
||||
<td colspan="1" align="center">数量</td>
|
||||
<td colspan="1" align="center">单价</td>
|
||||
<td colspan="1" align="center">总价</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr style="height: 40px">
|
||||
<td colspan="6">运费:</td>
|
||||
<td colspan="1" align="center">{{ freight }}</td>
|
||||
</tr>
|
||||
<tr style="height: 40px">
|
||||
<td colspan="6">总价: (人民币){{ RMB }}(含0.17增值税) </td>
|
||||
<td colspan="1" align="center">{{ TotalAmount }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<div id="23"/>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
@@ -184,6 +192,7 @@
|
||||
import { initContract, initBuyer, searchTable1, searchTable2 } from '@/api/PurchasingCenter/PurchaseContractSearch'
|
||||
import { searchFile } from '@/api/PurchasingCenter/CreateContract'
|
||||
import QRCode from 'qrcode'
|
||||
import { exportExcelMethod } from './exportExcel'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -238,6 +247,13 @@ export default {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
download() {
|
||||
if (this.contract) {
|
||||
exportExcelMethod('print', '采购合同', '采购合同sheet1')
|
||||
} else {
|
||||
this.$message.error('请选择合同')
|
||||
}
|
||||
},
|
||||
useqrcode(contractNum) {
|
||||
const opts = {
|
||||
errorCorrectionLevel: 'H',
|
||||
|
||||
Reference in New Issue
Block a user