wu
2024-08-16 5985a3693d4d902455b9fd46b052362417b044d7
UI-Project/src/views/UnLoadGlass/PrintFlow.vue
@@ -69,54 +69,56 @@
}
const printFlowCard = () => {
  // 需要打印的局部区域赋予"print-wrap"的id
  let el = document.getElementById("printFlowCard");
  let doc = document;
  let body = doc.body || doc.getElementsByTagName("body")[0];
  let printId = "print-" + Date.now();
// const printFlowCard = () => {
//   // 需要打印的局部区域赋予"print-wrap"的id
//   let el = document.getElementById("printFlowCard");
//   let doc = document;
//   let body = doc.body || doc.getElementsByTagName("body")[0];
//   let printId = "print-" + Date.now();
  // 创建无副作用的打印容器(因不确定页面的打印元素有无其它样式)
  let content = doc.createElement("div");
  content.id = printId;
//   // 创建无副作用的打印容器(因不确定页面的打印元素有无其它样式)
//   let content = doc.createElement("div");
//   content.id = printId;
  // 样式控制与打印无关的元素隐藏
  let style = doc.createElement("style");
  style.innerHTML =
      "body>#" +
      printId +
      "{display:none}@media print{" +
      "@page {" +
      "    size: auto; " +
      "    margin: 5mm 5mm 5mm 5mm; " +
      "  }body>:not(#" +
      printId +
      "){display:none !important}body>#" +
      printId +
      "{display:block;padding-top:1px}}";
  //
  content.innerHTML = el.outerHTML;
  // // console.log("el.outerHTML", el.outerHTML);
  body.appendChild(style);
//   // 样式控制与打印无关的元素隐藏
//   let style = doc.createElement("style");
//   style.innerHTML =
//       "body>#" +
//       printId +
//       "{display:none}@media print{" +
//       "@page {" +
//       "    size: auto; " +
//       "    margin: 5mm 5mm 5mm 5mm; " +
//       "  }body>:not(#" +
//       printId +
//       "){display:none !important}body>#" +
//       printId +
//       "{display:block;padding-top:1px}}";
//   //
//   content.innerHTML = el.outerHTML;
//   // // console.log("el.outerHTML", el.outerHTML);
//   body.appendChild(style);
  // 与style元素设置的样式相配合
  // 把打印内容的元素添加到body(作为body的子元素,可用body的子选择器 '>' 控制打印样式)
  body.appendChild(content);
  setTimeout(() => {
    window.print();
    body.removeChild(content);
    body.removeChild(style);
  }, 20);
}
//   // 与style元素设置的样式相配合
//   // 把打印内容的元素添加到body(作为body的子元素,可用body的子选择器 '>' 控制打印样式)
//   body.appendChild(content);
//   setTimeout(() => {
//     window.print();
//     body.removeChild(content);
//     body.removeChild(style);
//   }, 20);
// }
onMounted(async () => {
  console.log(props.printFlowCardId,props.printLayer)
  try {
    const response = await request.post('/unLoadGlass/downGlassInfo/downGlassPrint',{
        flowCardId:props.printFlowCardId,
        layer:props.printLayer
    });
    if (response.code == 200) {
      // 绑定成功,处理逻辑
      produceList.value = response.data;
      ElMessage.success(response.message);
@@ -209,11 +211,11 @@
      </tr>
      <tr>
        <td rowspan='2'>序号</td>
        <td rowspan='2'>编号</td>
        <td v-if="like!=null" rowspan="2">小片顺序</td>
        <td v-else style="display: none;" rowspan="2">小片顺序</td>
        <td rowspan='2'>宽*高</td>
        <td rowspan='2'>数量</td>
        <td rowspan='2'>落架数</td>
        <td rowspan='2'>面积</td>
        <td rowspan='2'>周长</td>
        <td rowspan='2'>半径</td>
@@ -244,7 +246,7 @@
      <tr v-for="(itemDatile,index) in item.detailList" :key="index">
        <td>{{ itemDatile.order_number }}</td>
        <!-- <td>{{ itemDatile.s01Value }}</td> -->
        <td>{{ itemDatile.s01Value }}</td>
        <td v-if="like=='1'">{{ itemDatile.technology_number }}</td>
        <td v-else style="display: none"></td>
        <td>{{ itemDatile.child_width }}</td>
@@ -252,10 +254,9 @@
          <!-- <el-input v-model="itemDatile.quantity" style="border: none" @keyup="handleSummary()"></el-input> -->
          {{ itemDatile.quantity }}
        </td>
        <td class="item" style="width: 5%;height: 100%;">
          <!-- <el-input v-model="itemDatile.quantity" style="border: none" @keyup="handleSummary()"></el-input> -->
        <!-- <td class="item" style="width: 5%;height: 100%;">
          {{ itemDatile.quantity1 }}
        </td>
        </td> -->
        <td>{{ itemDatile.total_area }}</td>
        <td>{{ itemDatile.perimeter }}</td>
        <td>{{ itemDatile.bend_radius }}</td>
@@ -415,7 +416,7 @@
@page {
  size: auto;  /* auto is the initial value */
  margin: 2mm 2mm 0mm 1mm  /* this affects the margin in the printer settings */
  margin: 10mm 2mm 10mm 1mm;  /* this affects the margin in the printer settings */
}