feat(scan): 添加手机扫码功能支持
- 在 FabricOutScanBar 组件中添加手机扫码图标和事件处理 - 更新工作台页面的扫码逻辑以支持手机扫码回退 - 在销售拣货详情页添加手机扫码按钮和处理方法 - 重构扫码设置页面以支持扫码方式选择 - 添加手机扫码配置和判断逻辑到扫码配置模块 - 扩展扫码混入模块以支持手机扫码模式和设备检测 - 在多个业务页面中集成手机扫码功能和界面元素 - 更新扫码配置存储和读取逻辑以兼容新配置结构
This commit is contained in:
@@ -3,25 +3,27 @@
|
||||
<common-navbar title="扫描设置"></common-navbar>
|
||||
<u-gap height="20" bg-color="#f5f5f5"></u-gap>
|
||||
<u-cell-group :border="false">
|
||||
<u-cell-item title="PDA品牌" :value="form.name || '请选择'" @click="brandSelectShow = true"></u-cell-item>
|
||||
<u-cell-item title="广播动作" :arrow="false">
|
||||
<u-input
|
||||
slot="right-icon"
|
||||
v-model="form.action"
|
||||
placeholder="请输入广播动作"
|
||||
input-align="right"
|
||||
:clearable="false"
|
||||
></u-input>
|
||||
</u-cell-item>
|
||||
<u-cell-item title="数据标签" :arrow="false">
|
||||
<u-input
|
||||
slot="right-icon"
|
||||
v-model="form.dataKey"
|
||||
placeholder="请输入数据标签"
|
||||
input-align="right"
|
||||
:clearable="false"
|
||||
></u-input>
|
||||
</u-cell-item>
|
||||
<u-cell-item title="扫码方式" :value="form.name || '请选择'" @click="brandSelectShow = true"></u-cell-item>
|
||||
<template v-if="!form.isPhoneScan">
|
||||
<u-cell-item title="广播动作" :arrow="false">
|
||||
<u-input
|
||||
slot="right-icon"
|
||||
v-model="form.action"
|
||||
placeholder="请输入广播动作"
|
||||
input-align="right"
|
||||
:clearable="false"
|
||||
></u-input>
|
||||
</u-cell-item>
|
||||
<u-cell-item title="数据标签" :arrow="false">
|
||||
<u-input
|
||||
slot="right-icon"
|
||||
v-model="form.dataKey"
|
||||
placeholder="请输入数据标签"
|
||||
input-align="right"
|
||||
:clearable="false"
|
||||
></u-input>
|
||||
</u-cell-item>
|
||||
</template>
|
||||
</u-cell-group>
|
||||
<view class="form-footer">
|
||||
<u-button type="primary" :loading="submitting" @click="submit">确定</u-button>
|
||||
@@ -33,7 +35,14 @@
|
||||
<script>
|
||||
import CommonNavbar from '@/components/common-navbar/index';
|
||||
import scanMixin from '@/common/scanMixin.js';
|
||||
import { getScanConfig, DICTIONARY_TYPE_SCANNER, mapDictionaryToScannerConfig, saveScanConfig } from '@/common/scanConfig.js';
|
||||
import {
|
||||
getScanConfig,
|
||||
DICTIONARY_TYPE_SCANNER,
|
||||
isPhoneScanConfig,
|
||||
mapDictionaryToScannerConfig,
|
||||
PHONE_SCAN_BRAND,
|
||||
saveScanConfig,
|
||||
} from '@/common/scanConfig.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -50,6 +59,7 @@ export default {
|
||||
name: '',
|
||||
action: '',
|
||||
dataKey: '',
|
||||
isPhoneScan: false,
|
||||
needSetup: false,
|
||||
setupAction: '',
|
||||
setupParams: null,
|
||||
@@ -79,7 +89,7 @@ export default {
|
||||
this.configList = list
|
||||
.map((item) => mapDictionaryToScannerConfig(item, builtinConfigs))
|
||||
.filter(Boolean);
|
||||
this.remoteScannerConfigs = this.configList;
|
||||
this.remoteScannerConfigs = this.configList.filter((item) => !isPhoneScanConfig(item));
|
||||
} else {
|
||||
this.useFallbackConfigList();
|
||||
}
|
||||
@@ -87,28 +97,42 @@ export default {
|
||||
console.log('获取扫码枪字典配置失败,使用内置配置', error);
|
||||
this.useFallbackConfigList();
|
||||
}
|
||||
this.ensurePhoneScanOption();
|
||||
this.initFormFromSaved();
|
||||
},
|
||||
useFallbackConfigList() {
|
||||
this.configList = this.getScannerConfigs();
|
||||
this.remoteScannerConfigs = [];
|
||||
},
|
||||
ensurePhoneScanOption() {
|
||||
const phoneConfig = this.getPhoneScanConfig();
|
||||
if (!this.configList.find((item) => item.brand === PHONE_SCAN_BRAND)) {
|
||||
this.configList.push(phoneConfig);
|
||||
}
|
||||
},
|
||||
initFormFromSaved() {
|
||||
const savedConfig = getScanConfig();
|
||||
const savedConfig = getScanConfig(this.getScannerConfigs());
|
||||
if (savedConfig) {
|
||||
this.applyConfig(savedConfig);
|
||||
return;
|
||||
}
|
||||
if (this.configList.length) {
|
||||
this.applyConfig(this.configList[0]);
|
||||
if (!this.isPdaDevice()) {
|
||||
this.applyConfig(this.getPhoneScanConfig());
|
||||
return;
|
||||
}
|
||||
const pdaConfigs = this.configList.filter((item) => !isPhoneScanConfig(item));
|
||||
if (pdaConfigs.length) {
|
||||
this.applyConfig(pdaConfigs[0]);
|
||||
}
|
||||
},
|
||||
applyConfig(config) {
|
||||
const isPhoneScan = isPhoneScanConfig(config);
|
||||
this.form = {
|
||||
brand: config.brand || '',
|
||||
name: config.name || '',
|
||||
action: config.action || '',
|
||||
dataKey: config.dataKey || '',
|
||||
isPhoneScan,
|
||||
needSetup: !!config.needSetup,
|
||||
setupAction: config.setupAction || '',
|
||||
setupParams: config.setupParams || null,
|
||||
@@ -122,27 +146,31 @@ export default {
|
||||
}
|
||||
},
|
||||
submit() {
|
||||
const action = (this.form.action || '').trim();
|
||||
const dataKey = (this.form.dataKey || '').trim();
|
||||
|
||||
if (!this.form.brand) {
|
||||
this.$u.toast('请选择PDA品牌');
|
||||
return;
|
||||
}
|
||||
if (!action) {
|
||||
this.$u.toast('请输入广播动作');
|
||||
return;
|
||||
}
|
||||
if (!dataKey) {
|
||||
this.$u.toast('请输入数据标签');
|
||||
this.$u.toast('请选择扫码方式');
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
...this.form,
|
||||
action,
|
||||
dataKey,
|
||||
};
|
||||
let payload;
|
||||
if (this.form.isPhoneScan) {
|
||||
payload = this.getPhoneScanConfig();
|
||||
} else {
|
||||
const action = (this.form.action || '').trim();
|
||||
const dataKey = (this.form.dataKey || '').trim();
|
||||
if (!action) {
|
||||
this.$u.toast('请输入广播动作');
|
||||
return;
|
||||
}
|
||||
if (!dataKey) {
|
||||
this.$u.toast('请输入数据标签');
|
||||
return;
|
||||
}
|
||||
payload = {
|
||||
...this.form,
|
||||
action,
|
||||
dataKey,
|
||||
};
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
if (!saveScanConfig(payload)) {
|
||||
@@ -153,7 +181,7 @@ export default {
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
this.unregisterScanBroadcast();
|
||||
const registered = this.registerScanBroadcastByConfig(payload);
|
||||
const registered = this.registerScanBroadcastByConfig(payload, null);
|
||||
if (!registered) {
|
||||
this.submitting = false;
|
||||
this.$u.toast('保存成功,但广播注册失败');
|
||||
|
||||
@@ -140,10 +140,7 @@ export default {
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// #ifdef APP-PLUS
|
||||
// 使用 scanMixin 的方法注册扫码广播,传入自定义回调
|
||||
this.registerScanBroadcast(this.handleScanCode);
|
||||
// #endif
|
||||
},
|
||||
// onUnload, onHide, onShow 已由 scanMixin 自动处理
|
||||
|
||||
@@ -178,10 +175,10 @@ export default {
|
||||
},
|
||||
// 处理扫码(手动点击扫码按钮)
|
||||
handleScan() {
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/saleship/salepickscandetail?order_no=FPD-PB-202412270196'
|
||||
// })
|
||||
// return
|
||||
if (this.usePhoneScanFallback) {
|
||||
this.openPhoneScan();
|
||||
return;
|
||||
}
|
||||
// #ifdef APP-PLUS || MP-WEIXIN
|
||||
uni.scanCode({
|
||||
scanType: ['qrCode', 'barCode'], // 同时支持二维码和条形码
|
||||
|
||||
Reference in New Issue
Block a user