|
@@ -16,13 +16,17 @@
|
|
<el-button type="primary" class="btn" @click="getPdfs()">
|
|
<el-button type="primary" class="btn" @click="getPdfs()">
|
|
<i class="el-icon-download"></i>下载PDF
|
|
<i class="el-icon-download"></i>下载PDF
|
|
</el-button>
|
|
</el-button>
|
|
|
|
+ <el-button type="primary" class="btn" @click="getExcel('船舶动态')">
|
|
|
|
+ <i class="el-icon-download"></i>下载Excel
|
|
|
|
+ </el-button>
|
|
</div>
|
|
</div>
|
|
- <table-item :tableData="tableData" :col="col" id="pdfDom"> </table-item>
|
|
|
|
|
|
+ <table-item ref="ship" :tableData="tableData" :col="col" id="pdfDom"> </table-item>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
import tableItem from "./tableItem";
|
|
import tableItem from "./tableItem";
|
|
|
|
+import FileSaver from "file-saver";
|
|
export default {
|
|
export default {
|
|
name: "TableView",
|
|
name: "TableView",
|
|
components: {
|
|
components: {
|
|
@@ -170,6 +174,26 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ getExcel(tableTitle) {
|
|
|
|
+ //let tables = this.$refs.ship;//此处是拿表格document元素,也可以取父div的ref
|
|
|
|
+ let tables = document.getElementById("pdfDom");
|
|
|
|
+ let table_book = XLSX.utils.table_to_book(tables);
|
|
|
|
+ console.log("table_book:",table_book);
|
|
|
|
+ var table_write = XLSX.write(table_book, {
|
|
|
|
+ bookType: "xlsx",
|
|
|
|
+ bookSST: true,
|
|
|
|
+ type: "array"
|
|
|
|
+ });
|
|
|
|
+ try {
|
|
|
|
+ FileSaver.saveAs(
|
|
|
|
+ new Blob([table_write], { type: "application/octet-stream" }),
|
|
|
|
+ tableTitle+".xlsx"
|
|
|
|
+ );
|
|
|
|
+ } catch (e) {
|
|
|
|
+ if (typeof console !== "undefined") console.log(e, table_write);
|
|
|
|
+ }
|
|
|
|
+ return table_write;
|
|
|
|
+ },
|
|
initialization() {
|
|
initialization() {
|
|
this.axios.post("/api/v1/tms/selectAllShipDynamaics").then(res => {
|
|
this.axios.post("/api/v1/tms/selectAllShipDynamaics").then(res => {
|
|
if (res.data.code == "200") {
|
|
if (res.data.code == "200") {
|