|
@@ -6,19 +6,7 @@
|
|
|
<a href="javascript:;" @click="handleBack"><a-icon type="left"></a-icon> 返回列表</a>
|
|
|
</template>
|
|
|
<template slot="extra" v-if="$hasPermissions('B_salesReturnPrint')">
|
|
|
- <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="salesReturnDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
|
|
|
- <a-button key="2" type="primary" id="salesReturnDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
|
|
|
- <a-button
|
|
|
- key="1"
|
|
|
- type="primary"
|
|
|
- class="button-warning"
|
|
|
- id="salesReturnDetail-export-btn"
|
|
|
- :disabled="localDataSource.length==0"
|
|
|
- @click="handlePrint('export')">导出Excel</a-button>
|
|
|
+ <Print :disabled="localDataSource.length==0" @handlePrint="handlePrint"></Print>
|
|
|
</template>
|
|
|
</a-page-header>
|
|
|
<!-- 基础信息 -->
|
|
@@ -70,19 +58,18 @@
|
|
|
</s-table>
|
|
|
</a-card>
|
|
|
</a-spin>
|
|
|
- <!-- 打印 -->
|
|
|
- <div id="print"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import moment from 'moment'
|
|
|
import { getOperationalPrecision } from '@/libs/tools.js'
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
import { salesReturnDetail, salesReturnQueryCount, salesReturnDetailList, salesReturnDetailPrint, salesDetailExport } from '@/api/salesReturn'
|
|
|
+import Print from '@/views/common/print.vue'
|
|
|
+import { hdPrint } from '@/libs/JGPrint'
|
|
|
export default {
|
|
|
name: 'SalesReturnDetail',
|
|
|
- components: { STable, VSelect },
|
|
|
+ components: { STable, VSelect, Print },
|
|
|
data () {
|
|
|
return {
|
|
|
spinning: false,
|
|
@@ -130,8 +117,7 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
localDataSource: [],
|
|
|
- detailData: null, // 详情数据
|
|
|
- printerType: 'NEEDLE' // 打印机类型
|
|
|
+ detailData: null // 详情数据
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -156,60 +142,18 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
// 打印预览/快捷打印
|
|
|
- handlePrint (type) {
|
|
|
+ handlePrint (type, printerType) {
|
|
|
const _this = this
|
|
|
_this.spinning = true
|
|
|
let url = salesReturnDetailPrint
|
|
|
- let params = { sn: this.$route.params.sn, type: this.printerType }
|
|
|
+ const params = { sn: this.$route.params.sn }
|
|
|
if (type == 'export') { // 导出
|
|
|
url = salesDetailExport
|
|
|
- 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="printfsrd" name="printfsrd" src="' + url + '" hidden></iframe>'
|
|
|
- if (type == 'preview') { // 预览
|
|
|
- window.open(url)
|
|
|
- } else if (type == 'print') { // 打印
|
|
|
- window.frames['printfsrd'].focus()
|
|
|
- window.frames['printfsrd'].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()
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|