yuan
13 小时以前 2f068c5676bc618c5a49d4e6b468b95c5455abb0
修改二维码样式
已修改2个文件
114 ■■■■■ 文件已修改
common/http.api.js 4 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/wareHouse/nuclearScale/nuclearscalerecord.vue 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/http.api.js
@@ -575,6 +575,10 @@
            queryPacking: (params = {}) => vm.$u.get('/mes/weighingVerification/queryPacking', params),
            // 核磅扫码查询客户名称
            queryCustomName: (params = {}) => vm.$u.get('/mes/weighingVerification/queryCustomName', params),
            // 发货通知单分页查询(按发货通知单号)
            queryDeliveryNotice: (params = {}) => vm.$u.get('/mes/deliveryNotice/page', params),
            // 发货通知单详情(含订单行明细,取订单行需求数量 buyQtyDue)
            getDeliveryNoticeById: (params = {}) => vm.$u.get('/mes/deliveryNotice/getDeliveryNoticeById', params),
        },
        // 取消领料
        cancelMaterialRequisition: {
pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -235,6 +235,8 @@
      errorMessage: "", // 错误信息
      verificationNo: "",
      failedPrintJobs: [],
      demandQtyMap: {}, // 订单行需求数量缓存:发货通知单号|订单号|行号 -> buyQtyDue
      loadedNoticeNos: [], // 已加载过明细的发货通知单号
    };
  },
  computed: {
@@ -347,6 +349,52 @@
    },
    checkBluetoothConnection() {
      return bluetooth.isConnected();
    },
    // 拉取发货通知单明细,缓存每个订单行的需求数量(buyQtyDue)
    async loadNoticeLineDemandQty(shippingNoticeNo) {
      if (
        !shippingNoticeNo ||
        this.loadedNoticeNos.indexOf(shippingNoticeNo) > -1
      ) {
        return;
      }
      const noticeRes = await this.$u.api.NuclearScaleEntry.queryDeliveryNotice({
        noticeNo: shippingNoticeNo,
        current: 1,
        size: 10,
      });
      const notices = (noticeRes && noticeRes.data && noticeRes.data.records) || [];
      const notice =
        notices.find((item) => item.noticeNo === shippingNoticeNo) || notices[0];
      if (!notice) {
        throw new Error(`未找到发货通知单:${shippingNoticeNo}`);
      }
      const detailRes = await this.$u.api.NuclearScaleEntry.getDeliveryNoticeById({
        id: notice.id,
      });
      const lines =
        (detailRes && detailRes.data && detailRes.data.deliveryNoticeLineList) ||
        [];
      lines.forEach((line) => {
        const key = `${shippingNoticeNo}|${line.orderNo}|${line.lineNo}`;
        this.$set(this.demandQtyMap, key, Number(line.buyQtyDue) || 0);
      });
      this.loadedNoticeNos.push(shippingNoticeNo);
    },
    // 取当前明细对应订单行的需求数量(取不到直接报错,避免打出错误的标签)
    async getOrderLineDemandQty(item) {
      const key = `${item.shippingNoticeNo}|${item.salesOrderNo}|${item.lineNo}`;
      if (this.demandQtyMap[key] === undefined) {
        await this.loadNoticeLineDemandQty(item.shippingNoticeNo);
      }
      if (this.demandQtyMap[key] === undefined) {
        throw new Error(
          `未取到订单行需求数量(订单${item.salesOrderNo} 行${item.lineNo})`
        );
      }
      return this.demandQtyMap[key];
    },
    //     // 直接使用已记录的连接状态,避免不必要的连接检查
@@ -477,12 +525,18 @@
          const ht = item.contractNo;
          const fh = item.newNetWeight;
          const scph = item.batchNo;
          // UQ:订单行需求数量(发货通知单明细 buyQtyDue)
          const uq = await this.getOrderLineDemandQty(item);
          // ===== 标签纸排版参数(单位:mm):40*70 标签纸 =====
          const LABEL_W = 40; // 标签宽度
          const LABEL_H = 70; // 标签长度(走纸方向)
          const MARGIN = 1; // 四周留白,防止打印截断
          const QR_SIZE = LABEL_W - MARGIN * 2; // 二维码铺满 40mm 宽(38mm)
          const QR_MARGIN = 0; // 二维码与纸边留白(0 = 二维码 40mm,铺满纸宽)
          const QR_SIZE = LABEL_W - QR_MARGIN * 2; // 二维码尺寸(40mm)
          const PAGE_MARGIN = 1; // 标题/文字的上、下留白
          const TEXT_PADDING = 1; // 文字的左右留白
          const TITLE_HEIGHT = 6; // 标题行高
          const TITLE_FONT_SIZE = 3; // 标题字号
          const TEXT_FONT_SIZE = 3; // 字段字号
          // 初始化画板:宽 40、长 70,不做旋转(x 为纸宽方向,y 为走纸方向)
@@ -492,21 +546,41 @@
            rotate: 0,
          });
          // 绘制二维码
          // 标题:中天科技装箱清单(居中、加粗)
          this.getDrawLabelText(
            TEXT_PADDING,
            PAGE_MARGIN,
            LABEL_W - TEXT_PADDING * 2,
            TITLE_HEIGHT,
            "中天科技装箱清单",
            TITLE_FONT_SIZE,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            1,
            1,
            1
          );
          // 绘制二维码(字段与顺序按标签规范)
          const qrContent = {
            company: item.customerNo,
            line_no: item.lineNo,
            lot_batch_no: item.batchNo,
            order_no: item.contractNo,
            part_no: item.partNo,
            total_qty: item.newNetWeight,
            qty_arrived: item.newNetWeight,
            release_no: item.relNo,
            order_no: ht, // 订单号
            part_no: item.partNo, // 零件号
            line_no: item.lineNo, // 行号
            UQ: uq, // 订单行需求数量
            lot_batch_no: scph, // 生产批号
            company: item.customerNo, // 客户编号
            qty_arrived: Number(item.newNetWeight) || 0, // 发货/装箱数
            release_no: item.relNo, // 交货号
          };
          // 二维码紧跟在标题下方
          const qrTop = PAGE_MARGIN + TITLE_HEIGHT;
          jcapi.drawLabelQrCode({
            x: MARGIN,
            y: MARGIN,
            x: QR_MARGIN,
            y: qrTop,
            width: QR_SIZE,
            height: QR_SIZE,
            value: qrContent,
@@ -514,9 +588,9 @@
            codeType: QrCodeType.QrCode,
          });
          // 全部框线已去掉;二维码下方剩余空间横向展示三个字段
          const textTop = MARGIN + QR_SIZE + MARGIN;
          const lineHeight = (LABEL_H - MARGIN - textTop) / 3;
          // 全部框线已去掉;二维码下方剩余空间展示三个字段(行距收紧)
          const textTop = qrTop + QR_SIZE;
          const lineHeight = (LABEL_H - PAGE_MARGIN - textTop) / 3;
          const fields = [
            { label: "合同号", value: ht },
            { label: "发货/装箱数", value: fh },
@@ -529,9 +603,9 @@
                ? ""
                : String(field.value);
            this.getDrawLabelText(
              MARGIN,
              TEXT_PADDING,
              textTop + index * lineHeight,
              LABEL_W - MARGIN * 2,
              LABEL_W - TEXT_PADDING * 2,
              lineHeight,
              `${field.label}: ${value}`,
              TEXT_FONT_SIZE,