feat:样品库管理

This commit is contained in:
houjunxiang
2025-11-19 11:02:11 +08:00
parent 06210e79fd
commit 0494d224be
33 changed files with 1282 additions and 673 deletions

View File

@@ -0,0 +1,3 @@
{
"minSdkVersion": "21"
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
import Activity from 'android.app.Activity';
import IntentFilter from 'android.content.IntentFilter';
import BroadcastReceiver from 'android.content.BroadcastReceiver';
import Context from 'android.content.Context';
import Intent from 'android.content.Intent';
import ScanManager from 'android.device.ScanManager';
import PropertyID from 'android.device.scanner.configuration.PropertyID';
import { OnScanReceiverCallback } from '../../interface.uts';
export default class ScanBroadcastReceiver {
private static instance : ScanBroadcastReceiver = new ScanBroadcastReceiver();
private context : Context | null = null;
private scanBroadcastReceiver: UrovoScanBroadcastReceiver | null = null;
private scanManager: ScanManager | null = null;
private intentFilter: IntentFilter | null = null;
private constructor() {
}
static getInstance(context : Context | null) : ScanBroadcastReceiver {
ScanBroadcastReceiver.instance.context = context;
return ScanBroadcastReceiver.instance;
}
registerReceiver(callback: OnScanReceiverCallback) {
this.scanBroadcastReceiver = new UrovoScanBroadcastReceiver(callback);
if(this.scanManager == null) {
this.scanManager = new ScanManager();
this.scanManager!.openScanner();
this.scanManager!.switchOutputMode(0);
}
this.intentFilter = new IntentFilter();
let idbuf = intArrayOf(PropertyID.WEDGE_INTENT_ACTION_NAME, PropertyID.WEDGE_INTENT_DATA_STRING_TAG);
let value_buf = this.scanManager!.getParameterString(idbuf);
if (value_buf != null && value_buf[0] != null && !value_buf[0].equals("")) {
this.intentFilter!.addAction(value_buf[0]);
} else {
this.intentFilter!.addAction(ScanManager.ACTION_DECODE);
}
//this.intentFilter!.addAction(ScanManager.ACTION_CAPTURE_IMAGE);
UTSAndroid.getUniActivity()!.registerReceiver(this.scanBroadcastReceiver, this.intentFilter);
}
unregisterReceiver () {
let uniActivity: Activity | null = UTSAndroid.getUniActivity();
if(this.scanBroadcastReceiver != null) {
uniActivity!.unregisterReceiver(this.scanBroadcastReceiver);
}
//停止扫描
if (this.scanManager != null){
this.scanManager?.stopDecode();
}
this.scanBroadcastReceiver = null;
}
}
class UrovoScanBroadcastReceiver extends BroadcastReceiver {
private callback: OnScanReceiverCallback;
constructor(callback: OnScanReceiverCallback) {
super();
this.callback = callback;
}
override onReceive(context : Context, intent : Intent) {
let barcode = intent.getByteArrayExtra(ScanManager.DECODE_DATA_TAG);
let barcodelen = intent.getIntExtra(ScanManager.BARCODE_LENGTH_TAG, 0);
let temp = intent.getByteExtra(ScanManager.BARCODE_TYPE_TAG, 0);
console.log("----codetype--:" + temp);
if(barcode != null) {
let barcodeStr : string = new String(barcode, 0, barcodelen.toInt());
this.callback(barcodeStr);
}
}
}

View File

@@ -0,0 +1,3 @@
{
"deploymentTarget": "9"
}

View File

@@ -0,0 +1,85 @@
/**
* 引用 iOS 系统库,示例如下:
* import { UIDevice } from "UIKit";
* [可选实现,按需引入]
*/
/* 引入 interface.uts 文件中定义的变量 */
import { MyApiOptions, MyApiResult, MyApi, MyApiSync } from '../interface.uts';
/* 引入 unierror.uts 文件中定义的变量 */
import { MyApiFailImpl } from '../unierror';
/**
* 引入三方库
* [可选实现,按需引入]
*
* 在 iOS 平台引入三方库有以下两种方式:
* 1、通过引入三方库framework 或者.a 等方式,需要将 .framework 放到 ./Frameworks 目录下,将.a 放到 ./Libs 目录下。更多信息[详见](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#ios-平台原生配置)
* 2、通过 cocoaPods 方式引入,将要引入的 pod 信息配置到 config.json 文件下的 dependencies-pods 字段下。详细配置方式[详见](https://uniapp.dcloud.net.cn/plugin/uts-ios-cocoapods.html)
*
* 在通过上述任意方式依赖三方库后,使用时需要在文件中 import:
* 示例import { LottieLoopMode } from 'Lottie'
*/
/**
* UTSiOS 为平台内置对象,不需要 import 可直接调用其API[详见](https://uniapp.dcloud.net.cn/uts/utsios.html)
*/
/**
* 异步方法
*
* uni-app项目中vue/nvue调用示例
* 1、引入方法声明 import { myApi } from "@/uni_modules/uts-api"
* 2、方法调用
* myApi({
* paramA: false,
* complete: (res) => {
* console.log(res)
* }
* });
*
*/
export const myApi : MyApi = function (options : MyApiOptions) {
if (options.paramA == true) {
// 返回数据
const res : MyApiResult = {
fieldA: 85,
fieldB: true,
fieldC: 'some message'
};
options.success?.(res);
options.complete?.(res);
} else {
// 返回错误
let failResult = new MyApiFailImpl(9010001);
options.fail?.(failResult)
options.complete?.(failResult)
}
}
/**
* 同步方法
*
* uni-app项目中vue/nvue调用示例
* 1、引入方法声明 import { myApiSync } from "@/uni_modules/uts-api"
* 2、方法调用
* myApiSync(true);
*
*/
export const myApiSync : MyApiSync = function (paramA : boolean) : MyApiResult {
// 返回数据,根据插件功能获取实际的返回值
const res : MyApiResult = {
fieldA: 85,
fieldB: paramA,
fieldC: 'some message'
};
return res;
}
/**
* 更多插件开发的信息详见https://uniapp.dcloud.net.cn/plugin/uts-plugin.html
*/

View File

@@ -0,0 +1,54 @@
/**
* interface.uts
* uts插件接口定义文件按规范定义接口文件可以在HBuilderX中更好的做到语法提示
*/
/**
* myApi 异步函数的参数在type里定义函数需要的参数以及api成功、失败的相关回调函数。
*/
export type MyApiOptions = {
paramA : boolean
success ?: (res : MyApiResult) => void
fail ?: (res : MyApiFail) => void
complete ?: (res : any) => void
}
/**
* 函数返回结果
* 可以是void, 基本数据类型自定义type, 或者其他类型。
* [可选实现]
*/
export type MyApiResult = {
fieldA : number,
fieldB : boolean,
fieldC : string
}
/**
* 错误码
* 根据uni错误码规范要求建议错误码以90开头以下是错误码示例
* - 9010001 错误信息1
* - 9010002 错误信息2
*/
export type MyApiErrorCode = 9010001 | 9010002;
/**
* myApi 的错误回调参数
*/
export interface MyApiFail extends IUniError {
errCode : MyApiErrorCode
};
/* 异步函数定义 */
export type MyApi = (options : MyApiOptions) => void
/* 同步函数定义 */
export type MyApiSync = (paramA : boolean) => MyApiResult
/* 扫码接收回调 */
export type OnScanReceiverCallback = (data: string) => void;
/* 扫码注册 */
export type ScanRegister = (callback : OnScanReceiverCallback) => void
/* 扫码卸载 */
export type ScanUnRegister = () => void

View File

@@ -0,0 +1,39 @@
/* 此规范为 uni 规范,可以按照自己的需要选择是否实现 */
import { MyApiErrorCode, MyApiFail } from "./interface.uts"
/**
* 错误主题
* 注意:错误主题一般为插件名称,每个组件不同,需要使用时请更改。
* [可选实现]
*/
export const UniErrorSubject = 'zzjc-urovo';
/**
* 错误信息
* @UniError
* [可选实现]
*/
export const MyAPIErrors : Map<MyApiErrorCode, string> = new Map([
/**
* 错误码及对应的错误信息
*/
[9010001, 'custom error mseeage1'],
[9010002, 'custom error mseeage2'],
]);
/**
* 错误对象实现
*/
export class MyApiFailImpl extends UniError implements MyApiFail {
/**
* 错误对象构造函数
*/
constructor(errCode : MyApiErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = MyAPIErrors.get(errCode) ?? "";
}
}