|
@@ -14,8 +14,8 @@
|
|
|
</template>
|
|
|
<!-- 操作区,位于 title 行的行尾 -->
|
|
|
<template slot="extra">
|
|
|
- <a-button key="2" id="allocateBillDetail-preview-btn">打印预览</a-button>
|
|
|
- <a-button key="1" type="primary" id="allocateBillDetail-print-btn">快速打印</a-button>
|
|
|
+ <a-button key="2" id="allocateBillDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
|
|
|
+ <a-button key="1" type="primary" id="allocateBillDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
|
|
|
</template>
|
|
|
</a-page-header>
|
|
|
<a-card size="small" :bordered="false" class="allocateBillDetail-cont">
|
|
@@ -48,13 +48,15 @@
|
|
|
bordered>
|
|
|
</s-table>
|
|
|
</a-card>
|
|
|
+ <!-- 打印 -->
|
|
|
+ <div id="print"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
import { getOperationalPrecision } from '@/libs/tools.js'
|
|
|
-import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount } from '@/api/allocateBill'
|
|
|
+import { allocateBillDetailList, allocateBillDetail, allocateBillDetailCount, allocateBillDetailPrint } from '@/api/allocateBill'
|
|
|
export default {
|
|
|
components: { STable, VSelect },
|
|
|
data () {
|
|
@@ -83,11 +85,13 @@ export default {
|
|
|
data.list[i].costSubtotal = getOperationalPrecision(data.list[i].cost, data.list[i].qty)
|
|
|
data.list[i].priceSubtotal = getOperationalPrecision(data.list[i].price, data.list[i].qty)
|
|
|
}
|
|
|
+ this.localDataSource = data.list
|
|
|
return data
|
|
|
})
|
|
|
},
|
|
|
basicInfoData: null, // 基本信息
|
|
|
- productTotal: null // 合计
|
|
|
+ productTotal: null, // 合计
|
|
|
+ localDataSource: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -123,6 +127,38 @@ export default {
|
|
|
// 编辑
|
|
|
handleEdit () {
|
|
|
this.$router.push({ path: `/allocationManagement/transferOut/edit/${this.basicInfoData.allocateSn}/${this.basicInfoData.targetName}` })
|
|
|
+ },
|
|
|
+ // 打印预览/快捷打印
|
|
|
+ handlePrint (type) {
|
|
|
+ const _this = this
|
|
|
+ allocateBillDetailPrint({ sn: this.$route.params.sn }).then(res => {
|
|
|
+ if (res.type == 'application/json') {
|
|
|
+ var reader = new FileReader()
|
|
|
+ reader.addEventListener('loadend', function () {
|
|
|
+ const obj = JSON.parse(reader.result)
|
|
|
+ _this.$notification.error({
|
|
|
+ message: '提示',
|
|
|
+ description: obj.message
|
|
|
+ })
|
|
|
+ })
|
|
|
+ reader.readAsText(res)
|
|
|
+ } else {
|
|
|
+ this.print(res, type)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ print (data, type) {
|
|
|
+ if (!data) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
|
|
|
+ document.getElementById('print').innerHTML = '<iframe id="printf" name="printf" src="' + url + '" hidden></iframe>'
|
|
|
+ if (type == 'preview') { // 预览
|
|
|
+ window.open(url)
|
|
|
+ } else if (type == 'print') { // 打印
|
|
|
+ window.frames['printf'].focus()
|
|
|
+ window.frames['printf'].print()
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
beforeRouteEnter (to, from, next) {
|