From 68107dac4f278d3e4b13b0f9030f096263a5d47b Mon Sep 17 00:00:00 2001 From: chenjianan Date: Thu, 29 Nov 2018 11:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=90=88=E5=90=8C=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=9A=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseContractSearch/exportExcel.js | 19 ++++ .../PurchaseContractSearch/index.vue | 94 +++++++++++-------- 2 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 src/views/PurchasingCenter/PurchaseContractSearch/exportExcel.js diff --git a/src/views/PurchasingCenter/PurchaseContractSearch/exportExcel.js b/src/views/PurchasingCenter/PurchaseContractSearch/exportExcel.js new file mode 100644 index 00000000..88de1a6d --- /dev/null +++ b/src/views/PurchasingCenter/PurchaseContractSearch/exportExcel.js @@ -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 = `{worksheet}{table}
` + 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() + } +})() diff --git a/src/views/PurchasingCenter/PurchaseContractSearch/index.vue b/src/views/PurchasingCenter/PurchaseContractSearch/index.vue index 06380a0a..16345b1c 100644 --- a/src/views/PurchasingCenter/PurchaseContractSearch/index.vue +++ b/src/views/PurchasingCenter/PurchaseContractSearch/index.vue @@ -46,6 +46,11 @@ icon="el-icon-search" style="margin-left:10px" @click="total1=0;pageCurrent1=1;pageSize1=10;searchTable1()">查询 + 导出 @@ -126,49 +131,52 @@
- - - - - - - - - - - - - - - - - -
GAOJING产品销售合同
需方江苏高精机电装备有限公司合同编号{{ contract }}
供方{{ supplier }}签订地点江苏盐城
-
一、 产品名称、型号、数量、单价、品牌:
- - - - - - - - - - - - - +
+
物料名称物料规格物料型号发货天数数量单价总价
- - + + + - - + + + + - -
运费:{{ freight }}GAOJING产品销售合同
总价: (人民币){{ RMB }}(含0.17增值税) {{ TotalAmount }}需方江苏高精机电装备有限公司合同编号{{ contract }}
-
+ + 供方 + {{ supplier }} + 签订地点 + 江苏盐城 + + +
一、 产品名称、型号、数量、单价、品牌:
+ + + + + + + + + + + + + + + + + + + + + + +
物料名称物料规格物料型号发货天数数量单价总价
运费:{{ freight }}
总价: (人民币){{ RMB }}(含0.17增值税) {{ TotalAmount }}
+
+
@@ -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',