|
|
|
@ -35,6 +35,14 @@
|
|
|
|
|
>
|
|
|
|
|
<a-icon type="appstore" />EXCEL导出
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button
|
|
|
|
|
class="btn btn-more-name"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="PrintExcel"
|
|
|
|
|
:disabled="list.length === 0"
|
|
|
|
|
>
|
|
|
|
|
<a-icon type="appstore" />打印
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button
|
|
|
|
|
class="btn btn-import-station"
|
|
|
|
|
type="primary"
|
|
|
|
@ -104,9 +112,37 @@
|
|
|
|
|
:settings="settings"
|
|
|
|
|
v-if="list.length !== 0"
|
|
|
|
|
></hot-table>
|
|
|
|
|
|
|
|
|
|
<div class="table-no-data" v-if="list.length === 0">暂无数据</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="loading" v-else>加载中 ...</div>
|
|
|
|
|
|
|
|
|
|
<div v-show="false">
|
|
|
|
|
<table id="printableTable" class="printTable">
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th
|
|
|
|
|
v-for="(key, index) in columns"
|
|
|
|
|
:key="key.data"
|
|
|
|
|
v-show="index !== 0 && index !== 1 && index !== 2 && index !== 3"
|
|
|
|
|
class="printTh"
|
|
|
|
|
>{{ key.title }}</th
|
|
|
|
|
>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr v-for="item in list" :key="item.id">
|
|
|
|
|
<td
|
|
|
|
|
v-for="(key, index) in columns"
|
|
|
|
|
:key="key.data"
|
|
|
|
|
v-show="index !== 0 && index !== 1 && index !== 2 && index !== 3"
|
|
|
|
|
class="printTd"
|
|
|
|
|
>{{ item[key.data] }}</td
|
|
|
|
|
>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-spin>
|
|
|
|
|
<a-modal
|
|
|
|
@ -217,6 +253,7 @@
|
|
|
|
|
import { GetPackageSelectList } from '/@/views/operation/seaexport/api/BookingLedger'
|
|
|
|
|
registerAllModules()
|
|
|
|
|
import * as XLSX from 'xlsx'
|
|
|
|
|
import printJS from 'print-js'
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
details: { type: Object, default: {} },
|
|
|
|
@ -1061,6 +1098,8 @@
|
|
|
|
|
async function UpExcel(file) {
|
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
reader.onload = (e: any) => {
|
|
|
|
|
console.log(e.target.result)
|
|
|
|
|
|
|
|
|
|
const data = new Uint8Array(e.target.result)
|
|
|
|
|
const workbook = XLSX.read(data, { type: 'array' })
|
|
|
|
|
const worksheet = workbook.Sheets[workbook.SheetNames[0]]
|
|
|
|
@ -1114,9 +1153,6 @@
|
|
|
|
|
}
|
|
|
|
|
// 导出 EXCEL
|
|
|
|
|
function ExportExcel() {
|
|
|
|
|
// title: '业务编号',
|
|
|
|
|
// width: 80,
|
|
|
|
|
// data: 'bsno',
|
|
|
|
|
let Data: any = []
|
|
|
|
|
let DelData = ['id', 'bsno', 'ctnCode']
|
|
|
|
|
list.value.forEach((item, index) => {
|
|
|
|
@ -1136,17 +1172,22 @@
|
|
|
|
|
|
|
|
|
|
// 创建工作簿
|
|
|
|
|
const workbook = XLSX.utils.book_new()
|
|
|
|
|
console.log(workbook, 'workbook')
|
|
|
|
|
|
|
|
|
|
// 将数据转换为工作表
|
|
|
|
|
const worksheet = XLSX.utils.json_to_sheet(Data)
|
|
|
|
|
console.log(workbook, 'worksheet')
|
|
|
|
|
// 将工作表添加到工作簿
|
|
|
|
|
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')
|
|
|
|
|
console.log(workbook, 'workbook')
|
|
|
|
|
// 生成Excel的配置
|
|
|
|
|
const wbout = XLSX.write(workbook, { bookType: 'xlsx', type: 'binary' })
|
|
|
|
|
console.log(wbout, 'wbout')
|
|
|
|
|
// 创建二进制对象并创建url
|
|
|
|
|
const blob = new Blob([s2ab(wbout)], { type: 'application/octet-stream' })
|
|
|
|
|
console.log(blob, 'blob')
|
|
|
|
|
const url = URL.createObjectURL(blob)
|
|
|
|
|
|
|
|
|
|
console.log(url, 'url')
|
|
|
|
|
// 创建a标签模拟点击进行下载
|
|
|
|
|
const a = document.createElement('a')
|
|
|
|
|
a.href = url
|
|
|
|
@ -1167,6 +1208,16 @@
|
|
|
|
|
for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff
|
|
|
|
|
return buf
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打印
|
|
|
|
|
async function PrintExcel() {
|
|
|
|
|
printJS({
|
|
|
|
|
printable: 'printableTable',
|
|
|
|
|
type: 'html',
|
|
|
|
|
header: null,
|
|
|
|
|
targetStyles: ['*'],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// -------------------------------
|
|
|
|
|
const loadingTable = ref(false)
|
|
|
|
|
const tableData: any = ref([{}])
|
|
|
|
@ -2086,6 +2137,28 @@
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.printTable {
|
|
|
|
|
font-family: verdana, arial, sans-serif;
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
color: #333333;
|
|
|
|
|
border-width: 1px;
|
|
|
|
|
border-color: #666666;
|
|
|
|
|
border-collapse: collapse;
|
|
|
|
|
}
|
|
|
|
|
.printTh {
|
|
|
|
|
border-width: 1px;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
border-style: solid;
|
|
|
|
|
border-color: #666666;
|
|
|
|
|
background-color: #dedede !important;
|
|
|
|
|
}
|
|
|
|
|
.printTd {
|
|
|
|
|
border-width: 1px;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
border-style: solid;
|
|
|
|
|
border-color: #666666;
|
|
|
|
|
background-color: #ffffff !important;
|
|
|
|
|
}
|
|
|
|
|
.ds-goods-tb-check {
|
|
|
|
|
left: 34px;
|
|
|
|
|
}
|
|
|
|
|