fcx
4 天以前 6ca81c89d606b5be26c8b8526b191ae8e773167b
pages/QC/SJ/ScanCode.vue
@@ -1,8 +1,8 @@
<template>
  <view class="sn-scan-page">
    <view class="title">SN 扫码页面</view>
    <view class="title">SN确认</view>
    <view class="remark">
    <view v-if="current === 'true'" class="remark">
      备注:点击"扫码"按钮扫描SN码,再次点击可覆盖上次记录
    </view>
@@ -10,20 +10,26 @@
      <view class="table-header">
        <text class="col name">项目名称</text>
        <text class="col sn">SN码</text>
        <text class="col action">操作</text>
        <text v-if="current === 'true'" class="col action">操作</text>
      </view>
      <view class="table-row" v-for="(item, index) in scanItems" :key="item.id">
        <text class="col name">{{ item.scanItem }}</text>
        <!-- 可编辑状态:显示输入框 -->
        <input
          v-if="current === 'true'"
          class="col sn-input"
          type="text"
          v-model="item.snNo"
          placeholder="请输入或扫码"
        />
        <!-- 只读状态:显示文本 -->
        <text v-if="current !== 'true'" class="col sn-text">{{ item.snNo }}</text>
        <button
          v-if="current === 'true'"
          class="col scan-btn"
          type="primary"
          @click="onScan(index)"
@@ -32,7 +38,7 @@
    </view>
    <view class="action-bar">
      <button type="success" @click="submit">保存</button>
      <button v-if="current === 'true'" type="success" @click="submit">保存</button>
    </view>
  </view>
</template>
@@ -43,12 +49,14 @@
    return {
      mid: null, // MES主表ID
      scanItems: [], // 从 MES_SJ_SCAN_ITEM_CK 获取
      current: 'true', // 控制是否可编辑
    };
  },
  onLoad(options) {
    // 假设从上一页传入 mid
    this.mid = options.id || null;
    this.current = options.current || 'true'; // 默认为可编辑状态
    this.getScanItems();
  },
@@ -92,7 +100,7 @@
      // #ifdef MP-WEIXIN
      uni.scanCode({
        success(res) {
        success(res){
          self.scanItems[index].snNo = res.result;
        },
        fail(err) {
@@ -110,7 +118,10 @@
      // #ifdef APP-PLUS
      uni.scanCode({
        scanType: ['barCode'],  // 新增这一行
        autoDecodeCharset: true, // 自动解码字符集
        success(res) {
            console.log(res)
          self.scanItems[index].snNo = res.result;
        },
      });