yyb
5 小时以前 fc1a5059e586ab6d41fc3ec3bfacb727accc4765
核磅录入打印装箱单
已添加1个文件
已修改1个文件
2349 ■■■■ 文件已修改
common/bluetoothPrinter.js 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/wareHouse/nuclearScale/nuclearscalerecord.vue 2247 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/bluetoothPrinter.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,102 @@
const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
let state = {
  connectedDevice: null,
  connectionStatus: "disconnected", // disconnected | connecting | connected
  listeners: [],
};
/** é€šçŸ¥æ‰€æœ‰è®¢é˜…页面 */
function notify() {
  state.listeners.forEach(fn => fn({
    connectedDevice: state.connectedDevice,
    connectionStatus: state.connectionStatus,
  }));
}
/** é¡µé¢è®¢é˜…蓝牙状态 */
function onChange(fn) {
  state.listeners.push(fn);
  fn({
    connectedDevice: state.connectedDevice,
    connectionStatus: state.connectionStatus,
  });
}
/** åˆå§‹åŒ–(全局只需一次) */
function init() {
  jcapi.initSDK();
  const saved = uni.getStorageSync("bluetoothConnection");
  if (saved) {
    state.connectedDevice = saved;
    state.connectionStatus = "connected";
  }
  // æ–­å¼€ç›‘听
  jcapi.didReadPrintErrorInfo((r) => {
    if (r.code === 23) {
      state.connectedDevice = null;
      state.connectionStatus = "disconnected";
      uni.removeStorageSync("bluetoothConnection");
      notify();
    }
  });
}
/** æœç´¢è®¾å¤‡ */
function searchDevices() {
  return new Promise((resolve, reject) => {
    uni.openBluetoothAdapter({
      success() {
        jcapi.getBluetoothDevices(list => {
          resolve(list || []);
        });
      },
      fail: reject
    });
  });
}
/** è¿žæŽ¥è®¾å¤‡ */
function connect(device) {
  return new Promise((resolve, reject) => {
    state.connectionStatus = "connecting";
    notify();
    jcapi.openPrinterByDevice({
      address: device.address,
      name: device.name,
      deviceType: 0,
    }, (r) => {
      if (r.code === 0) {
        state.connectedDevice = device;
        state.connectionStatus = "connected";
        uni.setStorageSync("bluetoothConnection", device);
        notify();
        resolve(device);
      } else {
        state.connectionStatus = "disconnected";
        notify();
        reject(r);
      }
    });
  });
}
function isConnected() {
  return state.connectionStatus === "connected";
}
function getCurrentDevice() {
  return state.connectedDevice;
}
export default {
  init,
  onChange,
  searchDevices,
  connect,
  isConnected,
  getCurrentDevice,
};
pages/wareHouse/nuclearScale/nuclearscalerecord.vue
@@ -1,1219 +1,1174 @@
<template>
    <view class="page">
        <view class="finishProductIn-locno-bg" />
        <u-navbar title="核磅记录" :background="background" :border-bottom="false" :title-bold="true" title-color="#000"
            back-icon-color="#000">
            <view class="navbar-right" slot="right" @click="goPrintAll">
                å…¨éƒ¨æ‰“印
            </view>
        </u-navbar>
        <view class="wrap">
            <!-- è¿žæŽ¥å’Œæ‰“印状态指示器 -->
            <view class="status-indicator" :class="{
  <view class="page">
    <view class="finishProductIn-locno-bg" />
    <u-navbar
      title=""
      :background="background"
      :border-bottom="false"
      :title-bold="true"
      title-color="#000"
      back-icon-color="#000"
    >
      <view class="navbar-right" slot="right">
        <text class="bluetooth-btn" @click="searchDevice">
          {{ connectedDevice ? `已连接:${connectedDevice.name}` : "连接蓝牙" }}
        </text>
        <text class="print-all-btn" @click="goPrintAll">全部打印</text>
      </view>
    </u-navbar>
    <view class="wrap">
      <!-- è¿žæŽ¥å’Œæ‰“印状态指示器 -->
      <view
        class="status-indicator"
        :class="{
          connected: connectionStatus === 'connected',
          connecting: connectionStatus === 'connecting',
          disconnected: connectionStatus === 'disconnected',
        }">
                <text class="status-text">{{ getConnectionStatusText() }}</text>
                <text class="print-status" v-if="printStatus !== 'idle'">- {{ getPrintStatusText() }}</text>
            </view>
            <scroll-view class="finishProductIn-locno-scroll-list" scroll-y="true" @scrolltolower="getmoreList()">
                <u-cell-group class="finishProductIn-locno-scroll-list-group" :border="false">
                    <view class="content" v-for="(item, index) in list" :key="item.locNo" :index="index"
                        @click="selectNo(item)">
                        <view class="content-header">
                            <view class="content-header-title">{{ list.length - index }}</view>
                        </view>
                        <view class="content-body">
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-1"> </view>
                                    <view class="_label-name">批次号:</view>
                                </view>
                                <view class="_content">
                                    {{ item.batchNo }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-2"> </view>
                                    <view class="_label-name">产品描述:</view>
                                </view>
                                <view class="_content">
                                    {{ item.partDescription }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-3"> </view>
                                    <view class="_label-name">零件号:</view>
                                </view>
                                <view class="_content">
                                    {{ item.partNo }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-1"> </view>
                                    <view class="_label-name">毛重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.newGrossWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-2"> </view>
                                    <view class="_label-name">盘重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.newWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-3"> </view>
                                    <view class="_label-name">净重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.newNetWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-1"> </view>
                                    <view class="_label-name">核磅重量:</view>
                                </view>
                                <view class="_content">
                                    {{ item.verificationWeight }}
                                </view>
                            </view>
                            <view class="row-list">
                                <view class="_label">
                                    <view class="_label-icon-2"> </view>
                                    <view class="_label-name">叉车盘重:</view>
                                </view>
                                <view class="_content">
                                    {{ item.forkliftWeight }}
                                </view>
                            </view>
                        </view>
                    </view>
                </u-cell-group>
                <view class="loadmore" @click="getmoreList()">
                    <u-loadmore :status="status" :load-text="loadText" @loadmore="getmoreList()" />
                </view>
            </scroll-view>
        </view>
        <u-toast ref="uToast" />
        <u-modal v-model="maskShow" title="" :show-confirm-button="false">
            <view @touchmove.stop.prevent="moveHandle" @click="maskclose">
                <scroll-view class="uni-scroll_box" scroll-y @touchmove.stop.prevent="moveHandle"
                    @click.stop="moveHandle">
                    <view class="modal-title">选择蓝牙设备</view>
                    <view v-if="listDevice.length === 0" class="empty-tip">暂无设备</view>
                    <view v-for="(item, index) in listDevice" :key="index" @click="tapQuery(item)" class="device-item">
                        <view class="device-name">
                            <text>名称:</text>
                            <text>{{ item.name || "未知设备" }}</text>
                        </view>
                        <view class="device-uuid">
                            <text>UUID:</text>
                            <text>{{ item.address || "无地址" }}</text>
                        </view>
                    </view>
                </scroll-view>
            </view>
        </u-modal>
    </view>
        }"
      >
        <text class="status-text">{{ getConnectionStatusText() }}</text>
        <text class="print-status" v-if="printStatus !== 'idle'"
          >- {{ getPrintStatusText() }}</text
        >
      </view>
      <scroll-view
        class="finishProductIn-locno-scroll-list"
        scroll-y="true"
        @scrolltolower="getmoreList()"
      >
        <u-cell-group
          class="finishProductIn-locno-scroll-list-group"
          :border="false"
        >
          <view
            class="content"
            v-for="(item, index) in list"
            :key="item.locNo"
            :index="index"
            @click="selectNo(item)"
          >
            <view class="content-header">
              <view class="content-header-title">{{
                list.length - index
              }}</view>
            </view>
            <view class="content-body">
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-1"> </view>
                  <view class="_label-name">批次号:</view>
                </view>
                <view class="_content">
                  {{ item.batchNo }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-2"> </view>
                  <view class="_label-name">产品描述:</view>
                </view>
                <view class="_content">
                  {{ item.partDescription }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-3"> </view>
                  <view class="_label-name">零件号:</view>
                </view>
                <view class="_content">
                  {{ item.partNo }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-1"> </view>
                  <view class="_label-name">毛重:</view>
                </view>
                <view class="_content">
                  {{ item.newGrossWeight }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-2"> </view>
                  <view class="_label-name">盘重:</view>
                </view>
                <view class="_content">
                  {{ item.newWeight }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-3"> </view>
                  <view class="_label-name">净重:</view>
                </view>
                <view class="_content">
                  {{ item.newNetWeight }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-1"> </view>
                  <view class="_label-name">核磅重量:</view>
                </view>
                <view class="_content">
                  {{ item.verificationWeight }}
                </view>
              </view>
              <view class="row-list">
                <view class="_label">
                  <view class="_label-icon-2"> </view>
                  <view class="_label-name">叉车盘重:</view>
                </view>
                <view class="_content">
                  {{ item.forkliftWeight }}
                </view>
              </view>
            </view>
          </view>
        </u-cell-group>
        <view class="loadmore" @click="getmoreList()">
          <u-loadmore
            :status="status"
            :load-text="loadText"
            @loadmore="getmoreList()"
          />
        </view>
      </scroll-view>
    </view>
    <u-toast ref="uToast" />
    <u-modal v-model="maskShow" title="" :show-confirm-button="false">
      <view @touchmove.stop.prevent="moveHandle" @click="maskclose">
        <scroll-view
          class="uni-scroll_box"
          scroll-y
          @touchmove.stop.prevent="moveHandle"
          @click.stop="moveHandle"
        >
          <view class="modal-title">选择蓝牙设备</view>
          <view v-if="listDevice.length === 0" class="empty-tip">暂无设备</view>
          <view
            v-for="(item, index) in listDevice"
            :key="index"
            @click="tapQuery(item)"
            class="device-item"
          >
            <view class="device-name">
              <text>名称:</text>
              <text>{{ item.name || "未知设备" }}</text>
            </view>
            <view class="device-uuid">
              <text>UUID:</text>
              <text>{{ item.address || "无地址" }}</text>
            </view>
          </view>
        </scroll-view>
      </view>
    </u-modal>
  </view>
</template>
<script>
    import content_bg from "@/static/custom/finishProductIn/locNoBg.png";
    const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
import content_bg from "@/static/custom/finishProductIn/locNoBg.png";
import bluetooth from "@/common/bluetoothPrinter.js";
    // äºŒç»´ç ç±»åž‹
    const QrCodeType = {
        QrCode: 31,
        PDF417: 32,
        DataMatrix: 33,
        AZTEC: 34,
    };
    // çº¿æ¡ç±»åž‹
    const LineType = {
        Solid: 1, // å®žçº¿
        Dotted: 2, // è™šçº¿ï¼ˆé»˜è®¤è™šå®ž1:1相间)
    };
    // æ¢è¡Œæ–¹å¼
    const LineModeType = {
        Justified: 1, // å®½é«˜å›ºå®šï¼Œå†…容自适应(字号/字间距/行间距按比例缩放)
        AutoHeight: 2, // å®½åº¦å›ºå®šï¼Œé«˜åº¦è‡ªé€‚应
        Fixed: 4, // å®½é«˜å›ºå®šï¼Œè¶…出部分裁剪
        Adapt: 6, // å®½é«˜å›ºå®šï¼Œå†…容超过时预设宽高自动缩小
    };
    export default {
        data() {
            return {
                background: {
                    backgroundImage: `url(${content_bg})`,
                    backgroundAttachment: "fixed",
                    backgroundSize: "100% auto",
                    backgroundRepeat: "no-repeat",
                },
                keywords: "",
                list: [],
                total: 0,
                pageNum: 1,
                pageSize: 10,
                status: "loading",
                loadText: {
                    loadmore: "加载更多...",
                    loading: "努力加载中...",
                    nomore: "没有更多了",
                },
                maskShow: false,
                listDevice: [], //蓝牙设备数据
                printQueue: [], // æ‰“印队列
                printing: false, // æ˜¯å¦æ­£åœ¨æ‰“印
                printDensity: 3, // é»˜è®¤æ‰“印浓度
                labelType: 1, // é»˜è®¤æ ‡ç­¾ç±»åž‹
                // 1:间隙纸
                // 2:黑标纸
                // 3:连续纸
                // 4:定孔纸
                // 5:透明纸
                printMode: 2, // é»˜è®¤æ‰“印模式
                //    1:热敏
                //     2:热转印
                connectedDevice: null, // å·²è¿žæŽ¥çš„æ‰“印机
                connectionStatus: "disconnected", // è¿žæŽ¥çŠ¶æ€: disconnected, connecting, connected
                printStatus: "idle", // æ‰“印状态: idle, printing, error
                errorMessage: "", // é”™è¯¯ä¿¡æ¯
                verificationNo: "",
                failedPrintJobs: [],
            };
        },
        onLoad(options) {
            this.verificationNo = JSON.parse(
                decodeURIComponent(options.verificationNo)
            );
            this.getlist();
            // åˆå§‹åŒ–SDK
            jcapi.initSDK();
const jcapi = uni.requireNativePlugin("JCSDK-JCApiModule");
            // å°è¯•恢复之前的蓝牙连接状态
            this.restoreBluetoothConnection();
// äºŒç»´ç ç±»åž‹
const QrCodeType = {
  QrCode: 31,
  PDF417: 32,
  DataMatrix: 33,
  AZTEC: 34,
};
// çº¿æ¡ç±»åž‹
const LineType = {
  Solid: 1, // å®žçº¿
  Dotted: 2, // è™šçº¿ï¼ˆé»˜è®¤è™šå®ž1:1相间)
};
// æ¢è¡Œæ–¹å¼
const LineModeType = {
  Justified: 1, // å®½é«˜å›ºå®šï¼Œå†…容自适应(字号/字间距/行间距按比例缩放)
  AutoHeight: 2, // å®½åº¦å›ºå®šï¼Œé«˜åº¦è‡ªé€‚应
  Fixed: 4, // å®½é«˜å›ºå®šï¼Œè¶…出部分裁剪
  Adapt: 6, // å®½é«˜å›ºå®šï¼Œå†…容超过时预设宽高自动缩小
};
export default {
  data() {
    return {
      background: {
        backgroundImage: `url(${content_bg})`,
        backgroundAttachment: "fixed",
        backgroundSize: "100% auto",
        backgroundRepeat: "no-repeat",
      },
      keywords: "",
      list: [],
      total: 0,
      pageNum: 1,
      pageSize: 10,
      status: "loading",
      loadText: {
        loadmore: "加载更多...",
        loading: "努力加载中...",
        nomore: "没有更多了",
      },
      maskShow: false,
      listDevice: [], //蓝牙设备数据
      printQueue: [], // æ‰“印队列
      printing: false, // æ˜¯å¦æ­£åœ¨æ‰“印
      printDensity: 10, // é»˜è®¤æ‰“印浓度
      labelType: 1, // é»˜è®¤æ ‡ç­¾ç±»åž‹
      // 1:间隙纸
      // 2:黑标纸
      // 3:连续纸
      // 4:定孔纸
      // 5:透明纸
      printMode: 2, // é»˜è®¤æ‰“印模式
      //    1:热敏
      //     2:热转印
      connectedDevice: null,
      connectionStatus: "disconnected",
      printStatus: "idle", // æ‰“印状态: idle, printing, error
      errorMessage: "", // é”™è¯¯ä¿¡æ¯
      verificationNo: "",
      failedPrintJobs: [],
    };
  },
  onLoad(options) {
    this.verificationNo = JSON.parse(
      decodeURIComponent(options.verificationNo)
    );
            // ç›‘听页码回调
            jcapi.didReadPrintCountInfo(function(r) {
                console.log("页码", r);
            });
    bluetooth.init();
            // ç›‘听错误回调
            jcapi.didReadPrintErrorInfo((r) => {
                console.log("错误", r);
                if (r.code == 23) {
                    // æ‰“印机断开连接
                    this.connectedDevice = null;
                    // æ¸…除本地存储的连接信息
                    uni.removeStorageSync("bluetoothConnection");
                    uni.showToast({
                        icon: "none",
                        title: "打印机连接已断开,请重新连接",
                        duration: 2 * 1000,
                    });
                } else {
                    uni.showToast({
                        icon: "none",
                        title: JSON.stringify(r),
                        duration: 2 * 1000,
                    });
                }
            });
        },
        methods: {
            restoreBluetoothConnection() {
                try {
                    // ä»Žæœ¬åœ°å­˜å‚¨èŽ·å–ä¹‹å‰ä¿å­˜çš„è¿žæŽ¥ä¿¡æ¯
                    const savedConnection = uni.getStorageSync("bluetoothConnection");
                    if (savedConnection && savedConnection.address) {
                        console.log("尝试恢复蓝牙连接:", savedConnection);
                        // è®¾ç½®ä¸ºè¿žæŽ¥ä¸­çŠ¶æ€
                        this.connectionStatus = "connecting";
    bluetooth.onChange(({ connectedDevice, connectionStatus }) => {
      this.connectedDevice = connectedDevice;
      this.connectionStatus = connectionStatus;
    });
                        // å°è¯•重新连接
                        jcapi.openPrinterByDevice({
                                address: savedConnection.address,
                                name: savedConnection.name,
                                deviceType: 0, // è®¾å¤‡ç±»åž‹ï¼š0-蓝牙,1-网络
                            },
                            (r) => {
                                if (r.code == 0) {
                                    this.connectedDevice = savedConnection;
                                    this.connectionStatus = "connected";
                                    console.log("蓝牙连接已恢复");
                                } else {
                                    this.connectionStatus = "disconnected";
                                    // å¦‚果重连失败,清除保存的连接信息
                                    uni.removeStorageSync("bluetoothConnection");
                                    console.log("蓝牙重连失败:", r);
                                }
                            }
                        );
                    }
                } catch (e) {
                    console.error("恢复蓝牙连接失败:", e);
                }
            },
            getmoreList() {
                if (this.pageSize >= this.total) {
                    this.status = "nomore";
                    return;
                }
                this.status = "loading";
                setTimeout(() => {
                    this.pageSize += this.pageSize;
                    this.getlist();
                }, 1000);
            },
            getlist() {
                this.$u.api.NuclearScaleEntry.queryPacking({
                    current: this.pageNum,
                    size: this.pageSize,
                    verificationNo: this.verificationNo,
                }).then((res) => {
                    this.list = res.data;
                    this.total = res.data.length;
                    if (this.pageSize >= this.total) {
                        this.status = "nomore";
                    } else {
                        this.status = "loadmore";
                    }
                });
            },
            search(value) {
                if (value) {
                    this.list = [];
                    this.pageSize = 10;
                    this.$u.api.NuclearScaleEntry.queryPacking({
                        current: this.pageNum,
                        size: this.pageSize,
                        moNo: value,
                    }).then((res) => {
                        this.list = res.data.records;
                        this.total = res.data.total;
                        if (this.pageSize >= this.total) {
                            this.status = "nomore";
                        } else {
                            this.status = "loadmore";
                        }
                    });
                } else {
                    this.getlist();
                }
            },
            // æ£€æŸ¥è“ç‰™è¿žæŽ¥çŠ¶æ€
            async checkBluetoothConnection() {
                if (!this.connectedDevice) {
                    this.connectionStatus = "disconnected";
                    return false;
                }
    this.getlist();
  },
                // è®¾ç½®ä¸ºè¿žæŽ¥ä¸­çŠ¶æ€
                this.connectionStatus = "connecting";
  // é¡µé¢å¸è½½æ—¶ä¸ä¸»åŠ¨æ–­å¼€è“ç‰™è¿žæŽ¥ï¼Œä¿æŒè¿žæŽ¥çŠ¶æ€
  onUnload() {
    // ä¸æ‰§è¡Œæ–­å¼€è¿žæŽ¥æ“ä½œï¼Œä¿æŒè“ç‰™è¿žæŽ¥
  },
  methods: {
    // restoreBluetoothConnection() {
    //     try {
    //         // ä»Žæœ¬åœ°å­˜å‚¨èŽ·å–ä¹‹å‰ä¿å­˜çš„è¿žæŽ¥ä¿¡æ¯
    //         const savedConnection = uni.getStorageSync("bluetoothConnection");
    //         if (savedConnection && savedConnection.address) {
    //             console.log("尝试恢复蓝牙连接:", savedConnection);
    //             // ç›´æŽ¥è®¾ç½®ä¸ºå·²è¿žæŽ¥çŠ¶æ€ï¼Œé¿å…ä¸å¿…è¦çš„é‡è¿ž
    //             // å®žé™…连接状态会通过SDK的回调自动更新
    //             this.connectedDevice = savedConnection;
    //             this.connectionStatus = "connected";
    //             console.log("蓝牙连接状态已恢复");
                // å¢žå¼ºè¿žæŽ¥çŠ¶æ€æ£€æµ‹
                return new Promise((resolve) => {
                    // ç®€åŒ–连接状态检测,直接使用已记录的连接状态
                    if (this.connectedDevice) {
                        this.connectionStatus = "connected";
                        resolve(true);
                    } else {
                        this.connectionStatus = "disconnected";
                        uni.showToast({
                            icon: "none",
                            title: "打印机未连接,请先连接",
                            duration: 2000,
                        });
                        resolve(false);
                    }
                });
            },
    //             // éªŒè¯è¿žæŽ¥æ˜¯å¦çœŸçš„æœ‰æ•ˆï¼Œé€šè¿‡å‘送一个简单的命令或检查状态
    //             // è¿™é‡Œä¸æ‰§è¡Œå®žé™…的重连操作,而是依赖SDK的连接状态回调
    //             // å¦‚果连接已断开,SDK会通过didReadPrintErrorInfo回调通知我们
    //         }
    //     } catch (e) {
    //         console.error("恢复蓝牙连接失败:", e);
    //         this.connectionStatus = "disconnected";
    //     }
    // },
    getmoreList() {
      if (this.pageSize >= this.total) {
        this.status = "nomore";
        return;
      }
      this.status = "loading";
      setTimeout(() => {
        this.pageSize += this.pageSize;
        this.getlist();
      }, 1000);
    },
    getlist() {
      this.$u.api.NuclearScaleEntry.queryPacking({
        current: this.pageNum,
        size: this.pageSize,
        verificationNo: this.verificationNo,
      }).then((res) => {
        this.list = res.data;
        this.total = res.data.length;
        if (this.pageSize >= this.total) {
          this.status = "nomore";
        } else {
          this.status = "loadmore";
        }
      });
    },
    search(value) {
      if (value) {
        this.list = [];
        this.pageSize = 10;
        this.$u.api.NuclearScaleEntry.queryPacking({
          current: this.pageNum,
          size: this.pageSize,
          moNo: value,
        }).then((res) => {
          this.list = res.data.records;
          this.total = res.data.total;
          if (this.pageSize >= this.total) {
            this.status = "nomore";
          } else {
            this.status = "loadmore";
          }
        });
      } else {
        this.getlist();
      }
    },
    checkBluetoothConnection() {
      return bluetooth.isConnected();
    },
            // æ·»åŠ åˆ°æ‰“å°é˜Ÿåˆ—
            addToPrintQueue(items) {
                if (!Array.isArray(items)) {
                    items = [items];
                }
    //     // ç›´æŽ¥ä½¿ç”¨å·²è®°å½•的连接状态,避免不必要的连接检查
    //     // å®žé™…连接状态会通过SDK的回调自动更新
    //     this.connectionStatus = "connected";
    //     return true;
    // },
                this.printQueue.push(...items);
                // å¦‚果不在打印中,则开始处理队列
                if (!this.printing) {
                    this.processPrintQueue();
                }
            },
    // æ·»åŠ åˆ°æ‰“å°é˜Ÿåˆ—
    addToPrintQueue(items) {
      if (!Array.isArray(items)) {
        items = [items];
      }
            // å¤„理打印队列
            async processPrintQueue() {
                while (this.printQueue.length > 0) {
                    // æ£€æŸ¥è¿žæŽ¥çŠ¶æ€
                    const isConnected = await this.checkBluetoothConnection();
                    if (!isConnected) {
                        // å¦‚果未连接,显示蓝牙连接对话框
                        this.searchDevice();
                        // ä¸æ˜¯ç›´æŽ¥return,而是等待用户连接后再继续处理
                        return;
                    }
      this.printQueue.push(...items);
      // å¦‚果不在打印中,则开始处理队列
      if (!this.printing) {
        this.processPrintQueue();
      }
    },
                    this.printing = true;
                    this.printStatus = "printing";
    // å¤„理打印队列
    async processPrintQueue() {
      while (this.printQueue.length > 0) {
        // æ£€æŸ¥è¿žæŽ¥çŠ¶æ€
        const isConnected = await this.checkBluetoothConnection();
        if (!isConnected) {
          // å¦‚果未连接,显示蓝牙连接对话框
          this.searchDevice();
          // ä¸æ˜¯ç›´æŽ¥return,而是等待用户连接后再继续处理
          return;
        }
                    // å–出队列中的第一个任务
                    const item = this.printQueue.shift();
        this.printing = true;
        this.printStatus = "printing";
                    try {
                        // æ‰§è¡Œæ‰“印
                        await this.printQrCode(item);
        // å–出队列中的第一个任务
        const item = this.printQueue.shift();
                        // æ‰“印成功后继续处理下一个
                        uni.showToast({
                            title: "打印成功",
                            icon: "success",
                            duration: 1000,
                        });
        try {
          // æ‰§è¡Œæ‰“印
          await this.printQrCode(item);
                        // çŸ­æš‚延迟,避免打印机缓存溢出
                        await new Promise((resolve) => setTimeout(resolve, 1000));
                    } catch (error) {
                        console.error("打印出错:", error);
                        this.printStatus = "error";
                        this.errorMessage = error.message || "打印时发生未知错误";
                        this.printing = false;
          // æ‰“印成功后继续处理下一个
          uni.showToast({
            title: "打印成功",
            icon: "success",
            duration: 1000,
          });
                        // è®°å½•失败的任务,不重新添加到队列
                        this.failedPrintJobs = this.failedPrintJobs || [];
                        this.failedPrintJobs.push(item);
          // çŸ­æš‚延迟,避免打印机缓存溢出
          await new Promise((resolve) => setTimeout(resolve, 1000));
        } catch (error) {
          console.error("打印出错:", error);
          this.printStatus = "error";
          this.errorMessage = error.message || "打印时发生未知错误";
          this.printing = false;
                        uni.showToast({
                            title: `打印失败: ${this.errorMessage}`,
                            icon: "none",
                            duration: 2000,
                        });
                        // ç»§ç»­å¤„理下一个任务
                        continue;
                    }
                }
          // è®°å½•失败的任务,不重新添加到队列
          this.failedPrintJobs = this.failedPrintJobs || [];
          this.failedPrintJobs.push(item);
                this.printing = false;
                this.printStatus = "idle";
            },
            // æ‰“印单个信息
            selectNo(item) {
                let that = this;
                uni.showModal({
                    title: "提示",
                    content: "是否打印装箱单?",
                    showCancel: true,
                    success: async function(res) {
                        if (res.confirm) {
                            // æ·»åŠ åˆ°æ‰“å°é˜Ÿåˆ—
                            that.addToPrintQueue(item);
                        }
                    },
                });
            },
          uni.showToast({
            title: `打印失败: ${this.errorMessage}`,
            icon: "none",
            duration: 2000,
          });
          // ç»§ç»­å¤„理下一个任务
          continue;
        }
      }
            // æ‰“印全部信息
            goPrintAll() {
                let that = this;
                uni.showModal({
                    title: "提示",
                    content: `是否打印全部${that.list.length}条装箱单?`,
                    showCancel: true,
                    success: async function(res) {
                        if (res.confirm) {
                            // æ·»åŠ åˆ°æ‰“å°é˜Ÿåˆ—
                            that.addToPrintQueue([...that.list]);
                        }
                    },
                });
            },
            moveHandle() {},
            maskclose() {},
            //打印二维码
            printQrCode(item) {
                return new Promise(async (resolve, reject) => {
                    // const params = {
                    //     rwMatlBindId: item.id
                    // };
                    try {
                        // let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
                        if (!item) {
                            this.$refs.uToast.show({
                                title: "未查询到该标签信息!",
                                type: "warning ",
                            });
                            reject(new Error("未查询到该标签信息"));
                            return;
                        }
      this.printing = false;
      this.printStatus = "idle";
    },
    // æ‰“印单个信息
    selectNo(item) {
      let that = this;
      uni.showModal({
        title: "提示",
        content: "是否打印装箱单?",
        success(res) {
          if (res.confirm) {
            // æŒ‰ batchNo åˆå¹¶
            const sameBatchList = that.list.filter(
              (i) => i.batchNo === item.batchNo
            );
            that.addToPrintQueue(sameBatchList);
          }
        },
      });
    },
                        const ht = item.contractNo;
                        const lj = item.partNo;
                        const ljms = item.ccontrProModel;
                        const fh = item.newNetWeight;
                        const scdt = item.productionDate;
                        const scph = item.batchNo;
                        const shdw = item.customerName;
                        const fhdw = "江东合金技术有限公司";
    // æ‰“印全部信息
    goPrintAll() {
      let that = this;
      uni.showModal({
        title: "提示",
        content: `是否打印全部${that.list.length}条装箱单?`,
        showCancel: true,
        success: async function (res) {
          if (res.confirm) {
            // æ·»åŠ åˆ°æ‰“å°é˜Ÿåˆ—
            that.addToPrintQueue([...that.list]);
          }
        },
      });
    },
    moveHandle() {},
    maskclose() {},
    //打印二维码
    printQrCode(item) {
      return new Promise(async (resolve, reject) => {
        // const params = {
        //     rwMatlBindId: item.id
        // };
        try {
          // let res = await this.$u.api.dailyPaper.zongjianLabelInfo(params)
          if (!item) {
            this.$refs.uToast.show({
              title: "未查询到该标签信息!",
              type: "warning ",
            });
            reject(new Error("未查询到该标签信息"));
            return;
          }
                        // åˆå§‹åŒ–画板
                        jcapi.initDrawingBoard({
                            width: 70,
                            height: 49,
                            rotate: 90,
                        });
          const ht = item.contractNo;
          const lj = item.partNo;
          const ljms = item.ccontrProModel;
          const fh = item.newNetWeight;
          const scdt = item.productionDate;
          const scph = item.batchNo;
          const shdw = item.customerName;
          const fhdw = "江东合金技术有限公司";
                        // ç»˜åˆ¶äºŒç»´ç 
                        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,
                        };
          // åˆå§‹åŒ–画板
          jcapi.initDrawingBoard({
            width: 70,
            height: 49,
            rotate: 90,
          });
                        jcapi.drawLabelQrCode({
                            x: 43.5,
                            y: 2,
                            width: 24,
                            height: 24,
                            value: qrContent,
                            rotate: 0,
                            codeType: QrCodeType.QrCode,
                        });
          // ç»˜åˆ¶äºŒç»´ç 
          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,
          };
                        // ç»˜åˆ¶æ¨ªçº¿
                        this.getDrawLabelLine(1, 1, 67, 0.5, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 23, 42, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 27.5, 67, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid);
                        this.getDrawLabelLine(1, 47, 67, 0.5, 0, LineType.Solid);
          jcapi.drawLabelQrCode({
            x: 43.5,
            y: 2,
            width: 24,
            height: 24,
            value: qrContent,
            rotate: 0,
            codeType: QrCodeType.QrCode,
          });
                        //绘制竖线
                        this.getDrawLabelLine(1, 1, 0.5, 46, 0, LineType.Solid); // ç«–线1
                        this.getDrawLabelLine(43, 1, 0.3, 26, 0, LineType.Solid); // ç«–线2
                        this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid); // ç«–线3
          // ç»˜åˆ¶æ¨ªçº¿
          this.getDrawLabelLine(1, 1, 67, 0.5, 0, LineType.Solid);
          this.getDrawLabelLine(1, 6, 42, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 11, 42, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 16, 42, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 23, 42, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 27.5, 67, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 32, 67, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 37, 67, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 42, 67, 0.3, 0, LineType.Solid);
          this.getDrawLabelLine(1, 47, 67, 0.5, 0, LineType.Solid);
                        // ç»˜åˆ¶æ–‡æœ¬
                        this.getDrawLabelText(
                            3,
                            2.5,
                            40,
                            8,
                            "中天科技装箱清单",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            1,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            7,
                            25,
                            8,
                            "合同号:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            12,
                            25,
                            8,
                            "零件号:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            17,
                            25,
                            8,
                            "零件描述:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            23.5,
                            25,
                            8,
                            "发货/装箱数:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            28.5,
                            25,
                            8,
                            "生产日期:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            32.5,
                            25,
                            8,
                            "生产批号:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            37.5,
                            25,
                            8,
                            "发货单位:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
                        this.getDrawLabelText(
                            2,
                            42.5,
                            25,
                            8,
                            "收货单位:",
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            1,
                            1
                        );
          //绘制竖线
          this.getDrawLabelLine(1, 1, 0.5, 46, 0, LineType.Solid); // ç«–线1
          this.getDrawLabelLine(43, 1, 0.3, 26, 0, LineType.Solid); // ç«–线2
          this.getDrawLabelLine(68, 1, 0.5, 46, 0, LineType.Solid); // ç«–线3
                        // å¡«å……参数值
                        this.getDrawLabelText(
                            11,
                            7,
                            30,
                            8,
                            ht,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            11,
                            12,
                            32,
                            8,
                            lj,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            14,
                            17,
                            30,
                            8,
                            ljms,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            17,
                            23.5,
                            27,
                            8,
                            fh,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            14,
                            28.5,
                            55,
                            8,
                            scdt,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            14,
                            32.7,
                            55,
                            8,
                            scph,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            14,
                            37.5,
                            55,
                            8,
                            fhdw,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        this.getDrawLabelText(
                            14,
                            42.5,
                            55,
                            8,
                            shdw,
                            2.5,
                            0,
                            LineModeType.AutoHeight,
                            0,
                            0,
                            0,
                            0,
                            1
                        );
                        // ç”Ÿæˆæ‰“印数据
                        let imageJsonObj = jcapi.generateLabelJson();
          // ç»˜åˆ¶æ–‡æœ¬
          this.getDrawLabelText(
            3,
            2.5,
            40,
            8,
            "中天科技装箱清单",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            1,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            7,
            25,
            8,
            "合同号:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            12,
            25,
            8,
            "零件号:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            17,
            25,
            8,
            "零件描述:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            23.5,
            25,
            8,
            "发货/装箱数:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            28.5,
            25,
            8,
            "生产日期:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            32.5,
            25,
            8,
            "生产批号:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            37.5,
            25,
            8,
            "发货单位:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
          this.getDrawLabelText(
            2,
            42.5,
            25,
            8,
            "收货单位:",
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            1,
            1
          );
                        // è®¾ç½®æ‰“印任务
                        jcapi.startJob({
                                totalCount: 1,
                                density: this.printDensity,
                                labelType: this.labelType,
                                printMode: this.printMode,
                            },
                            function(r) {
                                if (r.code == 0) {
                                    // æ‰“印数据
                                    // å­˜å‚¨åŽŸå§‹æ‰“å°è®¡æ•°å›žè°ƒ
                                    const originalPrintCountCallback =
                                        jcapi.didReadPrintCountInfo._callback;
                                    // ä¸´æ—¶æ‰“印计数回调,用于确认打印完成
                                    const tempPrintCountCallback = (printResult) => {
                                        // æ¢å¤åŽŸå§‹å›žè°ƒ
                                        jcapi.didReadPrintCountInfo(originalPrintCountCallback);
                                        // æ¸…除打印超时
                                        clearTimeout(printTimeout);
                                        // ç»“束当前打印任务
                                        // è§£æžPromise表示打印完成
                                        resolve();
                                    };
                                    // è®¾ç½®ä¸´æ—¶å›žè°ƒ
                                    jcapi.didReadPrintCountInfo(tempPrintCountCallback);
          // å¡«å……参数值
          this.getDrawLabelText(
            11,
            7,
            30,
            8,
            ht,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            11,
            12,
            32,
            8,
            lj,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            14,
            17,
            30,
            8,
            ljms,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            17,
            23.5,
            27,
            8,
            fh,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            14,
            28.5,
            55,
            8,
            scdt,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            14,
            32.7,
            55,
            8,
            scph,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            14,
            37.5,
            55,
            8,
            fhdw,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          this.getDrawLabelText(
            14,
            42.5,
            55,
            8,
            shdw,
            2.5,
            0,
            LineModeType.AutoHeight,
            0,
            0,
            0,
            0,
            1
          );
          // ç”Ÿæˆæ‰“印数据
          let imageJsonObj = jcapi.generateLabelJson();
                                    // æ·»åŠ æ‰“å°è¶…æ—¶å¤„ç†
                                    const printTimeout = setTimeout(() => {
                                        jcapi.didReadPrintCountInfo(originalPrintCountCallback);
                                        reject(new Error("打印超时未响应"));
                                    }, 20000);
          // è®¾ç½®æ‰“印任务
          jcapi.startJob(
            {
              totalCount: 1,
              density: this.printDensity,
              labelType: this.labelType,
              printMode: this.printMode,
            },
            function (r) {
              if (r.code == 0) {
                // æ‰“印数据
                // å­˜å‚¨åŽŸå§‹æ‰“å°è®¡æ•°å›žè°ƒ
                const originalPrintCountCallback =
                  jcapi.didReadPrintCountInfo._callback;
                // ä¸´æ—¶æ‰“印计数回调,用于确认打印完成
                const tempPrintCountCallback = (printResult) => {
                  // æ¢å¤åŽŸå§‹å›žè°ƒ
                  jcapi.didReadPrintCountInfo(originalPrintCountCallback);
                  // æ¸…除打印超时
                  clearTimeout(printTimeout);
                  // ç»“束当前打印任务
                  // è§£æžPromise表示打印完成
                  resolve();
                };
                // è®¾ç½®ä¸´æ—¶å›žè°ƒ
                jcapi.didReadPrintCountInfo(tempPrintCountCallback);
                                    jcapi.printData(
                                        imageJsonObj, {
                                            printQuantity: 1,
                                        },
                                        function(r) {
                                            if (r.code != 0) {
                                                // æ¢å¤åŽŸå§‹å›žè°ƒ
                                                jcapi.didReadPrintCountInfo(
                                                    originalPrintCountCallback);
                                                // ç»“束当前打印任务
                                                reject(new Error(r.msg || "打印失败"));
                                            }
                                            // æ‰“印数据发送成功后等待打印计数回调确认实际打印完成
                                        }
                                    );
                                } else {
                                    reject(new Error(r.msg || "设置打印任务失败"));
                                }
                            }
                        );
                    } catch (error) {
                        reject(error);
                    }
                });
            },
            tapQuery(item) {
                this.maskShow = false;
                // è¿žæŽ¥æ‰“印机
                let _this = this;
                // æ·»åŠ æ‰“å°è¶…æ—¶å¤„ç†
                const printTimeout = setTimeout(() => {
                  jcapi.didReadPrintCountInfo(originalPrintCountCallback);
                  reject(new Error("打印超时未响应"));
                }, 20000);
                // è®¾ç½®ä¸ºè¿žæŽ¥ä¸­çŠ¶æ€
                this.connectionStatus = "connecting";
                jcapi.printData(
                  imageJsonObj,
                  {
                    printQuantity: 1,
                  },
                  function (r) {
                    if (r.code != 0) {
                      // æ¢å¤åŽŸå§‹å›žè°ƒ
                      jcapi.didReadPrintCountInfo(originalPrintCountCallback);
                      // ç»“束当前打印任务
                      reject(new Error(r.msg || "打印失败"));
                    }
                    // æ‰“印数据发送成功后等待打印计数回调确认实际打印完成
                  }
                );
              } else {
                reject(new Error(r.msg || "设置打印任务失败"));
              }
            }
          );
        } catch (error) {
          reject(error);
        }
      });
    },
    async tapQuery(item) {
      this.maskShow = false;
      try {
        await bluetooth.connect(item);
        uni.showToast({ title: "连接成功" });
                jcapi.openPrinterByDevice({
                        address: item.address,
                        name: item.name,
                        deviceType: 0, // è®¾å¤‡ç±»åž‹ï¼š0-蓝牙,1-网络
                    },
                    function(r) {
                        // åœ¨tapQuery方法中,连接成功时添加保存连接信息的代码
                        if (r.code == 0) {
                            _this.connectedDevice = item;
                            _this.connectionStatus = "connected";
                            // ä¿å­˜è¿žæŽ¥ä¿¡æ¯åˆ°æœ¬åœ°å­˜å‚¨
                            uni.setStorageSync("bluetoothConnection", item);
                            uni.showToast({
                                title: "连接成功",
                                duration: 1500,
                            });
                            // å¼€å§‹å¤„理打印队列
                            if (_this.printQueue.length > 0) {
                                _this.processPrintQueue();
                            }
                        } else {
                            _this.connectionStatus = "disconnected";
                            uni.showToast({
                                title: "连接失败: " + (r.msg || "未知错误"),
                                icon: "none",
                                duration: 2000,
                            });
                        }
                    }
                );
            },
            //打印相关
            searchDevice() {
                let _this = this;
                uni.openBluetoothAdapter({
                    // ç¡®è®¤è“ç‰™æ˜¯å¦æ‰“å¼€
                    success(r) {
                        uni.showLoading({
                            title: "搜索中...",
                        });
                        // æœªæŽˆäºˆè“ç‰™ç›¸å…³æƒé™å’Œæœªæ‰“开手机定位会搜索不到设备
                        jcapi.getBluetoothDevices(function(r) {
                            console.log("device:" + JSON.stringify(r));
                            // æœç´¢åˆ°è®¾å¤‡å›žè°ƒ
                            uni.hideLoading();
                            // å¦‚果之前有连接的设备但不在搜索结果中,说明设备已更换
                            if (
                                _this.connectedDevice &&
                                !r.some((dev) => dev.address === _this.connectedDevice.address)
                            ) {
                                _this.connectedDevice = null;
                                uni.showToast({
                                    icon: "none",
                                    title: "已连接的蓝牙设备已更换,请重新选择",
                                    duration: 2000,
                                });
                            }
                            _this.listDevice = r;
                            _this.maskShow = true;
                        });
                    },
                    fail(e) {
                        uni.showModal({
                            title: "提示",
                            content: "打开蓝牙失败,请检查蓝牙是否开启",
                            showCancel: false,
                        });
                        console.log("开启蓝牙设备失败" + e);
                    },
                });
            },
            // ç»˜åˆ¶æ¨ªçº¿
            getDrawLabelLine(x, y, width, height, rotate, lineType) {
                jcapi.drawLabelLine({
                    x: x,
                    y: y,
                    width: width,
                    height: height,
                    rotate: rotate,
                    lineType: lineType,
                });
            },
            // å¡«å†²æ–‡å­—标题
            getDrawLabelText(
                x,
                y,
                width,
                height,
                value,
                fontSize,
                rotate,
                lineMode,
                lineSpace,
                letterSpace,
                textAlignHorizontal,
                textAlignVertical,
                bold
            ) {
                jcapi.drawLabelText({
                    x: x,
                    y: y,
                    width: width,
                    height: height,
                    value: value,
                    fontSize: fontSize,
                    rotate: rotate,
                    lineMode: lineMode,
                    lineSpace: lineSpace,
                    letterSpace: letterSpace,
                    textAlignHorizontal: textAlignHorizontal,
                    textAlignVertical: textAlignVertical,
                    bold: bold,
                });
            },
            getConnectionStatusText() {
                switch (this.connectionStatus) {
                    case "connected":
                        return "蓝牙已连接";
                    case "connecting":
                        return "蓝牙连接中...";
                    default:
                        return "蓝牙未连接";
                }
            },
            getPrintStatusText() {
                switch (this.printStatus) {
                    case "printing":
                        const total = this.printQueue.length + 1; // é˜Ÿåˆ—中剩余 + å½“前正在打印
                        const current = total - this.printQueue.length;
                        return `打印中(${current}/${total})`;
                    case "error":
                        return `打印错误: ${this.errorMessage}`;
                    default:
                        return "就绪";
                }
            },
            //刷新上一个页面
            refreshLastPage(no) {
                // å‘ŠçŸ¥ A.vue æ›´æ–°æ•°æ®
                // èŽ·å–é¡µé¢æ ˆ
                let pages = getCurrentPages();
        // å¦‚果有打印任务,继续打印
        if (this.printQueue.length) {
          this.processPrintQueue();
        }
      } catch (e) {
        uni.showToast({
          icon: "none",
          title: "连接失败",
        });
      }
    },
                // èŽ·å–ä¸Šä¸€é¡µæ ˆ
                let prevPage = pages[pages.length - 2];
    //打印相关
    async searchDevice() {
      try {
        uni.showLoading({ title: "搜索中..." });
        const devices = await bluetooth.searchDevices();
        uni.hideLoading();
                // è§¦å‘上一页 upData å‡½æ•°(并携带参数)
                prevPage.$vm.setNo(no);
        this.listDevice = devices;
        this.maskShow = true;
      } catch (e) {
        uni.hideLoading();
        uni.showModal({
          title: "提示",
          content: "请确认蓝牙和定位已开启",
          showCancel: false,
        });
      }
    },
                // è¿”回上一页
                uni.navigateBack({
                    delta: 1,
                });
            },
        },
    };
    // ç»˜åˆ¶æ¨ªçº¿
    getDrawLabelLine(x, y, width, height, rotate, lineType) {
      jcapi.drawLabelLine({
        x: x,
        y: y,
        width: width,
        height: height,
        rotate: rotate,
        lineType: lineType,
      });
    },
    // å¡«å†²æ–‡å­—标题
    getDrawLabelText(
      x,
      y,
      width,
      height,
      value,
      fontSize,
      rotate,
      lineMode,
      lineSpace,
      letterSpace,
      textAlignHorizontal,
      textAlignVertical,
      bold
    ) {
      jcapi.drawLabelText({
        x: x,
        y: y,
        width: width,
        height: height,
        value: value,
        fontSize: fontSize,
        rotate: rotate,
        lineMode: lineMode,
        lineSpace: lineSpace,
        letterSpace: letterSpace,
        textAlignHorizontal: textAlignHorizontal,
        textAlignVertical: textAlignVertical,
        bold: bold,
      });
    },
    getConnectionStatusText() {
      switch (this.connectionStatus) {
        case "connected":
          return "蓝牙已连接";
        case "connecting":
          return "蓝牙连接中...";
        default:
          return "蓝牙未连接";
      }
    },
    getPrintStatusText() {
      switch (this.printStatus) {
        case "printing":
          const total = this.printQueue.length + 1; // é˜Ÿåˆ—中剩余 + å½“前正在打印
          const current = total - this.printQueue.length;
          return `打印中(${current}/${total})`;
        case "error":
          return `打印错误: ${this.errorMessage}`;
        default:
          return "就绪";
      }
    },
    //刷新上一个页面
    refreshLastPage(no) {
      // å‘ŠçŸ¥ A.vue æ›´æ–°æ•°æ®
      // èŽ·å–é¡µé¢æ ˆ
      let pages = getCurrentPages();
      // èŽ·å–ä¸Šä¸€é¡µæ ˆ
      let prevPage = pages[pages.length - 2];
      // è§¦å‘上一页 upData å‡½æ•°(并携带参数)
      prevPage.$vm.setNo(no);
      // è¿”回上一页
      uni.navigateBack({
        delta: 1,
      });
    },
  },
};
</script>
<style lang="scss">
    .finishProductIn-locno-bg {
        background-color: #f6f9ff;
        background-image: url("~@/static/custom/finishProductIn/locNoBg.png");
        // background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0));
        padding: 0 20rpx;
        background-attachment: fixed;
        background-size: 100% auto;
        background-repeat: no-repeat;
        position: fixed;
        top: 0;
        bottom: 0;
        width: 100%;
        z-index: -1;
    }
.finishProductIn-locno-bg {
  background-color: #f6f9ff;
  background-image: url("~@/static/custom/finishProductIn/locNoBg.png");
  // background: linear-gradient(180deg,rgba(206,227,254,1),rgba(206,227,254,1) 20%,rgba(206,227,254,0.5) 40%,rgba(206,227,254,0.25) 60%,rgba(206,227,254,0.08) 80%,rgba(206,227,254,0));
  padding: 0 20rpx;
  background-attachment: fixed;
  background-size: 100% auto;
  background-repeat: no-repeat;
  position: fixed;
  top: 0;
  bottom: 0;
  width: 100%;
  z-index: -1;
}
    .finishProductIn-locno-search {
        padding: 40rpx 30rpx 20rpx 30rpx;
    }
.finishProductIn-locno-search {
  padding: 40rpx 30rpx 20rpx 30rpx;
}
    .wrap .finishProductIn-locno-scroll-list {
        height: calc(100vh - var(--window-top) - var(--window-bottom) - 242rpx);
        width: 100%;
    }
.wrap .finishProductIn-locno-scroll-list {
  height: calc(100vh - var(--window-top) - var(--window-bottom) - 242rpx);
  width: 100%;
}
    .finishProductIn-locno-scroll-list-group {
        ::v-deep .u-cell-item-box {
            background-color: rgba(250, 252, 255, 0.36) !important;
            padding: 0rpx 30rpx;
        }
.finishProductIn-locno-scroll-list-group {
  ::v-deep .u-cell-item-box {
    background-color: rgba(250, 252, 255, 0.36) !important;
    padding: 0rpx 30rpx;
  }
        .content {
            font-size: 12px;
            background-color: #ffffff;
            box-sizing: border-box;
            border-radius: 10rpx;
            margin: 0rpx 0rpx 16rpx;
            padding: 20rpx 8rpx;
            box-shadow: none;
            display: flex;
            align-items: center;
  .content {
    font-size: 12px;
    background-color: #ffffff;
    box-sizing: border-box;
    border-radius: 10rpx;
    margin: 0rpx 0rpx 16rpx;
    padding: 20rpx 8rpx;
    box-shadow: none;
    display: flex;
    align-items: center;
            .content-header {
                width: 40rpx;
                height: 90rpx;
                display: flex;
                align-items: center;
    .content-header {
      width: 40rpx;
      height: 90rpx;
      display: flex;
      align-items: center;
                .content-header-icon {
                    background-image: url("~@/static/custom/moveWareHouse/header_icon.png");
                    background-size: 100% auto;
                    background-repeat: no-repeat;
                    height: 28rpx;
                    width: 28rpx;
                }
      .content-header-icon {
        background-image: url("~@/static/custom/moveWareHouse/header_icon.png");
        background-size: 100% auto;
        background-repeat: no-repeat;
        height: 28rpx;
        width: 28rpx;
      }
                .content-header-title {
                    margin-left: 11rpx;
                    font-size: 26rpx;
                    font-weight: bold;
                    color: #3d52f5;
                }
            }
      .content-header-title {
        margin-left: 11rpx;
        font-size: 26rpx;
        font-weight: bold;
        color: #3d52f5;
      }
    }
            .content-body {
                flex: 1;
                background: #f5f9ff;
                border-radius: 10rpx;
                padding: 0rpx 23rpx;
    .content-body {
      flex: 1;
      background: #f5f9ff;
      border-radius: 10rpx;
      padding: 0rpx 23rpx;
                .row-list {
                    height: 60rpx;
                    display: flex;
                    flex-direction: row;
                    padding: 0px;
                    align-items: center;
                }
      .row-list {
        height: 60rpx;
        display: flex;
        flex-direction: row;
        padding: 0px;
        align-items: center;
      }
                .row-list ._label {
                    display: flex;
                    flex: 0.8;
                    color: #909399;
                    align-items: center;
      .row-list ._label {
        display: flex;
        flex: 0.8;
        color: #909399;
        align-items: center;
                    ._label-icon-1 {
                        background-image: url("~@/static/custom/moveWareHouse/label-icon-1.png");
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height: 26rpx;
                        width: 26rpx;
                    }
        ._label-icon-1 {
          background-image: url("~@/static/custom/moveWareHouse/label-icon-1.png");
          background-size: 100% auto;
          background-repeat: no-repeat;
          height: 26rpx;
          width: 26rpx;
        }
                    ._label-icon-2 {
                        background-image: url("~@/static/custom/moveWareHouse/label-icon-2.png");
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height: 26rpx;
                        width: 26rpx;
                    }
        ._label-icon-2 {
          background-image: url("~@/static/custom/moveWareHouse/label-icon-2.png");
          background-size: 100% auto;
          background-repeat: no-repeat;
          height: 26rpx;
          width: 26rpx;
        }
                    ._label-icon-3 {
                        background-image: url("~@/static/custom/moveWareHouse/label-icon-3.png");
                        background-size: 100% auto;
                        background-repeat: no-repeat;
                        height: 26rpx;
                        width: 26rpx;
                    }
        ._label-icon-3 {
          background-image: url("~@/static/custom/moveWareHouse/label-icon-3.png");
          background-size: 100% auto;
          background-repeat: no-repeat;
          height: 26rpx;
          width: 26rpx;
        }
                    ._label-name {
                        margin-left: 11rpx;
                        font-size: 26rpx;
                        font-weight: 500;
                        color: #666666;
                    }
                }
        ._label-name {
          margin-left: 11rpx;
          font-size: 26rpx;
          font-weight: 500;
          color: #666666;
        }
      }
                .row-list ._content {
                    flex: 1.5;
                    text-align: right;
                    color: #909399;
                    font-size: 24rpx;
                }
      .row-list ._content {
        flex: 1.5;
        text-align: right;
        color: #909399;
        font-size: 24rpx;
      }
                .row-list .s1 {
                    color: #d35651;
                }
            }
        }
    }
      .row-list .s1 {
        color: #d35651;
      }
    }
  }
}
    .navbar-right {
        font-weight: 500;
        font-size: 13px;
        color: #0b0b0b;
        line-height: 36rpx;
        margin-right: 32rpx;
    }
.navbar-right {
  font-weight: 500;
  font-size: 13px;
  color: #0b0b0b;
  line-height: 36rpx;
  margin-right: 32rpx;
}
    /* æ¨¡æ€æ¡†æ ·å¼ä¼˜åŒ– */
    .u-modal {
        --modal-width: 85% !important;
        --modal-radius: 16rpx !important;
        --modal-bg-color: #ffffff !important;
    }
/* æ¨¡æ€æ¡†æ ·å¼ä¼˜åŒ– */
.u-modal {
  --modal-width: 85% !important;
  --modal-radius: 16rpx !important;
  --modal-bg-color: #ffffff !important;
}
    /* æ¨¡æ€æ¡†å†…容区域 */
    .uni-scroll_box {
        height: 500rpx !important;
        padding: 20rpx;
    }
/* æ¨¡æ€æ¡†å†…容区域 */
.uni-scroll_box {
  height: 500rpx !important;
  padding: 20rpx;
}
    /* è®¾å¤‡åˆ—表项样式 */
    .device-item {
        background-color: #f5f9ff;
        border-radius: 12rpx;
        padding: 20rpx;
        margin-bottom: 16rpx;
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
    }
/* è®¾å¤‡åˆ—表项样式 */
.device-item {
  background-color: #f5f9ff;
  border-radius: 12rpx;
  padding: 20rpx;
  margin-bottom: 16rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}
    /* è®¾å¤‡åç§°æ ·å¼ */
    .device-name {
        font-size: 28rpx;
        font-weight: 500;
        color: #333333;
        margin-bottom: 10rpx;
        display: flex;
        justify-content: space-between;
    }
/* è®¾å¤‡åç§°æ ·å¼ */
.device-name {
  font-size: 28rpx;
  font-weight: 500;
  color: #333333;
  margin-bottom: 10rpx;
  display: flex;
  justify-content: space-between;
}
    /* UUID文本样式 */
    .device-uuid {
        font-size: 28rpx;
        font-weight: 500;
        color: #333333;
        margin-bottom: 10rpx;
        display: flex;
        justify-content: space-between;
    }
/* UUID文本样式 */
.device-uuid {
  font-size: 28rpx;
  font-weight: 500;
  color: #333333;
  margin-bottom: 10rpx;
  display: flex;
  justify-content: space-between;
}
    /* æ¨¡æ€æ¡†æ ‡é¢˜ */
    .modal-title {
        font-size: 32rpx;
        font-weight: bold;
        color: #333333;
        text-align: center;
        margin-bottom: 20rpx;
        padding-bottom: 10rpx;
        border-bottom: 1rpx solid #eeeeee;
    }
/* æ¨¡æ€æ¡†æ ‡é¢˜ */
.modal-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333333;
  text-align: center;
  margin-bottom: 20rpx;
  padding-bottom: 10rpx;
  border-bottom: 1rpx solid #eeeeee;
}
    /* ç©ºçŠ¶æ€æç¤º */
    .empty-tip {
        text-align: center;
        padding: 100rpx 0;
        color: #999999;
        font-size: 28rpx;
    }
/* ç©ºçŠ¶æ€æç¤º */
.empty-tip {
  text-align: center;
  padding: 100rpx 0;
  color: #999999;
  font-size: 28rpx;
}
    .status-indicator {
        padding: 8rpx 16rpx;
        font-size: 24rpx;
        text-align: center;
        color: #fff;
        background-color: #666;
.status-indicator {
  padding: 8rpx 16rpx;
  font-size: 24rpx;
  text-align: center;
  color: #fff;
  background-color: #666;
        &.connected {
            background-color: #07c160;
        }
  &.connected {
    background-color: #07c160;
  }
        &.connecting {
            background-color: #ff976a;
        }
  &.connecting {
    background-color: #ff976a;
  }
        &.disconnected {
            background-color: #f53f3f;
        }
  &.disconnected {
    background-color: #f53f3f;
  }
        .print-status {
            margin-left: 10rpx;
            font-size: 22rpx;
        }
    }
  .print-status {
    margin-left: 10rpx;
    font-size: 22rpx;
  }
}
</style>