|
@@ -1,5 +1,11 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="prescriptionTable">
|
|
3
|
+<!-- <el-button-->
|
|
4
|
+<!-- size="small"-->
|
|
5
|
+<!-- type="primary"-->
|
|
6
|
+<!-- icon="el-icon-download"-->
|
|
7
|
+<!-- @click="exportData"-->
|
|
8
|
+<!-- >导出</el-button>-->
|
3
|
9
|
<el-table
|
4
|
10
|
v-if="prescription.type == 1"
|
5
|
11
|
:data="prescription.advices"
|
|
@@ -119,7 +125,8 @@
|
119
|
125
|
</el-table-column>
|
120
|
126
|
</el-table>
|
121
|
127
|
<el-table
|
122
|
|
- v-if="prescription.type == 2"
|
|
128
|
+ id="out-table"
|
|
129
|
+ v-if="prescription.type == 2"
|
123
|
130
|
:data="prescription.project"
|
124
|
131
|
border
|
125
|
132
|
style="width: 99%"
|
|
@@ -305,6 +312,7 @@ export default {
|
305
|
312
|
};
|
306
|
313
|
},
|
307
|
314
|
mounted() {
|
|
315
|
+
|
308
|
316
|
getInitData().then((response) => {
|
309
|
317
|
if (response.data.state == 0) {
|
310
|
318
|
this.$message.error(response.data.msg);
|
|
@@ -316,6 +324,31 @@ export default {
|
316
|
324
|
});
|
317
|
325
|
},
|
318
|
326
|
methods: {
|
|
327
|
+ exportData(){
|
|
328
|
+ let excelName = '导出表格名称.xlsx';
|
|
329
|
+ var xlsxParam = { raw: true };//转换成excel时,使用原始的格式
|
|
330
|
+ // 克隆节点
|
|
331
|
+ let tables = document.getElementById("out-table").cloneNode(true);
|
|
332
|
+ // 判断是否为固定列,解决(为固定列时,会重复生成表格)
|
|
333
|
+ if (tables.querySelector('.el-table__fixed') !== null) {
|
|
334
|
+ tables.removeChild(tables.querySelector('.el-table__fixed'))
|
|
335
|
+ }
|
|
336
|
+ let table_book = this.$XLSX.utils.table_to_book(tables, xlsxParam);
|
|
337
|
+ var table_write = this.$XLSX.write(table_book, {
|
|
338
|
+ bookType: "xlsx",
|
|
339
|
+ bookSST: true,
|
|
340
|
+ type: "array"
|
|
341
|
+ });
|
|
342
|
+ try {
|
|
343
|
+ this.$FileSaver.saveAs(
|
|
344
|
+ new Blob([table_write], { type: "application/octet-stream" }),
|
|
345
|
+ excelName
|
|
346
|
+ );
|
|
347
|
+ } catch (e) {
|
|
348
|
+ if (typeof console !== "undefined") console.log(e, table_write);
|
|
349
|
+ }
|
|
350
|
+ return table_write;
|
|
351
|
+ },
|
319
|
352
|
changColor({ row, rowIndex }) {
|
320
|
353
|
if (rowIndex % 2 == 1) {
|
321
|
354
|
// 变颜色的条件
|