Преглед изворни кода

feat(采购收货单): 添加来料报检单打印功能

liujt пре 7 месеци
родитељ
комит
20d11dd4d6

+ 213 - 0
src/views/purchasingManage/purchaseOrder/invoice/components/print-template-tr.vue

@@ -0,0 +1,213 @@
+<template>
+  <ele-modal
+    title="入库单"
+    :visible.sync="QRvisible"
+    v-if="QRvisible"
+    width="80%"
+  >
+    <div
+      id="printSection"
+      style="
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        flex-direction: column;
+      "
+    >
+      <div
+        style="
+          text-align: center;
+          font-size: 20px;
+          font-weight: 800;
+          margin-bottom: 10px;
+        "
+        >{{ groupName + '来料报检单' }}</div
+      >
+      <div
+        style="
+          display: flex;
+          justify-content: space-between;
+          width: 100%;
+          min-width: 800px; 
+          margin-bottom: 10px;
+          font-size: 13px;
+        "
+      >
+        <span style="flex: 2; white-space: nowrap; padding-right: 10px"
+          >供应商/部门:{{ formData.supplierName }}</span
+        >
+        <span style="flex: 1; white-space: nowrap; padding: 0 10px"
+          >单据日期:{{ formData.receiveDate }}</span
+        >
+        <span style="flex: 2; white-space: nowrap; padding-left: 10px"
+          >单据编号:{{ formData.receiveNo }}</span
+        >
+      </div>
+      <!-- <div
+        style="
+          display: flex;
+          justify-content: space-between;
+          width: 100%;
+          margin-bottom: 10px;
+          font-size: 13px;
+        "
+      >
+        <span style="flex: 1">摘要:</span>
+      </div> -->
+      <table
+        cellspacing="0"
+        border
+        style="
+          width: 100%;
+          table-layout: fixed;
+          word-break: break-all;
+          word-wrap: break-word;
+          font-size: 12px;
+          margin-bottom: 10px;
+        "
+      >
+        <tbody>
+          <tr align="center">
+            <td style="padding: 5px" width="50px"> 序号 </td>
+            <td style="padding: 5px"> 物料编码 </td>
+            <td style="padding: 5px"> 物料名称 </td>
+            <td style="padding: 5px"> 厂家批号 </td>
+            <td style="padding: 5px"> 来料批号 </td>
+            <td style="padding: 5px">规格型号 </td>
+            <td style="padding: 5px">单位 </td>
+            <td style="padding: 5px"> 实收数量</td>
+            <td style="padding: 5px"> 取样量</td>
+            <td style="padding: 5px"> 退回量</td>
+            <td style="padding: 5px"> 备注</td>
+          </tr>
+
+          <tr align="center" v-for="(item, index) in formData?.resultList || []">
+            <td style="padding: 5px"> {{ index + 1 }} </td>
+            <td style="padding: 5px"> {{ item.productCode }} </td>
+            <td style="padding: 5px"> {{ item.productName }} </td>
+            <td style="padding: 5px">  </td>
+            <td style="padding: 5px"> {{ item.batchNo }} </td>
+            <td style="padding: 5px">
+              {{ item.specification || ''
+              }}{{ item.modelType ? '/' + item.modelType : '' }}
+            </td>
+            <td style="padding: 5px"> {{ item.measuringUnit }}</td>
+            <td style="padding: 5px"> {{ item.totalCount }}</td>
+            <td style="padding: 5px"> </td>
+            <td style="padding: 5px"> </td>
+            <td style="padding: 5px"> {{ item.remark }}</td>
+          </tr>
+        </tbody>
+      </table>
+      <div style="display: flex; justify-content: space-between; width: 100%; font-size: 13px;">
+        <span style="flex: 1">报检人/日期:{{formData.qualityName}}/{{ formData.qualityReportUploadTime }}</span>
+        <span style="flex: 1">签收人/日期:{{formData.makerName}}/{{ formData.createTime }}</span>
+      </div>
+    </div>
+    <div slot="footer">
+      <el-button @click="print">打印预览</el-button>
+      <el-button @click="close">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+import { getReceiveSaleOrderrecordDetail } from '@/api/purchasingManage/purchaseorderreceive';
+
+import { mapGetters } from 'vuex';
+export default {
+  name: 'print',
+  computed: {
+    ...mapGetters(['user'])
+  },
+  props: {
+    groupName: ''
+  },
+  data() {
+    return {
+      QRvisible: false,
+      formData: {}
+    };
+  },
+
+  methods: {
+    numToChinese(num) {
+    const digits = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
+    const units = ['', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿'];
+    const decimalUnits = ['角', '分'];
+
+    num = Number(num).toFixed(2); 
+    const [integerStr, decimalStr] = num.split('.');
+    let result = '';
+
+    const integerLen = integerStr.length;
+    if (integerLen === 0 || (integerLen === 1 && integerStr === '0')) {
+      result += '零元';
+    } else {
+      for (let i = 0; i < integerLen; i++) {
+        const digit = parseInt(integerStr[i]);
+        const unitIndex = integerLen - 1 - i; 
+
+        if (digit === 0) {
+          if (i < integerLen - 1 && parseInt(integerStr[i + 1]) !== 0) {
+            result += '零';
+          }
+        } else {
+          if (!(unitIndex === 1 && digit === 1 && i === 0)) {
+            result += digits[digit];
+          }
+          result += units[unitIndex];
+        }
+      }
+      result += '元'; 
+    }
+
+    const jiao = parseInt(decimalStr[0]);
+    const fen = parseInt(decimalStr[1]);
+    if (jiao === 0 && fen === 0) {
+      result += '整'; 
+    } else {
+      if (jiao !== 0) result += digits[jiao] + decimalUnits[0]; 
+      if (fen !== 0) result += digits[fen] + decimalUnits[1]; 
+    }
+
+    return result;
+  },
+    async open(id) {
+      this.formData = await getReceiveSaleOrderrecordDetail(id);
+      this.QRvisible = true;
+    },
+    close() {
+      this.QRvisible = false;
+    },
+    getAll(key) {
+      let num = 0;
+      this.formData.productList.forEach((item) => {
+        if (item[key]) {
+          num += Number(item[key]);
+        }
+      });
+      return num;
+    },
+    print() {
+      const printSection = document.getElementById('printSection');
+      // 创建打印任务
+      const printWindow = window.open('', '_blank');
+      printWindow.document.open();
+      printWindow.document.write('<html><head><title>打印预览</title>');
+      printWindow.document.write(
+        '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+      );
+      printWindow.document.write('</head><body>');
+      printWindow.document.write(printSection.innerHTML);
+      printWindow.document.write('</body></html>');
+      printWindow.document.close();
+      printWindow.onload = function () {
+        printWindow.print();
+      };
+    }
+  }
+};
+</script>
+
+<style lang="scss"></style>

+ 15 - 1
src/views/purchasingManage/purchaseOrder/invoice/index.vue

@@ -49,6 +49,12 @@
                   @click.native="handlePrint('printTemplateWlRef')"
                   >采购入库单</el-dropdown-item
                 >
+                <!-- 特瑞 -->
+                <el-dropdown-item
+                  v-if="$hasPermission('eom:purchaseorderreceive:print')"
+                  @click.native="handlePrint('printTemplateTrRef')"
+                  >来料报检单</el-dropdown-item
+                >
               </el-dropdown-menu>
             </el-dropdown>
           </template>
@@ -165,6 +171,11 @@
       ref="printTemplateWlRef"
       :groupName="groupName"
     ></printTemplateWl>
+    <!-- 特瑞 -->
+    <printTemplateTr
+      ref="printTemplateTrRef"
+      :groupName="groupName"
+    ></printTemplateTr>
   </div>
 </template>
 
@@ -173,6 +184,8 @@
   import addInvoiceDialog from './components/addInvoiceDialog.vue';
   import detailDialog from './components/detailDialog.vue';
   import printTemplateWl from './components/print-template-wl.vue';
+  import printTemplateTr from './components/print-template-tr.vue';
+
   import popModal from '@/components/pop-modal';
   import { reviewStatus } from '@/enum/dict';
   import orderDetailDialog from '@/views/purchasingManage/purchaseOrder/components/detailDialog.vue';
@@ -201,7 +214,8 @@
       orderDetailDialog,
       addInvoiceDialog,
       detailDialog,
-      printTemplateWl
+      printTemplateWl,
+      printTemplateTr
     },
     data() {
       return {