|
@@ -9,19 +9,7 @@
|
|
|
</template>
|
|
|
<!-- 操作区,位于 title 行的行尾 -->
|
|
|
<template slot="extra" v-if="$hasPermissions('B_purchasePrint')">
|
|
|
- <a-radio-group key="4" v-model="printerType">
|
|
|
- <a-radio value="NEEDLE">针式</a-radio>
|
|
|
- <a-radio value="INK">喷墨</a-radio>
|
|
|
- </a-radio-group>
|
|
|
- <a-button key="3" id="purchaseOrderEdit-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
|
|
|
- <a-button key="2" type="primary" id="purchaseOrderEdit-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
|
|
|
- <a-button
|
|
|
- key="1"
|
|
|
- type="primary"
|
|
|
- class="button-warning"
|
|
|
- id="purchaseOrderEdit-export-btn"
|
|
|
- :disabled="localDataSource.length==0"
|
|
|
- @click="handlePrint('export')">导出Excel</a-button>
|
|
|
+ <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
|
|
|
</template>
|
|
|
</a-page-header>
|
|
|
<!-- 基础信息 -->
|
|
@@ -242,13 +230,10 @@
|
|
|
<importGuideModal :openModal="openGuideModal" :params="{purchaseBillSn: $route.params.sn}" @close="openGuideModal=false" @ok="hanldeOk" />
|
|
|
<!-- 上次缺货 -->
|
|
|
<outStockModal :openModal="openOutStockModal" :paramsData="paramsData" @close="openOutStockModal=false" @ok="hanldeOkOutStock" />
|
|
|
- <!-- 打印 -->
|
|
|
- <div id="print"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import moment from 'moment'
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
import ImportGuideModal from './importGuideModal.vue'
|
|
|
import outStockModal from './outStockModal.vue'
|
|
@@ -258,8 +243,10 @@ import { purchaseDetailBySn, purchaseWriteSubmit, purchaseDetailPrint, purchaseD
|
|
|
import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount, purchaseDetailCancelList } from '@/api/purchaseDetail'
|
|
|
import { productListPurchase } from '@/api/product'
|
|
|
import defImg from '@/assets/def_img@2x.png'
|
|
|
+import Print from '@/views/common/print.vue'
|
|
|
+import { hdPrint } from '@/libs/JGPrint'
|
|
|
export default {
|
|
|
- components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal },
|
|
|
+ components: { STable, VSelect, ProductType, ProductBrand, ImportGuideModal, outStockModal, Print },
|
|
|
data () {
|
|
|
return {
|
|
|
spinning: false,
|
|
@@ -343,7 +330,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
localDataSource: [],
|
|
|
- printerType: 'NEEDLE', // 打印机类型
|
|
|
openGuideModal: false, // 导入产品引导
|
|
|
openOutStockModal: false,
|
|
|
paramsData: null
|
|
@@ -514,61 +500,20 @@ export default {
|
|
|
this.openOutStockModal = false
|
|
|
},
|
|
|
// 打印预览/快捷打印
|
|
|
- handlePrint (type) {
|
|
|
+ handlePrint (type, printerType) {
|
|
|
const _this = this
|
|
|
_this.spinning = true
|
|
|
let url = purchaseDetailPrint
|
|
|
- let params = { sn: this.$route.params.sn, type: this.printerType }
|
|
|
+ let params = { sn: this.$route.params.sn, type: printerType }
|
|
|
if (type == 'export') { // 导出
|
|
|
url = purchaseDetailExport
|
|
|
params = { sn: this.$route.params.sn }
|
|
|
}
|
|
|
- url(params).then(res => {
|
|
|
+ // 打印或导出
|
|
|
+ hdPrint(printerType, type, url, params, '采购单', function () {
|
|
|
_this.spinning = false
|
|
|
- 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 {
|
|
|
- if (type == 'export') { // 导出
|
|
|
- this.download(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="printfpoe" name="printfpoe" src="' + url + '" hidden></iframe>'
|
|
|
- if (type == 'preview') { // 预览
|
|
|
- window.open(url)
|
|
|
- } else if (type == 'print') { // 打印
|
|
|
- window.frames['printfpoe'].focus()
|
|
|
- window.frames['printfpoe'].print()
|
|
|
- }
|
|
|
- },
|
|
|
- download (data) {
|
|
|
- if (!data) { return }
|
|
|
- const url = window.URL.createObjectURL(new Blob([data]))
|
|
|
- const link = document.createElement('a')
|
|
|
- link.style.display = 'none'
|
|
|
- link.href = url
|
|
|
- const a = moment().format('YYYYMMDDHHmmss')
|
|
|
- const fname = '采购' + a
|
|
|
- link.setAttribute('download', fname + '.xlsx')
|
|
|
- document.body.appendChild(link)
|
|
|
- link.click()
|
|
|
- },
|
|
|
// 返回列表
|
|
|
handleBack () {
|
|
|
this.$router.push({ path: '/purchasingManagement/purchaseOrder/list', query: { closeLastOldTab: true } })
|