Selaa lähdekoodia

Merge branch 'test' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-eom into dev

2213980799@qq.com 9 kuukautta sitten
vanhempi
commit
bc6a99f9ce
1 muutettua tiedostoa jossa 230 lisäystä ja 117 poistoa
  1. 230 117
      src/views/saleManage/saleOrder/invoice/components/print-template-jr.vue

+ 230 - 117
src/views/saleManage/saleOrder/invoice/components/print-template-jr.vue

@@ -2,6 +2,8 @@
   <ele-modal title="出库单" :visible.sync="QRvisible" width="90%">
     <div id="printSection">
       <div
+        v-for="(item, index) in page"
+        :key="index"
         class="print"
         style="
           display: flex;
@@ -20,12 +22,12 @@
           "
         >
           <span style="width: 48%">
-            <span style="width: 60px; display: inline-block">购货单位:</span>
+            <span style="width: 60px; display: inline-block"></span>
             {{ formData.contactName }}
           </span>
           <span>
-            <span style="width: 60px; display: inline-block">单据编码:</span>
-            {{ formData.docNo }}
+            <span style="width: 60px; display: inline-block"></span>
+            {{ formData.docNo }} {{ page.length + '/' + (index + 1) }}
           </span>
         </div>
         <div
@@ -37,27 +39,24 @@
           "
         >
           <span style="width: 48%">
-            <span style="width: 170px; display: inline-block"
-              >生产厂家/上市许可持有人:</span
-            >
+            <span style="width: 170px; display: inline-block"></span>
             湖南聚仁中药饮片有限公司
           </span>
           <span style="width: 17%">
-            <span style="width: 60px; display: inline-block">发货仓库</span>
-            成品仓
+            <span style="width: 60px; display: inline-block"></span>
+            {{ formData?.productList[0]?.warehouseName }}
           </span>
           <span style="width: 17%">
-            <span style="width: 60px; display: inline-block">发货日期</span>
-            2025-01-01
+            <span style="width: 60px; display: inline-block"></span>
+            {{ formData.createTime }}
           </span>
           <span style="width: 17%">
-            <span style="width: 60px; display: inline-block">总计金额</span>
+            <span style="width: 60px; display: inline-block"></span>
             ¥{{ formData.totalPrice }}
           </span>
         </div>
         <table
           cellspacing="0"
-          border
           style="
             width: 100%;
             height: 240px;
@@ -69,45 +68,56 @@
         >
           <tbody>
             <tr align="center" style="height: 35px">
-              <td style="width: 6%"> 商品编号 </td>
-              <td style="width: 6%"> 品名 </td>
-              <td style="width: 6%"> 规格 </td>
-              <td style="width: 6%"> 产地</td>
-              <td style="width: 3%"> 单位</td>
-              <td style="width: 6%"> 数量</td>
-              <td style="width: 7%"> 单价</td>
-              <td style="width: 7%"> 金额</td>
-              <td style="width: 8%"> 批号</td>
-              <td style="width: 8%"> 生产日期</td>
-              <td style="width: 8%"> 保质期至</td>
-              <td> 贮藏</td>
-              <td> 备注</td>
+              <td style="width: 6%"> </td>
+              <td style="width: 6%"> </td>
+              <td style="width: 6%"> </td>
+              <td style="width: 6%"> </td>
+              <td style="width: 3%"> </td>
+              <td style="width: 6%"> </td>
+              <td style="width: 7%"> </td>
+              <td style="width: 7%"> </td>
+              <td style="width: 8%"> </td>
+              <td style="width: 8%"> </td>
+              <td style="width: 8%"> </td>
+              <td> </td>
+              <td> </td>
             </tr>
             <tr
               align="center"
               style="height: 30px"
-              v-for="(item, index) in [{}, {}, {}, {}, {}, {}]"
+              v-for="(val, index) in item"
             >
-              <td> {{ item.productCode }} </td>
-              <td> {{ item.productName }} </td>
-              <td> {{ item.totalWeight }}</td>
-              <td> {{ item.totalCount }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
-              <td> {{ item.remark }}</td>
+              <td> {{ val.productCode }} </td>
+              <td> {{ val.productName }} </td>
+              <td> {{ val.specification }}</td>
+              <td>
+                {{
+                  val.provenance && val.provenance.length
+                    ? val.provenance
+                        .map((key) => getDictValue('产地', key))
+                        .join(',')
+                    : ''
+                }}</td
+              >
+              <td> {{ val.measuringUnit }}</td>
+              <td> {{ val.totalCount }}</td>
+              <td> {{ val.singlePrice }}</td>
+              <td> {{ val.totalPrice }}</td>
+              <td> {{ val.batchNo }}</td>
+              <td> </td>
+              <td> {{ val.guaranteePeriodDeadline }}</td>
+              <td> </td>
+              <td> {{ val.remark }}</td>
             </tr>
             <tr align="center" style="height: 30px">
               <td :colspan="5">
-                <div style="margin-left: 35px"></div>
+                <div style="margin-left: 35px">
+                  {{convertToChineseCurrency(getTotalValue('singlePrice', 2))  }}
+                </div>
               </td>
               <td :colspan="3">
                 <div style="margin-left: 65px"></div>
+                ¥{{ getTotalValue('singlePrice', 2) }}
               </td>
               <td :colspan="5">
                 <div style="margin-left: 65px"></div>
@@ -125,22 +135,22 @@
           "
         >
           <div style="flex: 1">
-            <div>开票员:</div>
+            <div>{{ formData.createUserName }}</div>
           </div>
           <div style="flex: 1">
-            <div>业务员:</div>
+            <div>{{ formData.saleOrderList[0]?.partbLinkName }}</div>
           </div>
           <div style="flex: 1">
-            <div>发货员:</div>
+            <div></div>
           </div>
           <div style="flex: 1">
-            <div>收货方:</div>
+            <div></div>
           </div>
           <div style="flex: 1">
-            <div>质量状况:</div>
+            <div></div>
           </div>
           <div style="flex: 1">
-            <div>提货方式:</div>
+            <div></div>
           </div>
         </div>
       </div>
@@ -154,66 +164,169 @@
 </template>
 
 <script>
-  import { getSendSaleOrderrecordDetailSplit } from '@/api/saleManage/saleordersendrecord';
-  import { getInfoBySourceBizNoAll } from '@/api/wms';
-  import { mapGetters } from 'vuex';
-  export default {
-    name: 'print',
-    computed: {
-      ...mapGetters(['user'])
+import { getSendSaleOrderrecordDetailSplit } from '@/api/saleManage/saleordersendrecord';
+import { getInfoBySourceBizNoAll } from '@/api/wms';
+import { mapGetters } from 'vuex';
+import dictMixins from '@/mixins/dictMixins';
+
+export default {
+  mixins: [dictMixins],
+
+  name: 'print',
+  computed: {
+    ...mapGetters(['user'])
+  },
+  props: {
+    groupName: ''
+  },
+  data() {
+    return {
+      checked: '',
+      page: [],
+      QRvisible: false,
+      isPrintPrice: false,
+      formData: {},
+      outBound: {}
+    };
+  },
+
+  methods: {
+    getTotalValue(key, num) {
+      let val = this.formData?.productList?.reduce((total, item) => {
+        return (total += Number(item[key]));
+      }, 0);
+
+      return (
+        (val &&
+          parseFloat(val)
+            .toFixed(num)
+            .replace(/\.?0+$/, '')) ||
+        0
+      );
     },
-    props: {
-      groupName: ''
+    async open(id) {
+      this.formData = await getSendSaleOrderrecordDetailSplit(id);
+      this.QRvisible = true;
+
+      this.page = this.chunkArray(this.formData.productList, 6);
+      console.log(this.page, 'this.page');
+      // let dataArray = await getInfoBySourceBizNoAll(this.formData.docNo);
+      // this.outBound = JSON.parse(JSON.stringify(dataArray[0]));
+      // this.outBound['outInDetailRecordRequestList'] = [];
+
+      // dataArray.forEach((item) => {
+      //   item.outInDetailList.forEach((val) => {
+      //     if (val.outInDetailRecordRequestList.length) {
+      //       val.outInDetailRecordRequestList.forEach((j) => {
+      //         j['categoryName'] = val.categoryName;
+      //         j['categoryModel'] = val.categoryModel;
+      //         j['specification'] = val.specification;
+      //         j['categoryCode'] = val.categoryCode;
+      //       });
+      //       this.outBound['outInDetailRecordRequestList'].push(
+      //         ...val.outInDetailRecordRequestList
+      //       );
+      //     } else {
+      //       this.outBound['outInDetailRecordRequestList'].push(val);
+      //     }
+      // });
+      // });
+      //包装维度
     },
-    data() {
-      return {
-        checked: '',
-        QRvisible: false,
-        isPrintPrice: false,
-        formData: {},
-        outBound: {}
-      };
+    chunkArray(array, size) {
+      const result = [];
+      for (let i = 0; i < array.length; i += size) {
+        result.push(array.slice(i, i + size));
+      }
+      return result;
+    },
+    close() {
+      this.QRvisible = false;
+      this.page = [];
     },
+    convertToChineseCurrency(amount) {
+      // 定义数字到汉字的映射
+      const chineseNums = [
+        '零',
+        '壹',
+        '贰',
+        '参',
+        '肆',
+        '伍',
+        '陆',
+        '柒',
+        '捌',
+        '玖'
+      ];
+      // 定义单位
+      const units = [
+        '分',
+        '角',
+        '元',
+        '拾',
+        '佰',
+        '佰',
+        '亿',
+        '万',
+        '仟',
+        '佰'
+      ];
 
-    methods: {
-      async open(id) {
-        this.formData = await getSendSaleOrderrecordDetailSplit(id);
-        this.QRvisible = true;
-        let dataArray = await getInfoBySourceBizNoAll(this.formData.docNo);
-        this.outBound = JSON.parse(JSON.stringify(dataArray[0]));
-        this.outBound['outInDetailRecordRequestList'] = [];
+      // 处理小数部分
+      let decimalPart = (amount * 100) % 100; // 获取分
+      let decimalStr = '';
+      if (decimalPart !== 0) {
+        decimalStr = chineseNums[decimalPart % 10] + units[0]; // 分
+        if (decimalPart >= 10) {
+          decimalStr =
+            chineseNums[Math.floor(decimalPart / 10)] + units[1] + decimalStr; // 角
+        }
+      }
+
+      // 处理整数部分
+      let integerPart = Math.floor(amount);
+      let integerStr = '';
+      if (integerPart === 0) {
+        integerStr = chineseNums[0]; // 特殊处理0元的情况
+      } else {
+        integerPart = integerPart
+          .toString()
+          .replace(/(0+)$/, '')
+          .replace(/9(?=0)/g, '玖'); // 处理9后面跟0的情况
+        integerStr = integerPart
+          .split('')
+          .reverse()
+          .map((num, index) => {
+            return chineseNums[parseInt(num)] + units[index + 2]; // 从元开始计数,跳过已经处理的分和角
+          })
+          .reverse()
+          .join('');
+      }
 
-        dataArray.forEach((item) => {
-          item.outInDetailList.forEach((val) => {
-            if (val.outInDetailRecordRequestList.length) {
-              val.outInDetailRecordRequestList.forEach((j) => {
-                j['categoryName'] = val.categoryName;
-                j['categoryModel'] = val.categoryModel;
-                j['specification'] = val.specification;
-                j['categoryCode'] = val.categoryCode;
-              });
-              this.outBound['outInDetailRecordRequestList'].push(
-                ...val.outInDetailRecordRequestList
-              );
-            } else {
-              this.outBound['outInDetailRecordRequestList'].push(val);
-            }
-          });
-        });
-        //包装维度
-      },
-      close() {
-        this.QRvisible = false;
-      },
+      // 清理多余的零和单位
+      integerStr = integerStr
+        .replace(/零([元|万|亿])/g, '$1')
+        .replace(/零+/g, '零')
+        .replace(/零([角|分])/g, '$1');
 
-      print() {
-        const printSection = document.getElementById('printSection');
-        // 创建打印任务
-        const printWindow = window.open('', '_blank');
-        printWindow.document.open();
-        printWindow.document.write('<html><head><title>打印预览</title>');
-        printWindow.document.write(`<style>
+      // 组合整数部分和小数部分
+      return integerStr + (decimalStr ? '整' : '') + decimalStr;
+    },
+    print() {
+      const printSection = document.getElementById('printSection');
+      // 创建打印任务
+      const printWindow = window.open('', '_blank');
+      printWindow.document.open();
+      printWindow.document.write('<html><head><title>打印预览</title>');
+      printWindow.document.write(`<style>
 @media print {
+  table{
+    border:none
+  }
+  .print {
+    page-break-before: always !important;
+    page-break-inside: avoid !important;
+  }
   @page {
     size: 30cm 11cm; /* 设置打印尺寸 */
     margin: 0; /* 去除页边距 */
@@ -233,27 +346,27 @@
   
   </style>`);
 
-        printWindow.document.write('</head><body>');
-        printWindow.document.write(printSection.innerHTML);
-        printWindow.document.write('</body></html>');
-        printWindow.document.close();
-        printWindow.onload = function () {
-          printWindow.print();
-        };
-      }
+      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>
-  @media print {
-    .print {
-      page-break-before: always !important;
-      page-break-inside: avoid !important;
-    }
-    @page {
-      size: 30cm 11cm;
-      margin: 0;
-    }
+@media print {
+  .print {
+    page-break-before: always !important;
+    page-break-inside: avoid !important;
+  }
+  @page {
+    size: 30cm 11cm;
+    margin: 0;
   }
+}
 </style>