wangfei
2024-08-28 56fab901b298857ff4985b7429ef843c9a9d1471
UI-Project/src/views/UnLoadGlass/loadmachinerack.vue
@@ -9,6 +9,7 @@
import PrintFlow from "@/views/UnLoadGlass/PrintFlow.vue";
import Landingindication from "./Landingindication.vue";
import Landingindicationtwo from "./Landingindicationtwo.vue";
import PrintLabel from "@/views/UnLoadGlass/PrintCustomLabelSemi1.vue";
const router = useRouter()
const {t} = useI18n()
@@ -36,10 +37,12 @@
const selectValuesa = reactive({});
const selectOptionsa = ref([]);
const dialogTableVisible = ref(false)
const dialogTableVisible1 = ref(false)
const printFlowCardId = ref('')
const printLayer = ref('')
const now = new Date();
const timeRange = ref([])
const browser=ref(false)
const handleChange = async () => {
  console.log("触发开关")
@@ -62,7 +65,15 @@
    console.error(error);
  }
}
const confirmBrowser = () =>{
  if (/chrome|chromium/i.test(navigator.userAgent) && !/edg/i.test(navigator.userAgent)) {
    browser.value=true
} else if (/edg/i.test(navigator.userAgent)) {
  browser.value=false
} else {
  browser.value=false
}
}
const handleInputChangea = (value, rowId) => {
  // 更新对应行的 select 值
@@ -199,8 +210,8 @@
    autoPrint.value = data.autoPrint[0];
  }
  if (fullFlowCard.value == ""&&autoPrint.value==true) {
  //自动打印
  if (fullFlowCard.value == ""&&autoPrint.value==true&&browser.value==true) {
    for (let i = 0; i < tableData.length; i++) {
      if (tableData[i].totalQuantity != 0) {
        if (tableData[i].totalQuantity == tableData[i].racksNumber + tableData[i].otherNumber && fullFlowCard.value != tableData[i].flowCardId) {
@@ -222,6 +233,7 @@
};
// 初始化 WebSocket,并传递消息处理函数
onMounted(() => {
  confirmBrowser();//获取浏览器
  fetchFlowCardId();
  fetchTableData(); // 获取数据
  socket = initializeWebSocket(socketUrl, handleMessage);
@@ -292,11 +304,19 @@
  printLayer.value = row.layer
  dialogTableVisible.value = true;
  setTimeout(() => {
    printFlowCard(); // 替换成你要执行的函数名
    //dialogTableVisible.value = false;
  }, 1000);
    printFlowCard();
    dialogTableVisible.value = false;
  }, 2000);
}
const open1 = async (row) => {
printFlowCardId.value = row.flowCardId;
printLayer.value = row.layer
dialogTableVisible1.value = true;
setTimeout(() => {
  printFlowCard1();
  //dialogTableVisible1.value = false;
}, 1000);
}
const printFlowCard = () => {
@@ -309,6 +329,8 @@
  // 创建无副作用的打印容器(因不确定页面的打印元素有无其它样式)
  let content = doc.createElement("div");
  content.id = printId;
  // alert(/Chrome/.test(userAgent) && !/Edge/.test(userAgent));
  // 样式控制与打印无关的元素隐藏
  let style = doc.createElement("style");
@@ -342,6 +364,46 @@
  }, 20);
}
const printFlowCard1 = () => {
  // 需要打印的局部区域赋予"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 style = doc.createElement("style");
  style.innerHTML =
      "body>#" +
      printId +
      "{display:none}@media print{" +
      "@page {" +
      "    size: auto; " +
      "    margin: 2mm 2mm 2mm 2mm;  " +
      "  }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);
}
@@ -352,15 +414,15 @@
</script>
<template>
  <div>
    <el-button style="margin-top: 5px;margin-left: 10px;" id="searchButton" type="primary"
    <el-button style="margin-top: 10px;margin-left: 10px;margin-bottom: 10px;" id="searchButton" type="primary"
               @click="dialogFormVisibleaDownGlass = true">落架详情
    </el-button>
    <el-switch style="margin-top: 5px;margin-left: 10px;" v-model="autoPrint" class="mb-2" :inactive-text="$t('自动打印')"
    <el-switch style="margin-top: 10px;margin-left: 15px;margin-bottom: 10px;" v-model="autoPrint" class="mb-2" :inactive-text="$t('自动打印')"
               @change="handleChange"/>
    <el-card style="flex: 1;" v-loading="loading">
      <el-card style="flex: 1;margin-left: 4px;margin-top: 1px;" v-loading="loading">
        <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
          <el-table height="200px" ref="table" @selection-change="handleSelectionChange" :data="tableData"
          <el-table height="350px" ref="table" @selection-change="handleSelectionChange" :data="tableData"
                    :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
            <el-table-column prop="workstationId" align="center" :label="$t('reportWork.lowerbit')" min-width="80"/>
            <el-table-column prop="workstationId" align="center" :label="$t('reportWork.shelfnumber')"
@@ -380,14 +442,15 @@
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="200">
            <el-table-column fixed="right" :label="$t('reportWork.operate')" align="center" width="400">
              <template #default="scope">
                <el-button size="mini" type="text" plain v-show="scope.row.enableState !== '已启用'"
                           @click="handleBindRack(scope.row)">{{ $t('reportWork.bindingshelves') }}
                </el-button>
                <el-button size="mini" type="text" plain @click="handleBindRack2(scope.row)">{{ $t('reportWork.clear')
                  }}</el-button>
                <el-button @click="open(scope.row)" :disabled="scope.row.flowCardId == null">打印</el-button>
                <el-button @click="open(scope.row)" :disabled="scope.row.flowCardId == null">打印流程卡</el-button>
                <el-button @click="open1(scope.row)" :disabled="scope.row.flowCardId == null">打印标签</el-button>
              </template>
            </el-table-column>
@@ -497,6 +560,10 @@
    <print-flow id="child" :printFlowCardId="printFlowCardId" :printLayer="printLayer"
                style="width: 100%;height: 100%"/>
  </el-dialog>
  <el-dialog id="sizePrintCalrd1" v-model="dialogTableVisible1" destroy-on-close >
    <print-label id="printFlowCard" :printFlowCardId="printFlowCardId" :printLayer="printLayer"
                style=""/>
  </el-dialog>
</template>
<style scoped>