lkk
2024-12-11 2b70897ed6fae223f1808f1895d636bc9375894f
dayin
1个文件已修改
130 ■■■■ 已修改文件
src/views/sampling/sampling/index.vue 130 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/sampling/sampling/index.vue
@@ -123,12 +123,10 @@
        style="margin: 10px 15px"
        v-show="samplingList.length > 0 && tjStatus == 0"
      >
        <el-button
          type="primary"
          :disabled="!selectList.length"
          @click="Collection"
        <el-button type="primary" :disabled="!selectList.length" @click="buda"
          >补打条码</el-button
        >
        <!-- @click="Collection" -->
        <el-button type="primary" :disabled="!disabled" @click="Cancellation"
          >撤销合并</el-button
        >
@@ -380,6 +378,8 @@
    return {
      msg: "",
      getNumbr: null,
      valueUrl: "ws://127.0.0.1:6789/websocket",
      webSocket: null,
      list: [],
      selectList: [],
      selectedRows: [],
@@ -821,17 +821,12 @@
    /** 点击补打条码按钮 **/
    async Collection() {
      // console.log("selectList:", this.selectList);
      const jyxh = this.selectList.map((item) => item.jyxh);
      console.log("jyxh:", jyxh);
      try {
        // 请求接口并获取宽度值
        const widthResponse = await getTxmkd();
        const barcodeWidth = `${Number(widthResponse.msg)}%` || "70%"; // 获取宽度值,默认使用 70%
        // const jyxh = this.selectList.map((item) => item.jyxh);
        // await this.$nextTick(); // 确保 DOM 更新
        jyxh.forEach((number, index) => {
          const barcodeContent = number; // 确保 jyxh 是有效的
@@ -842,7 +837,6 @@
              height: 50,
              displayValue: false,
            });
          } else {
            console.log(`条形码内容无效: ${barcodeContent}`); // 调试输出
          }
@@ -867,7 +861,7 @@
        const newWindow = window.open("", "_blank", "width=800,height=600");
        const printContents = document.getElementById("printSection").innerHTML;
        // console.log(printContents);
        console.log(printContents);
        newWindow.document.write(`
      <html>
        <head>
@@ -969,28 +963,67 @@
      // console.log(selection);
      this.selectList = selection;
      // console.log(this.selectList, 5555);
      console.log(this.selectList, 9977);
      var array = selection;
      this.ids = array.map((item) => item.id);
    },
    // 禁选
    // selectEnable(row, rowIndex) {
    //     if(row.isSignFor === "0"){
    //         return false
    //     }else{
    //         return true
    //     }
    // },
    // 确定按钮
    submitForm() {},
    buda() {
      var websocket = null;
      var url = this.valueUrl;
      if ("WebSocket" in window) {
        websocket = new WebSocket(url);
      } else if ("MozWebSocket" in window) {
        websocket = new MozWebSocket(url);
      }
      if (websocket == null) {
        alert("创建WebSocket对象失败");
      }
      websocket.onerror = function () {
        alert("请检查读卡器连接是否正常");
      };
      websocket.onopen = () => {
        this.websocket = websocket;
        var list = this.selectList;
        var data = list.map((item) => ({
          jyxh: item.jyxh,
          proName: item.proName,
          cusName: item.cusName,
          cusSex: item.customer.cusSex,
          age: item.customer.age,
          cardId: item.cardId,
          tjTime: item.createTime,
        }));
        // 连接设备
        var jsonObj = {
          type: "3",
          array: {
            data: data,
          },
        };
        var jStr = JSON.stringify(jsonObj);
        this.websocket.send(jStr);
        var jsonObj = {};
        this.dialogVisible = false;
      };
      // websocket.onmessage = (event) => {
      //   var resultObj = eval("(" + event.data + ")");
      //   console.log(resultObj, 9988);
      // };
      this.getList();
    },
    // 确认采样
    Confirmreceipt() {
      // let data = this.ids;
      console.log(this.ids, 999);
      console.log(this.selectList, 999);
      console.log(1111);
      const loadingInstance = this.$loading({
        lock: true, // 锁定屏幕
@@ -1000,10 +1033,55 @@
      });
      confirmSampling(this.ids)
        .then((res) => {
          if (res.code === 200) {
            // this.$modal.msgSuccess("采样成功");
          console.log(this.selectList, 2222);
            this.Collection();
          if (res.code === 200) {
            // var websocket = null;
            this.buda();
            /* var url = this.valueUrl;
            if ("WebSocket" in window) {
              websocket = new WebSocket(url);
            } else if ("MozWebSocket" in window) {
              websocket = new MozWebSocket(url);
            }
            if (websocket == null) {
              alert("创建WebSocket对象失败");
            }
            websocket.onerror = function () {
              alert("请检查读卡器连接是否正常");
            };
            websocket.onopen = () => {
              this.websocket = websocket;
              var list = this.selectList;
              var data = list.map((item) => ({
                jyxh: item.jyxh,
                proName: item.proName,
                cusName: item.cusName,
                cusSex: item.customer.cusSex,
                age: item.customer.age,
                cardId: item.cardId,
                tjTime: item.createTime,
              }));
              // 连接设备
              var jsonObj = {
                type: "3",
                array: {
                  data: data,
                },
              };
              var jStr = JSON.stringify(jsonObj);
              this.websocket.send(jStr);
              var jsonObj = {};
              this.dialogVisible = false;
            };
            websocket.onmessage = (event) => {
              var resultObj = eval("(" + event.data + ")");
              console.log(resultObj, 9988);
            };
 */
            // this.Collection();
            this.getList();
          } else {
            this.$message.error(res.msg);