|
@@ -9,19 +9,7 @@
|
|
|
</template>
|
|
|
<!-- 操作区,位于 title 行的行尾 -->
|
|
|
<template slot="extra" v-if="$hasPermissions('B_salesPrint')">
|
|
|
- <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="salesEdit-preview-btn" :disabled="dataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
|
|
|
- <a-button key="2" type="primary" id="salesEdit-print-btn" :disabled="dataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
|
|
|
- <a-button
|
|
|
- key="1"
|
|
|
- type="primary"
|
|
|
- class="button-warning"
|
|
|
- id="salesEdit-export-btn"
|
|
|
- :disabled="dataSource.length==0"
|
|
|
- @click="handlePrint('export')">导出Excel</a-button>
|
|
|
+ <Print :disabled="dataSource.length==0" @handlePrint="handlePrint"></Print>
|
|
|
</template>
|
|
|
</a-page-header>
|
|
|
<a-card size="small" :bordered="false" class="salesEdit-cont">
|
|
@@ -173,23 +161,22 @@
|
|
|
</div>
|
|
|
<!-- 选择客户弹框 -->
|
|
|
<choose-custom-modal ref="custModal" :show="openModal" @updateData="updateData" @cancel="openModal=false" />
|
|
|
- <!-- 打印 -->
|
|
|
- <div id="print"></div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import moment from 'moment'
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
-import { JGPrint } from '@/libs/JGPrint'
|
|
|
import queryPart from './queryPart.vue'
|
|
|
import chooseCustomModal from './chooseCustomModal.vue'
|
|
|
import { stockByProductSn } from '@/api/stock'
|
|
|
import { salesDetail, salesWriteSubmit, salesWriteDiscount, salesDetailPrint, salesDetailExport } from '@/api/sales'
|
|
|
import { salesDetailList, salesDetailInsert, salesDetailUpdatePrice, salesDetailUpdateQty, salesDetailDel, salesDetailDelAll } from '@/api/salesDetail'
|
|
|
+import Print from '@/views/common/print.vue'
|
|
|
+import { hdPrint } from '@/libs/JGPrint'
|
|
|
export default {
|
|
|
name: 'SalesDetail',
|
|
|
- components: { STable, VSelect, queryPart, chooseCustomModal },
|
|
|
+ components: { STable, VSelect, queryPart, chooseCustomModal, Print },
|
|
|
data () {
|
|
|
return {
|
|
|
spinning: false,
|
|
@@ -243,6 +230,20 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 打印预览/快捷打印
|
|
|
+ handlePrint (type, printerType) {
|
|
|
+ const _this = this
|
|
|
+ _this.spinning = true
|
|
|
+ let url = salesDetailPrint
|
|
|
+ const params = { sn: this.outBizSn || this.$route.params.sn }
|
|
|
+ if (type == 'export') { // 导出
|
|
|
+ url = salesDetailExport
|
|
|
+ }
|
|
|
+ // 打印或导出
|
|
|
+ hdPrint(printerType, type, url, params, '销售单', function () {
|
|
|
+ _this.spinning = false
|
|
|
+ })
|
|
|
+ },
|
|
|
// 已选产品 销售数量 blur
|
|
|
qtyBlur (val, record) {
|
|
|
const _this = this
|
|
@@ -316,49 +317,6 @@ export default {
|
|
|
isCost (val) {
|
|
|
this.isCosts = val
|
|
|
},
|
|
|
- // 打印预览/快捷打印
|
|
|
- handlePrint (type) {
|
|
|
- const _this = this
|
|
|
- _this.spinning = true
|
|
|
- let url = salesDetailPrint
|
|
|
- let params = { sn: this.$route.params.sn, type: this.printerType }
|
|
|
- if (type == 'export') { // 导出
|
|
|
- url = salesDetailExport
|
|
|
- params = { sn: this.$route.params.sn }
|
|
|
- }
|
|
|
- url(params).then(res => {
|
|
|
- _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 {
|
|
|
- JGPrint(res, type, this.printerType)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- 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()
|
|
|
- },
|
|
|
// 更新产品列表
|
|
|
updateData (priceType) {
|
|
|
// 价格类型变更
|