| | |
| | | <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> |
| | | |
| | |
| | | <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)" |
| | |
| | | </view> |
| | | |
| | | <view class="action-bar"> |
| | | <button type="success" @click="submit">保存</button> |
| | | <button v-if="current === 'true'" type="success" @click="submit">保存</button> |
| | | </view> |
| | | </view> |
| | | </template> |
| | |
| | | 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(); |
| | | }, |
| | | |
| | |
| | | |
| | | // #ifdef MP-WEIXIN |
| | | uni.scanCode({ |
| | | success(res) { |
| | | success(res){ |
| | | self.scanItems[index].snNo = res.result; |
| | | }, |
| | | fail(err) { |
| | |
| | | |
| | | // #ifdef APP-PLUS |
| | | uni.scanCode({ |
| | | scanType: ['barCode'], // 新增这一行 |
| | | autoDecodeCharset: true, // 自动解码字符集 |
| | | success(res) { |
| | | console.log(res) |
| | | self.scanItems[index].snNo = res.result; |
| | | }, |
| | | }); |