|
@@ -3,20 +3,13 @@
|
|
|
<div>
|
|
<div>
|
|
|
<DkModal
|
|
<DkModal
|
|
|
v-model="showChooseTemplate"
|
|
v-model="showChooseTemplate"
|
|
|
- :title="$t('W_136')"
|
|
|
|
|
|
|
+ title="选择打印模板"
|
|
|
@modalOk="printBtn"
|
|
@modalOk="printBtn"
|
|
|
@modalCancel="showChooseTemplate = false"
|
|
@modalCancel="showChooseTemplate = false"
|
|
|
@on-cancel="showChooseTemplate = false"
|
|
@on-cancel="showChooseTemplate = false"
|
|
|
>
|
|
>
|
|
|
<DkForm :col-count="1">
|
|
<DkForm :col-count="1">
|
|
|
- <DkFormItem :label="$t('printerId')" required>
|
|
|
|
|
- <SelectPop v-model="currentPrinter" :multiple="false"
|
|
|
|
|
- :options="printerList"
|
|
|
|
|
- labelKey="printerName"
|
|
|
|
|
- valueKey="printerCode">
|
|
|
|
|
- </SelectPop>
|
|
|
|
|
- </DkFormItem>
|
|
|
|
|
- <DkFormItem :label="$t('printLayoutId')" required>
|
|
|
|
|
|
|
+ <DkFormItem label="打印模板" required>
|
|
|
<SelectPop v-model="currentTemplate" :multiple="false"
|
|
<SelectPop v-model="currentTemplate" :multiple="false"
|
|
|
:options="templateList"
|
|
:options="templateList"
|
|
|
labelKey="layoutName"
|
|
labelKey="layoutName"
|
|
@@ -29,25 +22,22 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-
|
|
|
|
|
- import { hiprint } from 'vue-plugin-hiprint'
|
|
|
|
|
|
|
+import {formMixin} from '@/mixins/form'
|
|
|
|
|
+import { hiprint } from 'vue-plugin-hiprint'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
|
|
+ mixins: [formMixin],
|
|
|
name: 'print_modal',
|
|
name: 'print_modal',
|
|
|
components: {},
|
|
components: {},
|
|
|
props: {
|
|
props: {
|
|
|
- orderType: {
|
|
|
|
|
- type: String,
|
|
|
|
|
- default: ''
|
|
|
|
|
- },
|
|
|
|
|
- labelKind: {
|
|
|
|
|
|
|
+ docName: {
|
|
|
type: String
|
|
type: String
|
|
|
},
|
|
},
|
|
|
service: {
|
|
service: {
|
|
|
type: Object
|
|
type: Object
|
|
|
},
|
|
},
|
|
|
id: {
|
|
id: {
|
|
|
- type: Number
|
|
|
|
|
|
|
+ type: String
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
@@ -66,48 +56,41 @@
|
|
|
this.$Message.warning('请先选择一个模板再打印')
|
|
this.$Message.warning('请先选择一个模板再打印')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (!this.currentPrinter) {
|
|
|
|
|
- this.$Message.warning('请先选择一个打印机再打印')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
if (!this.id) {
|
|
if (!this.id) {
|
|
|
this.$Message.warning('请先选择一条数据再打印')
|
|
this.$Message.warning('请先选择一条数据再打印')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- // console.log('currentTemplate', this.currentTemplate)
|
|
|
|
|
- // console.log('currentPrinter', this.currentPrinter)
|
|
|
|
|
let template = this.templateList.find(it => it.layoutId == this.currentTemplate)?.layoutData
|
|
let template = this.templateList.find(it => it.layoutId == this.currentTemplate)?.layoutData
|
|
|
- // console.log('template', template)
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 打印机code,保存到缓存
|
|
|
|
|
- let data = localStorage.getItem('currentPrinter')
|
|
|
|
|
- if (data) {
|
|
|
|
|
- data = JSON.parse(localStorage.getItem('currentPrinter'))
|
|
|
|
|
- } else {
|
|
|
|
|
- data = {}
|
|
|
|
|
- }
|
|
|
|
|
- data[this.$store.state.user.ftyId] = this.currentPrinter
|
|
|
|
|
- localStorage.setItem('currentPrinter', JSON.stringify(data))
|
|
|
|
|
- //获取打印数据
|
|
|
|
|
- this.excuteNoParams(this.$service.printDataService, this.$service.printDataService.getPrintData, [this.id]).then(res => {
|
|
|
|
|
- if (res.code === 200 && res.data) {
|
|
|
|
|
- let printData = res.data
|
|
|
|
|
-
|
|
|
|
|
- this.$printUtil.print(template,printData,this.currentPrinter)
|
|
|
|
|
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$Message.warning(res.message)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ console.log('this.service',this.service)
|
|
|
|
|
+ let header=this.excuteNoParam(this.service, this.service.selectById,[this.id])
|
|
|
|
|
+ // .then(res => {
|
|
|
|
|
+ // if (res.code === this.$config.SUCCESS_CODE) {
|
|
|
|
|
+ // console.log(res.data)
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // this.$Message.warning(res.message)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ let detail=this.excuteNoParam(this.$service.orderService, this.$service.orderService.selectOrderInfoById, [this.id])
|
|
|
|
|
+ Promise.all([header, detail])
|
|
|
|
|
+ .then((results) => {
|
|
|
|
|
+ // 在这里执行接下来的操作
|
|
|
|
|
+ if(results?.[0]?.code === this.$config.SUCCESS_CODE && results?.[1]?.code === this.$config.SUCCESS_CODE){
|
|
|
|
|
+ let header =results?.[0]?.data
|
|
|
|
|
+ let detail =results?.[1]?.data
|
|
|
|
|
+ this.$set(header, 'table', detail['orderItem'])
|
|
|
|
|
+ let printData = {...header}
|
|
|
|
|
+ this.$printUtil.print(template,printData)
|
|
|
|
|
+ }else {
|
|
|
|
|
+ this.$Message.warning(this.$t('W_006'))
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
getTemplateList() {
|
|
getTemplateList() {
|
|
|
- this.excute(this.$service.labelPrintLayoutService, this.$service.labelPrintLayoutService.selectByCond, {
|
|
|
|
|
|
|
+ this.excute(this.$service.printLayoutService, this.$service.printLayoutService.selectByCond, {
|
|
|
flgValid: true,
|
|
flgValid: true,
|
|
|
- labelKind: this.labelKind,
|
|
|
|
|
- ftyId: this.$store.state.user.ftyId
|
|
|
|
|
|
|
+ docName: this.docName,
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
this.templateList = res.data.list
|
|
this.templateList = res.data.list
|
|
@@ -116,33 +99,10 @@
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- /**
|
|
|
|
|
- * @desc : 查询打印机
|
|
|
|
|
- * @author : 洪旭东
|
|
|
|
|
- * @date : 2023-04-10 13:04
|
|
|
|
|
- */
|
|
|
|
|
- getPrinter() {
|
|
|
|
|
- this.excute(this.$service.labelPrinterService, this.$service.labelPrinterService.selectByCond, { flgValid: true,ftyId: this.$store.state.user.ftyId
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- if (res.code === this.$config.SUCCESS_CODE) {
|
|
|
|
|
- this.printerList = res.data.list
|
|
|
|
|
- //从缓存中取出打印机code
|
|
|
|
|
- if (localStorage.getItem('currentPrinter')) {
|
|
|
|
|
- let localPrinterCode = JSON.parse(localStorage.getItem('currentPrinter'))[this.$store.state.user.ftyId]
|
|
|
|
|
- let list = this.printerList.filter(it => it.printerCode == localPrinterCode)
|
|
|
|
|
- if (localPrinterCode && list.length > 0) {
|
|
|
|
|
- this.currentPrinter = localPrinterCode
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- this.$Message.warning(res.message)
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
|
this.getTemplateList()
|
|
this.getTemplateList()
|
|
|
- this.getPrinter()
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
}
|
|
}
|