|
@@ -13,21 +13,19 @@
|
|
|
@click.stop="handleEdit">编辑</a-button>
|
|
|
</template>
|
|
|
<template slot="extra" v-if="$hasPermissions('B_salesPrint')">
|
|
|
- <!-- <span>打印字段:</span>
|
|
|
- <a-select key="1" style="width:150px" id="salesDetail-pritKey" placeholder="请选择打印字段" allowClear>
|
|
|
- <a-select-option v-for="item in pritKey" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
|
|
|
- </a-select>
|
|
|
- <span><i style="color: red;">*</i>打印模板:</span>
|
|
|
- <a-select key="2" style="width:150px" id="salesDetail-pritKey" placeholder="请选择打印模板" allowClear>
|
|
|
- <a-select-option v-for="item in pritModal" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
|
|
|
- </a-select> -->
|
|
|
- <!-- <a-button key="5" id="salesDetail-export-btn">导出</a-button> -->
|
|
|
- <a-radio-group key="3" v-model="printerType">
|
|
|
+ <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="2" id="salesDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
|
|
|
- <a-button key="1" type="primary" id="salesDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
|
|
|
+ <a-button key="3" id="salesDetail-preview-btn" :disabled="localDataSource.length==0" @click="handlePrint('preview')">打印预览</a-button>
|
|
|
+ <a-button key="2" type="primary" id="salesDetail-print-btn" :disabled="localDataSource.length==0" @click="handlePrint('print')">快捷打印</a-button>
|
|
|
+ <a-button
|
|
|
+ key="1"
|
|
|
+ type="primary"
|
|
|
+ class="button-warning"
|
|
|
+ id="salesDetail-export-btn"
|
|
|
+ :disabled="localDataSource.length==0"
|
|
|
+ @click="handlePrint('export')">导出Excel</a-button>
|
|
|
</template>
|
|
|
</a-page-header>
|
|
|
<!-- 基础信息 -->
|
|
@@ -93,9 +91,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import moment from 'moment'
|
|
|
import { getOperationalPrecision } from '@/libs/tools.js'
|
|
|
import { STable, VSelect } from '@/components'
|
|
|
-import { salesDetailBySn, salesDetailPrint } from '@/api/sales'
|
|
|
+import { salesDetailBySn, salesDetailPrint, salesDetailExport } from '@/api/sales'
|
|
|
import { salesDetailList } from '@/api/salesDetail'
|
|
|
export default {
|
|
|
name: 'SalesDetail',
|
|
@@ -110,16 +109,6 @@ export default {
|
|
|
return {
|
|
|
spinning: false,
|
|
|
disabled: false,
|
|
|
- pritKey: [
|
|
|
- { id: 0, name: '打印促销' },
|
|
|
- { id: 1, name: '打印支付方式' },
|
|
|
- { id: 2, name: '打印收款方式' }
|
|
|
- ],
|
|
|
- pritModal: [
|
|
|
- { id: 0, name: '普通模板一' },
|
|
|
- { id: 1, name: '普通模板二' },
|
|
|
- { id: 2, name: '仓库模板一' }
|
|
|
- ],
|
|
|
// 表头
|
|
|
columns: [
|
|
|
{ title: '序号', dataIndex: 'no', width: 80, align: 'center' },
|
|
@@ -193,7 +182,13 @@ export default {
|
|
|
handlePrint (type) {
|
|
|
const _this = this
|
|
|
_this.spinning = true
|
|
|
- salesDetailPrint({ sn: this.outBizSn || this.$route.params.sn, type: this.printerType }).then(res => {
|
|
|
+ let url = salesDetailPrint
|
|
|
+ let params = { sn: this.outBizSn || this.$route.params.sn, type: this.printerType }
|
|
|
+ if (type == 'export') { // 导出
|
|
|
+ url = salesDetailExport
|
|
|
+ params = { sn: this.outBizSn || this.$route.params.sn }
|
|
|
+ }
|
|
|
+ url(params).then(res => {
|
|
|
_this.spinning = false
|
|
|
if (res.type == 'application/json') {
|
|
|
var reader = new FileReader()
|
|
@@ -206,7 +201,11 @@ export default {
|
|
|
})
|
|
|
reader.readAsText(res)
|
|
|
} else {
|
|
|
- this.print(res, type)
|
|
|
+ if (type == 'export') { // 导出
|
|
|
+ this.download(res)
|
|
|
+ } else {
|
|
|
+ this.print(res, type)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -222,6 +221,18 @@ export default {
|
|
|
window.frames['printf'].focus()
|
|
|
window.frames['printf'].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 () {
|