Browse Source

【修改】 bug

Howie 3 years ago
parent
commit
8c39ec9220

+ 15 - 16
src/views/supply/deliver/components/design/panel.js

@@ -83,7 +83,7 @@ export default {
         "fontSize": 13,
         "fontSize": 13,
         "title": "备注",
         "title": "备注",
         "fontFamily": '黑体',
         "fontFamily": '黑体',
-        "field": "correspondName",
+        "field": "headerRemark",
         "testData": "",
         "testData": "",
         "color": "#000",
         "color": "#000",
         "textAlign": "left"
         "textAlign": "left"
@@ -105,7 +105,7 @@ export default {
             "title": "出库单号",
             "title": "出库单号",
             "field": "salesId",
             "field": "salesId",
             "width": 40,
             "width": 40,
-            "align": "center",
+            "align": "left",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
@@ -114,40 +114,39 @@ export default {
             "title": "发货单号",
             "title": "发货单号",
             "field": "invoiceId",
             "field": "invoiceId",
             "width": 45,
             "width": 45,
-            "align": "center",
+            "align": "left",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
-
+            
 
 
           }
           }
           , {
           , {
             "title": "发货日期",
             "title": "发货日期",
-            "field": "id",
+            "field": "createTime",
             "width": 50,
             "width": 50,
-            "align": "center",
+            "align": "left",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
-
+           
 
 
           }
           }
           , {
           , {
             "title": "订单号",
             "title": "订单号",
             "field": "enginOrderType",
             "field": "enginOrderType",
             "width": 40,
             "width": 40,
-            "align": "center",
+            "align": "left",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
-
-
+            
           }
           }
           , {
           , {
             "title": "存货名称",
             "title": "存货名称",
             "field": "materialName",
             "field": "materialName",
             "width": 40,
             "width": 40,
-            "align": "center",
+            "align": "left",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
@@ -157,7 +156,7 @@ export default {
             "title": "规格型号",
             "title": "规格型号",
             "field": "specification",
             "field": "specification",
             "width": 100,
             "width": 100,
-            "align": "center",
+            "align": "left",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
@@ -168,7 +167,7 @@ export default {
             "title": "数量",
             "title": "数量",
             "field": "refundableQty",
             "field": "refundableQty",
             "width": 23,
             "width": 23,
-            "align": "center",
+            "align": "right",
             "colspan": 1,
             "colspan": 1,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
@@ -190,7 +189,7 @@ export default {
             "title": "备注说明",
             "title": "备注说明",
             "field": "pjxh1Text",
             "field": "pjxh1Text",
             "width": 60,
             "width": 60,
-            "align": "center",
+            "align": "left",
             "colspan": 2,
             "colspan": 2,
             "rowspan": 1,
             "rowspan": 1,
             "fontSize": 13,
             "fontSize": 13,
@@ -220,9 +219,9 @@ export default {
         "height": 13,
         "height": 13,
         "width": 218,
         "width": 218,
         "fontSize": 13,
         "fontSize": 13,
-        "title": "退货人",
+        "title": "",
         "fontFamily": '黑体',
         "fontFamily": '黑体',
-        "field": "",
+        "field": "tiTui",
         "testData": "",
         "testData": "",
         "color": "#000",
         "color": "#000",
         "textAlign": "left"
         "textAlign": "left"

+ 29 - 18
src/views/supply/deliver/components/design/preview.vue

@@ -1,5 +1,6 @@
 <template>
 <template>
-  <el-dialog :visible="visible" :maskClosable="false" @cancel="hideModal" :width="350 + 'mm'">
+  <el-dialog :visible.sync="visible" :show-close="false" :maskClosable="false" :close-on-click-modal="false"
+    @cancel="hideModal" :width="350 + 'mm'">
     <div :spinning="spinning" style="min-height: 100px">
     <div :spinning="spinning" style="min-height: 100px">
       <div id="preview_content" ref="printDom">
       <div id="preview_content" ref="printDom">
 
 
@@ -21,8 +22,9 @@
 </template>
 </template>
 
 
 <script>
 <script>
-import { downloadPDF } from '@/utils/pdf'
+// import { downloadPDF } from '@/utils/pdf'
 import { addPrint } from './print-data'
 import { addPrint } from './print-data'
+import { detailArr } from './print-data'
 export default {
 export default {
   name: "printPreview",
   name: "printPreview",
   props: {},
   props: {},
@@ -46,13 +48,14 @@ export default {
   mounted() {
   mounted() {
   },
   },
   methods: {
   methods: {
-    handleExport() {
-      downloadPDF(this.$refs.printDom);
-
-    },
+    // handleExport() {
+    //   downloadPDF(this.$refs.printDom);
+    // },
     hideModal() {
     hideModal() {
       this.visible = false
       this.visible = false
       this.waitShowPrinter = false
       this.waitShowPrinter = false
+      this.$parent.initPrint()
+      // console.log(this.$parent);
     },
     },
     show(hiprintTemplate, printData, width = '210') {
     show(hiprintTemplate, printData, width = '210') {
       this.visible = true
       this.visible = true
@@ -67,23 +70,31 @@ export default {
       }, 500)
       }, 500)
     },
     },
     print() {
     print() {
-      this.waitShowPrinter = true
-
+       
       this.hiprintTemplate.print(this.printData, {}, {
       this.hiprintTemplate.print(this.printData, {}, {
-        // styleHandler: () => {
-        //   // 这里拼接成放html->head标签内的css/style
-        //   // 1.例如:使用hiprin官网的样式
-        //   let css = '<link href="http://hiprint.io/Content/hiprint/css/print-lock.css" media="print" rel="stylesheet">'
-        //   // 2.重写样式:所有文本红色
-        //   css += '<style>.hiprint-printElement-text{color:red !important;}</style>'
-        //   return css
-        // },
         callback: () => {
         callback: () => {
-          console.log('callback')
           addPrint()
           addPrint()
-          this.waitShowPrinter = false
+          this.hiprintTemplate = {}
+          this.$parent.getList()
+          this.$parent.tableSelection =[]
         }
         }
       })
       })
+      // this.hiprintTemplate.on('printSuccess', function (data) {
+      //   console.log('打印完成')
+      //      addPrint()
+      //     this.hiprintTemplate = {}
+      //     this.$parent.getList()
+      //     this.$parent.tableSelection =[]
+      // })
+      // this.hiprintTemplate.on('printError', function (data) {
+      //   console.log('打印失败')
+      //   this.hiprintTemplate = {}
+      //     this.$parent.getList()
+      //     this.$parent.tableSelection =[]
+      // })
+      setTimeout(()=>{
+        this.hideModal()
+      },2000)
     },
     },
     // toPdf() {
     // toPdf() {
     //   downloadPDF(this.$refs.printDom);
     //   downloadPDF(this.$refs.printDom);

+ 90 - 82
src/views/supply/deliver/components/design/print-data.js

@@ -1,112 +1,120 @@
 import { getDeliverDetail } from '@/api/supply/deliver'
 import { getDeliverDetail } from '@/api/supply/deliver'
 import { addPrints } from '@/api/supply/pickup'
 import { addPrints } from '@/api/supply/pickup'
 import { getCompanyList } from '@/api/user'
 import { getCompanyList } from '@/api/user'
-    
-    const detailArr = []
-    let detailData = []
-    let company = ''
-  // 获取详情
-  getCompanyLists() 
- function  getDetail(ids) {
-    let newIds =[]
-    newIds =ids
-    for (let i = 0; i < newIds.length; i++) {
 
 
-      getDeliverDetail({ id: newIds[i].id }).then(res => {
-        detailData = res.data
-        const item = res.data
-        const table = []
-      
-        item.invoicePickBeans.length=5
-        item.invoicePickBeans.forEach(e => {
-          table.push({
-              salesId:e.salesId,
-              invoiceId:e.invoiceId,
-              id:e.id,
-              enginOrderType:e.enginOrderType =='HOME' || e.enginOrderType =='TRADE'? e.enginOrderNo :e.mainOrderId ,
-              materialName:e.materialName  || '',
-              specification:e.specification || '',
-              refundableQty:100,
-              // headerRemark:e.headerRemark,
-              pjxh1Text:e.pjxh1Text || ''
-            })
-        });
-     
-        // table.push({},{},{},{},{})
-        console.log(company);
-        detailArr.push({
-            type:item.type,
-            company:item.type === 2 ? `${company}销售退货单`:`${company}销售发货单`,
-            pickOrderWater:item.pickOrderWater, 
-            customerNumber:item.customerNumber,
-            nowDate:nowDate(),
-            customerName:item.customerName || '',
-            correspondName:item.correspondName || '',
-            createBy:item.createBy,
-            table
+let detailArr = []
+let detailData = []
+let company = ''
+// 获取详情
+getCompanyLists()
+function getDetail(ids) {
+
+  detailArr = []
+  // detailData = ids 
+  let newIds = []
+  newIds = ids
+  for (let i = 0; i < newIds.length; i++) {
+    getDeliverDetail({ id: newIds[i].id }).then(res => {
+      const item = res.data
+      detailData.push(item)
+      const table = []
+      item.invoicePickBeans.length = 5
+      item.invoicePickBeans.forEach(e => {
+        table.push({
+          salesId: e.salesOrderId,
+          invoiceId: e.invoiceId,
+          id: e.id,
+          createTime: e.id ? dateToDayFilter(item.createTime) : '',
+          enginOrderType: e.enginOrderType == 'HOME' || e.enginOrderType == 'TRADE' ? e.enginOrderNo : e.mainOrderId,
+          materialName: e.materialName || '',
+          specification: e.specification || '',
+          refundableQty: 100,
+          // headerRemark:e.headerRemark,
+          pjxh1Text: e.pjxh1Text || ''
         })
         })
-     })
-    }
+      });
 
 
+      console.log(company);
+      detailArr.push({
+        type: item.type,
+        tiTui:item.type === 2 ? `退货人` : `提货人`,
+        headerRemark:item.remark,
+        total_num: item.total_num,
+        company: item.type === 2 ? `${company}销售退货单` : `${company}销售发货单`,
+        pickOrderWater: item.pickOrderWater,
+        customerNumber: item.customerNumber,
+        nowDate: nowDate(),
+        customerName: item.customerName || '',
+        correspondName: item.correspondName || '',
+        createBy: item.createBy,
+        table
+      })
+    })
   }
   }
-    console.log(detailArr);
- 
-  function nowDate() {
-    var date = new Date();
-    var seperator1 = "-";
-    var year = date.getFullYear();
-    var month = date.getMonth() + 1;
-    var strDate = date.getDate();
-    if (month >= 1 && month <= 9) {
-        month = "0" + month;
-    }
-    if (strDate >= 0 && strDate <= 9) {
-        strDate = "0" + strDate;
-    }
-    var currentdate = year + seperator1 + month + seperator1 + strDate;
-    return currentdate;
+}
+
+function nowDate() {
+  var date = new Date();
+  var seperator1 = "-";
+  var year = date.getFullYear();
+  var month = date.getMonth() + 1;
+  var strDate = date.getDate();
+  if (month >= 1 && month <= 9) {
+    month = "0" + month;
   }
   }
+  if (strDate >= 0 && strDate <= 9) {
+    strDate = "0" + strDate;
+  }
+  var currentdate = year + seperator1 + month + seperator1 + strDate;
+  console.log(currentdate);
+  return currentdate;
+}
 
 
+function dateToDayFilter(date) {
+  if (!date) { return '' }
+  return date.slice(0, 10)
+}
 
 
-  function getCompanyLists() {
-    getCompanyList().then(res => {
-      company = res.data ? res.data[0].companyName : ''
-    
-    })
-    return company
-  }
- 
- // 添加次数
- function  addPrint() {
-  console.log('add',999,detailData);
-  const ids = detailData.map(item => {
+function getCompanyLists() {
+  getCompanyList().then(res => {
+    company = res.data ? res.data[0].companyName : ''
+  })
+  return company
+}
+
+// 添加次数
+function addPrint() {
+        // console.log(detailData);
+  let ids = detailData.map(item => {
+    console.log(item.invoicePickBeans);
     if (item.invoicePickBeans && item.invoicePickBeans.length) {
     if (item.invoicePickBeans && item.invoicePickBeans.length) {
       for (let index = 0; index < item.invoicePickBeans.length; index++) {
       for (let index = 0; index < item.invoicePickBeans.length; index++) {
         const element = item.invoicePickBeans[index];
         const element = item.invoicePickBeans[index];
-        return item.invoiceOrderId || element.invoiceOrderId || element.id
+            // console.log(element.id ,'element.id ');
+        return  element.id 
       }
       }
     } else {
     } else {
+      // console.log(item.invoiceOrderId ,'item.invoiceOrderId ');
       return item.invoiceOrderId || item.id
       return item.invoiceOrderId || item.id
     }
     }
-
+  
   })
   })
-      console.log(ids);
+    ids = [...new Set(ids)]
   // console.log(document.execCommand('print'),'4545');
   // console.log(document.execCommand('print'),'4545');
   addPrints({ ids: ids.join(',') }).then(res => {
   addPrints({ ids: ids.join(',') }).then(res => {
-    console.log('chenggong ');
+      console.log('chenggong ');
     // this.$successMsg('提交成功');
     // this.$successMsg('提交成功');
     // this.$parent.getList()
     // this.$parent.getList()
+ 
   })
   })
 }
 }
 
 
 
 
 
 
- const myData =  detailArr
 
 
 
 
- export {
-    getDetail ,getCompanyLists,
-    myData,
-    detailArr,
-    addPrint
+export {
+  getDetail, getCompanyLists,
+  detailArr,
+  addPrint
 }
 }

+ 59 - 32
src/views/supply/deliver/sum_list.vue

@@ -327,15 +327,34 @@ import { getCategoryList, getSalesmanList } from '@/api/common'
 import SumPrint from '@/views/supply/deliver/components/sum_print'
 import SumPrint from '@/views/supply/deliver/components/sum_print'
 import { disAutoConnect, hiprint, defaultElementTypeProvider } from 'vue-plugin-hiprint'
 import { disAutoConnect, hiprint, defaultElementTypeProvider } from 'vue-plugin-hiprint'
 disAutoConnect();
 disAutoConnect();
-let hiprintTemplate;
+
 import panel from './components/design/panel'
 import panel from './components/design/panel'
-import { getDetail, getCompanyLists, myData } from './components/design/print-data'
+import { getDetail, detailArr } from './components/design/print-data'
 import printPreview from './components/design/preview.vue'
 import printPreview from './components/design/preview.vue'
 export default {
 export default {
   components: {
   components: {
     SumPrint,
     SumPrint,
     printPreview
     printPreview
   },
   },
+  filters: {
+    orderTypeFilter(val) {
+      const MAP = {
+        HOME: '家用单',
+        TRADE: '商用单',
+        RETAIL: '零售单',
+        RETAIL_POLICY: '销售政策单',
+        PERMU_HOME: '置换家用单',
+        PERMU_TRADE: '置换商用单',
+        PERMU_RETAIL: '置换零售单',
+        PERMU_RETAIL_POLICY: '置换销售政策单',
+        REQUISITION_HOME: '调拨家用单',
+        REQUISITION_TRADE: '调拨商用单',
+        REQUISITION_RETAIL: '调拨零售单',
+        REQUISITION_RETAIL_POLICY: '调拨销售政策单',
+      }
+      return MAP[val];
+    }
+  },
   data() {
   data() {
     return {
     return {
       currentPage: 1, // 当前页码
       currentPage: 1, // 当前页码
@@ -407,6 +426,7 @@ export default {
       dialogFormRules: {
       dialogFormRules: {
         password: [{ required: true, message: "请输入密码", trigger: "blur" }],
         password: [{ required: true, message: "请输入密码", trigger: "blur" }],
       },
       },
+    hiprintTemplate:''
 
 
     }
     }
   },
   },
@@ -463,40 +483,44 @@ export default {
     this.getCategoryList();
     this.getCategoryList();
     this.getList();
     this.getList();
   },
   },
-  mounted() {
-    hiprint.init({
+  activated(){
+    this.initPrint()
+  },
+  methods: {
+   initPrint(){
+      hiprint.init({
       providers: [new defaultElementTypeProvider()]
       providers: [new defaultElementTypeProvider()]
     });
     });
     // 还原配置
     // 还原配置
     hiprint.setConfig()
     hiprint.setConfig()
     // 替换配置
     // 替换配置
-    // hiprint.setConfig({
-    //   movingDistance: 2.5,
-    //   text: {
-    //     supportOptions: [
-    //       {
-    //         name: 'styler',
-    //         hidden: true
-    //       },
-    //       {
-    //         name: 'formatter',
-    //         hidden: true
-    //       },
-    //     ]
-    //   }
-    // })
+    hiprint.setConfig({
+      movingDistance: 2.5,
+      text: {
+        supportOptions: [
+          {
+            name: 'styler',
+            hidden: true
+          },
+          {
+            name: 'formatter',
+            hidden: true
+          },
+        ]
+      }
+    })
     // eslint-disable-next-line no-undef
     // eslint-disable-next-line no-undef
     hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
     hiprint.PrintElementTypeManager.buildByHtml($('.ep-draggable-item'));
-    hiprintTemplate = new hiprint.PrintTemplate({
+    this.hiprintTemplate = new hiprint.PrintTemplate({
       template: panel,
       template: panel,
       settingContainer: '#PrintElementOptionSetting',
       settingContainer: '#PrintElementOptionSetting',
       paginationContainer: '.hiprint-printPagination'
       paginationContainer: '.hiprint-printPagination'
     });
     });
-    hiprintTemplate.design('#hiprint-printTemplate');
+    this.hiprintTemplate.design('#hiprint-printTemplate');
     // 获取当前放大比例, 当zoom时传true 才会有
     // 获取当前放大比例, 当zoom时传true 才会有
     // this.scaleValue = hiprintTemplate.editingPanel.scale || 1;
     // this.scaleValue = hiprintTemplate.editingPanel.scale || 1;
-  },
-  methods: {
+    }
+,
     // 获取业务员列表
     // 获取业务员列表
     getSalesmanList() {
     getSalesmanList() {
       getSalesmanList({
       getSalesmanList({
@@ -521,8 +545,8 @@ export default {
 
 
     // 查询列表
     // 查询列表
     getList() {
     getList() {
+      console.log(888);
       this.listLoading = true;
       this.listLoading = true;
-
       let params = {
       let params = {
         pageNum: this.currentPage,
         pageNum: this.currentPage,
         pageSize: this.pageSize,
         pageSize: this.pageSize,
@@ -596,17 +620,19 @@ export default {
 
 
     // 点击打印
     // 点击打印
     toPrint() {
     toPrint() {
-
+      // this.$refs
       this.queryItem = this.tableSelection;
       this.queryItem = this.tableSelection;
-      console.log(this.tableSelection);
-      getDetail(this.tableSelection)
+      // console.log(this.tableSelection);
       // this.isShowPrint = true;
       // this.isShowPrint = true;
       // this.$refs.myPdfComponent.print()
       // this.$refs.myPdfComponent.print()
-      this.$refs.preView.show(hiprintTemplate, myData)
-
+      // console.log(this.hiprintTemplate, detailArr);
+      // getDetail(this.tableSelection)
+      // this.$refs.preView.show(this.hiprintTemplate, detailArr)
       if (!this.tableSelection[0].printNum) {
       if (!this.tableSelection[0].printNum) {
         this.queryItem = this.tableSelection;
         this.queryItem = this.tableSelection;
         // this.isShowPrint = true;
         // this.isShowPrint = true;
+        getDetail(this.tableSelection)
+        this.$refs.preView.show(this.hiprintTemplate, detailArr)
       } else {
       } else {
         this.queryItem = this.tableSelection;
         this.queryItem = this.tableSelection;
         this.dialogForm.createMan = JSON.parse(
         this.dialogForm.createMan = JSON.parse(
@@ -633,7 +659,8 @@ export default {
           };
           };
           checkPassword(params).then((res) => {
           checkPassword(params).then((res) => {
             this.cancelDialogForm();
             this.cancelDialogForm();
-            this.isShowPrint = true;
+            getDetail(this.tableSelection)
+             this.$refs.preView.show(this.hiprintTemplate, detailArr)
           });
           });
         }
         }
       });
       });
@@ -669,10 +696,10 @@ export default {
       try {
       try {
         if (Object.keys(this.paperTypes).includes(type)) {
         if (Object.keys(this.paperTypes).includes(type)) {
           this.curPaper = { type: type, width: value.width, height: value.height }
           this.curPaper = { type: type, width: value.width, height: value.height }
-          hiprintTemplate.setPaper(value.width, value.height)
+          this.hiprintTemplate.setPaper(value.width, value.height)
         } else {
         } else {
           this.curPaper = { type: 'other', width: value.width, height: value.height }
           this.curPaper = { type: 'other', width: value.width, height: value.height }
-          hiprintTemplate.setPaper(value.width, value.height)
+          this.hiprintTemplate.setPaper(value.width, value.height)
         }
         }
       } catch (error) {
       } catch (error) {
         this.$message.error(`操作失败: ${error}`)
         this.$message.error(`操作失败: ${error}`)