feat: 工作台改版并区分东大与新大陆扫码
This commit is contained in:
@@ -4,6 +4,9 @@ export const DICTIONARY_TYPE_SCANNER = 10046;
|
||||
|
||||
export const PHONE_SCAN_BRAND = 'phone';
|
||||
|
||||
// 历史误用 brand=newland 表示东集;真正的新大陆是 nlscan
|
||||
const LEGACY_SEUIC_BRANDS = ['newland', '东集', 'idata'];
|
||||
|
||||
export const PHONE_SCAN_CONFIG = {
|
||||
brand: PHONE_SCAN_BRAND,
|
||||
name: '手机扫码',
|
||||
@@ -16,6 +19,28 @@ export function isPhoneScanConfig(config) {
|
||||
return !!(config && (config.isPhoneScan || config.brand === PHONE_SCAN_BRAND));
|
||||
}
|
||||
|
||||
function migrateLegacySeuicBrand(config) {
|
||||
if (!config || isPhoneScanConfig(config)) {
|
||||
return config;
|
||||
}
|
||||
const brand = String(config.brand || '');
|
||||
const name = String(config.name || '');
|
||||
const action = String(config.action || '');
|
||||
// 历史内置配置把东集误标成 brand=newland;真正的新大陆是 nlscan
|
||||
const isLegacySeuicLabel = LEGACY_SEUIC_BRANDS.includes(brand) || name === '东集';
|
||||
if (!isLegacySeuicLabel) {
|
||||
return config;
|
||||
}
|
||||
if (action.includes('nlscan')) {
|
||||
return config;
|
||||
}
|
||||
return {
|
||||
...config,
|
||||
brand: 'seuic',
|
||||
name: (!name || name === '东集') ? '东大集成(AUTOID)' : name,
|
||||
};
|
||||
}
|
||||
|
||||
function enrichFromBuiltinConfig(config, builtinConfigs = []) {
|
||||
if (!config || !builtinConfigs.length) {
|
||||
return config;
|
||||
@@ -24,7 +49,13 @@ function enrichFromBuiltinConfig(config, builtinConfigs = []) {
|
||||
const builtin = builtinConfigs.find((item) => {
|
||||
return item.action === config.action
|
||||
|| item.name === config.name
|
||||
|| item.brand === config.brand;
|
||||
|| item.brand === config.brand
|
||||
|| (item.brand === 'seuic' && (
|
||||
String(config.name || '').includes('东大')
|
||||
|| String(config.name || '').includes('东集')
|
||||
|| String(config.name || '').includes('AUTOID')
|
||||
|| String(config.action || '').includes('scannerservice.broadcast')
|
||||
));
|
||||
});
|
||||
|
||||
if (!builtin) {
|
||||
@@ -49,7 +80,7 @@ export function normalizeConfig(raw, builtinConfigs = []) {
|
||||
return { ...PHONE_SCAN_CONFIG };
|
||||
}
|
||||
|
||||
const config = enrichFromBuiltinConfig({
|
||||
let config = {
|
||||
brand,
|
||||
name: raw.name || '',
|
||||
action: raw.action || raw.code || '',
|
||||
@@ -57,7 +88,10 @@ export function normalizeConfig(raw, builtinConfigs = []) {
|
||||
needSetup: raw.needSetup != null ? raw.needSetup : !!raw.need_setup,
|
||||
setupAction: raw.setupAction || raw.setup_action || '',
|
||||
setupParams: raw.setupParams || raw.setup_params || null,
|
||||
}, builtinConfigs);
|
||||
};
|
||||
|
||||
config = migrateLegacySeuicBrand(config);
|
||||
config = enrichFromBuiltinConfig(config, builtinConfigs);
|
||||
|
||||
if (!config.brand || !config.action || !config.dataKey) {
|
||||
return null;
|
||||
@@ -73,7 +107,16 @@ export function mapDictionaryToScannerConfig(raw, builtinConfigs = []) {
|
||||
export function getScanConfig(builtinConfigs = []) {
|
||||
try {
|
||||
const data = uni.getStorageSync(STORAGE_KEY);
|
||||
return normalizeConfig(data, builtinConfigs);
|
||||
const normalized = normalizeConfig(data, builtinConfigs);
|
||||
// 旧 brand=newland(东集) 迁移后写回,避免下次仍读到错误 brand
|
||||
if (normalized && data && String(data.brand || '') !== String(normalized.brand || '')) {
|
||||
try {
|
||||
uni.setStorageSync(STORAGE_KEY, normalized);
|
||||
} catch (e) {
|
||||
console.log('迁移扫码枪配置写回失败', e);
|
||||
}
|
||||
}
|
||||
return normalized;
|
||||
} catch (e) {
|
||||
console.log('读取扫码枪配置失败', e);
|
||||
return null;
|
||||
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
} from '@/common/scanConfig.js';
|
||||
|
||||
const PDA_DEVICE_KEYWORDS = [
|
||||
'newland', 'nls', 'sunmi', 'urovo', 'zebra', 'honeywell', 'idata', 'seuic',
|
||||
'newland', 'nls', 'nlscan', 'sunmi', 'urovo', 'zebra', 'honeywell',
|
||||
'idata', 'seuic', 'autoid', '东集', '东大',
|
||||
];
|
||||
|
||||
export default {
|
||||
@@ -29,16 +30,18 @@ export default {
|
||||
getScannerConfigs() {
|
||||
return [
|
||||
{
|
||||
brand: 'newland',
|
||||
name: '东集',
|
||||
// 东大集成 SEUIC / AUTOID 系列(如 AUTOID9),勿与新大陆 nlscan 混淆
|
||||
brand: 'seuic',
|
||||
name: '东大集成(AUTOID)',
|
||||
action: 'com.android.server.scannerservice.broadcast',
|
||||
dataKey: 'scannerdata',
|
||||
needSetup: true,
|
||||
setupAction: 'com.android.scanner.service_settings',
|
||||
setupParams: {
|
||||
barcode_send_mode: 'BROADCAST',
|
||||
action_barcode_broadcast: 'com.android.server.scannerservice.broadcast',
|
||||
key_barcode_broadcast: 'scannerdata',
|
||||
endchar: 'ENTER'
|
||||
endchar: 'NONE'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -56,6 +59,7 @@ export default {
|
||||
needSetup: false
|
||||
},
|
||||
{
|
||||
// 新大陆 Newland,广播为 nlscan.action.SCANNER_RESULT
|
||||
brand: 'nlscan',
|
||||
name: '新大陆',
|
||||
action: 'nlscan.action.SCANNER_RESULT',
|
||||
|
||||
Reference in New Issue
Block a user