Browse Source

wx打印pdf

zhangxiaomu 2 năm trước cách đây
mục cha
commit
759e8327fa

+ 0 - 7
src/components/business/print/modal.vue

@@ -65,13 +65,6 @@ import { hiprint } from 'vue-plugin-hiprint'
 
         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) => {

+ 10 - 0
src/router/routers.js

@@ -38,6 +38,16 @@ let menu = [
     component: () => import('@/view/login/qv-login.vue')
   },
   {
+    path: '/wx-print',
+    name: 'wx-print',
+    meta: {
+      title: '单据打印',
+      hideInMenu: true,
+      notCache: true
+    },
+    component: () => import('@/view/wx-print/index.vue')
+  },
+  {
     path: '/',
     name: '_home',
     component: Main,

+ 78 - 0
src/view/wx-print/index.vue

@@ -0,0 +1,78 @@
+<template>
+
+</template>
+
+<script>
+import {formMixin} from '@/mixins/form'
+import {hiprint} from "vue-plugin-hiprint";
+
+export default {
+  mixins: [formMixin],
+  components: {
+    print
+  },
+  name: 'wx-print',
+  data() {
+    return {
+      templateList: [],
+      docs:{
+        'sa':{'docName':this.$config.docCode.order,'service':this.$service.orderService,}
+      },
+    }
+  },
+  methods: {
+  },
+  created() {
+  },
+  mounted() {
+    console.log('this.$route.query',this.$route.query)
+    if (!this.$route.query.layout_id) {
+      this.$Message.warning('请先选择一个模板再打印')
+      return
+    }
+    if (!this.$route.query.data_id) {
+      this.$Message.warning('请先选择一条数据再打印')
+      return
+    }
+    if (!this.$route.query.doc) {
+      this.$Message.warning('请先选择单据类型再打印')
+      return
+    }
+
+    // let template = this.templateList.find(it => it.layoutId == this.$route.query.layout_id)?.layoutData
+    console.log('templateList',this.templateList)
+
+    let layout = this.excute(this.$service.printLayoutService, this.$service.printLayoutService.selectByCond, { flgValid: true, docName: this.docs[this.$route.query.doc].docName, })
+    let header=this.excuteNoParam(this.docs[this.$route.query.doc].service, this.docs[this.$route.query.doc].service.selectById,[this.$route.query.data_id])
+    let detail=this.excuteNoParam(this.docs[this.$route.query.doc].service, this.docs[this.$route.query.doc].service.selectOrderInfoById, [this.$route.query.data_id])
+    Promise.all([header, detail,layout])
+      .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
+          let layout =results?.[2]?.data?.list.find(it => it.layoutId == this.$route.query.layout_id)?.layoutData
+          this.$set(header, 'table', detail['orderItem'])
+
+
+          let printData = {...header}
+
+          let hiprintTemplate = new hiprint.PrintTemplate({
+            template: layout,
+          })
+
+          hiprintTemplate.toPdf(printData,'单据打印')
+
+
+        }else {
+          this.$Message.warning(this.$t('W_006'))
+        }
+      })
+  }
+
+}
+</script>
+
+<style scoped>
+
+</style>