廖井涛
2025-11-24 ff1be3b4ed56b84848ad34ea2383788c220bff64
north-glass-erp/northglass-erp/src/components/sd/delivery/PrintSheet2.vue
@@ -13,7 +13,7 @@
let otherMoneys = 0
let takeCare = "注意:请妥善保管好我司的玻璃架,如有丢失或损坏,按1500元只赔偿。谢谢配合!"
let remark = company.deliveryRemark
const printStyle = ref(null);
let produceList2 = ref([])
let props = defineProps({
@@ -52,59 +52,8 @@
}
onMounted(() => {
  clearPrintStyles()
  addPrintStyles()
  getData()
})
const clearPrintStyles = () => {
  // 2. 清除所有样式表中包含@media print的规则(适用于全局样式)
  Array.from(document.styleSheets).forEach(styleSheet => {
    try {
      // 遍历样式规则
      const rules = styleSheet.cssRules || styleSheet.rules;
      if (!rules) return;
      // 从后往前删除,避免索引错乱
      for (let i = rules.length - 1; i >= 0; i--) {
        const rule = rules[i];
        // 检查是否为打印媒体查询规则
        if (rule.media && rule.media.mediaText.includes('print')) {
          styleSheet.deleteRule(i);
        }
      }
    } catch (e) {
      // 跨域样式表可能无法访问,忽略错误
      console.log('无法清理跨域样式表:', e);
    }
  });
};
const addPrintStyles = () => {
  printStyle.value = document.createElement('style');
  printStyle.value.id = 'dynamic-print-style';
  printStyle.value.textContent = `
    @media print {
  @page {
    margin: 12mm 10mm 20mm 10mm !important;
  }
  .pages {
    page-break-after: always;
  }
  @page {
    @top-right {
      margin-top: 50px;
      content: "第 " counter(page)  " 页"; /* 使用counter添加页码 */
    }
  }
}
  `;
  document.head.appendChild(printStyle.value);
};
const  stringToJson = (productList) => {
  productList.forEach(item => {
@@ -172,7 +121,9 @@
      </tr>
      <tr>
        <th style="text-align: left;border:none;" colspan="4">客户名称:<span>{{itme1.delivery.customerName}}</span></th>
        <th style="text-align: left;border:none;" colspan="3">项目名称:<span>{{itme1.delivery.project}}</span></th>
        <th style="text-align: left;border:none;" v-if="itme1.data[0].DeliveryDetail.order.batch!==''" colspan="3">
          项目名称:<span>{{itme1.delivery.project}}({{itme1.data[0].DeliveryDetail.order.batch}})</span></th>
        <th style="text-align: left;border:none;" v-else colspan="3">项目名称:<span>{{itme1.delivery.project}}</span></th>
        <th style="text-align: left;border:none;" colspan="2">联系人:<span>{{itme1.delivery.contacts}}</span></th>
      </tr>
      <tr>
@@ -189,7 +140,8 @@
              <thead>
              <tr v-if="index===0">
                <th style="width: 6%;">序号</th>
                <th style="width: 20%;">楼层编号(箱号)</th>
                <th style="width: 10%;">楼层编号</th>
                <th style="width: 10%;">箱号</th>
                <th style="width: 20%;" colspan="2">宽X高</th>
                <th style="width: 10%;">数量</th>
                <th style="width: 10%;">面积</th>
@@ -199,30 +151,33 @@
              </thead>
              <tr>
                <td style="font-size: 15px;text-align: left" colspan="4">产品名称:<span>{{item.DeliveryDetail.orderDetail.productName}}</span></td>
                <td style="font-size: 15px;text-align: left" colspan="2">订货日期:<span>{{item.DeliveryDetail.order.contractId}}</span></td>
                <td style="font-size: 15px;text-align: left" colspan="5">产品名称:<span>{{item.DeliveryDetail.orderDetail.productName}}</span></td>
                <td v-if="company.showDeliveryCreator" style="font-size: 15px;text-align: left" colspan="2">订货日期:<span>{{item.DeliveryDetail.order.contractId}}</span></td>
                <td style="font-size: 15px;text-align: left" colspan="3">订单编号:<span>{{item.DeliveryDetail.orderDetail.orderId}}</span></td>
              </tr>
              <tr class="day-in" v-for="(items, index1) in item.DeliveryDetailList" :key="index1">
                <td>{{items.order_number}}</td>
                <td v-if="items.box_no!=null&&items.box_no!=''">{{items.buildingNumber}}({{items.box_no}})</td>
                <td v-else>{{items.buildingNumber}}</td>
                <td colspan="2" style="font-size: 15px;font-weight: bold;" v-if="items.other_columns!=null&&(JSON.parse(items.other_columns).S02!=null)">{{JSON.parse(items.other_columns).S02}}</td>
                <td colspan="2" style="font-size: 15px;font-weight: bold;" v-else>{{items.width}}x{{items.height}}</td>
                <td >{{items.buildingNumber}}</td>
                <td >{{items.box_no}}</td>
<!--                <td colspan="2" style="font-size: 15px;font-weight: bold;" v-if="items.other_columns!=null&&(JSON.parse(items.other_columns).S02!=null && company.companyName==='金华福喜天成玻璃有限公司')">{{JSON.parse(items.other_columns).S02}}</td>-->
                <td colspan="2" style="font-size: 15px;font-weight: bold;" >
                  {{items.other_columns!=null&&(JSON.parse(items.other_columns).S02!=null )?"("+JSON.parse(items.other_columns).S02+")":''}}
                  {{items.width}}x{{items.height}}
                </td>
                <td>{{items.quantity}}</td>
                <td>{{items.area}}</td>
                <td colspan="3">{{items.processingNote}}</td>
              </tr>
              <tr class="day-in" >
                <td style="font-size: 15px;" colspan="4">小计:</td>
                <td style="font-size: 15px;" colspan="5">小计:</td>
                <td>{{item.DeliveryDetail.quantity}}</td>
                <td>{{item.DeliveryDetail.area}}</td>
              </tr>
            </template>
            <tr class="day-in">
              <td style="font-size: 15px;" colspan="4">合计:</td>
              <td style="font-size: 15px;" colspan="5">合计:</td>
              <td>{{itme1.delivery.quantity}}</td>
              <td>{{itme1.delivery.area}}</td>
            </tr>
@@ -305,7 +260,20 @@
<style scoped>
@media print {
  @page {
    margin: 12mm 10mm 20mm 10mm !important;
  }
  .pages {
    page-break-after: always;
  }
  @page {
    @top-right {
      margin-top: 50px;
      content: "第 " counter(page)  " 页"; /* 使用counter添加页码 */
    }
  }
}
h1,h3{
  left:0;
  right:0;