commit 26bb4704954c63b465deb2574b75930bcb71588a Author: 马超 <871197610@qq.com> Date: Fri Oct 24 10:43:44 2025 +0800 首次提交 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66d763e --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer +/entry/.preview/ +/entry/build/ +/entry/oh_modules/ diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000..66bb3aa --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,11 @@ +{ + "app": { + "bundleName": "com.rs.rchl", + "vendor": "example", + "versionCode": 1002, + "versionName": "1.0.2", + "icon": "$media:ic_applogin", + "label": "$string:app_name", + + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000..cf7e48e --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "人车物核验" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000..a39445d Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/AppScope/resources/base/media/ic_applogin.png b/AppScope/resources/base/media/ic_applogin.png new file mode 100644 index 0000000..ffd6ea1 Binary files /dev/null and b/AppScope/resources/base/media/ic_applogin.png differ diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000..c0272b9 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,55 @@ +{ + "app": { + "signingConfigs": [ + { + "name": "default", + "type": "HarmonyOS", + "material": { + "storeFile": "D:/HuaweiKey/ruansee.p12", + "storePassword": "00000019B0DB8FE574FD50A879BBF742834E5E7C42686D2544E206B2B9574BD89950A2BC085D9EB5DA", + "keyAlias": "ruansee", + "keyPassword": "00000019EB933EC3D92A04C62A54ED52F7E484900F0D627B11FFF05C3C1C1024D88A15D218823F5BF5", + "signAlg": "SHA256withECDSA", + "profile": "D:/HuaweiKey/rcwhy/ruanss_rcwhy_debugDebug.p7b", + "certpath": "D:/HuaweiKey/rcwhy/ruansee_rcwhy_debug.cer" + } + } + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.1(13)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000..77b31b5 --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,20 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/entry/.gitignore b/entry/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000..4d61187 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000..c6edcd9 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/libs/tdos_sdk_js.har b/entry/libs/tdos_sdk_js.har new file mode 100644 index 0000000..49bfc8a Binary files /dev/null and b/entry/libs/tdos_sdk_js.har differ diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package-lock.json5 b/entry/oh-package-lock.json5 new file mode 100644 index 0000000..b1873bc --- /dev/null +++ b/entry/oh-package-lock.json5 @@ -0,0 +1,37 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@kit/tdos@libs/tdos_sdk_js.har": "@kit/tdos@libs/tdos_sdk_js.har", + "@pura/harmony-dialog@1.0.7": "@pura/harmony-dialog@1.1.8", + "@pura/spinkit@^1.0.5": "@pura/spinkit@1.0.5" + }, + "packages": { + "@kit/tdos@libs/tdos_sdk_js.har": { + "name": "@kit/tdos", + "version": "5.0.1", + "resolved": "libs/tdos_sdk_js.har", + "registryType": "local" + }, + "@pura/harmony-dialog@1.1.8": { + "name": "@pura/harmony-dialog", + "version": "1.1.8", + "integrity": "sha512-IG2BJti8LBvJvkAD7yLwk6F2D66BGYPt6mae2yqAB9hMU5HnOTslWJbrReN9qPQl+ssIjSahMC7aJexEFYm5Dw==", + "resolved": "https://repo.harmonyos.com/ohpm/@pura/harmony-dialog/-/harmony-dialog-1.1.8.har", + "registryType": "ohpm", + "dependencies": { + "@pura/spinkit": "^1.0.5" + } + }, + "@pura/spinkit@1.0.5": { + "name": "@pura/spinkit", + "version": "1.0.5", + "integrity": "sha512-EKG+yzbCj/owI5zUYukIZV+YMRbeS/Ymd281Dj5asCKQHTWoEUVGmow3HCo7rl2Bdh8yliIT/StxPokUf8a6bQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@pura/spinkit/-/spinkit-1.0.5.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000..dc3153f --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "@pura/harmony-dialog": "1.0.7", + "@kit/tdos": "file:libs/tdos_sdk_js.har" + } +} + diff --git a/entry/src/main/ets/app/AppCache.ets b/entry/src/main/ets/app/AppCache.ets new file mode 100644 index 0000000..8ca0bb5 --- /dev/null +++ b/entry/src/main/ets/app/AppCache.ets @@ -0,0 +1,309 @@ +import { buffer, util } from "@kit.ArkTS"; +import { StringUtils } from "../util/StringUtils"; +import { geoLocationManager } from "@kit.LocationKit"; +import { UserInfoModel } from "../request/data/UserInfoModel"; +import { UserCache } from "./UserCache"; +import { getCoordinateDescription } from "../request/api/Api"; +import { AxiosError } from "@ohos/axios"; +import { IdGeneratedUtils } from "../util/IdGeneratedUtils"; + +export class AppCache { + private static appCache: AppCache = new AppCache(); + private idGeneratedUtils :IdGeneratedUtils|undefined=undefined; + + /*请求服务的Ip*/ + private ip: string | undefined = undefined + /*请求服务的端口*/ + private port: string | undefined = undefined + private serviceNodeName:string = "/yhc_out/" + + //用于存放品高的Token + private pgToken :string| undefined = undefined; + + //权限状态 + private permissionsStatus: boolean = false; + + /* TODO 临时人员ID 用于避免每次查询都直接改变peopleId,导致查询失败后,之前查询的人员信息和ID对不上 */ + private peopleTemporarilyId: string = "" + /* TODO 人员ID 只有当查询成功时才将 tempPeopleId的值 赋给 peopleId */ + private peopleId: string = "" + /*车辆ID*/ + private carId: string = "" + /* TODO 主ID 由APP生成 传递给后端 */ + private historyId: string = "" + /*物品ID*/ + // private goodsId:string ="" + + /*缓存的物品数据*/ + private goodsJson: string = "" + //本机IP + private localIp: string |undefined= ""; + + /*任务id*/ + private taskId: string|undefined = "" + + private taskName:string|undefined = "" + /*卡点id*/ + private cardPointId: string|undefined = "" + private cardPointName :string|undefined= "" + + //定位的坐标 + private locationX: number = 0.0; + private locationY: number = 0.0; + + //卡点的坐标 + private cardPointX: string = "0.0"; + private cardPointY: string = "0.0"; + + private locationAddress:string|undefined=""; + private cardPointAddress:string|undefined=""; + + private constructor() { + + } + + // + public static getAppCache(): AppCache { + if (AppCache.appCache == null) { + AppCache.appCache = new AppCache() + } + return AppCache.appCache; + } + + /** + * 服务节点 + * @param ip + * @param port + * @param serviceName + */ + public setIpOrPort(ip:string,port:string,serviceNodeName:string){ + this.ip = ip; + this.port = port; + this.serviceNodeName = serviceNodeName; + } + + public getServiceAddress(){ + return 'http://'+this.ip+":"+this.port+this.serviceNodeName + } + + /** + * 获取一个随机ID 生存规则 四位随机数 + 随机UUID+ 四位随机数 + * @returns + */ + public getRandomId(): string { + if (this.idGeneratedUtils == undefined) { + this.idGeneratedUtils = IdGeneratedUtils.getInstance(UserCache.getUserCache().getIdCardNum) + } + return this.idGeneratedUtils.generatedRandomID(); + // return (Math.round(1000) + 1000) + util.generateRandomUUID(false) + (Math.round(1000) + 1000) + } + + /** + * 将临时人员ID设为ID + * 在查询人员成功后调用 + */ + public temporarilyPeopleIdEffect() { + this.peopleId = this.peopleTemporarilyId + this.peopleTemporarilyId = ""; + } + + /** + * TODO 创建一个临时的人员ID,用于查询人员信息时传参,当查询人员成功后,再赋值给{ peopleId } + * + */ + public createPeopleTemporarilyId() { + this.peopleTemporarilyId = this.getRandomId(); + } + + public getPeopleTemporarilyId(): string { + if (StringUtils.isNullOrEmpty(this.peopleTemporarilyId)) { + this.peopleTemporarilyId = this.getRandomId(); + } + return this.peopleTemporarilyId; + } + + public getPeopleId(): string { + if (StringUtils.isNullOrEmpty(this.peopleId)) { + this.peopleId = this.getPeopleTemporarilyId(); + } + return this.peopleId + } + + public getCarId(): string { + if (StringUtils.isNullOrEmpty(this.carId)) { + this.carId = this.getRandomId(); + } + return this.carId; + } + + public getHistoryId(): string { + if (StringUtils.isNullOrEmpty(this.historyId)) { + this.historyId = this.getRandomId(); + } + return this.historyId; + } + + /** + * TODO 仅在初始化页面和提交或移交完成后调用 + * 重置ID + */ + public resetIds(){ + this.historyId = this.getRandomId(); + this.peopleId = this.getRandomId(); + this.carId = this.getRandomId(); + this.createPeopleTemporarilyId() + } + + /** + * 提交成功重置id Submitted successfully + */ + public submitSuccessResetIDs(){ + this.peopleId = "" + this.peopleTemporarilyId = "" + this.carId = "" + this.historyId = "" + this.peopleId = "" + this.peopleId = "" + } + + + /** + * 权限状态 + * @returns + */ + get getPermissionsStatus(): boolean { + return this.permissionsStatus; + } + + set setPermissionsStatus(permissionsStatus: boolean) { + this.permissionsStatus = permissionsStatus; + } + + public setLocation(location :geoLocationManager.Location){ + if (location == null) return + this.locationX = location.longitude; + this.locationY = location.latitude; + } + + public getLocationX():number{ + return this.locationX; + } + public getLocationY():number{ + return this.locationY; + } + + public setCardLocation(cardPointX:string,cardPointY:string,address:string){ + this.cardPointX = cardPointX; + this.cardPointY = cardPointY; + this.cardPointAddress = address; + } + + public getCardPointLocationX():string{ + return this.cardPointX; + } + public getCardPointLocationY():string{ + return this.cardPointY; + } + + public set setLocalIp(localIp :string|undefined){ + this.localIp = localIp; + } + + public get getLocalIp():string|undefined{ + return this.localIp; + } + + public get getPgToken():string|undefined{ + return this.pgToken + } + + public set setPgToken(pgToken:string){ + this.pgToken = pgToken; + } + + public get getTaskId(){ + if(StringUtils.isNullOrEmpty(this.taskId)){ + return ""; + } + if (this.taskId != undefined){ + return this.taskId; + } + return '' + } + + public set setTaskId(taskId:string|undefined){ + this.taskId = taskId; + } + + public get getTaskName():string{ + if(StringUtils.isNullOrEmpty(this.taskName)){ + return ""; + } + if (this.taskName != undefined){ + return this.taskName; + } + return '' + } + + public set setTaskName(taskName:string|undefined){ + this.taskName = taskName; + } + + public get getCardPointIdId(){ + if(StringUtils.isNullOrEmpty(this.cardPointId)){ + return ""; + } + if (this.cardPointId != undefined){ + return this.cardPointId; + } + return '' + } + + public set setCardPointId(cardPointId:string|undefined){ + this.cardPointId = cardPointId; + } + + public get getCardPointName():string{ + if(StringUtils.isNullOrEmpty(this.cardPointName)){ + return ""; + } + if (this.cardPointName != undefined){ + return this.cardPointName; + } + return '' + } + + public set setCardPointName(cardPointName:string|undefined){ + this.cardPointName = cardPointName; + } + + public get getLocationAddress():string{ + if(StringUtils.isNullOrEmpty(this.locationAddress)){ + return ""; + } + if (this.locationAddress != undefined){ + return this.locationAddress; + } + return '' + } + + public set setLocationAddress(locationAddress:string|undefined){ + this.locationAddress = locationAddress; + } + + public get getCardPointAddress():string{ + if(StringUtils.isNullOrEmpty(this.cardPointAddress)){ + return ""; + } + if (this.cardPointAddress != undefined){ + return this.cardPointAddress; + } + return '' + } + + convertPhotoUrl(photoUrl:string):string{ + if (StringUtils.isNullOrEmpty(photoUrl)) return"" + return photoUrl.replace("http://53.1.214.228:9000/ypc","http://20.90.2.2/rcwhy_image_out") + .replace("http://53.1.227.17:9000/ypc","http://20.90.2.2/rcwhy_image_out") + } +} \ No newline at end of file diff --git a/entry/src/main/ets/app/AppConstant.ets b/entry/src/main/ets/app/AppConstant.ets new file mode 100644 index 0000000..e51af6d --- /dev/null +++ b/entry/src/main/ets/app/AppConstant.ets @@ -0,0 +1,36 @@ + +export default class AppConstants { + + /** + * Maximum width. + */ + static readonly PERCENTAGE_MAX: string = '100%'; + + /** + * 品高的appID和secret + */ + static readonly PG_APP_KEY_SECRET='ksSt5bxNze8SBsPXGt6f:pkPaXjZCHTnzhZhMAhAn8YYbZ6r2H7' + + /** + * 盘查方式 - 输入 + */ + static readonly CHECK_TYPE_INPUT = 0; + /** + * 盘查方式 - NFC读卡 + */ + static readonly CHECK_TYPE_NFC = 1; + /** + * 盘查方式 - 人像识别 + */ + static readonly CHECK_TYPE_FACE = 2; + /** + * 盘查方式 - 语音 + */ + static readonly CHECK_TYPE_AUDIO = 3; + /** + * 盘查方式 - OCR识别 + */ + static readonly CHECK_TYPE_OCR = 4; + + +} \ No newline at end of file diff --git a/entry/src/main/ets/app/JointType.ets b/entry/src/main/ets/app/JointType.ets new file mode 100644 index 0000000..9d14ec0 --- /dev/null +++ b/entry/src/main/ets/app/JointType.ets @@ -0,0 +1,8 @@ +import { HashMap } from "@kit.ArkTS"; + + +// 定义联合类型(根据实际需求调整泛型参数) +export type CustomUnionType = + string | // 字符串类型 + Map | // 键为string、值为number的Map + Array; // 元素为string的数组 diff --git a/entry/src/main/ets/app/PCCacheData.ets b/entry/src/main/ets/app/PCCacheData.ets new file mode 100644 index 0000000..a2d2b28 --- /dev/null +++ b/entry/src/main/ets/app/PCCacheData.ets @@ -0,0 +1,106 @@ +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil"; +import { StrUtil } from "@pura/harmony-utils/src/main/ets/utils/StrUtil"; +import { CarData } from "../model/resultModel/CheckCarResultModel"; + +export class PCCacheData { + public static pcCacheData: PCCacheData = new PCCacheData(); + /*盘查人员总数*/ + zcCount: number = 0; + /*异常人员数*/ + yiCount: number = 0; + /*物品数据*/ + wpCount: number = 0; + /*现场照片url*/ + xczpUrl: string = ""; + /*现场照片Id*/ + xczpId: string = ""; + /*照片文件*/ + // photoFile: string = ""; + /*人员关注类型*/ + // focusType: number = 0; + carJson: string = ""; + carPeopleTypeJson: string = ""; + goodsJson: string = ""; + /*是否有现场招片 1 :true 0 :false*/ + isXczp: boolean = false; + /*已盘查的身份证集合 避免一次盘查 核查同一个人多次*/ + sfzhArray: Array = new Array + idCardPhoto: string | Resource = ""; + + private constructor() { + + } + + public addYcPeople() { + this.yiCount++; + } + + public addZcPeople() { + this.zcCount++; + } + + public get getYiCount(): number { + return this.yiCount; + } + + public get getZcCount(): number { + return this.zcCount; + } + + set setYcCount(ycCount: number) { + this.yiCount = ycCount; + } + + set setZcCount(ZcCount: number) { + this.zcCount = ZcCount; + } + + /** + * 是否一盘查过该人员 + * @param idCard + * @returns true表示已经盘查过 + */ + public isCheck(idCard: string): boolean { + let index = this.sfzhArray.indexOf(idCard); + if (index > -1) { + return true + } + return false; + } + + public saveQuerySfzh(idCard: string) { + if (StrUtil.isNotEmpty(idCard)) { + if (this.sfzhArray != null) { + this.sfzhArray.push(idCard) + } + } + } + + public clear() { + this.sfzhArray = new Array; + this.isXczp = false; + this.zcCount = 0; + this.yiCount = 0; + this.wpCount = 0; + this.carJson = ""; + this.goodsJson = "" + this.carPeopleTypeJson = ""; + this.idCardPhoto = ""; + this.xczpUrl = ""; + this.xczpId = ""; + } + + + public isCanExit(carHit: string): boolean { + if (this.zcCount != 0) return false + if (this.sfzhArray.length>0) return false + if (StrUtil.isNotEmpty(this.carJson)&&JSONUtil.isJSONStr(this.carJson)) return false + if (StrUtil.isNotEmpty(this.goodsJson)&&JSONUtil.isJSONStr(this.goodsJson)) return false + if ("添加随行车辆" != carHit) return false + return true + } + + +} + + diff --git a/entry/src/main/ets/app/RuanseeAbitityStag.ets b/entry/src/main/ets/app/RuanseeAbitityStag.ets new file mode 100644 index 0000000..d92b03e --- /dev/null +++ b/entry/src/main/ets/app/RuanseeAbitityStag.ets @@ -0,0 +1,51 @@ +import { AbilityConstant, AbilityStage, Configuration, Want } from "@kit.AbilityKit"; +import { StringUtils } from "../util/StringUtils"; +import { hilog } from "@kit.PerformanceAnalysisKit"; +import { AppCache } from "./AppCache"; +import { UserCache } from "./UserCache"; +import { tdvision } from '@kit.TdosVisionkit' + +export class RuanseeAbitityStag extends AbilityStage{ + + public static appCache:AppCache; + public static userCache:UserCache; + + onCreate(): void { + hilog.info(0x0000, 'RuanseeAbitityStag', '%{public}s', 'AbilityStage onCreate()'); + RuanseeAbitityStag.appCache = AppCache.getAppCache(); + RuanseeAbitityStag.appCache.setIpOrPort('20.90.2.2', '80', "/ypc_test_out/") + RuanseeAbitityStag.userCache = UserCache.getUserCache(); + tdvision.setup() + } + + onAcceptWant(want: Want): string { + hilog.info(0x0000, 'RuanseeAbitityStag', '%{public}s', 'AbilityStage onAcceptWant()'); + return StringUtils.get(want.abilityName,""); + } + + onNewProcessRequest(want: Want): string { + hilog.info(0x0000, 'RuanseeAbitityStag', '%{public}s', 'AbilityStage onNewProcessRequest()'); + return StringUtils.get(want.abilityName,""); + } + + onMemoryLevel(level: AbilityConstant.MemoryLevel): void { + hilog.info(0x0000, 'RuanseeAbitityStag', '%{public}s', 'AbilityStage onMemoryLevel()'); + + } + + onConfigurationUpdate(newConfig: Configuration): void { + hilog.info(0x0000, 'RuanseeAbitityStag', '%{public}s', 'AbilityStage onConfigurationUpdate()'); + + } + /** + * 转换图片IP和端口 + * + * @return http://ip:端口 + */ + public static convertPhotoUrl( photoUrl:string) :string{ + if (StringUtils.isNullOrEmpty(photoUrl)) return ""; + return photoUrl.replace("http://53.1.214.228:9000/ypc","http://20.90.2.2/rcwhy_image_out") + .replace("http://53.1.227.17:9000/ypc","http://20.90.2.2/rcwhy_image_out"); +} + +} \ No newline at end of file diff --git a/entry/src/main/ets/app/UserCache.ets b/entry/src/main/ets/app/UserCache.ets new file mode 100644 index 0000000..6cce1d6 --- /dev/null +++ b/entry/src/main/ets/app/UserCache.ets @@ -0,0 +1,118 @@ +import { StringUtils } from "../util/StringUtils"; +import { preferences } from '@kit.ArkData'; +import { UserInfoModel } from "../request/data/UserInfoModel"; +import { AppCache } from "./AppCache"; +import { buffer, util } from "@kit.ArkTS"; + +const preferencesName = "CacheNae"; + +export class UserCache { + public static userCache: UserCache = new UserCache(); + private userName: string = ""; + private userCode: string = ""; + private deptName: string = ""; + private deptCode: string = ""; + private idCardNum: string = ""; + private phoneNum: string = ""; + private userInfo: string = ""; + private authToken: string = "" + private profilePhoto: string = ""; + + private constructor() { + } + + public static getUserCache(): UserCache { + if (UserCache.userCache == null) { + UserCache.userCache = new UserCache(); + } + return UserCache.userCache; + } + + + get getUserName(): string { + return this.userName; + } + + set setUserName(userName:string){ + this.userName = userName; + } + + get getUserCode(): string { + return this.userCode; + } + + set setUserCode(userCode:string){ + this.userCode = userCode; + } + + get getDeptName(): string { + return this.deptName; + } + + set setDeptName(deptName:string){ + this.deptName = deptName; + } + + get getDeptCode(): string { + return this.deptCode; + } + + set setDeptCode(deptCode:string){ + this.deptCode = deptCode; + } + + get getPhoneNum(): string { + return this.phoneNum; + } + + set setPhoneNum(phoneNum:string){ + this.phoneNum = phoneNum; + } + + get getIdCardNum(): string { + return this.idCardNum; + } + + set setIdCardNum(idCardNum:string){ + this.idCardNum = idCardNum; + } + + public getUserInfo():string{ + if (StringUtils.isNullOrEmpty(this.userInfo)) { + let cs: UserInfoModel = { + "userName":UserCache.getUserCache().getUserCode , + "realName": UserCache.getUserCache().getUserName, + "orgName":UserCache.getUserCache().getDeptName, + "orgCode": UserCache.getUserCache().getDeptCode, + "idCardNum": UserCache.getUserCache().getIdCardNum, + "ip":AppCache.getAppCache().getLocalIp||"10.115.101.1" + } + let userInfo = JSON.stringify(cs) + let byte = new Uint8Array(buffer.from(userInfo, 'utf-8').buffer); + this.userInfo = new util.Base64Helper().encodeToStringSync(byte); + } + return this.userInfo + } + + public set setUserInfo(userInfo:string){ + this.userInfo = userInfo; + } + + + get getAuthToken(): string { + return this.authToken; + } + + set setAuthToken(authToken:string){ + this.authToken = authToken; + } + + get getProfilePhoto(): string { + return this.profilePhoto; + } + + set setProfilePhoto(profilePhoto:string){ + this.profilePhoto = profilePhoto; + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/callbcak/ResultCallback.ets b/entry/src/main/ets/callbcak/ResultCallback.ets new file mode 100644 index 0000000..2735d61 --- /dev/null +++ b/entry/src/main/ets/callbcak/ResultCallback.ets @@ -0,0 +1,8 @@ + + +export interface ResultCallBack { + + onResult:(model?: T)=> void; + +} + diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000..feedff4 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,146 @@ +import { abilityAccessCtrl, AbilityConstant, bundleManager, Permissions, UIAbility, Want,common } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { router, window } from '@kit.ArkUI'; +import { UserCache } from '../app/UserCache'; +import { AppCache } from '../app/AppCache'; +import { ToastUtils } from '../util/ToasUtils'; +import { AppUtil } from '@pura/harmony-utils'; +import { DialogHelper } from '@pura/harmony-dialog'; +import { DBUtils } from '../model/db/DBUtils'; +import { FileUtils } from '../util/FileUtils'; + +export default class EntryAbility extends UIAbility { + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + AppUtil.init(this.context); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + UserCache.getUserCache() + //初始化数据库 + DBUtils.getInstance().HOInit(this.context) + FileUtils.init(this.context) + this.applyForPermission() + // 在Ability中监听事件 + this.context.eventHub.on('ui_event', (data:Array) => { + // console.log('Received UI event:', data); + if (data!=null) { + this.requestPermissionsFromUser(data) + } + }); + + //简单初始化(1.0.8版本及以后) + //必须在UIAbility的onCreate方法里初始化context。 + DialogHelper.setDefaultConfig((config) => { + config.uiAbilityContext = this.context; + }) + } + + checkPermissionGrant(permissionArray: Array) { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() + // 获取应用程序的accessTokenID + let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION) + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo + let tokenId: number = appInfo.accessTokenId + let wsqPermissionArray = new Array() + for (let i = 0; i < permissionArray.length; i++) { + let grantStatus = atManager.checkAccessTokenSync(tokenId, permissionArray[i]) + if (grantStatus == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { + wsqPermissionArray.push(permissionArray[i]) + } + } + if (wsqPermissionArray.length>0) { + //有未申请的权限 + this.requestPermissionsFromUser(wsqPermissionArray) + } else { + //权限全部申请 + AppCache.getAppCache().setPermissionsStatus = true; + } + } + + /** + *AUTHOR:AbnerMing + *INTRODUCE:向用户获取权限授权 + */ + requestPermissionsFromUser(permissions: Array) { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() + let uiContext :common.UIAbilityContext = this.context as common.UIAbilityContext; + atManager.requestPermissionsFromUser(uiContext, permissions) + .then((data) => { + let grantStatus: Array = data.authResults; + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] === 0) { + // 用户授权,可以继续访问目标操作 + console.log("===用户授权") + router.replaceUrl({ url: 'ui/pages/MainPages' }); + } else { + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 + ToastUtils.toastCenter("您拒绝了权限,请到设置里打开!") + console.log("===用户拒绝了授权") + return + } + } + console.log("===权限授权成功") + }) + } + + /** + *AUTHOR:AbnerMing + *INTRODUCE:校验应用是否被授予权限 + */ + private getGrantStatus(permissionName: Permissions): abilityAccessCtrl.GrantStatus { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() + // 获取应用程序的accessTokenID + let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION) + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo + let tokenId: number = appInfo.accessTokenId + //检查权限状态 + let grantStatus = atManager.checkAccessTokenSync(tokenId, permissionName) + return grantStatus + } + + //申请权限 + applyForPermission() { + let permissions = new Array(); + permissions.push('ohos.permission.LOCATION') + permissions.push('ohos.permission.APPROXIMATELY_LOCATION') + permissions.push('ohos.permission.MICROPHONE') + permissions.push('ohos.permission.CAMERA') + this.checkPermissionGrant(permissions) + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability 600782 3675 + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + windowStage.getMainWindow().then((window=>{ + window.setWindowLayoutFullScreen(true) + })) + windowStage.loadContent('ui/pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } + + +} diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000..dc55c03 --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,12 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/AudioCapturer.ts b/entry/src/main/ets/model/AudioCapturer.ts new file mode 100644 index 0000000..b266b9d --- /dev/null +++ b/entry/src/main/ets/model/AudioCapturer.ts @@ -0,0 +1,118 @@ +import {audio} from '@kit.AudioKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const TAG = 'AudioCapturer'; + +/** + * Audio collector tool + */ +export default class AudioCapturer { + /** + * Collector object + */ + private mAudioCapturer = null; + + /** + * Audio Data Callback Method + */ + private mDataCallBack: (data: ArrayBuffer) => void = null; + + /** + * Indicates whether recording data can be obtained. + */ + private mCanWrite: boolean = true; + + /** + * Audio stream information + */ + private audioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_16000, + channels: audio.AudioChannel.CHANNEL_1, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + } + + /** + * Audio collector information + */ + private audioCapturerInfo = { + source: audio.SourceType.SOURCE_TYPE_MIC, + capturerFlags: 0 + } + + /** + * Audio Collector Option Information + */ + private audioCapturerOptions = { + streamInfo: this.audioStreamInfo, + capturerInfo: this.audioCapturerInfo + } + + /** + * Initialize + * @param audioListener + */ + public async init(dataCallBack: (data: ArrayBuffer) => void) { + if (null != this.mAudioCapturer) { + hilog.error(0x0000, TAG, 'AudioCapturerUtil already init'); + return; + } + this.mDataCallBack = dataCallBack; + this.mAudioCapturer = await audio.createAudioCapturer(this.audioCapturerOptions).catch(error => { + hilog.error(0x0000, TAG, `AudioCapturerUtil init createAudioCapturer failed, code is ${error.code}, message is ${error.message}`); + }); + } + + /** + * start recording + */ + public async start() { + hilog.error(0x0000, TAG, `AudioCapturerUtil start`); + let stateGroup = [audio.AudioState.STATE_PREPARED, audio.AudioState.STATE_PAUSED, audio.AudioState.STATE_STOPPED]; + if (stateGroup.indexOf(this.mAudioCapturer.state) === -1) { + hilog.error(0x0000, TAG, `AudioCapturerUtil start failed`); + return; + } + this.mCanWrite = true; + await this.mAudioCapturer.start(); + while (this.mCanWrite) { + let bufferSize = await this.mAudioCapturer.getBufferSize(); + let buffer = await this.mAudioCapturer.read(bufferSize, true); + this.mDataCallBack(buffer) + } + } + + /** + * stop recording + */ + public async stop() { + if (this.mAudioCapturer.state !== audio.AudioState.STATE_RUNNING && this.mAudioCapturer.state !== audio.AudioState.STATE_PAUSED) { + hilog.error(0x0000, TAG, `AudioCapturerUtil stop Capturer is not running or paused`); + return; + } + this.mCanWrite = false; + await this.mAudioCapturer.stop(); + if (this.mAudioCapturer.state === audio.AudioState.STATE_STOPPED) { + hilog.info(0x0000, TAG, `AudioCapturerUtil Capturer stopped`); + } else { + hilog.error(0x0000, TAG, `Capturer stop failed`); + } + } + + /** + * release + */ + public async release() { + if (this.mAudioCapturer.state === audio.AudioState.STATE_RELEASED || this.mAudioCapturer.state === audio.AudioState.STATE_NEW) { + hilog.error(0x0000, TAG, `Capturer already released`); + return; + } + await this.mAudioCapturer.release(); + this.mAudioCapturer = null; + if (this.mAudioCapturer.state == audio.AudioState.STATE_RELEASED) { + hilog.info(0x0000, TAG, `Capturer released`); + } else { + hilog.error(0x0000, TAG, `Capturer release failed`); + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/db/DBUtils.ets b/entry/src/main/ets/model/db/DBUtils.ets new file mode 100644 index 0000000..502023a --- /dev/null +++ b/entry/src/main/ets/model/db/DBUtils.ets @@ -0,0 +1,60 @@ +import { EventParamsBaseType, IEventSender, Rdb, RdbDao, RdbDatabase } from "rdbstore" +import { relationalStore } from "@kit.ArkData"; +import { DeptTableEntity } from "./TableEntity"; + +export class DBUtils { + private static dbUtils: DBUtils = new DBUtils() + private static dbVersion = 1; + private static dbName = 'rcwhy.db'; + private static database: RdbDatabase; + private static deptDao: RdbDao + + private constructor() { + + } + + static getInstance(): DBUtils { + if (!DBUtils.dbUtils) { + DBUtils.dbUtils = new DBUtils(); + } + return DBUtils.dbUtils; + } + + getDatabase():RdbDatabase{ + return DBUtils.database; + } + + async getDeptDao(): Promise> { + if (!DBUtils.deptDao) { + DBUtils.deptDao = await DBUtils.database.getDao(DeptTableEntity) + } + return DBUtils.deptDao; + } + + + //TODO 该方法请在 UIAbility onCreate 方法中初始化 + async HOInit(context: Context) { + DBUtils.database = Rdb.databaseBuilder(context, { + version: DBUtils.dbVersion, + dbName: DBUtils.dbName, + entities: [DeptTableEntity], + migrations: [], + encrypt: false, + securityLevel: relationalStore.SecurityLevel.S1, + autoMigrate: true + })// .setLogger(new DBLog()) + .setEvent(new EventSender()) + .build() + await DBUtils.database.initTask + DBUtils.database.getDao(DeptTableEntity).then((res) => { + DBUtils.deptDao = res; + }) + } + + +} +export class EventSender implements IEventSender { + send(key: string, params: Record): void { + console.log(`rdbStore key: ${key}, params: ${JSON.stringify(params)}`) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/db/TableEntity.ets b/entry/src/main/ets/model/db/TableEntity.ets new file mode 100644 index 0000000..68694c1 --- /dev/null +++ b/entry/src/main/ets/model/db/TableEntity.ets @@ -0,0 +1,23 @@ +import { Columns, ColumnType, Entity } from "rdbstore"; + +@Entity({ + tableName: 'deptTable' + // index: [{ name: 'idIndex', columnName: ['age', 'id'] }, + // { name: 'idIndex2', columnName: ['id'], unique: true }] +}) +export class DeptTableEntity { + + @Columns({ + name: 'deptId', + type: ColumnType.TEXT, + isPrimaryKey: true, + }) + deptId: string | null = null; + @Columns({ name: 'deptName', type: ColumnType.TEXT }) + deptName: string | null = null + @Columns({ name: 'parentId', type: ColumnType.TEXT }) + parentId: string | null = null + @Columns({ name: 'updateTime', type: ColumnType.TEXT }) + updateTime: string | null = null + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/requestModel/CheckRequestModel.ets b/entry/src/main/ets/model/requestModel/CheckRequestModel.ets new file mode 100644 index 0000000..6fc5b21 --- /dev/null +++ b/entry/src/main/ets/model/requestModel/CheckRequestModel.ets @@ -0,0 +1,175 @@ + +/** + * 盘查相关请求数据模型 + */ + +/*盘查人员请求模型*/ +export class CheckPersonRequestModel{ + //人员json数据 + data?:string; + personId?:string; + historyId?:string; + sfz?:string; + checkAddress?:string; + pointX?:string; + pointY?:string; + policeXm?:string; + policeId?:string; + policeIdCard?:string; + policePhone?:string; + policeZzjgCode?:string; + policeZzjgMc?:string; + checkType?:string; +} + +export interface RequestCheckPersonCount{ + sfz:string; +} + +export interface UploadFile{ + contentType:string; + filename:string +} + +export interface UpdatePersonFocusModel{ + focusType:string + peopleIdCardNum:string + policeIdCardNum:string + +} + +export interface UpdateCarFocusModel{ + focusType:number + cjh:string + policeIdCardNum: string +} + +export interface GetFocusListModel{ + pageNum:string + pageSize:string + policeIdCardNum:string +} + + +/*盘查车辆请求模型*/ +export class CheckCarRequestModel{ + carNum?:string + policeId?:string + policeIdCard?:string + policeXm?:string + policeZzjgCode?:string + policeZzjgMc?:string +} + +export interface SaveCarDataRequestModel{ + uuid:string + historyId:string + policeId:string + policeXm:string + policeIdCard:string + policePhone:string + policeZzjgCode:string + policeZzjgMc:string + pointX:string + pointY:string + checkAddress:string + jdchphm:string + clxh:string + jdcfdjh:string + jdccsys:string + jdchpzl:string + clsbdh:string + jdcsyr:string + clpp:string + sfzh:string + syrstatus:string + bdqzt:string + checkType:string + checkTime:string + +} + +export interface QueryCarCountRequestModel{ + carNum:string + clsbdh:string + +} + +export interface GetPersonListModel{ + mainId:string, + pageNum:number, + pageSize:number +} + +/** + * 实体 + */ +export class CheckSubmitEntity{ + remark?:string + peopleCount?:string + unusualPeopleCount?:string + carCount?:string + unusualCarCount?:string + goodsCount?:string + type?:string + checkReason?:string + checkAddress?:string + pointX?:string + pointY?:string + taskId?:string + kkid?:string + mainId?:string + checkTime?:string + status?:string + groupId?:string + yjdw?:string + yjdwmc?:string + userName?:string + idCard?:string + deptId?:string + deptName?:string + orgCode?:string + orgName?:string + policeName?:string + policeIdCard?:string + policeNum?:string + +} + +export class CheckSubmitModel{ + checkHistoryEntity?:CheckSubmitEntity + personIds?:Array + carIds?:Array +} + +export interface RequestTaskModel{ + nowTime:string + orgCode:string + taskName:string + pageNum:string + pageSize:string +} + +export interface QueryCardPointModel{ + taskId:string + orgCode:string + +} + +export interface QueryCardFocusModel{ + cjh:string + policeIdCardNum:string +} + +export interface RequestCheckPeopleRecordModel{ + idCardNum:string; + pageNum:number; + pageSize:string; +} + +export interface RequestCheckCarRecordModel{ + carNum:string; + clsbdh:string; + pageNum:number; + pageSize:string; +} \ No newline at end of file diff --git a/entry/src/main/ets/model/requestModel/LocationRequestModel.ets b/entry/src/main/ets/model/requestModel/LocationRequestModel.ets new file mode 100644 index 0000000..4db45f8 --- /dev/null +++ b/entry/src/main/ets/model/requestModel/LocationRequestModel.ets @@ -0,0 +1,19 @@ + + +export class GetLocationAddress{ + + x:string="" + y:string="" + fromIndex:string="" + toIndex:string="" + maxReturn:string="" + geoDecodingRadius:string="" + +} + +export class LocationDescription{ + score?:number; + address?:string + + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/requestModel/MainRequestModel.ets b/entry/src/main/ets/model/requestModel/MainRequestModel.ets new file mode 100644 index 0000000..11f9933 --- /dev/null +++ b/entry/src/main/ets/model/requestModel/MainRequestModel.ets @@ -0,0 +1,28 @@ +export class GetStatisticsModel { + sfz?: string + beginTime?: string + endTime?: string +} + +export interface GetDeptChile { + deptId: string, + updateTime: string, +} + + +export interface QueryMainHistoryRecordModel { + + policeIdCard: string + type: number //0 - 巡逻盘查记录 1 卡点核录记录 + pageNum: number + pageSize: string + taskId: string + startTime: String + beginTime: String + endTime: String + sfz:string +} + +export interface QueryCarRecordByMainModel{ + historyId:string +} diff --git a/entry/src/main/ets/model/resultModel/BaseResultModel.ets b/entry/src/main/ets/model/resultModel/BaseResultModel.ets new file mode 100644 index 0000000..9816857 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/BaseResultModel.ets @@ -0,0 +1,15 @@ + + +export class BaseResultModel{ + msg?: string; + code?: number; + total?:number = 0; + data?:T; + rows?:T; +} + +export class PageModel{ + + total:number = 0; + rows?:Array +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/CheckCarResultModel.ets b/entry/src/main/ets/model/resultModel/CheckCarResultModel.ets new file mode 100644 index 0000000..d3922fc --- /dev/null +++ b/entry/src/main/ets/model/resultModel/CheckCarResultModel.ets @@ -0,0 +1,211 @@ +import { ArrayList } from "@kit.ArkTS"; +import { StringUtils } from "../../util/StringUtils"; +import { ZdlxItem } from "../../model/resultModel/CheckPeopleResultModel"; + + + +export class CarHpzlType{ + cacheMap:Map = new Map(); + + constructor() { + this.cacheMap.set("01","大型汽车") + this.cacheMap.set("02","小型汽车") + this.cacheMap.set("03","摩托") + this.cacheMap.set("04","摩托") + this.cacheMap.set("05","临时行驶车") + this.cacheMap.set("99","其他") + } + + getValue(key:string):string{ + return StringUtils.get(this.cacheMap.get(key),""); + } + +} + +export const CAR_HPZL_TYPE :CarHpzlType= new CarHpzlType(); + +export interface CheckCarResultModes{ + stealList:CarAbnormal[] + list:CarData[] + //临控车辆 + localCar:string + isProvinceSteal:boolean + newLkCar:CarTypeOV[] +} + +export interface CarAbnormal{ + jdcfdjh:string + clsbdh:string +} + +@Observed +export class CarData{ + isSelect:boolean = false + + id:string = "" + csys:string="" + clsbdh:string="" + jdczt:string="" + type:number=0 + syzzjzl:string="" + clpp:string="" + jdcsyr:string="" + sfzh:string="" + hpzl:string="" + clxh:string="" + hphm:string="" + fdjh:string="" + xczp:string="" + xczpId:string="" + status:string=""; //盘查结果 + + isSteal:boolean=false + zdlxBeanList:Array|undefined =undefined + + addZdlxBean(zdlx:ZdlxItem){ + if (this.zdlxBeanList==null||this.zdlxBeanList == undefined) { + this.zdlxBeanList = new Array(); + } + this.zdlxBeanList.push(zdlx) + } +} + +export class ZdlxBean{ + zdlx:string="正常人员" + //1 正常 2 黄色 3 红色 + styleType:number = 1 + + sqyy?:string + czcs?:string + jzrq?:string + lxdh?:string + lxmj?:string + lxmjQQ?:string + remark?:string + xyrPhone?:string + peopleType?:string + isClickPopup:boolean = false + isShow:boolean = false + zdsxList?:ArrayList + + constructor(zdlx: string, styleType: number) { + this.zdlx = zdlx; + this.styleType = styleType; + } + + addKeyOrValue(key:string,value:string){ + if (this.zdsxList==null) { + this.zdsxList = new ArrayList(); + } + this.zdsxList.add(new ZdlxSxItem(key,value)) + } + + + public getIcon():Resource { + if (this.zdlx.startsWith("被盗抢")) { + return $r("app.media.ic_type_bdq") + } + if (this.zdlx.startsWith("临时")) { + return $r("app.media.ic_type_control") + } + return $r('app.media.ic_type_normal') + } + +} + +export class ZdlxSxItem{ + key:string="" + value:string="" + + testColor:Resource = $r("app.color.black") + + constructor(key: string, value: string) { + this.key = key; + this.value = value; + } + +} + +export class CarTypeOV{ + + zdlx:string="" + czcs:string="" + sqyy:string="" + jzrq:string="" + lxdh:string="" + lxmj:string="" + lxmjQQ:string="" + remark:string="" + xyrPhone:string="" + peopleType:string="" + order:number = 0; + type:number = -1; + status:number = 0; + show:boolean= false + + + +} + +export interface LocalCarData{ + jdchpzl:string + sfzh:string + jdcsyr:string + policePhone:string + zrPoliceName:string + reason:string + solution:string +} + +//复制自己 为适应 Observed +export const copyCarData = (value:CarData) => { + let car = new CarData(); + car.id = value.id + car.isSelect = value.isSelect + car.csys = value.csys + car.clsbdh = value.clsbdh + car.jdczt = value.jdczt + car.type = value.type + car.syzzjzl = value.syzzjzl + car.clpp = value.clpp + car.jdcsyr = value.jdcsyr + car.sfzh = value.sfzh + car.hpzl = value.hpzl + car.clxh = value.clxh + car.hphm = value.hphm + car.fdjh = value.fdjh + car.isSteal = value.isSteal + car.zdlxBeanList = value.zdlxBeanList + return car; +} + +export class CarRecordItem{ + id:string="" + historyId:string="" + uuid:string="" + carNum:string="" + carStatus:string="" + status:string="" + pinpai:string="" + color:string="" + fdjh:string="" + clsbdh:string="" + clsyr:string="" + syrzjhm:string="" + syrStatus:string="" + checkTime:string="" + checkType:string="" + checkTypeStr:string="" + jdchpzl:string="" + userName:string="" + policeName:string="" + idCard:string="" + deptId:string="" + deptName:string="" + pointX:string="" + pointY:string="" + checkAddress:string="" + policePhone:string="" + isCommit:string="" + photos:string="" +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/CheckPeopleResultModel.ets b/entry/src/main/ets/model/resultModel/CheckPeopleResultModel.ets new file mode 100644 index 0000000..692c429 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/CheckPeopleResultModel.ets @@ -0,0 +1,344 @@ + +import { JSON } from "@kit.ArkTS"; +import { StringUtils } from "../../util/StringUtils"; + +export interface CheckPeopleResultModel { + + NationPoint?:string; + newLKRY?:string; + zdr: string + extend?: string; + peopleData: PeopleData; + focusType?:number; + checkPersonEntity?:string +} + +export interface CheckPersonEntity{ + /** + * 0:正常 + * 1:涉恐 + * 2:涉稳 + * 3:在逃 + * 4: 涉毒 + * 5:前科 + * 6:精神病 + * 7:非访 + * 8:临控 + * 此值可能会为多个: 1,5,6 等 + */ + peopleStatus:string +} + + +export class NationPoint { + status?: string + result?: zdrylbbjType[] +} + +export interface zdrylbbjType { + zdrylbbj: string + ZDRYXL:string + LADW:string + ZJLASJ:string + +} + +export class LocalLkryData { + zdlx: string ="" + sqyy: string ="" + czcs: string ="" + jzrq: string ="" + lxmj: string ="" + lxmjQQ: string ="" + xyrPhone: string ="" + peopleType: string ="" + type: string ="" + status: string ="" + lxdh: string ="" + remark: string ="" + show: boolean = false +} + +export class ZdrData { + peopleType?: string + xyrPhone?: string + zrPoliceName?: string + policePhone?: string + reason?: string + householdAddress?: string +} + +export class ExtendData { + zdlx?: string + peopleType?: string + zdrPhone?: string + householdAddress?: string + zrPoliceCode?: string + zrPoliceName?: string + zrPolicePhone?: string + disposal?: string + reason?: string + terminationTime?: string +} + +export class PeopleData { + private _xm?: string | undefined; + + public get xm(): string { + return StringUtils.get(this._xm, "") + } + + private _peopleHJDZ?: string; + + public get peopleHJDZ(): string { + return StringUtils.get(this._peopleHJDZ, "") + } + + private _mz?: string | undefined; + + public set mz(value: string | undefined) { + this._mz = value; + } + + public get mz(): string { + return StringUtils.get(this._mz, "") + } + + public handMz(){ + if (this.type=="nation") { + this.mz = PeopleData.getMzChan(StringUtils.get(this._mz, "")) + } + this.mz = StringUtils.get(this._mz, "") + } + + private _csrq?: string | undefined; + + public get csrq(): string { + let csrqs = StringUtils.get(this._csrq, ""); + if (csrqs.length<8) { + return csrqs; + } + + return csrqs.substring(0,4)+"年"+csrqs.substring(4,6)+"月"+csrqs.substring(6,8)+"日" + } + + private _sfz?: string | undefined; + + public get sfz(): string { + return StringUtils.get(this._sfz, "") + } + + private _xb?: string | undefined; + + public set xb(value: string | undefined) { + this._xb = value; + } + + public get xb(): string { + return StringUtils.get(this._xb, ""); + } + + public handXb() { + if (this.type=="nation") { + if ("1"==this._xb) { + this.xb = "男" + } else if ("2"==this._xb) { + this.xb = "女"; + } + } + this.xb = StringUtils.get(this._xb, ""); + } + + private _type?: string | undefined; + + public get type(): string { + return StringUtils.get(this._type, "") + } + + private _zp?: string | undefined; + + public get zp(): string { + return StringUtils.get(this._zp, "") + } + + public static getMzChan(key: string): string { + let mzKey = + "[{\"id\":\"01\",\"name\":\"汉族\"},{\"id\":\"02\",\"name\":\"蒙古族\"},{\"id\":\"03\",\"name\":\"回族\"}," + + "{\"id\":\"04\",\"name\":\"藏族\"},{\"id\":\"05\",\"name\":\"维吾尔族\"},{\"id\":\"06\",\"name\":\"苗族\"}," + + "{\"id\":\"07\",\"name\":\"彝族\"},{\"id\":\"08\",\"name\":\"壮族\"},{\"id\":\"09\",\"name\":\"布依族\"}," + + "{\"id\":\"10\",\"name\":\"朝鲜族\"},{\"id\":\"11\",\"name\":\"满族\"},{\"id\":\"12\",\"name\":\"侗族\"}," + + "{\"id\":\"13\",\"name\":\"瑶族\"},{\"id\":\"14\",\"name\":\"白族\"},{\"id\":\"15\",\"name\":\"土家族\"}," + + "{\"id\":\"16\",\"name\":\"哈尼族\"},{\"id\":\"17\",\"name\":\"哈萨克族\"},{\"id\":\"18\",\"name\":\"傣族\"}," + + "{\"id\":\"19\",\"name\":\"黎族\"},{\"id\":\"20\",\"name\":\"傈僳族\"},{\"id\":\"21\",\"name\":\"佤族\"}," + + "{\"id\":\"22\",\"name\":\"畲族\"},{\"id\":\"23\",\"name\":\"高山族\"},{\"id\":\"24\",\"name\":\"拉祜族\"}," + + "{\"id\":\"25\",\"name\":\"水族\"},{\"id\":\"26\",\"name\":\"东乡族\"},{\"id\":\"27\",\"name\":\"纳西族\"}," + + "{\"id\":\"28\",\"name\":\"景颇族\"},{\"id\":\"29\",\"name\":\"柯尔克孜族\"},{\"id\":\"30\",\"name\":\"土族\"}," + + "{\"id\":\"31\",\"name\":\"达斡尔族\"},{\"id\":\"32\",\"name\":\"仫佬族\"},{\"id\":\"33\",\"name\":\"羌族\"}," + + "{\"id\":\"34\",\"name\":\"布朗族\"},{\"id\":\"35\",\"name\":\"撒拉族\"},{\"id\":\"36\",\"name\":\"毛难族\"}," + + "{\"id\":\"37\",\"name\":\"仡佬族\"},{\"id\":\"38\",\"name\":\"锡伯族\"},{\"id\":\"39\",\"name\":\"阿昌族\"}," + + "{\"id\":\"40\",\"name\":\"普米族\"},{\"id\":\"41\",\"name\":\"塔吉克族\"},{\"id\":\"42\",\"name\":\"怒族\"}," + + "{\"id\":\"43\",\"name\":\"乌孜别克族\"},{\"id\":\"44\",\"name\":\"俄罗斯族\"},{\"id\":\"45\",\"name\":\"鄂温克族\"}," + + "{\"id\":\"46\",\"name\":\"崩龙族\"},{\"id\":\"47\",\"name\":\"保安族\"},{\"id\":\"48\",\"name\":\"裕固族\"}," + + "{\"id\":\"49\",\"name\":\"京族\"},{\"id\":\"50\",\"name\":\"塔塔尔族\"},{\"id\":\"51\",\"name\":\"独龙族\"}," + + "{\"id\":\"52\",\"name\":\"鄂伦春族\"},{\"id\":\"53\",\"name\":\"赫哲族\"},{\"id\":\"54\",\"name\":\"门巴族\"}," + + "{\"id\":\"55\",\"name\":\"珞巴族\"},{\"id\":\"56\",\"name\":\"基诺族\"}]"; + + const param = JSON.parse(mzKey) as MzItem[]; + + for (let i = 0; i < param.length; i++) { + let item = param[i] as MzItem; + if (item.id == key) { + return item.name + } + } + return "未知"; + } +} +// 1 2 3 4 +// 珂珂 萧辰 灵士 +export interface MzItem { + id: string; + name: string; +} + +export class ZdlxItem{ + zdlx:string="正常人员" + //1 正常 2 黄色 3 红色 + styleType:number = 1 + zdxqArray?:Array + isShow :boolean = false; + + constructor(zdlx: string, styleType: number) { + this.zdlx = zdlx; + this.styleType = styleType; + } + + addXQ(zdXqItem:ZdXqItem){ + if (this.zdxqArray == null) { + this.zdxqArray = new Array(); + } + this.zdxqArray.push(zdXqItem) + } + + public getIcon():Resource{ + if (this.zdlx.startsWith("涉稳")) { + return $r("app.media.ic_type_stability") + } + if (this.zdlx.startsWith("涉恐")) { + return $r("app.media.ic_type_fear") + } + if (this.zdlx.startsWith("关注")) { + return $r("app.media.ic_type_focus") + } + if (this.zdlx.startsWith("云控")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(this.zdlx,"精神")) { + return $r("app.media.ic_type_fine") + } + if (this.zdlx.startsWith("非访")) { + return $r("app.media.ic_type_non") + } + if (this.zdlx.startsWith("前科")) { + return $r("app.media.ic_type_criminal_record") + } + if (StringUtils.containsChar(this.zdlx,"毒")) { + return $r("app.media.ic_type_poison") + } + if (StringUtils.containsChar(this.zdlx,"临")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(this.zdlx,"逃")) { + return $r("app.media.ic_type_escape") + } + return $r("app.media.ic_type_normal"); + } + +} + +export class HistoryBean{ + id?:string; + queryType?:string; + mz?:string; + xb?:string; + hjd?:string; + csrq?:string; + sfzh?:string; + queryPName?:string; + queryDate?:string; + startDate?:string; + endDate?:string; + type?:number; + isUpdate?:boolean +} + +export interface CheckPeopleCount{ + code:number + count:number + msg:string +} + +export class ZdXqItem{ + key?:string + value?:string + textColor:Resource= $r('app.color.black') + + constructor(key: string, value: string, textColor: Resource) { + this.key = key; + this.value = value; + this.textColor = textColor; + } +} + +export interface OCRIdCardNumResultModel{ + name:string + sex:string + nationality:string + address:string + birth:string + idNumber:string + cardImageUri:string + originalImageUri:string +} + +export class PersonCountModel{ + count?:number + peoplePhone?:string +} + + +export class AccompanPersonBean1{ + total:number = 0; + rows?:Array +} + +export class AccompanPersonBean{ + peopleStatusStr?:string + checkTime?:string + name?:string + sfz?:string + uuid?:string + address?:string + mz?:string + csrq?:string + status?:string + idCardPhoto:string = "" + id:string = "" + sex:number = 0 +} + +export class CheckPeopleRecordItem{ + id:string=""; + policeNum:string=""; + policeName:string=""; + checkTime:string=""; + checkTypeStr:string="" + deptName:string="" + policePhone:string="" + pointX:string="" + pointY:string="" + checkType:number=1 + checkAddress:string="" + + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/FocusModel.ets b/entry/src/main/ets/model/resultModel/FocusModel.ets new file mode 100644 index 0000000..0dee714 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/FocusModel.ets @@ -0,0 +1,36 @@ +@Observed +export class FocusPersonBean{ + + updateTime?:string + realName?:string + idCardNum?:string + mz?:string + address?:string + birthDate?:string + sex?:string + phone?:string + focusType?:number + rylx?:string + @Track idCardPhoto?:string|Resource + +} + +export class FocusCarBean{ + updateTime?:string + hphm?:string + clsyr?:string + csys?:string + clpp?:string + cjh?:string + fdjh?:string + cllx?:string + syrzjhm?:string + focusType?:number + carStatus?:string +} + +export class GetFocusCarData{ + + focusType:number =0 + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/LocationModel.ets b/entry/src/main/ets/model/resultModel/LocationModel.ets new file mode 100644 index 0000000..58f85c4 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/LocationModel.ets @@ -0,0 +1,5 @@ + + +export class LocationAddress{ + address?:string +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/MainResultModel.ets b/entry/src/main/ets/model/resultModel/MainResultModel.ets new file mode 100644 index 0000000..3b33540 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/MainResultModel.ets @@ -0,0 +1,36 @@ + +export class StatisticsResultModel{ + + peopleCount?:number + unusualPeopleCount?:number + carCount?:number + goodsCount?:number + unusualCarCount?:number + commitPeopleCount?:number + commitCarCount?:number + allCount?:number +} + +export class MainRecordResultModel{ + id:string="" + mainId:string="" //盘查id + carNum:string="" //车牌号 + peopleCount:string="" // 正常人员数 + unusualPeopleCount:string=""// + unusualCarCount:string="" + goodsCount:string="" // 物品数 + checkTime:string="" //盘查时间 + checkAddress:string="" //盘查地址 + status:number=0 //移交1、通过0 + checkReason:string="" //盘查原因 + yjdw:string="" //移交单位 + yjdwmc:string="" //移交单位 + remark:string="" //备注 + kkid:string="" //卡口id + userName:string="" //警号 + policeName:string="" //警员姓名 + pointName:string="" + taskName:string="" + classType:string="" + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/PgResultModel.ets b/entry/src/main/ets/model/resultModel/PgResultModel.ets new file mode 100644 index 0000000..a1407db --- /dev/null +++ b/entry/src/main/ets/model/resultModel/PgResultModel.ets @@ -0,0 +1,6 @@ + +export interface PgTokenModel{ + access_token:string + refresh_token:string + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/TaskCardPointModel.ets b/entry/src/main/ets/model/resultModel/TaskCardPointModel.ets new file mode 100644 index 0000000..f2ecd68 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/TaskCardPointModel.ets @@ -0,0 +1,28 @@ + + +export class TaskModel{ + baseType:number = 1 + name?:string + id?:string + kssj?:string + jssj?:string + phone?:string + description?:string + deptId?:string + deptName?:string + +} + +export class CardPointModel{ + name?:string + id:string="" + address?:string + pointX?:string + pointY?:string + +} + +export class DeptResultModel{ + + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/resultModel/UploadPhotoModel.ets b/entry/src/main/ets/model/resultModel/UploadPhotoModel.ets new file mode 100644 index 0000000..f5162b4 --- /dev/null +++ b/entry/src/main/ets/model/resultModel/UploadPhotoModel.ets @@ -0,0 +1,13 @@ + +export class UploadPhotoModel{ + + status?:number + code?:number + msg?:string + data?:DataBean +} + +export class DataBean{ + photoId?:string + url?:string +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/BeanModel.ets b/entry/src/main/ets/model/uiModel/BeanModel.ets new file mode 100644 index 0000000..aaad88b --- /dev/null +++ b/entry/src/main/ets/model/uiModel/BeanModel.ets @@ -0,0 +1,23 @@ + +export class ErrorOfEmptyModel{ + // image: Resource = $r('app.media.icon_error') ; + + //0 = 空白页 -1 表示错误页 + type:number = 0; + msg: string | Resource = ""; + + + constructor(type:number, msg: string | Resource) { + this.type = type; + this.msg = msg; + } + + + getIcon():Resource{ + if (this.type == 0){ + return $r('app.media.icon_empty') + } + return $r('app.media.icon_error') + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/FaceImageModel.ets b/entry/src/main/ets/model/uiModel/FaceImageModel.ets new file mode 100644 index 0000000..57277ac --- /dev/null +++ b/entry/src/main/ets/model/uiModel/FaceImageModel.ets @@ -0,0 +1,32 @@ +/** + * 图像数据接口 + */ +export interface IImageData { + data: string; +} + +/** + * 图像配置接口 + */ +export interface IImageConfig { + image: IImageData; + face_selection: string; +} + +/** + * 数据库配置接口 + */ +export interface IDatabaseConfig { + db_id: string; + top_k: string; + min_score: string; +} + +/** + * 人脸识别请求接口 + */ +export interface IFaceRecognitionRequest { + image: IImageConfig; + dbs: IDatabaseConfig[]; + type: string; +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/GoodsModel.ets b/entry/src/main/ets/model/uiModel/GoodsModel.ets new file mode 100644 index 0000000..c521717 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/GoodsModel.ets @@ -0,0 +1,76 @@ +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { StringUtils } from "../../util/StringUtils"; + + +export class GoodsTypeBean { + /** + * {"dwvalue":"11","thingsname":"非法出版物","thingsvalue":"11","ordersort":2,"dwname":"件"}, + * {"dwvalue":"8","thingsname":"危化物品","thingsvalue":"8","ordersort":3,"dwname":"千克"}, + * {"dwvalue":"9","thingsname":"毒品","thingsvalue":"9","ordersort":4,"dwname":"克"}, + * {"dwvalue":"1","thingsname":"假套车牌","thingsvalue":"1","ordersort":5,"dwname":"套"}, + */ + dwvalue: string = "0"; + thingsname: string = "0"; + thingsvalue: string = "0"; + ordersort: string = "0"; + dwname: string = "0"; +} + +export class GoodsBean { + name: string = "" + count: string = "" + createTime: string = "" + unit: string = "" + dwValue: string = "" + thingsValue: string = "" + remark: string = "" + category: string = "" + dangerLevel: string = "" + checkTime: string = "" + photoUrl: string = "" + photoId: string = "" + historyId: string = "" + deptId: string = "" + uuid: string = "" + userName: string = "" + idCard: string = "" + deptName: string = "" + policeName: string = "" + //是否移交 + isYj: boolean = false; + // isSelect: boolean = true; + // + // getIcon(): Resource { + // if (StringUtils.containsChar(this.name, "车牌")) { + // return $r('app.media.log_tp') + // } + // if (StringUtils.containsChar(this.name, "枪")) { + // return $r('app.media.log_qz') + // } + // if (StringUtils.containsChar(this.name, "子弹")) { + // return $r('app.media.log_zd') + // } + // if (StringUtils.containsChar(this.name, "雷管") || StringUtils.containsChar(this.name, "炸药")) { + // return $r('app.media.log_zylg') + // } + // if (StringUtils.containsChar(this.name, "烟花")) { + // return $r('app.media.log_yhbz') + // } + // if (StringUtils.containsChar(this.name, "危化物品")) { + // return $r('app.media.log_whwp') + // } + // return $r('app.media.icon_qtwp') + // } + + setUserData(){ + this.historyId = RuanseeAbitityStag.appCache.getHistoryId() + this.deptId = RuanseeAbitityStag.userCache.getDeptCode + } + +} + +export class CheckReasonModel{ + dictLabel?:string + dictValue?:string + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/HandOverModel.ets b/entry/src/main/ets/model/uiModel/HandOverModel.ets new file mode 100644 index 0000000..25e0ac1 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/HandOverModel.ets @@ -0,0 +1,60 @@ + +@Observed +export class PersonItemBean { + baseType: number = 1 + peopleStatusStr?: string + checkTime?: string + name?: string + sfz?: string + isSelect:boolean = false; + id?: string +} + +@Observed +export class CarItemBean { + hpzl:string="" + clxh:string="" + hphm:string="" + sfzh:string="" + carZdlx:string="" + isSelect:boolean = false; + id?: string +} + +@Observed +export class GoodsItemBean{ + name: string = "" + count: string = "" + createTime: string = "" + unit: string = "" + dwValue: string = "" + thingsValue: string = "" + isSelect:boolean = false; + id?: string +} + +export class HanoverItem { + /** + * 1 = 标题 2 = 车 3 = 人 4 = 物品 + */ + baseType: number = 1; + baseMsg: string = "" + id?: string + + personData?:PersonItemBean + carData?:CarItemBean + goodsData?:GoodsItemBean + +} + +@Observed +export class SelectDept{ + randomId:string = "" + deptId: string | null = null; + deptName: string | null = null + parentId: string | null = null + updateTime: string | null = null + isSelect:boolean = false; + + +} diff --git a/entry/src/main/ets/model/uiModel/IAuthTaskType.ets b/entry/src/main/ets/model/uiModel/IAuthTaskType.ets new file mode 100644 index 0000000..c79a39e --- /dev/null +++ b/entry/src/main/ets/model/uiModel/IAuthTaskType.ets @@ -0,0 +1,74 @@ +/** + * 统一认证 + */ +export enum IAuthTaskType { + /** + * 获取token模式 + */ + AUTH_TASK_TOKEN = 0, + /** + * token登录模式 + */ + AUTH_TASK_USER = 1, + /** + * 登录页面模式 + */ + AUTH_TASK_START_AUTH = 2, + /** + * 多因子绑定模式 + */ + AUTH_TASK_BIND = 3, + /** + * 多因子解绑模式 + */ + AUTH_TASK_UNBIND = 4, + /** + * 个人信息修改模式 + */ + AUTH_TASK_SET_UP = 5, +} + + +export class AuthUserModel { + age?: number; + birthdate?: string; + code: string = ''; + email?: string; + orderId: number; + orgId: string; + orgName: string; + phoneNum?: string; + policeTypeId: string; + policeTypeName: string; + profilePhoto?: string; + realName: string; + token: string; + userName: string; + userNum: string; + workPhone?: string; + sysTypeId: string; + + constructor(code: string, orderId: number, orgId: string, orgName: string, policeTypeId: string, + policeTypeName: string, realName: string, token: string, userName: string, userNum: string, + sysTypeId: string, age?: number, birthdate?: string, email?: string, phoneNum?: string, + profilePhoto?: string, workPhone?: string) { + + this.code = code; + this.orderId = orderId; + this.orgId = orgId; + this.orgName = orgName; + this.policeTypeId = policeTypeId; + this.policeTypeName = policeTypeName; + this.realName = realName; + this.token = token; + this.userName = userName; + this.userNum = userNum; + this.sysTypeId = sysTypeId; + this.age = age === undefined ? 0 : age; + this.birthdate = birthdate === undefined ? '' : birthdate; + this.email = email === undefined ? '' : email; + this.phoneNum = phoneNum === undefined ? '' : phoneNum; + this.profilePhoto = profilePhoto === undefined ? '' : profilePhoto; + this.workPhone = workPhone === undefined ? '' : workPhone; + } +} diff --git a/entry/src/main/ets/model/uiModel/MainBean.ets b/entry/src/main/ets/model/uiModel/MainBean.ets new file mode 100644 index 0000000..709a8e6 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/MainBean.ets @@ -0,0 +1,20 @@ + +export interface MainButtonBean{ + icon:Resource; + name:string|Resource; + routerPage?: string + tag?: number + +} + + +export interface OCRIdCardNumResultModel{ + name:string + sex:string + nationality:string + address:string + birth:string + idNumber:string + cardImageUri:string + originalImageUri:string +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/PageParamModel.ets b/entry/src/main/ets/model/uiModel/PageParamModel.ets new file mode 100644 index 0000000..ee975a1 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/PageParamModel.ets @@ -0,0 +1,90 @@ + +export class SkipCheckPageModel{ + + titleType:number = 0; + taskId?:string; + taskName?:string; + cardPointName?:string; +} + +export class SkipCheckCardModel { + isCardPoint?:boolean; +} + +export class SkipPassPageParam{ + //是否卡点盘查 + isCardPoint?:boolean; + carNumStatus: number = 0; + +} + +/** + * 跳转到选择移交单位参数 + */ +export class SkipHandOverSelectDeptParam { + isCardPoint?:boolean; + carNumStatus: number = 0; + personIds?: Array + carId?:string; + +} + +/** + * 跳转到移交最后一步操作 + */ +export class SkipHandOverParam { + isCardPoint?:boolean; + carNumStatus: number = 0; + personIds?: Array + carId?:string; + selectDeptId?:string; + selectDeptName?:string; +} + + +export interface SkipCheckCountParam{ + what:number; + name :string; + sex :string; + idCardNum :string; + birthDate :string; + nation :string; + address :string; + photoData: string | Resource + zdlx: string + +} + + +export interface SkipCarCountParam{ + what:number; + carNum :string; + carYs :string; + carZL :string; + carPP :string; + carJH :string; + carFDJH :string; + carSYR :string; + idCardNum :string; + carStatus:string +} + +export interface SkipHistoryDetailsParam{ + pctime:string + policenum:string + policename:string + pcyy:string + yjdw:string + mainId:string + status:number + address:string + taskName:string + type:number +} +export class RouterResultModel{ + + pageTag?:string + + data?:T + +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/PageResultModel.ets b/entry/src/main/ets/model/uiModel/PageResultModel.ets new file mode 100644 index 0000000..5bf0589 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/PageResultModel.ets @@ -0,0 +1,11 @@ + + +export class BasePageResult{ + //标识类型 + type:number=0; + //第二标识 + what:number=0; + //传递的参数 + data?:ESObject; + +} diff --git a/entry/src/main/ets/model/uiModel/PeopleFaceRequestModel.ets b/entry/src/main/ets/model/uiModel/PeopleFaceRequestModel.ets new file mode 100644 index 0000000..87971e8 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/PeopleFaceRequestModel.ets @@ -0,0 +1,28 @@ + + +export class PeopleFaceRequestModel{ + listLibIds:string = "" + start:string = "" + size:string = "" + similarityMin:string = "" + picBase64:string = "" + // credentialsNum:string = "" +} + + +export class PeopleFaceResultModel{ + total:number = 0 + pageNo:number = 0 + pageSize:number = 0 + list:Array=[] + success:boolean = false +} + + +export class FaceItem{ + credentialsNum: string="" + humanName: string="" + facePicUrl: string="" + listLibId?: string + similarity: string="" +} \ No newline at end of file diff --git a/entry/src/main/ets/model/uiModel/SelectTask.ets b/entry/src/main/ets/model/uiModel/SelectTask.ets new file mode 100644 index 0000000..9f07e81 --- /dev/null +++ b/entry/src/main/ets/model/uiModel/SelectTask.ets @@ -0,0 +1,42 @@ +import { SymbolGlyphModifier } from "@ohos.arkui.modifier"; + +/** + * 任务模型 + */ +export class SelectTaskModel implements SelectOption{ + + /** + * 任务名称 name + */ + value: string = ""; + icon?: ResourceStr | undefined; + symbolIcon?: SymbolGlyphModifier | undefined; + + id?:string; + kssj?:string; + jssj?:string; + phone?:string; + description?:string; + deptId?:string; + deptName?:string; + +} + +@Observed +export class CardProtModel{ + orgName?:string; + id?:string; + orgCode?:string; + address?:string + pointX?:string + pointY?:string + isSelect?:boolean = false; +} + +@Observed +export class SelectTaskObservedModel{ + baseType:number = 1 + taskName: string = ""; + taskId: string = ""; + isSelect?:boolean = false; +} \ No newline at end of file diff --git a/entry/src/main/ets/request/HttpUtils.ets b/entry/src/main/ets/request/HttpUtils.ets new file mode 100644 index 0000000..2ebd14f --- /dev/null +++ b/entry/src/main/ets/request/HttpUtils.ets @@ -0,0 +1,166 @@ +import axios, { + AxiosError, + AxiosHeaders, + AxiosInstance, + AxiosRequestConfig, + AxiosResponse, + InternalAxiosRequestConfig, + RawAxiosRequestHeaders +} from "@ohos/axios"; +import { AppCache } from '../app/AppCache'; +import { UserCache } from '../app/UserCache'; +import { StringUtils } from '../util/StringUtils'; +import App from '@system.app'; + +// axios 请求配置 +const config: AxiosRequestConfig = { + baseURL: AppCache.getAppCache().getServiceAddress(), + // baseURL: '/api', + timeout: 1000 * 30, + connectTimeout : 30*1000, + readTimeout:30*1000, +} + +// 定义返回值类型 +interface Result { + code: number; + message: string; + data: T; +} + +class Http { + // axios 实例 + private instance: AxiosInstance; + + // 构造函数初始化 + constructor(config: AxiosRequestConfig) { + this.instance = axios.create(config); + //定义拦截器 + this.interceptors(); + } + + private interceptors() { + // axios 发送请求之前的处理 + this.instance.interceptors.request.use((config: InternalAxiosRequestConfig) => { + // 在请求头部携带token + // let token = sessionStorage.getItem('token'); + let token = UserCache.getUserCache().getUserInfo(); + if (token) { + config.headers!['userInfo'] = token; + // 把 token 放到 headers 里面 + // (config.headers as AxiosRequestHeaders).token = token; + } + let pgToken = AppCache.getAppCache().getPgToken; + if (pgToken) { + config.headers!['Authorization'] = pgToken; + } + console.log('' + config); + return config; + + }, (error: ESObject) => { + error.data = {}; + error.data.msg = '服务器异常,请联系管理员!' + return error; + }) + // axios 请求返回之后的处理 + // 请求返回处理 + this.instance.interceptors.response.use((res: AxiosResponse) => { + let msg = JSON.stringify(res.data); + msg = StringUtils.toJsonParaphrase(msg); + console.info('获取到的数据:' + msg); + if (res.status != 200) { + console.log(res.data.msg || '服务器出错啦'); + return Promise.reject(res.data.msg || '服务器出错啦'); + } + return res.data; + }, (error: AxiosError) => { + console.log('进入错误!'); + // error.data = {}; + if (error.code == "2300028") { + error.message = "网络超时"; + } else { + if (error && error.response) { + switch (error.response.status) { + case 400: + error.message = "错误请求"; + break; + case 401: + error.message = "未授权,请登录"; + break; + case 403: + error.message = "拒绝访问"; + break; + case 404: + error.message = "请求错误,未找到该资源"; + break; + case 405: + error.message = "请求方法未允许"; + break; + case 408: + error.message = "请求超时"; + break; + case 500: + error.message = "服务器端出错"; + break; + case 501: + error.message = "网络未实现"; + break; + case 502: + error.message = "网络错误"; + break; + case 503: + error.message = "服务不可用"; + break; + case 504: + error.message = "网络超时"; + break; + case 505: + error.message = "http版本不支持该请求"; + break; + default: + error.message = `连接错误${error.response.status}`; + } + } else { + error.message = "连接到服务器失败"; + } + } + console.log(error.message) + return Promise.reject(error); + }) + } + + // GET方法 + get(url: string, params?: object,headers?: AxiosHeaders): Promise { + return this.instance.get(url, { params,headers:headers }); + } + + // POST方法 + post(url: string, data?: object,headers?: AxiosHeaders): Promise { + return this.instance.post(url, data,{headers:headers}); + } + + // POST方法 + postFromJson(url: string, data?: string): Promise { + return this.instance.post(url, data, { headers:new AxiosHeaders({ 'Content-Type': 'application/json; charset=utf-8'})}); + } + + // POST方法 + postFromBody(url: string, data?: object,headers?: AxiosHeaders): Promise { + return this.instance.post(url, null, { params: data ,headers:headers}); + } + + // PUT方法 + put(url: string, data?: object): Promise { + return this.instance.put(url, data); + } + + // DELETE方法 + delete(url: string): Promise { + return this.instance.delete(url); + } +} + +export default new Http(config); + + + diff --git a/entry/src/main/ets/request/RequestUtils.ets b/entry/src/main/ets/request/RequestUtils.ets new file mode 100644 index 0000000..17e099e --- /dev/null +++ b/entry/src/main/ets/request/RequestUtils.ets @@ -0,0 +1,88 @@ + +import { inspector } from '@kit.ArkUI'; +import axios, { RawAxiosRequestHeaders, AxiosHeaders, AxiosResponse, AxiosError, + InternalAxiosRequestConfig } from '@ohos/axios'; +import { AppCache } from '../app/AppCache'; +import { UserCache } from '../app/UserCache'; + +export class RequestUtils { + instance = axios.create({ + timeout:20000 + + }); + + create(){ + + // 添加请求拦截器 + this.instance.interceptors.request.use((config:InternalAxiosRequestConfig) => { + // 在发送请求之前做些什么 + return config; + }, (error:AxiosError) => { + // 对请求错误做些什么 + return Promise.reject(error); + }); + + //响应拦截器,通过响应拦截器进一步对返回的数据做处理 + this.instance.interceptors.response.use( + (response:AxiosResponse) => { + return response; + } + , (error:AxiosError) => { + return Promise.reject(error) + }, + { + }) + } + + //街面检查 Street inspection + async postRequest(disposition: RequestDisposition, callback: RequestCallback) { + await axios, Map>({ + method: "post", + url: disposition.url, + params: disposition.params, + headers: { + "userInfo": UserCache.getUserCache().getUserInfo(), + 'Content-Type': 'application/x-www-form-urlencoded' + } + }) + .then((response: AxiosResponse) => { + let msg = JSON.stringify(response.data); + console.info('获取到的数据:' + msg); + if (response.status != 200) { + callback.error(msg) + return + } + + const resultModel = JSON.parse(msg) as T; + callback.successful(resultModel) + // 获取到的数据赋值给users数组 + }) + .catch((error: AxiosError) => { + console.info('捕获到异常:', JSON.stringify(error)); + callback.error(JSON.stringify(error)) + }) + .then(() => { + // 总是会执行 + }); + } +} + +export interface RequestDisposition { + url: string + fullUrl?: string + params?: D + data?: D + // headers?: any; + timeout?: number; + readTimeout?: number; + timeoutErrorMessage?: string; + connectTimeout?: number; +} + +export interface RequestCallback { + error(msg: string): void + + successful(resultModel: T): void + + onFinally():void +} diff --git a/entry/src/main/ets/request/api/Api.ets b/entry/src/main/ets/request/api/Api.ets new file mode 100644 index 0000000..2881dbf --- /dev/null +++ b/entry/src/main/ets/request/api/Api.ets @@ -0,0 +1,480 @@ +import { AxiosHeaders, FormData } from "@ohos/axios" +import http from "../HttpUtils" +import { buffer, util } from "@kit.ArkTS" +import AppConstants from "../../app/AppConstant" +import { PgTokenModel } from "../../model/resultModel/PgResultModel" +import { MainRecordResultModel, StatisticsResultModel } from "../../model/resultModel/MainResultModel" +import { ResultPageModel } from "../data/ResultModel" +import { + CheckCarRequestModel, + CheckPersonRequestModel, + CheckSubmitModel, + GetFocusListModel, + GetPersonListModel, + QueryCarCountRequestModel, + QueryCardFocusModel, + QueryCardPointModel, + RequestCheckCarRecordModel, + RequestCheckPeopleRecordModel, + RequestCheckPersonCount, + RequestTaskModel, + SaveCarDataRequestModel, + UpdateCarFocusModel, + UpdatePersonFocusModel, + UploadFile +} from "../../model/requestModel/CheckRequestModel" +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag" +import { + AccompanPersonBean, + CheckPeopleRecordItem, + CheckPeopleResultModel, + PersonCountModel +} from "../../model/resultModel/CheckPeopleResultModel" +import { BaseResultModel, PageModel } from "../../model/resultModel/BaseResultModel" +import { UploadPhotoModel } from "../../model/resultModel/UploadPhotoModel" +import fs from '@ohos.file.fs'; +import { LocationDescription, GetLocationAddress } from "../../model/requestModel/LocationRequestModel" +import { CarData, CarRecordItem, CheckCarResultModes } from "../../model/resultModel/CheckCarResultModel" +import { DateFormat, DateUtils } from "../../util/DateUtils" +import { CardPointModel, TaskModel } from "../../model/resultModel/TaskCardPointModel" +import { FocusCarBean, FocusPersonBean, GetFocusCarData } from "../../model/resultModel/FocusModel" +import { GetDeptChile, + QueryCarRecordByMainModel, + QueryMainHistoryRecordModel } from "../../model/requestModel/MainRequestModel" +import { DeptTableEntity } from "../../model/db/TableEntity" +import { DateUtil, JSONUtil } from "@pura/harmony-utils" +import { CustomUnionType } from "../../app/JointType" +import { StringUtils } from "../../util/StringUtils" +import { IFaceRecognitionRequest } from "../../model/uiModel/FaceImageModel" +import { GoodsBean } from "../../model/uiModel/GoodsModel" +import { UserCache } from "../../app/UserCache" +import { PeopleFaceRequestModel, PeopleFaceResultModel } from "../../model/uiModel/PeopleFaceRequestModel" + + +/*获取首页统计数字*/ +export const getMainStatistics = (data?: ESObject) => { + return http.postFromBody>("task/getStaticsByPolice", data) +} + +/*获取品高认证*/ +export const getPgToken = (data?: ESObject) => { + let byte = new Uint8Array(buffer.from(AppConstants.PG_APP_KEY_SECRET, 'utf-8').buffer); + let ac = new util.Base64Helper().encodeToStringSync(byte); + return http.postFromBody("http://20.90.2.2/sso_out/oauth2/token?grant_type=client_credentials", data, + new AxiosHeaders({ + 'Authorization': 'Basic ' + ac, + 'Content-Type': 'application/x-www-form-urlencoded' + })) +} + +/** + * 盘查人员 + * @param checkType 盘查方式(0 身份证 1 nfc 2 人像 3 语音 4 OCR) + */ +export const checkPerson = + (checkType: number, checkIdCard: string, isCardPoint: boolean, data?: CheckPersonRequestModel) => { + if (!data) { + data = new CheckPersonRequestModel(); + } + data.policeXm = RuanseeAbitityStag.userCache.getUserName; + data.policeId = RuanseeAbitityStag.userCache.getUserCode; + data.policeZzjgCode = RuanseeAbitityStag.userCache.getDeptCode; + data.policeZzjgMc = RuanseeAbitityStag.userCache.getDeptName; + data.policeIdCard = RuanseeAbitityStag.userCache.getIdCardNum; + data.policePhone = RuanseeAbitityStag.userCache.getPhoneNum; + data.sfz = checkIdCard; + data.personId = RuanseeAbitityStag.appCache.getPeopleTemporarilyId(); + data.historyId = RuanseeAbitityStag.appCache.getHistoryId(); + data.checkType = `${checkType}` + if (isCardPoint) { + data.pointX = RuanseeAbitityStag.appCache.getCardPointLocationX() + data.pointY = RuanseeAbitityStag.appCache.getCardPointLocationY() + data.checkAddress = RuanseeAbitityStag.appCache.getCardPointAddress + } else { + data.pointX = `${RuanseeAbitityStag.appCache.getLocationX()}` + data.pointY = `${RuanseeAbitityStag.appCache.getLocationY()}` + data.checkAddress = RuanseeAbitityStag.appCache.getLocationAddress + } + return http.postFromBody>("person/checkPerson", data) + } + +/** + * 查询人员被核查次数 + */ +export const checkPersonCount = (idCard: string) => { + let data: RequestCheckPersonCount = { + sfz: idCard + } + return http.postFromBody>("person/countPeople", data) +} + +//上传文件 +export const uploadFile = (filePath: string, typeId: string) => { + let formData = new FormData(); + + // 读取文件内容为ArrayBuffer + let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY); + let stat = fs.statSync(filePath); + let arrayBuffer = new ArrayBuffer(stat.size); + fs.readSync(file.fd, arrayBuffer); + fs.closeSync(file); + + let fileName: UploadFile = { + filename: "sf", + contentType: "image/jpeg" + }; + + + formData.append('photoFile', arrayBuffer, fileName); + formData.append('personId', typeId); + + return http.post("person/uploadPhoto", formData, + new AxiosHeaders({ + 'Content-Type': 'multipart/form-data' + })) +} + +/** + * 获取位置描述 + */ +export const getCoordinateDescription = () => { + let queryData: GetLocationAddress = { + x: RuanseeAbitityStag.appCache.getLocationX() + "", + y: RuanseeAbitityStag.appCache.getLocationY() + "", + fromIndex: "0", + toIndex: "10", + maxReturn: '10', + geoDecodingRadius: "-1" + } + return http.get>("http://20.90.2.2/mapserver/services/addressMatch-index/restjsr/v1/address/geodecoding.json", + queryData); +} + +/** + * 设置关注人员手机号吗 + */ +export const addFocusPersonPhone = (jsonData: string) => { + return http.postFromJson>("focus/addPhone", jsonData) +} + +/** + * 添加关注人员 + * @param jsonData json数据 + */ +export const addFocusPerson = (param: Map) => { + let userData = RuanseeAbitityStag.userCache; + let policeEntity = new Map(); + policeEntity.set("userName", userData.getUserName) + policeEntity.set("deptId", userData.getDeptCode) + policeEntity.set("deptName", userData.getDeptName) + policeEntity.set("idCard", userData.getIdCardNum) + policeEntity.set("idCardNum", userData.getIdCardNum) + policeEntity.set("orgCode", userData.getDeptCode) + policeEntity.set("orgName", userData.getDeptName) + policeEntity.set("phoneNum", userData.getPhoneNum) + policeEntity.set("policeTypeName", "") + policeEntity.set("realName", userData.getUserName) + param.set("policeEntity", JSONUtil.mapToJsonStr(policeEntity)); + let json = JSONUtil.mapToJsonStr(param); + let paramJson = StringUtils.toJsonParaphrase(json); + return http.postFromJson>("focus/addToMyFocus", paramJson); +} + +/** + * 添加关注车辆 + * @param jsonData json数据 + */ +export const addFocusCar = (param: Map) => { + let userData = RuanseeAbitityStag.userCache; + let policeEntity = new Map(); + policeEntity.set("userName", userData.getUserName) + policeEntity.set("deptId", userData.getDeptCode) + policeEntity.set("deptName", userData.getDeptName) + policeEntity.set("idCard", userData.getIdCardNum) + policeEntity.set("idCardNum", userData.getIdCardNum) + policeEntity.set("orgCode", userData.getDeptCode) + policeEntity.set("orgName", userData.getDeptName) + policeEntity.set("phoneNum", userData.getPhoneNum) + policeEntity.set("policeTypeName", "") + policeEntity.set("realName", userData.getUserName) + param.set("policeEntity", JSONUtil.mapToJsonStr(policeEntity)); + let json = JSONUtil.mapToJsonStr(param); + let paramJson = StringUtils.toJsonParaphrase(json); + return http.postFromJson>("focus/addCarToFocus", paramJson); +} + +/** + * 查询车辆关注信息 + */ +export const checkCarFocus = (cjh: string) => { + let param: QueryCardFocusModel = { + cjh: cjh, + policeIdCardNum: RuanseeAbitityStag.userCache.getIdCardNum + } + return http.postFromBody>("focus/checkCarFocus",param) +} + +/** + * 取消关注 + */ +export const updateFocus = (idCardNum: string) => { + let data: UpdatePersonFocusModel = { + focusType: "0", + peopleIdCardNum: idCardNum, + policeIdCardNum: RuanseeAbitityStag.userCache.getIdCardNum + } + return http.postFromBody("focus/updateFocus", data) +} + +//取消车辆关注 +export const updateCarFocus = (cjh: string) => { + let data: UpdateCarFocusModel = { + focusType: 0, + cjh: cjh, + policeIdCardNum: RuanseeAbitityStag.userCache.getIdCardNum + } + return http.postFromBody("focus/updateCarFocus", data) +} + +/** + * 盘查车辆 + */ +export const queryCheckCar = (carNum: string) => { + let queryModel: CheckCarRequestModel = { + carNum: carNum, + policeXm: RuanseeAbitityStag.userCache.getUserName, + policeId: RuanseeAbitityStag.userCache.getUserCode, + policeZzjgCode: RuanseeAbitityStag.userCache.getDeptCode, + policeZzjgMc: RuanseeAbitityStag.userCache.getDeptName, + policeIdCard: RuanseeAbitityStag.userCache.getIdCardNum + } + // car/checkCar + return http.postFromBody>("car/checkCar", queryModel); +} + +/** + * 保存车辆数据 + */ +export const saveCarData = (carData: CarData, isCardPoint: boolean) => { + // car/saveCarHistoryV3 this.historyId = this.getRandomId(); + let pointX = "" + let pointY = "" + let checkAddress = "" + if (isCardPoint) { + pointX = `${RuanseeAbitityStag.appCache.getCardPointLocationX()}` + pointY = `${RuanseeAbitityStag.appCache.getCardPointLocationY()}` + checkAddress = RuanseeAbitityStag.appCache.getCardPointAddress + } else { + pointX = `${RuanseeAbitityStag.appCache.getLocationX()}` + pointY = `${RuanseeAbitityStag.appCache.getLocationY()}` + checkAddress = RuanseeAbitityStag.appCache.getLocationAddress + } + + let param: SaveCarDataRequestModel = { + uuid: RuanseeAbitityStag.appCache.getCarId(), + historyId: RuanseeAbitityStag.appCache.getHistoryId(), + policeId: RuanseeAbitityStag.userCache.getUserCode, + policeXm: RuanseeAbitityStag.userCache.getUserName, + policeIdCard: RuanseeAbitityStag.userCache.getIdCardNum, + policePhone: RuanseeAbitityStag.userCache.getPhoneNum, + policeZzjgCode: RuanseeAbitityStag.userCache.getDeptCode, + policeZzjgMc: RuanseeAbitityStag.userCache.getDeptName, + pointX: pointX, + pointY: pointY, + checkAddress: checkAddress, + jdchphm: carData.hphm, + jdcfdjh: carData.fdjh, + jdccsys: carData.csys, + jdchpzl: carData.hpzl, + clsbdh: carData.clsbdh, + jdcsyr: carData.jdcsyr, + clpp: carData.clpp, + sfzh: carData.sfzh, + syrstatus: "1", + bdqzt: carData.isSelect ? "1" : "0", + checkType: "0", + checkTime: DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSSdSSS), + clxh: carData.clxh + } + + return http.postFromBody("car/saveCarHistoryV3", param); +} + +/** + * 查询车辆盘查次数 + */ +export const getCarCount = (hphm: string, cjh: string) => { + let param: QueryCarCountRequestModel = { + carNum: hphm, + clsbdh: cjh + } + return http.postFromBody>("car/countCar", param) +} + +/** + * 根据主ID查询人员列表(随行人员/选择移交人员) + */ +export const getPersonListByMainId = (pageNum: number, pageSize?: number,mainId?:string) => { + let param: GetPersonListModel = { + mainId: StringUtils.get(mainId,RuanseeAbitityStag.appCache.getHistoryId()), + pageNum: pageNum, + pageSize: pageSize ? pageSize : 20 + } + return http.postFromBody>>("person/getPersonListByMainId", param) +} + +/** + * 保存主记录 + * Json + */ +export const saveMainHistoryAndChangeStatus = (model: CheckSubmitModel) => { + return http.post>("main/saveMainHistoryAndChangeStatus", model + ) +} + +/** + * 获取任务 + */ +export const getTaskList = (searchTaskName ="", pageNum: number,nowTime?:string) => { + let param: RequestTaskModel = { + nowTime: StringUtils.get(nowTime,""), + orgCode: RuanseeAbitityStag.userCache.getDeptCode, + taskName: searchTaskName, + pageNum: pageNum + "", + pageSize: "30" + } + return http.postFromBody>>("task/getTaskByOrgCode", param); +} + +/** + * 获取卡点 + */ +export const getCardPointList = (taskId: string) => { + let param: QueryCardPointModel = { + taskId: taskId, + orgCode: RuanseeAbitityStag.userCache.getDeptCode + } + return http.postFromBody>>("task/getStuckByTaskId", param) +} + +/** + * 获取关注人员 + */ +export const getMyFocusPersonList = (pageNum: number) => { + let param: GetFocusListModel = { + pageNum: "" + pageNum, + pageSize: "30", + policeIdCardNum: RuanseeAbitityStag.userCache.getIdCardNum + } + return http.postFromBody>>("focus/getMyFocusList", param) +} + +/** + * 获取关注车辆 + */ +export const getMyFocusCaraList = (pageNum: number) => { + let param: GetFocusListModel = { + pageNum: "" + pageNum, + pageSize: "30", + policeIdCardNum: RuanseeAbitityStag.userCache.getIdCardNum + } + return http.postFromBody>>("focus/getMyFocusCarList", param) +} + +/** + * 发送物品数据到后台 + */ +export const saveGoodsData = (goodsJson: string) => { + let param = `{"thingsList":${goodsJson}}` + return http.postFromJson("things/insertThingsBatch", param) +} + +/** + * 获取组织机构 + */ +export const getDeptChile = (deptId: string, updateTime: string) => { + let param: GetDeptChile = { + deptId: deptId, + updateTime: updateTime + } + return http.postFromBody>>("dept/getDeptChild", param) +} + +/** + * 保存处置措施 + */ +export const saveCzcs = (value: string) => { + //person/saveCzcs + let param = `{"uuid":"${RuanseeAbitityStag.appCache.getPeopleId()}","czcs":"${value}"}` + return http.postFromJson>("person/saveCzcs", param) +} + +//人像比对 +export const comparisonFace=(data?:PeopleFaceRequestModel)=>{ + // return http.post("http://20.90.2.2/st_1n_new_out/engine/api-wrapper/v1/face/search_image_in_dbs",data) + return http.post>("http://20.90.2.2/st_1n_new_out/artemis/api/ctm01iaconv/v1/iface/identityConfirm",data, + new AxiosHeaders({ + "id_card":UserCache.getUserCache().getIdCardNum, + "fizz-appid":"34001", + "fizz-sign":"43bd0e9821c04d309e39e61faf8fd21a" + })) +} + +/** + * 获取人员盘查记录 + */ +export const getCheckPeopleRecord = (requestMode: RequestCheckPeopleRecordModel)=>{ + return http.postFromBody>>("person/getPersonListByIdCardNum",requestMode) +} + +/** + * 获取车辆盘查记录 + */ +export const getCheckCarRecord = (requestMode: RequestCheckCarRecordModel)=>{ + return http.postFromBody>>("car/getCheckedCarList",requestMode) +} + +/** + * 查询盘查主记录 + */ +export const queryMainRecordList = (type:number,taskId:string,pageNum: number,beginTime: string,endTime: string,sfz?:string)=>{ + let param : QueryMainHistoryRecordModel= { + policeIdCard: RuanseeAbitityStag.userCache.getIdCardNum, + type: type, + pageNum: pageNum, + pageSize: "20", + taskId: taskId, + startTime: beginTime, + beginTime: beginTime, + endTime: endTime, + sfz:StringUtils.get(sfz,"") + } + return http.postFromBody>>("main/getMainHistoryList",param) +} + +/** + * 根据主ID 查询车辆记录 + */ +export const getCarHistoryByMainId = (mainId?:string)=>{ + let param :QueryCarRecordByMainModel={ + historyId:StringUtils.get(mainId,RuanseeAbitityStag.appCache.getHistoryId()) + } + return http.postFromBody>>("car/getCarListByHistoryId",param); +} + +/** + * 根据主ID 查询物品记录 + */ +export const getGoodsHistoryByMainId = (mainId?:string)=>{ + let param :QueryCarRecordByMainModel={ + historyId:StringUtils.get(mainId,RuanseeAbitityStag.appCache.getHistoryId()) + } + return http.postFromBody>>("things/getListByHistoryId",param); +} + + + + + + + diff --git a/entry/src/main/ets/request/data/RequestModel.ets b/entry/src/main/ets/request/data/RequestModel.ets new file mode 100644 index 0000000..139597f --- /dev/null +++ b/entry/src/main/ets/request/data/RequestModel.ets @@ -0,0 +1,2 @@ + + diff --git a/entry/src/main/ets/request/data/ResultModel.ets b/entry/src/main/ets/request/data/ResultModel.ets new file mode 100644 index 0000000..b98a20c --- /dev/null +++ b/entry/src/main/ets/request/data/ResultModel.ets @@ -0,0 +1,11 @@ + + + +export interface ResultPageModel { + msg: string; + code: number; + count2: number; + page: T; + data:T; + row:T +} \ No newline at end of file diff --git a/entry/src/main/ets/request/data/UserInfoModel.ets b/entry/src/main/ets/request/data/UserInfoModel.ets new file mode 100644 index 0000000..5002494 --- /dev/null +++ b/entry/src/main/ets/request/data/UserInfoModel.ets @@ -0,0 +1,10 @@ + +export interface UserInfoModel{ + "userName": string; + "realName": string; + "orgName": string; + "orgCode": string; + "idCardNum": string; + "ip": string; + +} \ No newline at end of file diff --git a/entry/src/main/ets/style/BorderStyle.ets b/entry/src/main/ets/style/BorderStyle.ets new file mode 100644 index 0000000..e5f5e52 --- /dev/null +++ b/entry/src/main/ets/style/BorderStyle.ets @@ -0,0 +1,18 @@ + +export const cardRoundBorderStyle :BorderOptions={ + + width:$r('app.float.default_1'), + color:$r('app.color.white'), + radius:$r('app.float.default_5') + +} + + +export const cardRoundBorderGreyStyle :BorderOptions={ + width:$r('app.float.default_1'), + color:$r('app.color.colorGrey2'), + radius:$r('app.float.default_5') + +} + + diff --git a/entry/src/main/ets/ui/fragment/CarListFragment.ets b/entry/src/main/ets/ui/fragment/CarListFragment.ets new file mode 100644 index 0000000..0372fc5 --- /dev/null +++ b/entry/src/main/ets/ui/fragment/CarListFragment.ets @@ -0,0 +1,159 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh"; +import { AxiosError } from "@ohos/axios"; +import { ToastUtil } from "@pura/harmony-utils"; +import AppConstants from "../../app/AppConstant"; +import { CarRecordItem } from "../../model/resultModel/CheckCarResultModel"; +import { SkipCarCountParam } from "../../model/uiModel/PageParamModel"; +import { getCarHistoryByMainId } from "../../request/api/Api"; +import { getCarStatusIcon } from "../../util/StatusIconUtils"; +import { StringUtils } from "../../util/StringUtils"; +import { router } from "@kit.ArkUI"; + +@Preview({ + title: 'ContentTable' +}) +@Component +export struct CarListFragment { + @State mainId :string = "" + @State carList:Array = [] + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + + aboutToAppear(): void { + setTimeout(()=>{ + this.controller.isAutoRefresh = true + },300) + } + + build() { + Column(){ + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + enableLoadMore:false, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + getRecordListData() { + getCarHistoryByMainId(this.mainId) + .then((res) => { + this.controller.finishRefresh() + if(res.code == 200){ + let data = res.data; + if (data) { + this.carList = data; + }else { + ToastUtil.showToast(StringUtils.get(res.msg,"未查询到车辆!")) + } + }else { + ToastUtil.showToast(StringUtils.get(res.msg,"查询失败!")) + } + }) + .catch((err:AxiosError) => { + this.controller.finishRefresh() + ToastUtil.showShort(err.message) + }) + } + + @Builder + listView() { + List({ scroller: this.scroller}) { + ForEach(this.carList, (item: CarRecordItem) => { + ListItem() { + this.itemView(item) + } + .onClick(() => { + let param :SkipCarCountParam = { + what: 0, + carNum: StringUtils.get(item.carNum, ""), + carZL: StringUtils.get(item.jdchpzl, ""), + carPP: StringUtils.get(item.pinpai, ""), + carJH: StringUtils.get(item.clsbdh, ""), + carFDJH: StringUtils.get(item.fdjh, ""), + carSYR: StringUtils.get(item.clsyr, ""), + idCardNum: StringUtils.get(item.syrzjhm, ""), + carYs: StringUtils.get(item.color, ""), + carStatus: StringUtils.get(item.carStatus, "") + } + router.pushUrl({url:"ui/pages/CarCheckDetailsPages",params:param}) + }) + }) + } + .divider({ + strokeWidth: $r('app.float.default_1'), + color: $r('app.color.colorGrey2'), + startMargin:$r('app.float.default_63') + }) + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + itemView(item: CarRecordItem) { + Row() { + Image(getCarStatusIcon(item.carStatus)) + .width($r('app.float.default_43')) + .height($r('app.float.default_43')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Column() { + Row() { + Text(item.carNum) + .fontSize($r('app.float.default_16')) + .fontColor($r('app.color.colorGrey8')) + Text(item.status== "1" ? "移交" : "通过") + .fontColor(item.status == "1" ? $r('app.color.colorYellow7') : $r('app.color.colorBluen7')) + .backgroundColor(item.status == "1" ? $r('app.color.colorYellow2') : $r('app.color.colorBluen2')) + .fontSize($r('app.float.text_size_12')) + .border({ + width: $r('app.float.default_1'), + color: item.status == "1" ? $r('app.color.colorYellow6') : $r('app.color.colorBluen6'), + radius: $r('app.float.default_20'), + }) + .padding({ + left: $r('app.float.default_8'), + right: $r('app.float.default_8'), + top: $r('app.float.default_2'), + bottom: $r('app.float.default_2') + }) + .textAlign(TextAlign.Center) + .margin({ left: $r('app.float.default_5') }) + + } + .width('95%') + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + + Text(item.pinpai) + .fontSize($r('app.float.default_14')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .layoutWeight(1) + .alignItems(HorizontalAlign.Start) + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_60')) + .padding({ top: $r('app.float.default_8'), bottom: $r('app.float.default_8') }) + .backgroundColor($r('app.color.white')) + .width(AppConstants.PERCENTAGE_MAX) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/fragment/CheckPointHistoryFragment.ets b/entry/src/main/ets/ui/fragment/CheckPointHistoryFragment.ets new file mode 100644 index 0000000..ebd869d --- /dev/null +++ b/entry/src/main/ets/ui/fragment/CheckPointHistoryFragment.ets @@ -0,0 +1,502 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh"; +import { AxiosError } from "@ohos/axios"; +import { StrUtil, ToastUtil } from "@pura/harmony-utils"; +import AppConstants from "../../app/AppConstant"; +import { MainRecordResultModel } from "../../model/resultModel/MainResultModel"; +import { ErrorOfEmptyModel } from "../../model/uiModel/BeanModel"; +import { SkipHistoryDetailsParam } from "../../model/uiModel/PageParamModel"; +import { queryMainRecordList } from "../../request/api/Api"; +import { cardRoundBorderGreyStyle, cardRoundBorderStyle } from "../../style/BorderStyle"; +import { StringUtils } from "../../util/StringUtils"; +import { ToastUtils } from "../../util/ToasUtils"; +import { router } from "@kit.ArkUI"; +import { common } from "@kit.AbilityKit"; +import { SelectTaskObservedModel } from "../../model/uiModel/SelectTask"; +import { DateUtils } from "../../util/DateUtils"; + +/* + * 卡点核录记录 街面盘查 + */ +@Preview({ + title: 'ContentTable' +}) +@Component +export struct CheckPointHistoryFragment { + // @State selectValue:Array = [] + @State taskName: string | undefined = undefined + @State taskId: string | undefined = undefined + @State beginTime: string | undefined = undefined + @State endTime: string | undefined = undefined + @State recordDescription: string = "共搜索到 0 条" + @State recordList: Array = []; + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + total: number = 0; + pageNum: number = 1; + isRefreshStatus: number = 0; + + aboutToAppear(): void { + // this.selectValue.push("任务名称") + // this.selectValue.push("人员信息") + // this.selectValue.push("车辆信息") + // this.selectValue.push("物品类型") + + let context = getContext(this) as common.UIAbilityContext; + context.eventHub.on("select_task", (data: SelectTaskObservedModel) => { + if (data) { + this.taskName = data.taskName + this.taskId = data.taskId + } + }) + setTimeout(() => { + this.controller.isAutoRefresh = true + }, 300) + } + + aboutToDisappear(): void { + let context = getContext(this) as common.UIAbilityContext; + context.eventHub.off("select_task") + } + + getRecordListData() { + queryMainRecordList(1, StringUtils.get(this.taskId, ""), this.pageNum, StringUtils.get(this.beginTime, ""," 00:00:00"), + StringUtils.get(this.endTime, ""," 23:59:59")) + .then((res) => { + console.debug("查询主记录列表成功", JSON.stringify(res)) + if (res.code == 200) { + let data = res.data; + if (data) { + this.total = data.total; + this.recordDescription = `共搜索到 ${data.total} 条` + let list = data.rows + if (list) { + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.recordList = new Array; + this.controller.finishRefresh() + } + if (this.isRefreshStatus = 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + } + list.forEach((item) => { + this.recordList.push(item) + }) + if (this.pageNum * 20 >= this.total) { + this.controller.closeLoadMore = true + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, StringUtils.get(res.msg, "获取失败!"))); + } + }) + .catch((e: AxiosError) => { + console.debug("查询主记录列表失败", e.message) + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, e.message)); + + }) + } + + handlerErrorOrEmpty(model: ErrorOfEmptyModel) { + ToastUtils.toastBottom(model.msg) + if (this.isRefreshStatus == 1) { + //刷新 + this.controller.finishRefresh() + this.recordList = new Array + } + if (this.isRefreshStatus == 2) { + //加载 + this.controller.finishLoadMore() + } + this.isRefreshStatus = 0 + } + + + /** + * 时间选择 + * @param type startTime/endTime + */ + showTimePicker(type: string) { + let currentTime = new Date() + if (type == 'startTime') { + let start = DateUtils.pastStrDate(this.beginTime); + currentTime = start == null ? new Date() : start + + } + if (type == 'endTime') { + let end = DateUtils.pastStrDate(this.endTime); + currentTime = end == null ? new Date() : end + } + + DatePickerDialog.show({ + start: new Date('2020-1-1'), + end: new Date('2030-12-31'), + selected: currentTime, + lunar: false, // 是否显示农历 + showTime: false, // 是否显示时间 + onAccept: (value: DatePickerResult) => { + let month = (value.month? value.month : 0)+1 + let data = value.year + '-' + DateUtils.padZero(month) + '-' + DateUtils.padZero(value.day) + if (type == 'startTime') { + this.beginTime = data + } + if (type == 'endTime') { + this.endTime = data + } + console.info('确认日期:', value.toString()); + }, + onCancel: () => { + console.info('用户取消选择'); + } + }); + } + + build() { + Column() { + this.searchContent() + + Text(this.recordDescription) + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey8')) + .textAlign(TextAlign.Center) + + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.controller.closeLoadMore = false; + this.pageNum = 1; + this.isRefreshStatus = 1; + this.getRecordListData() + }, + onLoadMore: () => { + if (this.pageNum * 30 >= this.total) { + this.controller.finishLoadMore() + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .backgroundColor($r('app.color.page_background')) + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + @Builder + searchContent() { + Column() { + Row() { + Text('任务名称:') + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.colorGrey8')) + .height($r('app.float.default_40')) + .margin({ + left: $r('app.float.default_10'), + top: $r('app.float.default_10') + }) + .textAlign(TextAlign.Center); + + Text(StringUtils.get(this.taskName, "请选择任务")) + .fontSize($r('app.float.text_size_16')) + .fontColor(this.taskName ? $r('app.color.colorGrey8') : $r('app.color.colorGrey6')) + .margin({ + right: $r('app.float.default_10'), + top: $r('app.float.default_10') + }) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .height($r('app.float.default_40')) + .layoutWeight(1) + .width($r('app.float.default_88')) + .textAlign(TextAlign.Start) + .border(cardRoundBorderGreyStyle) + .onClick(() => { + router.pushUrl({ url: "ui/pages/SelectTaskListPage" }) + }) + + } + .width('95%') + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_10') + }); + + Row() { + Row() { + Text(StringUtils.get(this.beginTime, "开始时间")) + .fontSize($r('app.float.text_size_16')) + .fontColor(this.beginTime ? $r('app.color.colorGrey8') : $r('app.color.colorGrey6')) + .margin({ + right: $r('app.float.default_5'), + }) + .height($r('app.float.default_40')) + .layoutWeight(1) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .width($r('app.float.default_88')) + .textAlign(TextAlign.Start); + + Image($r('app.media.log_rl')) + .width($r('app.float.default_20')) + .height($r('app.float.default_20')); + } + .alignItems(VerticalAlign.Center) + .layoutWeight(1) + .onClick(() => { + this.showTimePicker('startTime') + }) + + Divider() + .width($r('app.float.default_1')) + .height($r('app.float.default_40')) + .backgroundColor($r('app.color.colorGrey2')) + .margin({ + right: $r('app.float.default_5'), + left: $r('app.float.default_5') + }); + + Row() { + Text(StringUtils.get(this.endTime, "结束时间")) + .fontSize($r('app.float.text_size_16')) + .fontColor(this.endTime ? $r('app.color.colorGrey8') : $r('app.color.colorGrey6')) + .margin({ + right: $r('app.float.default_5'), + }) + .height($r('app.float.default_40')) + .layoutWeight(1) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .width($r('app.float.default_88')) + .textAlign(TextAlign.Start); + + Image($r('app.media.log_rl')) + .width($r('app.float.default_20')) + .height($r('app.float.default_20')) + .margin({ + right: $r('app.float.default_5'), + }); + } + .alignItems(VerticalAlign.Center) + .layoutWeight(1) + .onClick(() => { + this.showTimePicker('endTime') + }) + + } + .border(cardRoundBorderGreyStyle) + .width('95%') + .margin({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .margin($r('app.float.default_10')); + + Button("搜索", { type: ButtonType.Normal, stateEffect: true }) + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.white')) + .backgroundColor($r('app.color.bull')) + .borderRadius(8) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + bottom: $r('app.float.default_10'), + }) + .onClick(() => { + this.controller.isAutoRefresh = true + }) + .width('95%'); + } + .width('95%') + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + .margin($r('app.float.default_10')) + } + + @Builder + listView() { + List({ scroller: this.scroller }) { + ForEach(this.recordList, (item: MainRecordResultModel, index) => { + ListItem() { + this.itemView(item) + } + .onClick(() => { + let param: SkipHistoryDetailsParam = { + pctime: item.checkTime, + policenum: item.policeName, + policename: item.policeName, + pcyy: item.checkReason, + yjdw: item.yjdwmc, + mainId: item.mainId, + status: item.status, + address: item.checkAddress, + taskName: item.taskName, + type: 1 + } + router.pushUrl({ url: "ui/pages/HistoryDetailsPage", params: param }) + }) + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + itemView(item: MainRecordResultModel) { + Column() { + Row() { + Text("时间:") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Text(item.checkTime) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .margin({ left: $r('app.float.default_5') }) + + Text(item.status == 1 ? "移交" : "通过") + .fontColor(item.status == 1 ? $r('app.color.colorYellow7') : $r('app.color.colorBluen7')) + .backgroundColor(item.status == 1 ? $r('app.color.colorYellow2') : $r('app.color.colorBluen2')) + .fontSize($r('app.float.text_size_12')) + .border({ + width: $r('app.float.default_1'), + color: item.status == 1 ? $r('app.color.colorYellow6') : $r('app.color.colorBluen6'), + radius: $r('app.float.default_20'), + }) + .padding({ + left: $r('app.float.default_8'), + right: $r('app.float.default_8'), + top: $r('app.float.default_2'), + bottom: $r('app.float.default_2') + }) + .textAlign(TextAlign.Center) + .margin({ left: $r('app.float.default_5') }) + + } + .width('95%') + + Row() { + Text("任务:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Text(item.taskName) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + } + .width('95%') + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text("地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Text(item.checkAddress) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + } + .width('95%') + .margin({ top: $r('app.float.default_5') }) + + Row() { + Column() { + Text("总人数/异常数") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Row() { + Text(StringUtils.get(item.peopleCount, "0", "人")) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + Text("/") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Text(StringUtils.get(item.unusualPeopleCount, "0", "人")) + .fontColor($r('app.color.colorYellow8')) + .fontSize($r('app.float.text_size_14')) + } + .justifyContent(FlexAlign.Center) + .margin({ top: $r('app.float.default_5') }) + } + .justifyContent(FlexAlign.Center) + .height($r('app.float.default_52')) + .layoutWeight(1) + .border(cardRoundBorderGreyStyle) + + Column() { + Text("车牌") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + + Text(StringUtils.get(item.carNum, "-")) + .fontColor(item.unusualCarCount == "0" ? $r('app.color.bull') : $r('app.color.colorYellow7')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_5') }) + + } + .justifyContent(FlexAlign.Center) + .height($r('app.float.default_52')) + .layoutWeight(1) + .border(cardRoundBorderGreyStyle) + .margin({ left: $r('app.float.default_5'), right: $r('app.float.default_5') }) + + Column() { + Text("物品") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + + Text(this.getGoodCount(item.goodsCount)) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_5') }) + } + .justifyContent(FlexAlign.Center) + .height($r('app.float.default_52')) + .layoutWeight(1) + .border(cardRoundBorderGreyStyle) + + } + .width('95%') + .margin({ top: $r('app.float.default_5') }) + } + .width('95%') + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + .padding($r('app.float.default_10')) + .margin($r('app.float.default_10')) + } + + getGoodCount(goodsCount: string): string { + let count = StringUtils.get(goodsCount, "-") + if (count == "0") { + return "-" + } + return count; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/fragment/GoodsListFragment.ets b/entry/src/main/ets/ui/fragment/GoodsListFragment.ets new file mode 100644 index 0000000..cd9da7f --- /dev/null +++ b/entry/src/main/ets/ui/fragment/GoodsListFragment.ets @@ -0,0 +1,168 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh" +import { AxiosError } from "@ohos/axios" +import { ToastUtil } from "@pura/harmony-utils" +import AppConstants from "../../app/AppConstant" +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag" +import { GoodsBean } from "../../model/uiModel/GoodsModel" +import { getGoodsHistoryByMainId } from "../../request/api/Api" +import { StringUtils } from "../../util/StringUtils" + +@Preview({ + title: 'ContentTable' +}) +@Component +export struct GoodsListFragment { + @State mainId :string = "" + @State isYj:boolean = false + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + @State goodsList:Array = [] + + aboutToAppear(): void { + setTimeout(()=>{ + this.controller.isAutoRefresh = true + },300) + } + + getRecordListData() { + getGoodsHistoryByMainId(this.mainId) + .then(res => { + this.controller.finishRefresh() + if (res.code == 200) { + let data = res.data + if (data) { + this.goodsList = new Array + data.forEach((item)=>{ + item.isYj = this.isYj + this.goodsList.push(item) + }) + }else { + ToastUtil.showToast(StringUtils.get(res.msg,"未查询到物品!")) + } + }else { + ToastUtil.showToast(`查询物品失败${StringUtils.get(res.msg,"")}`) + } + }) + .catch((err:AxiosError) => { + this.controller.finishRefresh() + ToastUtil.showToast(`查询物品失败${err.message}`) + }) + } + + build() { + Column(){ + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + enableLoadMore:false, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + + @Builder + listView() { + List({ scroller: this.scroller}) { + ForEach(this.goodsList, (item: GoodsBean) => { + ListItem() { + this.itemView(item) + } + .onClick(() => { + + }) + }) + } + .divider({ + strokeWidth: $r('app.float.default_1'), + color: $r('app.color.colorGrey2'), + startMargin:$r('app.float.default_63') + }) + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + +//http://53.1.214.228:9000/ypc/2025/09/25/dd809f10a803450986480b3a50acfa84.jpg + @Builder + itemView(item: GoodsBean) { + Row() { + Image(RuanseeAbitityStag.appCache.convertPhotoUrl(item.photoUrl)) + .width($r('app.float.default_43')) + .height($r('app.float.default_43')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Column() { + Row() { + Text(item.name) + .fontSize($r('app.float.default_16')) + .fontColor($r('app.color.colorGrey8')) + + Text(String(item.count)) + .fontSize($r('app.float.default_16')) + .fontColor($r('app.color.colorGrey8')) + .margin({ left: $r('app.float.default_5') ,right: $r('app.float.default_5')}) + + Text(item.unit) + .fontSize($r('app.float.default_16')) + .fontColor($r('app.color.colorGrey8')) + Text(item.isYj ? "移交" : "通过") + .fontColor(item.isYj ? $r('app.color.colorYellow7') : $r('app.color.colorBluen7')) + .backgroundColor(item.isYj ? $r('app.color.colorYellow2') : $r('app.color.colorBluen2')) + .fontSize($r('app.float.text_size_12')) + .border({ + width: $r('app.float.default_1'), + color: item.isYj? $r('app.color.colorYellow6') : $r('app.color.colorBluen6'), + radius: $r('app.float.default_20'), + }) + .padding({ + left: $r('app.float.default_8'), + right: $r('app.float.default_8'), + top: $r('app.float.default_2'), + bottom: $r('app.float.default_2') + }) + .textAlign(TextAlign.Center) + .margin({ left: $r('app.float.default_5') }) + + } + .width('95%') + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + + Text(item.remark) + .fontSize($r('app.float.default_14')) + .fontColor($r('app.color.colorGrey6')) + .visibility(item.remark ? Visibility.Visible : Visibility.None) + .margin({ top: $r('app.float.default_5') }) + + Text(item.checkTime) + .fontSize($r('app.float.default_14')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .layoutWeight(1) + .alignItems(HorizontalAlign.Start) + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_72')) + .padding({ top: $r('app.float.default_8'), bottom: $r('app.float.default_8') }) + .backgroundColor($r('app.color.white')) + .width(AppConstants.PERCENTAGE_MAX) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/fragment/MyAttentionCarFragment.ets b/entry/src/main/ets/ui/fragment/MyAttentionCarFragment.ets new file mode 100644 index 0000000..d038bbd --- /dev/null +++ b/entry/src/main/ets/ui/fragment/MyAttentionCarFragment.ets @@ -0,0 +1,311 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh"; +import { AxiosError } from "@ohos/axios"; +import { ToastUtil } from "@pura/harmony-utils"; +import AppConstants from "../../app/AppConstant"; +import { FocusCarBean } from "../../model/resultModel/FocusModel"; +import { SkipCarCountParam } from "../../model/uiModel/PageParamModel"; +import { getMyFocusCaraList } from "../../request/api/Api"; +import { StringUtils } from "../../util/StringUtils"; +import router from "@ohos.router"; + +@Preview({ + title: 'ContentTable' +}) +@Component +export struct MyAttentionCarFragment{ + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + @State personList: Array = [] ; + pageNum: number = 1; + total: number = 0; + //刷新组件状态 0 = 未触发的状态 1 = 正在刷新状态 2 = 正在加载中 + isRefreshStatus: number = 0; + //获取数据的状态 0 = 加载数据为空此时应该显示加载空界面 -1 = 加载数据失败,显示加载失败页面 1 = 表示正常加载列表页面 + @State getDataStatus: number = 1; + + aboutToAppear(): void { + + // 模拟网络请求延时(3秒) + setTimeout(() => { + this.isRefreshStatus = 1 + this.controller.isAutoRefresh = true + }, 300); + } + + onPageShow(): void { + // this.controller.closeLoadMore = true; 移交 + + } + + getAttentionPersonList() { + getMyFocusCaraList(this.pageNum) + .then((res) => { + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0; + this.controller.finishRefresh() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + let data = res.data + if (data) { + this.total = data.total; + let rows = data.rows; + if (rows) { + this.personList = new Array(); + this.getDataStatus = 1; + rows.forEach((item) => { + this.personList.push(item) + }) + if (this.total <= this.pageNum * 30) { + //没有更多数据 + this.controller.closeLoadMore = true; + } + } else { + ToastUtil.showToast("你还未关注人员!") + this.getDataStatus = 0; + } + } else { + ToastUtil.showToast("你还未关注人员!") + this.getDataStatus = 0; + } + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0; + this.controller.finishLoadMore() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + let data = res.data + if (data) { + this.total = data.total; + let rows = data.rows; + if (rows) { + this.personList = new Array(); + rows.forEach((item) => { + this.personList.push(item) + }) + if (this.total <= this.pageNum * 30) { + //没有更多数据 + this.controller.closeLoadMore = true; + } + } else { + ToastUtil.showToast("未获取到更多关注人员!") + } + } else { + ToastUtil.showToast("未获取到更多关注人员!") + } + } + }) + .catch((e: AxiosError) => { + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.controller.finishRefresh() + this.getDataStatus = -1; + return + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + } + }) + } + + build() { + Column() { + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + if (this.getDataStatus == 1) { + this.listView() + } + }, + onRefresh: () => { + this.pageNum = 1; + this.isRefreshStatus = 1; + this.controller.closeLoadMore = false; + this.getAttentionPersonList() + }, + onLoadMore: () => { + if (this.total <= this.pageNum * 30) { + //没有更多数据 + ToastUtil.showToast("没有更多数据!") + this.controller.closeLoadMore = true; + this.controller.finishLoadMore() + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getAttentionPersonList() + } + }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + @Builder + listView() { + List({ scroller: this.scroller, space: 10 }) { + ForEach(this.personList, (item: FocusCarBean) => { + ListItem() { + this.itemView(item) + } + .onClick(()=>{ + let param :SkipCarCountParam = { + what: 0, + carNum: StringUtils.get(item.hphm, ""), + carZL: StringUtils.get(item.cllx, ""), + carPP: StringUtils.get(item.clpp, ""), + carJH: StringUtils.get(item.cjh, ""), + carFDJH: StringUtils.get(item.fdjh, ""), + carSYR: StringUtils.get(item.clsyr, ""), + idCardNum: StringUtils.get(item.syrzjhm, ""), + carYs: StringUtils.get(item.csys, ""), + carStatus: StringUtils.get(item.carStatus, "") + } + router.pushUrl({url:"ui/pages/CarCheckDetailsPages",params:param}) + }) + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + itemView(bean: FocusCarBean) { + Row() { + + + Column() { + Row() { + Text(bean.hphm) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Image(this.getIcon(StringUtils.get(bean.carStatus, ""))) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + .margin({ left: $r('app.float.default_5') }) + } + + Row(){ + + Text(bean.cllx) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + + Text(bean.csys) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + } + + Text(bean.updateTime) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + } + .height($r('app.float.default_120')) + .layoutWeight(1) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + .margin({ left: $r('app.float.default_10') }) + + + //关注图标 + Column() { + Image(this.getAttentionRes(1)) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Start) + .width($r('app.float.default_26')) + .height($r('app.float.default_120')) + + //又箭头 + Column() { + Image($r('app.media.ic_row_right')) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .width($r('app.float.default_26')) + .margin({ left: $r('app.float.default_8'), right: $r('app.float.default_10') }) + .height($r('app.float.default_120')) + + } + .width(`calc(100% - 20vp)`) + .height($r('app.float.default_120')) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey2'), + radius: $r('app.float.default_5') + }) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } + + getAttentionRes(attentionStatus: number): Resource { + if (attentionStatus == 1) { + return $r('app.media.icon_attention_leven1'); + } + if (attentionStatus == 2) { + return $r('app.media.icon_attention_leven2'); + } + if (attentionStatus == 1) { + return $r('app.media.icon_attention_leven3'); + } + return $r('app.media.icon_attention_leven1'); + } + + getIcon(peopleStatus: string): Resource { + if (peopleStatus.startsWith("涉稳")) { + return $r("app.media.ic_type_stability") + } + if (peopleStatus.startsWith("涉恐")) { + return $r("app.media.ic_type_fear") + } + if (peopleStatus.startsWith("关注")) { + return $r("app.media.ic_type_focus") + } + if (peopleStatus.startsWith("云控")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(peopleStatus, "精神")) { + return $r("app.media.ic_type_fine") + } + if (peopleStatus.startsWith("非访")) { + return $r("app.media.ic_type_non") + } + if (peopleStatus.startsWith("前科")) { + return $r("app.media.ic_type_criminal_record") + } + if (StringUtils.containsChar(peopleStatus, "毒")) { + return $r("app.media.ic_type_poison") + } + if (StringUtils.containsChar(peopleStatus, "临")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(peopleStatus, "逃")) { + return $r("app.media.ic_type_escape") + } + return $r("app.media.ic_type_normal"); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/fragment/MyAttentionPersonFragment.ets b/entry/src/main/ets/ui/fragment/MyAttentionPersonFragment.ets new file mode 100644 index 0000000..843a573 --- /dev/null +++ b/entry/src/main/ets/ui/fragment/MyAttentionPersonFragment.ets @@ -0,0 +1,280 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh"; +import { AxiosError } from "@ohos/axios"; +import { ToastUtil } from "@pura/harmony-utils/src/main/ets/action/ToastUtil"; +import AppConstants from "../../app/AppConstant"; +import { FocusPersonBean } from "../../model/resultModel/FocusModel"; +import { getMyFocusPersonList } from "../../request/api/Api"; +import { StringUtils } from "../../util/StringUtils"; +import { fileUri } from "@kit.CoreFileKit"; +import { getPersonStatusIcon } from "../../util/StatusIconUtils"; +import { SkipCheckCountParam } from "../../model/uiModel/PageParamModel"; +import { FileUtils } from "../../util/FileUtils"; +import router from "@ohos.router"; + +@Preview({ + title: 'ContentTable' +}) +@Component +export struct MyAttentionPersonFragment { + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + @State personList: Array = [] ; + fileDir: string = ""; + pageNum: number = 1; + total: number = 0; + //刷新组件状态 0 = 未触发的状态 1 = 正在刷新状态 2 = 正在加载中 + isRefreshStatus: number = 0; + //获取数据的状态 0 = 加载数据为空此时应该显示加载空界面 -1 = 加载数据失败,显示加载失败页面 1 = 表示正常加载列表页面 + @State getDataStatus: number = 1; + + aboutToAppear(): void { + this.fileDir = FileUtils.ID_CARD_DIR + // 模拟网络请求延时(3秒) + setTimeout(() => { + this.isRefreshStatus = 1 + this.controller.isAutoRefresh = true + }, 300); + } + + + getAttentionPersonList() { + getMyFocusPersonList(this.pageNum) + .then((res) => { + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0; + this.controller.finishRefresh() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + let data = res.data + if (data) { + this.total = data.total; + let rows = data.rows; + if (rows) { + this.personList = new Array(); + this.getDataStatus = 1; + rows.forEach((item) => { + let filePate = `${this.fileDir}/${item.idCardNum}.png`; + item.idCardPhoto = fileUri.getUriFromPath(filePate) + this.personList.push(item) + }) + if (this.total <= this.pageNum * 30) { + //没有更多数据 + this.controller.closeLoadMore = true; + } + } else { + ToastUtil.showToast("你还未关注人员!") + this.getDataStatus = 0; + } + } else { + ToastUtil.showToast("你还未关注人员!") + this.getDataStatus = 0; + } + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0; + this.controller.finishLoadMore() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + let data = res.data + if (data) { + this.total = data.total; + let rows = data.rows; + if (rows) { + this.personList = new Array(); + rows.forEach((item) => { + let filePate = `${this.fileDir}/${item.idCardNum}.png`; + item.idCardPhoto = fileUri.getUriFromPath(filePate) + this.personList.push(item) + }) + if (this.total <= this.pageNum * 30) { + //没有更多数据 + this.controller.closeLoadMore = true; + } + } else { + ToastUtil.showToast("未获取到更多关注人员!") + } + } else { + ToastUtil.showToast("未获取到更多关注人员!") + } + } + }) + .catch((e: AxiosError) => { + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.controller.finishRefresh() + this.getDataStatus = -1; + return + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + } + }) + } + + build() { + Column() { + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + if (this.getDataStatus == 1) { + this.listView() + } + }, + onRefresh: () => { + this.pageNum = 1; + this.isRefreshStatus = 1; + this.controller.closeLoadMore = false; + this.getAttentionPersonList() + }, + onLoadMore: () => { + if (this.total <= this.pageNum * 30) { + //没有更多数据 + ToastUtil.showToast("没有更多数据!") + this.controller.closeLoadMore = true; + this.controller.finishLoadMore() + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getAttentionPersonList() + } + }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + @Builder + listView() { + List({ scroller: this.scroller, space: 10 }) { + ForEach(this.personList, (item: FocusPersonBean) => { + ListItem() { + this.itemView(item) + } + .onClick(()=>{ + let param : SkipCheckCountParam = { + what: 0, + name: StringUtils.get(item.realName, ""), + sex: StringUtils.get(item.sex, ""), + idCardNum: StringUtils.get(item.idCardNum, ""), + birthDate: StringUtils.get(item.birthDate, ""), + nation: StringUtils.get(item.mz, ""), + address: StringUtils.get(item.address, ""), + photoData: "", + zdlx:StringUtils.get(item.rylx, ""), + } + router.pushUrl({url:"ui/pages/PeopleCheckDetailsPages",params:param}) + + }) + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + itemView(bean: FocusPersonBean) { + Row() { + Image(bean.idCardPhoto) + .width($r('app.float.default_88')) + .height($r('app.float.default_100')) + .margin({ left: $r('app.float.default_10') }) + .alt($r('app.media.icon_load_image')) + .onError(() => { + bean.idCardPhoto = $r('app.media.icon_error_image') + }) + + Column() { + Row() { + Text(bean.realName) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Image(getPersonStatusIcon(StringUtils.get(bean.rylx, ""))) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + .margin({ left: $r('app.float.default_5') }) + } + + Text(bean.idCardNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + + Text(bean.address) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + } + .height($r('app.float.default_120')) + .layoutWeight(1) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + .margin({ left: $r('app.float.default_10') }) + + + //关注图标 + Column() { + Image(this.getAttentionRes(1)) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Start) + .width($r('app.float.default_26')) + .height($r('app.float.default_120')) + + //又箭头 + Column() { + Image($r('app.media.ic_row_right')) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .width($r('app.float.default_26')) + .margin({ left: $r('app.float.default_8'), right: $r('app.float.default_10') }) + .height($r('app.float.default_120')) + + } + .width(`calc(100% - 20vp)`) + .height($r('app.float.default_120')) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey2'), + radius: $r('app.float.default_5') + }) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } + + getAttentionRes(attentionStatus: number): Resource { + if (attentionStatus == 1) { + return $r('app.media.icon_attention_leven1'); + } + if (attentionStatus == 2) { + return $r('app.media.icon_attention_leven2'); + } + if (attentionStatus == 1) { + return $r('app.media.icon_attention_leven3'); + } + return $r('app.media.icon_attention_leven1'); + } + + +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/fragment/PeopleListFragment.ets b/entry/src/main/ets/ui/fragment/PeopleListFragment.ets new file mode 100644 index 0000000..206f05f --- /dev/null +++ b/entry/src/main/ets/ui/fragment/PeopleListFragment.ets @@ -0,0 +1,230 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh" +import { AxiosError } from "@ohos/axios"; +import { JSONUtil, ToastUtil } from "@pura/harmony-utils"; +import AppConstants from "../../app/AppConstant" +import { AccompanPersonBean } from "../../model/resultModel/CheckPeopleResultModel"; +import { SkipCheckCountParam } from "../../model/uiModel/PageParamModel"; +import { getPersonListByMainId } from "../../request/api/Api"; +import { getPersonStatusIcon } from "../../util/StatusIconUtils"; +import { StringUtils } from "../../util/StringUtils"; +import { router } from "@kit.ArkUI"; + +@Preview({ + title: 'ContentTable' +}) +@Component +export struct PeopleListFragment { + @State mainId: string = "" + @State personList: Array = new Array; + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + total: number = 0; + pageNum: number = 1; + isRefreshStatus: number = 0; + + aboutToAppear(): void { + setTimeout(() => { + this.controller.isAutoRefresh = true + }, 300) + } + + getRecordListData() { + getPersonListByMainId(this.pageNum,20,this.mainId) + .then((res) => { + console.debug(JSONUtil.beanToJsonStr(res)) + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.controller.finishRefresh() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + if (res.data) { + this.total = res.data.total; + let rows = res.data.rows; + if (rows && rows != undefined) { + this.personList = new Array + for (let i = 0; i < rows.length; i++) { + let bean = rows[i]; + // let filePate = `${this.fileDir}/${bean.sfz}.png`; + // bean.idCardPhoto = fileUri.getUriFromPath(filePate) + this.personList.push(bean); + } + } else { + ToastUtil.showToast("未查询到数据!") + return + } + } else { + ToastUtil.showToast("未查询到数据!") + return + } + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + if (res.data) { + this.total = res.data.total; + let rows = res.data.rows; + if (rows && rows != undefined) { + for (let i = 0; i < rows.length; i++) { + let bean = rows[i]; + // let filePate = `${this.fileDir}/${bean.sfz}.png`; + // bean.idCardPhoto = fileUri.getUriFromPath(filePate) + this.personList.push(bean); + } + if (this.pageNum * 20 >= this.total) { + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + } else { + ToastUtil.showToast("没有更多数据!") + return + } + } else { + ToastUtil.showToast("没有更多数据!") + return + } + } + }) + .catch((e: AxiosError) => { + console.error(e.message) + ToastUtil.showToast(e.message) + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.controller.finishRefresh() + return + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + } + }) + } + + build() { + Column() { + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.controller.closeLoadMore = false; + this.pageNum = 1; + this.isRefreshStatus = 1; + this.getRecordListData() + }, + onLoadMore: () => { + if (this.pageNum * 30 >= this.total) { + this.controller.finishLoadMore() + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + }.width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + @Builder + listView() { + List({ scroller: this.scroller}) { + ForEach(this.personList, (item: AccompanPersonBean) => { + ListItem() { + this.itemView(item) + } + .onClick(() => { + let param : SkipCheckCountParam = { + what: 0, + name: StringUtils.get(item.name, ""), + sex: item.sex==1?"男":item.sex==2?"女":"未知", + idCardNum: StringUtils.get(item.sfz, ""), + birthDate: StringUtils.get(item.csrq, ""), + nation: StringUtils.get(item.mz, ""), + address: StringUtils.get(item.address, ""), + photoData: "", + zdlx:StringUtils.get(item.peopleStatusStr, ""), + } + router.pushUrl({url:"ui/pages/PeopleCheckDetailsPages",params:param}) + }) + }) + } + .divider({ + strokeWidth: $r('app.float.default_1'), + color: $r('app.color.colorGrey2'), + startMargin:$r('app.float.default_63') + }) + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + itemView(item: AccompanPersonBean) { + Row() { + Image(getPersonStatusIcon(item.peopleStatusStr)) + .width($r('app.float.default_43')) + .height($r('app.float.default_43')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Column() { + Row() { + Text(`姓名:${item.name}`) + .fontSize($r('app.float.default_16')) + .fontColor($r('app.color.colorGrey8')) + Text(item.status == "1" ? "移交" : "通过") + .fontColor(item.status == "1" ? $r('app.color.colorYellow7') : $r('app.color.colorBluen7')) + .backgroundColor(item.status == "1" ? $r('app.color.colorYellow2') : $r('app.color.colorBluen2')) + .fontSize($r('app.float.text_size_12')) + .border({ + width: $r('app.float.default_1'), + color: item.status == "1" ? $r('app.color.colorYellow6') : $r('app.color.colorBluen6'), + radius: $r('app.float.default_20'), + }) + .padding({ + left: $r('app.float.default_8'), + right: $r('app.float.default_8'), + top: $r('app.float.default_2'), + bottom: $r('app.float.default_2') + }) + .textAlign(TextAlign.Center) + .margin({ left: $r('app.float.default_5') }) + + } + .width('95%') + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + + Text(item.sfz) + .fontSize($r('app.float.default_14')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .layoutWeight(1) + .alignItems(HorizontalAlign.Start) + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_60')) + .padding({ top: $r('app.float.default_8'), bottom: $r('app.float.default_8') }) + .backgroundColor($r('app.color.white')) + .width(AppConstants.PERCENTAGE_MAX) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/fragment/StreetSearchHistoryFragment.ets b/entry/src/main/ets/ui/fragment/StreetSearchHistoryFragment.ets new file mode 100644 index 0000000..4e76546 --- /dev/null +++ b/entry/src/main/ets/ui/fragment/StreetSearchHistoryFragment.ets @@ -0,0 +1,481 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh" +import { AxiosError } from "@ohos/axios" +import { ToastUtil } from "@pura/harmony-utils" +import AppConstants from "../../app/AppConstant" +import { MainRecordResultModel } from "../../model/resultModel/MainResultModel" +import { ErrorOfEmptyModel } from "../../model/uiModel/BeanModel" +import { SkipHistoryDetailsParam } from "../../model/uiModel/PageParamModel" +import { queryMainRecordList } from "../../request/api/Api" +import { cardRoundBorderGreyStyle, cardRoundBorderStyle } from "../../style/BorderStyle" +import { IdCardNumUtils } from "../../util/IdCardNumUtils" +import { StringUtils } from "../../util/StringUtils" +import { ToastUtils } from "../../util/ToasUtils" +import { router } from "@kit.ArkUI" +import { DateUtils } from "../../util/DateUtils" + +/* + * 卡点核录记录 街面盘查 + */ +@Preview({ + title: 'ContentTable' +}) +@Component +export struct StreetSearchHistoryFragment{ + + @State inputContent: string | undefined = undefined + + @State beginTime: string | undefined = undefined + @State endTime: string | undefined = undefined + @State recordDescription: string = "共搜索到 0 条" + @State recordList: Array = []; + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + total: number = 0; + pageNum: number = 1; + isRefreshStatus: number = 0; + + aboutToAppear(): void { + setTimeout(() => { + this.controller.isAutoRefresh = true + }, 300) + } + + getRecordListData() { + if (this.inputContent){ + if (!IdCardNumUtils.validateIdCardNum(this.inputContent)) { + ToastUtil.showToast("请检查身份证号是否正确!") + this.controller.finishRefresh() + this.controller.finishLoadMore() + this.isRefreshStatus = 0 + return + } + } + + queryMainRecordList(0, "", this.pageNum, StringUtils.get(this.beginTime, ""," 00:00:00"), + StringUtils.get(this.endTime, ""," 23:59:59"),StringUtils.get(this.inputContent,"")) + .then((res) => { + console.debug("查询主记录列表成功", JSON.stringify(res)) + if (res.code == 200) { + let data = res.data; + if (data) { + this.total = data.total; + this.recordDescription = `共搜索到 ${data.total} 条` + let list = data.rows + if (list) { + if (this.isRefreshStatus == 1){ + this.isRefreshStatus = 0 + this.recordList = new Array; + this.controller.finishRefresh() + } + if (this.isRefreshStatus = 2){ + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + } + list.forEach((item) => { + this.recordList.push(item) + }) + if (this.pageNum * 20 >= this.total) { + this.controller.closeLoadMore = true + } + }else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + }else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, StringUtils.get(res.msg, "获取失败!"))); + } + }) + .catch((e: AxiosError) => { + console.debug("查询主记录列表失败", e.message) + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, e.message)); + + }) + } + + + handlerErrorOrEmpty(model: ErrorOfEmptyModel) { + ToastUtils.toastBottom(model.msg) + if (this.isRefreshStatus == 1) { + //刷新 + this.controller.finishRefresh() + this.recordList = new Array + } + if (this.isRefreshStatus == 2) { + //加载 + this.controller.finishLoadMore() + } + this.isRefreshStatus = 0 + } + + + /** + * 时间选择 + * @param type startTime/endTime + */ + showTimePicker(type: string) { + let currentTime = new Date() + if (type == 'startTime') { + let start = DateUtils.pastStrDate(this.beginTime); + currentTime = start == null ? new Date() : start + + } + if (type == 'endTime') { + let end = DateUtils.pastStrDate(this.endTime); + currentTime = end == null ? new Date() : end + } + + DatePickerDialog.show({ + start: new Date('2020-1-1'), + end: new Date('2030-12-31'), + selected: currentTime, + lunar: false, // 是否显示农历 + showTime: false, // 是否显示时间 + onAccept: (value: DatePickerResult) => { + let month = (value.month? value.month : 0)+1 + let data = value.year + '-' + DateUtils.padZero(month) + '-' + DateUtils.padZero(value.day) + if (type == 'startTime') { + this.beginTime = data + } + if (type == 'endTime') { + this.endTime = data + } + console.info('确认日期:', value.toString()); + }, + onCancel: () => { + console.info('用户取消选择'); + } + }); + } + + build() { + Column() { + this.searchContent() + + Text(this.recordDescription) + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey8')) + .textAlign(TextAlign.Center) + + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.controller.closeLoadMore = false; + this.pageNum = 1; + this.isRefreshStatus = 1; + this.getRecordListData() + }, + onLoadMore: () => { + if (this.pageNum * 30 >= this.total) { + this.controller.finishLoadMore() + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .backgroundColor($r('app.color.page_background')) + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + @Builder + searchContent() { + Column() { + Row() { + Text('人员信息:') + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.colorGrey8')) + .height($r('app.float.default_40')) + .margin({ + left: $r('app.float.default_10'), + top: $r('app.float.default_10') + }) + .textAlign(TextAlign.Center); + + TextInput({text:this.inputContent,placeholder:"请输入被核验人员证件号码"}) + .placeholderColor( $r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.colorGrey8') ) + .margin({ + right: $r('app.float.default_10'), + top: $r('app.float.default_10') + }) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .onChange((text: string) => { + this.inputContent = text; + }) + .height($r('app.float.default_40')) + .layoutWeight(1) + .width($r('app.float.default_88')) + .textAlign(TextAlign.Start) + .border(cardRoundBorderGreyStyle); + + } + .width('95%') + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_10') + }); + + Row() { + Row() { + Text(StringUtils.get(this.beginTime, "开始时间")) + .fontSize($r('app.float.text_size_16')) + .fontColor(this.beginTime ? $r('app.color.colorGrey8') : $r('app.color.colorGrey6')) + .margin({ + right: $r('app.float.default_5'), + }) + .height($r('app.float.default_40')) + .layoutWeight(1) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .width($r('app.float.default_88')) + .textAlign(TextAlign.Start); + + Image($r('app.media.log_rl')) + .width($r('app.float.default_20')) + .height($r('app.float.default_20')); + } + .alignItems(VerticalAlign.Center) + .layoutWeight(1) + .onClick(() => { + this.showTimePicker('startTime') + }) + + Divider() + .width($r('app.float.default_1')) + .height($r('app.float.default_40')) + .backgroundColor($r('app.color.colorGrey2')) + .margin({ + right: $r('app.float.default_5'), + left: $r('app.float.default_5') + }); + + Row() { + Text(StringUtils.get(this.endTime, "结束时间")) + .fontSize($r('app.float.text_size_16')) + .fontColor(this.endTime ? $r('app.color.colorGrey8') : $r('app.color.colorGrey6')) + .margin({ + right: $r('app.float.default_5'), + }) + .height($r('app.float.default_40')) + .layoutWeight(1) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .width($r('app.float.default_88')) + .textAlign(TextAlign.Start); + + Image($r('app.media.log_rl')) + .width($r('app.float.default_20')) + .height($r('app.float.default_20')) + .margin({ + right: $r('app.float.default_5'), + }); + } + .alignItems(VerticalAlign.Center) + .layoutWeight(1) + .onClick(() => { + this.showTimePicker('endTime') + }) + + } + .border(cardRoundBorderGreyStyle) + .width('95%') + .margin({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .margin($r('app.float.default_10')); + + Button("搜索", { type: ButtonType.Normal, stateEffect: true }) + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.white')) + .backgroundColor($r('app.color.bull')) + .borderRadius(8) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + bottom: $r('app.float.default_10'), + }) + .onClick(() => { + this.controller.isAutoRefresh = true + }) + .width('95%'); + } + .width('95%') + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + .margin($r('app.float.default_10')) + } + + @Builder + listView() { + List({ scroller: this.scroller }) { + ForEach(this.recordList, (item: MainRecordResultModel, index) => { + ListItem() { + this.itemView(item) + } + .onClick(()=>{ + let param:SkipHistoryDetailsParam = { + pctime: item.checkTime, + policenum: item.policeName, + policename: item.policeName, + pcyy: item.checkReason, + yjdw: item.yjdwmc, + mainId: item.mainId, + status: item.status, + address: item.checkAddress, + taskName: item.taskName, + type: 0 + } + router.pushUrl({url:"ui/pages/HistoryDetailsPage",params:param}) + }) + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + itemView(item: MainRecordResultModel) { + Column() { + Row() { + Text("时间:") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Text(item.checkTime) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .margin({ left: $r('app.float.default_5') }) + + Text(item.status == 1 ? "移交" : "通过") + .fontColor(item.status == 1 ? $r('app.color.colorYellow7') : $r('app.color.colorBluen7')) + .backgroundColor(item.status == 1 ? $r('app.color.colorYellow2') : $r('app.color.colorBluen2')) + .fontSize($r('app.float.text_size_12')) + .border({ + width:$r('app.float.default_1'), + color: item.status == 1 ? $r('app.color.colorYellow6') : $r('app.color.colorBluen6'), + radius: $r('app.float.default_20'), + }) + .padding({left: $r('app.float.default_8'), right: $r('app.float.default_8'), + top: $r('app.float.default_2'), bottom: $r('app.float.default_2')}) + .textAlign(TextAlign.Center) + .margin({ left: $r('app.float.default_5') }) + + } + .width('95%') + + Row() { + Text("地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Text(item.checkAddress) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + } + .width('95%') + .margin({ top: $r('app.float.default_5') }) + + Row() { + Column() { + Text("总人数/异常数") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Row() { + Text(StringUtils.get(item.peopleCount,"0","人")) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + Text("/") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + Text(StringUtils.get(item.unusualPeopleCount,"0","人")) + .fontColor($r('app.color.colorYellow8')) + .fontSize($r('app.float.text_size_14')) + } + .justifyContent(FlexAlign.Center) + .margin({ top: $r('app.float.default_5') }) + } + .justifyContent(FlexAlign.Center) + .height($r('app.float.default_52')) + .layoutWeight(1) + .border(cardRoundBorderGreyStyle) + + Column() { + Text("车牌") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + + Text(StringUtils.get(item.carNum,"-")) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_5') }) + } + .justifyContent(FlexAlign.Center) + .height($r('app.float.default_52')) + .layoutWeight(1) + .margin({ left: $r('app.float.default_5'), right: $r('app.float.default_5') }) + .border(cardRoundBorderGreyStyle) + + Column() { + Text("物品") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + + Text(this.getGoodCount(item.goodsCount)) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_5') }) + } + .justifyContent(FlexAlign.Center) + .height($r('app.float.default_52')) + .layoutWeight(1) + .border(cardRoundBorderGreyStyle) + + } + .width('95%') + .margin({ top: $r('app.float.default_5') }) + } + .width('95%') + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + .padding($r('app.float.default_10')) + .margin($r('app.float.default_10')) + + } + + getGoodCount(goodsCount:string):string{ + let count = StringUtils.get(goodsCount,"-") + if (count == "0") { + return "-" + } + return count; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/AboutPage.ets b/entry/src/main/ets/ui/pages/AboutPage.ets new file mode 100644 index 0000000..89e9571 --- /dev/null +++ b/entry/src/main/ets/ui/pages/AboutPage.ets @@ -0,0 +1,154 @@ + +import { bundleManager } from '@kit.AbilityKit'; +import { LengthUnit } from '@kit.ArkUI'; +import { BaseTopBar } from '../../view/custom/BaseTopTar'; +import { createWaterMark } from '../../view/custom/Watermark'; + +@Preview +@Entry +@Component +struct AboutPage { + @State about1: string = ' 支持NFC、人像、OCR等方式快速实现巡逻、卡点人车物盘查功能。' + @State about2: string = ' 提供省厅、地市两级用户盘查统计实时展示分析、任务管理、卡点管理、本地临时关注人员车辆管理等功能。' + // @State about3: string = ' 2、实时比对车辆被盗抢库和临时布控库,方便民警快速发现问题车辆。' + @State versionName: string = "1.0" + @State versionCode: string = "1" + + aboutToAppear(): void { + this.getAppVersion() + } + + + /** + * 获取应用版本号 + */ + async getAppVersion() { + let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION; + try { + // 使用await等待Promise的结果 + const data = await bundleManager.getBundleInfoForSelf(bundleFlags); + if (data) { + console.info('FileUtil', 'getBundleInfoForSelf successfully. Data: %s', JSON.stringify(data)); + this.versionName = data.versionName + this.versionCode = data.versionCode + "" + } else { + console.error('FileUtil', 'getBundleInfoForSelf returned an empty result.'); + } + } catch (err) { + console.error('FileUtil', 'getBundleInfoForSelf failed: %s', err.message); + } + } + + build() { + Column() { + BaseTopBar({ + title:$r('app.string.title_About') + }) + + Column() { + + Image($r('app.media.ic_applogin')) + .width($r('app.float.default_68')) + .height($r('app.float.default_68')) + + Text($r('app.string.app_name')) + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_20')) + .margin({ top: $r('app.float.default_10') }) + + + Column() { + Row() { + Text('版本:') + .fontColor($r('app.color.grad')) + .fontSize($r('app.float.text_size_16')) + Text(this.versionName) + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_3') }) + } + .width('100%') + + Divider() + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.page_background')) + .width('100%') + .margin({ top: $r('app.float.default_10') }) + + Row() { + Text('版本号:') + .fontColor($r('app.color.grad')) + .fontSize($r('app.float.text_size_16')) + Text(this.versionCode) + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_3') }) + } + .width('100%') + .margin({ top: $r('app.float.default_10') }) + + Divider() + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.page_background')) + .width('100%') + .margin({ top: $r('app.float.default_10') }) + + + Text('功能介绍') + .fontColor($r('app.color.grad')) + .fontSize($r('app.float.text_size_16')) + .margin({ top: $r('app.float.default_10') }) + + Text(this.about1) + .width('100%') + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_16')) + .lineSpacing({ + value: 2, + unit: LengthUnit.FP + }) + .margin({ top: $r('app.float.default_10') }) + Text(this.about2) + .width('100%') + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_16')) + .lineSpacing({ + value: 2, + unit: LengthUnit.FP + }) + .margin({ top: $r('app.float.default_3') }) + // Text(this.about3) + // .width('100%') + // .fontColor($r('app.color.black')) + // .fontSize($r('app.float.text_size_16')) + // .margin({ top: $r('app.float.default_3') }) + // .lineSpacing({ + // value: 2, + // unit: LengthUnit.FP + // }) + + } + .width('90%') + .padding($r('app.float.default_15')) + .margin({ top: $r('app.float.default_40') }) + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.comm_image_radius') + }) + + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .margin({ bottom: $r('app.float.default_40') }) + .width('100%') + .layoutWeight(1) + + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/AccompPersonPage.ets b/entry/src/main/ets/ui/pages/AccompPersonPage.ets new file mode 100644 index 0000000..dfe7791 --- /dev/null +++ b/entry/src/main/ets/ui/pages/AccompPersonPage.ets @@ -0,0 +1,257 @@ +import { LitheRefresh, RefreshController } from "@abner/lithe_refresh"; +import { AxiosError } from "@ohos/axios"; +import { ToastUtil } from "@pura/harmony-utils/src/main/ets/action/ToastUtil"; +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil"; +import AppConstants from "../../app/AppConstant"; +import { AccompanPersonBean } from "../../model/resultModel/CheckPeopleResultModel"; +import { getPersonListByMainId } from "../../request/api/Api"; +import { StringUtils } from "../../util/StringUtils"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { fileUri } from "@kit.CoreFileKit"; +import { FileUtils } from "../../util/FileUtils"; + +/** + * 随行人员 + */ +@Preview +@Component +@Entry +export struct AccompPersonPage { + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + @State personList: Array = new Array; + fileDir: string = ""; + pageNum: number = 1; + total: number = 0; + isRefreshStatus: number = 0; + + aboutToAppear(): void { + this.fileDir = FileUtils.ID_CARD_DIR; + } + + getAccompanPerson() { + getPersonListByMainId(this.pageNum) + .then((res) => { + console.debug(JSONUtil.beanToJsonStr(res)) + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.controller.finishRefresh() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + if (res.data) { + this.total = res.data.total; + let rows = res.data.rows; + if (rows && rows != undefined) { + this.personList = new Array + for (let i = 0; i < rows.length; i++) { + let bean = rows[i]; + let filePate = `${this.fileDir}/${bean.sfz}.png`; + bean.idCardPhoto = fileUri.getUriFromPath(filePate) + this.personList.push(bean); + } + } else { + ToastUtil.showToast("未查询到数据!") + return + } + } else { + ToastUtil.showToast("未查询到数据!") + return + } + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + if (res.code != 200) { + ToastUtil.showToast(res.msg) + return + } + if (res.data) { + this.total = res.data.total; + let rows = res.data.rows; + if (rows && rows != undefined) { + for (let i = 0; i < rows.length; i++) { + let bean = rows[i]; + let filePate = `${this.fileDir}/${bean.sfz}.png`; + bean.idCardPhoto = fileUri.getUriFromPath(filePate) + this.personList.push(bean); + } + if (this.pageNum*20>=this.total) { + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + } else { + ToastUtil.showToast("没有更多数据!") + return + } + } else { + ToastUtil.showToast("没有更多数据!") + return + } + } + }) + .catch((e: AxiosError) => { + console.error(e.message) + ToastUtil.showToast(e.message) + if (this.isRefreshStatus == 1) { + this.isRefreshStatus = 0 + this.controller.finishRefresh() + return + } + if (this.isRefreshStatus == 2) { + this.isRefreshStatus = 0 + this.controller.finishLoadMore() + } + }) + } + + onPageShow(): void { + this.isRefreshStatus = 1 + this.controller.isAutoRefresh = true + + } + + public getIcon(peopleStatus: string): Resource { + if (peopleStatus.startsWith("涉稳")) { + return $r("app.media.ic_type_stability") + } + if (peopleStatus.startsWith("涉恐")) { + return $r("app.media.ic_type_fear") + } + if (peopleStatus.startsWith("关注")) { + return $r("app.media.ic_type_focus") + } + if (peopleStatus.startsWith("云控")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(peopleStatus, "精神")) { + return $r("app.media.ic_type_fine") + } + if (peopleStatus.startsWith("非访")) { + return $r("app.media.ic_type_non") + } + if (peopleStatus.startsWith("前科")) { + return $r("app.media.ic_type_criminal_record") + } + if (StringUtils.containsChar(peopleStatus, "毒")) { + return $r("app.media.ic_type_poison") + } + if (StringUtils.containsChar(peopleStatus, "临")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(peopleStatus, "逃")) { + return $r("app.media.ic_type_escape") + } + return $r("app.media.ic_type_normal"); + } + + @Builder + itemView(bean: AccompanPersonBean) { + Row() { + Image(bean.idCardPhoto) + .width($r('app.float.default_88')) + .height($r('app.float.default_100')) + .margin({ left: $r('app.float.default_10') }) + + Column() { + Row() { + Text(bean.name) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Image(this.getIcon(StringUtils.get(bean.peopleStatusStr, ""))) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + .margin({left:$r('app.float.default_5')}) + } + + Text(bean.sfz) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + + Text(bean.address) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + } + .height($r('app.float.default_120')) + .layoutWeight(1) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + .margin({ left: $r('app.float.default_10') }) + + } + .width(`calc(100% - 20vp)`) + .height($r('app.float.default_120')) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey2'), + radius: $r('app.float.default_5') + }) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } + + @Builder + listView() { + List({ scroller: this.scroller, space: 10 }) { + ForEach(this.personList, (item: AccompanPersonBean) => { + ListItem() { + this.itemView(item) + } + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + build() { + Column() { + BaseTopBar({ + title: $r('app.string.title_accompan_person'), + }) + + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.controller.closeLoadMore= false; + this.pageNum = 1; + this.isRefreshStatus = 1; + this.getAccompanPerson() + }, + onLoadMore: () => { + if (this.pageNum*20>=this.total) { + this.controller.finishLoadMore() + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getAccompanPerson() + } + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/CarCheckDetailsPages.ets b/entry/src/main/ets/ui/pages/CarCheckDetailsPages.ets new file mode 100644 index 0000000..68782c0 --- /dev/null +++ b/entry/src/main/ets/ui/pages/CarCheckDetailsPages.ets @@ -0,0 +1,437 @@ +import { LitheRefresh, RefreshController } from '@abner/lithe_refresh'; +import { router } from '@kit.ArkUI'; +import { AxiosError } from '@ohos/axios'; +import { DateUtil, ToastUtil } from '@pura/harmony-utils'; +import AppConstants from '../../app/AppConstant'; +import { RequestCheckCarRecordModel } from '../../model/requestModel/CheckRequestModel'; +import { CheckPeopleRecordItem, ZdlxItem } from '../../model/resultModel/CheckPeopleResultModel'; +import { ErrorOfEmptyModel } from '../../model/uiModel/BeanModel'; +import { SkipCarCountParam } from '../../model/uiModel/PageParamModel'; +import { getCheckCarRecord } from '../../request/api/Api'; +import { cardRoundBorderStyle } from '../../style/BorderStyle'; +import { IdCardNumUtils } from '../../util/IdCardNumUtils'; +import { getCarStatusIcon, getCheckTypeIcon } from '../../util/StatusIconUtils'; +import { StringUtils } from '../../util/StringUtils'; +import { ToastUtils } from '../../util/ToasUtils'; +import { BaseTopBar } from '../../view/custom/BaseTopTar'; +import { createWaterMark } from '../../view/custom/Watermark'; + +@Preview +@Entry +@Component +struct CarCheckDetailsPages { + @State carNum: string = ""; + @State carZL: string = ""; + @State carPP: string = ""; + @State carJH: string = ""; + @State carFDJH: string = ""; + @State carSYR: string = ""; + @State idCardNum: string = ""; + @State carYS: string = ""; + //=================== 列表属性 ================== + @State dataSet: Array | null = null; + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + total: number = 0; + pageNum: number = 1; + isRefreshStatus: number = 0; + @State zdlxImg: Array | undefined = undefined; + + aboutToAppear(): void { + this.analyzeCar() + setTimeout(() => { + this.controller.isAutoRefresh = true; + }, 800) + } + + handlerErrorOrEmpty(model: ErrorOfEmptyModel) { + ToastUtils.toastBottom(model.msg) + if (this.isRefreshStatus == 1) { + //刷新 + this.controller.finishRefresh() + this.dataSet = new Array + } + if (this.isRefreshStatus == 2) { + //加载 + this.controller.finishLoadMore() + } + this.isRefreshStatus = 0 + } + + async getRecordListData() { + let requestModel: RequestCheckCarRecordModel = { + carNum: this.carNum, + pageSize: '30', + pageNum: this.pageNum, + clsbdh: this.carJH + } + getCheckCarRecord(requestModel) + .then((res) => { + if (res.code == 200) { + let list = res.rows; + if (res.total){ + this.total =res.total + } + if (list) { + if (this.isRefreshStatus == 1) { + //刷新 + this.controller.finishRefresh() + this.dataSet = new Array + list.forEach((item) => { + this.dataSet?.push(item) + }) + } + if (this.isRefreshStatus == 2) { + //加载 + this.controller.finishLoadMore() + list.forEach((item) => { + this.dataSet?.push(item) + }) + } + this.isRefreshStatus = 0 + if (this.pageNum * 30 >= this.total) { + this.controller.closeLoadMore = true; + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + }) + .catch((error: AxiosError) => { + console.error("请求失败:", JSON.stringify(error)) + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, error.message)) + }) + } + + /** + * 解析车辆数据 + */ + analyzeCar() { + let pageParam = router.getParams() as SkipCarCountParam; + if (pageParam == null) { + return + } + this.carNum = pageParam.carNum + this.carZL = pageParam.carZL + this.carPP = pageParam.carPP + this.carJH = pageParam.carJH + this.carFDJH = pageParam.carFDJH + this.carSYR = pageParam.carSYR + this.idCardNum = pageParam.idCardNum + this.carYS = pageParam.carYs + + this.zdlxImg = new Array; + if (StringUtils.containsChar(pageParam.carStatus,"被盗抢车辆")) { + this.zdlxImg.push(new ZdlxItem("被盗抢车辆",2)); + } + if (StringUtils.containsChar(pageParam.carStatus,"临控车辆")) { + this.zdlxImg.push(new ZdlxItem("临控车辆",3)); + } + if (StringUtils.containsChar(pageParam.carStatus,"临时关注车辆")) { + this.zdlxImg.push(new ZdlxItem("临时关注车辆",3)); + } + if (this.zdlxImg.length <=0){ + this.zdlxImg.push(new ZdlxItem("正常车辆",1)); + } + } + + build() { + Column() { + BaseTopBar({ + title: "盘查记录", + leftClickEvent: () => { + if (this.isRefreshStatus!=0){ + this.controller.finishRefresh() + this.controller.finishLoadMore() + DateUtil + } + } + }) + + this.carDetails() + Row() { + Image($r('app.media.icon_history_list')) + .height($r('app.float.default_16')) + .width($r('app.float.default_16')) + Text('核查记录') + .fontColor($r('app.float.default_14')) + .fontColor($r('app.color.black')) + .margin({ left: $r('app.float.default_8') }) + } + .width('100%') + .height($r('app.float.default_36')) + .alignItems(VerticalAlign.Center) + .padding({ left: $r('app.float.default_10') }) + + Divider() + .width('100%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.page_background')) + + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.controller.closeLoadMore = false; + this.pageNum = 1; + this.isRefreshStatus = 1; + this.getRecordListData() + }, + onLoadMore: () => { + if (this.pageNum * 30 >= this.total) { + this.controller.finishLoadMore() + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + @Builder + recordListItem(dataItem: CheckPeopleRecordItem) { + Row() { + Image(getCheckTypeIcon(dataItem.checkTypeStr)) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Column() { + Row() { + Text("警员:") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + Text(dataItem.policeName) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + Text(dataItem.checkTime) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + } + .width(AppConstants.PERCENTAGE_MAX) + .padding({ right: $r('app.float.default_8') }) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text("单位:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + Text(dataItem.deptName) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text("地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + Text(dataItem.checkAddress) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + } + .layoutWeight(1) + } + .width('95%') + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + .margin({ top: $r('app.float.default_10'), right: $r('app.float.default_10'), left: $r('app.float.default_10') }) + .padding({ top: $r('app.float.default_8'), bottom: $r('app.float.default_8') }) + } + + /** + * 刷新列表 + */ + @Builder + listView() { + List({ scroller: this.scroller }) { + ForEach(this.dataSet, (item: CheckPeopleRecordItem) => { + ListItem() { + this.recordListItem(item) + } + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + @Builder + carDetails() { + Column() { + Row() { + Text("机动车所有人:") + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + Text(this.carSYR) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_3') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_10'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Text(IdCardNumUtils.validateIdCardNum(this.idCardNum) ? "证件号码:" : '社会统一信用代码:') + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + Text(this.idCardNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Row() { + Text("车牌号码:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + + } + .layoutWeight(1) + + Row() { + Text("号牌种类:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carZL) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + .maxLines(1) + .ellipsisMode(EllipsisMode.END) + } + .layoutWeight(1) + + } + .width('90%') + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Row() { + Text("车辆颜色:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carYS) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + + } + .layoutWeight(1) + + Row() { + Text("车辆品牌:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carPP) + .maxLines(1) + .ellipsisMode(EllipsisMode.END) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .layoutWeight(1) + + } + .width('90%') + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Text("车架号码:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carJH) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Text("发动机号:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carFDJH) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Divider() + .width('98%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey1')) + .margin({ left: $r('app.float.default_10'), top: $r('app.float.default_10') }) + + Row() { + + Text('车辆属性:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_15') }) + + List() { + ForEach(this.zdlxImg, (item: ZdlxItem) => { + ListItem() { + Image(getCarStatusIcon(item.zdlx)) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .onClick(() => { + ToastUtils.toastBottom(item.zdlx) + }) + }) + } + .alignListItem(ListItemAlign.Center) + .listDirection(Axis.Horizontal) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_38')) + .width(AppConstants.PERCENTAGE_MAX) + + } + .alignItems(HorizontalAlign.Start) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .justifyContent(FlexAlign.Start) + .width('92%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .padding({ bottom: $r('app.float.default_2') }) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/CheckCarPage.ets b/entry/src/main/ets/ui/pages/CheckCarPage.ets new file mode 100644 index 0000000..e02ebfa --- /dev/null +++ b/entry/src/main/ets/ui/pages/CheckCarPage.ets @@ -0,0 +1,1144 @@ +import AppConstants from "../../app/AppConstant" +import CommonConstants from "../../view/keyboard/data/CommonConstants"; +import { KeyEventObserved } from "../../view/keyboard/KeyEventObserved"; +import { router } from "@kit.ArkUI"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { LoadingDialog } from "../../view/dialog/LoadingDialog"; +import { DialogAction, DialogHelper } from "@pura/harmony-dialog"; +import { ImageUtil, ToastUtil } from "@pura/harmony-utils"; +import { + addFocusCar, + checkCarFocus, + getCarCount, + queryCheckCar, + saveCarData, + updateCarFocus, + uploadFile +} from "../../request/api/Api"; +import { ToastUtils } from "../../util/ToasUtils"; +import { AxiosError } from "@ohos/axios"; +import { ZdlxItem, ZdXqItem } from "../../model/resultModel/CheckPeopleResultModel"; +import { CarEnglishKeyboard } from "../../view/keyboard/keylayout/CarEnglishKeyBoard"; +import { CarNumKeyboard } from "../../view/keyboard/keylayout/CarNumKeyBoard"; +import { Province1Keyboard } from "../../view/keyboard/keylayout/Province1KeyBoard"; +import { Province2Keyboard } from "../../view/keyboard/keylayout/Province2Keyboard"; +import { fileIo, fileUri } from "@kit.CoreFileKit"; +import { camera, cameraPicker } from '@kit.CameraKit' +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { StrUtil } from "@pura/harmony-utils/src/main/ets/utils/StrUtil"; +import { IdCardNumUtils } from "../../util/IdCardNumUtils"; +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil"; +import { + CarData, + CAR_HPZL_TYPE, + CheckCarResultModes, + copyCarData, + LocalCarData +} from "../../model/resultModel/CheckCarResultModel"; +import { StringUtils } from "../../util/StringUtils"; +import { SelectCarDialog } from "../../view/dialog/SelectCarDialog"; +import { ObservedArray } from "../../view/custom/ObservedArray"; +import { ResultCallBack } from "../../callbcak/ResultCallback"; +import { VibratorUtils } from "../../util/VibratorUtils"; +import { ImportanceInfoDialog } from "../../view/dialog/ImportanceInfoDialog"; +import { SkipCarCountParam, SkipCheckCardModel } from "../../model/uiModel/PageParamModel"; +import { PCCacheData } from "../../app/PCCacheData"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { getCarStatusIcon } from "../../util/StatusIconUtils"; +import { AttentionDialog } from "../../view/dialog/AttentionDialog"; +import { CustomUnionType } from "../../app/JointType"; +import { FileUtils } from "../../util/FileUtils"; +import { VoiceRecognitionDialog } from "../../view/dialog/VoiceRecognitionDialog"; + +/** + * 街面盘查 + */ +@Preview +@Component +@Entry +export struct CheckCarPage { + @State backImage: Resource = $r('app.media.icon_back3') + @Provide searchContent: string = ""; + //输入法键盘模式 + @Provide menuType: number = CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE1; + private searchController: SearchController = new SearchController(); + @Provide keyEventObserved: KeyEventObserved = new KeyEventObserved(this.searchController); + //关注状态 0:未关注(显示文字) 1: 关注等级1 2: 关注等级2 3: 关注等级3 + @State attentionStatus: number = 0; + @State loadDialogTips: string | Resource = $r('app.string.loading_check_people') + //=====================车辆基本信息参数=============================== + @State carSyrName: string = ""; + @State carSyrIdCard: string = ""; + @State carNum: string = ""; + @State carZl: string = ""; + @State carColor: string = ""; + @State carPinPai: string = ""; + @State carCJH: string = ""; + @State carFDJH: string = ""; + @State zdlxImg: Array | undefined = undefined; + //车辆查询次数 + @State carCheckCount: number = -1 + @State carXczp: string | Resource = $r('app.media.background') + @State carXczpStatus: boolean = false; + isCardPoint: boolean = false; + carData: CarData | null = null + //=====================车辆基本信息参数=============================== + dialogID: string = ""; //加载弹框 + dialogController: CustomDialogController = new CustomDialogController({ + builder: LoadingDialog({ + loadingTips: this.loadDialogTips, + }), + autoCancel: false // 关键参数 + }); + selectCarDialogController: CustomDialogController | null = null + showCarTypeDialogController: CustomDialogController | null = null + callback: ResultCallBack = { + onResult: (car?: CarData) => { + if (car) { + this.showCarUI(car) + } + } + } + + onBackPress(): boolean | void { + this.backOneLevelPage() + return true; + } + + aboutToAppear(): void { + let param = router.getParams() as SkipCheckCardModel; + this.isCardPoint = param.isCardPoint!; + let carJson = PCCacheData.pcCacheData.carJson; + if (StrUtil.isNotEmpty(carJson) && JSONUtil.isJSONStr(carJson)) { + this.carData = JSONUtil.jsonToBean(carJson, CarData); + if (this.carData) { + this.showCarUI(this.carData); + this.carXczp = this.carData.xczp; + if (this.carXczp) { + this.carXczpStatus = true; + } else { + this.carXczpStatus = false; + } + } + } + this.keyEventObserved.onSearchKeyMethod = (value) => { + this.searchController.stopEditing() + this.checkCar(value); + }; + } + + onPageShow(): void { + let param: BasePageResult = router.getParams() as BasePageResult; + if (param) { + if (param.type == 2) { //车辆返回参数 + let data: string = param.data; + if (StrUtil.isNotEmpty(data)) { + this.searchContent = data + this.keyEventObserved.inputContent = data + this.checkCar(data) + } + return + } + } + } + + onPageHide(): void { + if (this.carData) { + PCCacheData.pcCacheData.carJson = JSONUtil.beanToJsonStr(this.carData) + } + } + + /** + * 语音识别弹框 + */ + showVioceRecognDialog() { + let dialogController = new CustomDialogController({ + builder: VoiceRecognitionDialog({ + controller: this.dialogController, + type: "carNum", + onResult: (value) => { + console.log(value) + this.searchContent = value + this.keyEventObserved.inputContent = value + this.checkCar(value) + dialogController.close() + } + }) + }); + dialogController.open() + } + + checkCar(value: string) { + if (StrUtil.isEmpty(value)) { + ToastUtils.toastCenter("请输入车牌号查询!") + return + } + if (StrUtil.isNotEmpty(this.carNum)) { + ToastUtils.toastCenter("请先提交此次盘查!") + return + } + if (!IdCardNumUtils.isCarNumberNO(value)) { + ToastUtils.toastCenter("请检查车牌号码是否正确!") + return + } + RuanseeAbitityStag.appCache.getCarId(); + this.loadDialogTips = "正在查询,请稍后..." + this.dialogController.open() + queryCheckCar(value) + .then((res) => { + this.dialogController.close() + console.log(JSONUtil.beanToJsonStr(res)) + if (res.code != 200) { + ToastUtils.toastBottom(`查询失败!${res.msg}`) + return + } + let data = res.data; + if (data == null) { + ToastUtils.toastBottom("未查询到车辆!") + return + } + this.handlerCarUI(data) + }) + .catch((error: AxiosError) => { + this.dialogController.close() + console.error(error.message) + }) + } + + handlerCarUI(model: CheckCarResultModes) { + let carListData = model.list; + if (carListData == null || carListData.length < 1) { + ToastUtils.toastBottom("未查询到车辆!") + return + } + //解析车辆信息 + let carDatas = new Array(); + for (let i = 0; i < carListData.length; i++) { + let carData = carListData[i]; + if (carData == null) { + continue; + } + + let copyCatData = copyCarData(carData); + if (!copyCatData.hpzl) { + continue + } + let zxzt = copyCatData.jdczt; + if (StringUtils.isNullOrEmpty(zxzt) + || StringUtils.containsChar(zxzt, "注销") + || StringUtils.containsChar(zxzt, "失效") + || StringUtils.containsChar(zxzt, "过期") + || StringUtils.containsChar(zxzt, "无效") + || StringUtils.containsChar(zxzt, "转出")) { + continue + } + if (IdCardNumUtils.isJc(copyCatData.hphm)) { + copyCatData.hphm = "皖" + copyCatData.hphm + } else { + copyCatData.hphm = copyCatData.hphm + } + carDatas.push(copyCatData); + } + + if (carDatas == null || carDatas.length < 1) { + ToastUtils.toastBottom("未查询到该车牌,或该车牌被注销!") + return + } + + if (model.stealList) { + for (let i = 0; i < model.stealList.length; i++) { + let steal = model.stealList[i]; + if (steal == null) { + continue + } + for (let i = 0; i < carDatas.length; i++) { + let car = carDatas[i]; + if (car.clsbdh == steal.clsbdh || car.fdjh == steal.jdcfdjh) { + // let zdlxItme = new ZdlxBean("被盗抢车辆", 1); + let zdlxItem = new ZdlxItem("被盗抢车辆", 2); + + car.isSteal = true; + car.addZdlxBean(zdlxItem) + } + } + } + } + if (model.localCar) { + let localLk = JSON.parse(model.localCar) as LocalCarData + for (let i = 0; i < carDatas.length; i++) { + let car = carDatas[i]; + let hpzl = CAR_HPZL_TYPE.getValue(localLk.jdchpzl) + if (StringUtils.containsChar(car.hpzl, hpzl)) { + let zdlxItem = new ZdlxItem("临时布控车辆", 3); + zdlxItem.addXQ(new ZdXqItem("联系民警", localLk.zrPoliceName, $r('app.color.black'))) + zdlxItem.addXQ(new ZdXqItem("联系电话", localLk.policePhone, $r('app.color.black'))) + zdlxItem.addXQ(new ZdXqItem("布控原因", localLk.reason, $r('app.color.black'))) + zdlxItem.addXQ(new ZdXqItem("处置措施", localLk.solution, $r('app.color.black'))) + car.addZdlxBean(zdlxItem) + } + } + } + if (carDatas.length == 1) { + this.showCarUI(carDatas[0]) + } else { + this.showSelectCarDialog(carDatas) + } + } + + showCarUI(carData: CarData) { + carData.id = RuanseeAbitityStag.appCache.getCarId(); + this.carNum = carData.hphm + this.carZl = carData.hpzl + this.carColor = carData.csys + this.carPinPai = carData.clpp + this.carCJH = carData.clsbdh + this.carFDJH = carData.fdjh + this.carSyrIdCard = carData.sfzh + this.carSyrName = carData.jdcsyr + if (carData.zdlxBeanList == null || carData.zdlxBeanList == undefined) { + let zdlxBeanList = new Array() + zdlxBeanList.push(new ZdlxItem("正常车辆", 1)) + this.zdlxImg = zdlxBeanList + } else { + this.zdlxImg = carData.zdlxBeanList + VibratorUtils.startVibrator() + } + this.sendCar(carData) + + this.getCarFocusData(); + setTimeout(() => { + this.queryCarCount(carData.hphm, carData.clsbdh) + }, 800) + } + + getCarFocusData() { + checkCarFocus(this.carCJH) + .then((res) => { + if (res.code == 200) { + let data = res.data; + if (data) { + this.attentionStatus = data.focusType?data.focusType:0; + } else { + this.attentionStatus = 0 + } + } + }) + .catch((e: AxiosError) => { + this.attentionStatus = 0 + }) + } + + queryCarCount(hphm: string, clsbdh: string) { + getCarCount(hphm, clsbdh) + .then((res) => { + console.debug(JSONUtil.beanToJsonStr(res)) + if (res.code == 200) { + this.carCheckCount = res.data?res.data:0; + } + }) + .catch((error: AxiosError) => { + console.error(error.message) + }) + } + + showZdxqDialog(item: ZdlxItem) { + if (item.styleType == 1) { + ToastUtils.toastBottom(item.zdlx) + return + } + if (item.zdxqArray == null || item.zdxqArray == undefined || item.zdxqArray.length < 1) { + ToastUtils.toastBottom("暂无详细信息!") + return + } + let showCarTypeDialogController = new CustomDialogController({ + builder: ImportanceInfoDialog({ + zdlx: item, + controller: this.dialogController + }) + }); + showCarTypeDialogController.open() + } + + sendCar(carData: CarData) { + this.carData = carData; + saveCarData(carData, this.isCardPoint) + .then((res) => { + console.debug(JSONUtil.beanToJsonStr(res)) + }) + .catch((error: AxiosError) => { + console.error(error.message) + }); + + } + + showSelectCarDialog(carData: Array) { + let carDatas = new ObservedArray() + carData.forEach((car) => { + carDatas.push(copyCarData(car)) + }) + this.selectCarDialogController = new CustomDialogController({ + builder: SelectCarDialog({ + observeData: carDatas, + resultCallback: this.callback + }) + }); + this.selectCarDialogController.open() + } + + /** + * 拍照 + */ + async takePhoto() { + if (StrUtil.isEmpty(this.carNum)) { + ToastUtils.toastBottom("请先盘查车辆在拍照!") + return + } + let pathDir = FileUtils.IMAGE_DIR; + let fileName = `${new Date().getTime()}.JPEG` + let filePath = `${pathDir}/${fileName}` + let imageFileUri: string | undefined = undefined; + fileIo.createRandomAccessFileSync(filePath, fileIo.OpenMode.CREATE); + + let fileUris = fileUri.getUriFromPath(filePath); + let pickerProfile: cameraPicker.PickerProfile = { + cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK, + saveUri: fileUris, + }; + let result: cameraPicker.PickerResult = + await cameraPicker.pick(getContext(), [cameraPicker.PickerMediaType.PHOTO], + pickerProfile); + console.info(`picker resultCode: ${result.resultCode},resultUri: ${result.resultUri},mediaType: ${result.mediaType}`); + if (result.resultCode == 0) { + if (result.mediaType === cameraPicker.PickerMediaType.PHOTO) { + imageFileUri = result.resultUri + imageFileUri = await ImageUtil.compressPhoto(imageFileUri, 150); + // this.peoplePhoto = imageFileUri; + this.loadDialogTips = "正在上传,请稍后..." + this.dialogController.open() + this.updatePhoto(imageFileUri); + } + } + } + + /** + * 上传照片 + * @param imageFileUri + */ + updatePhoto(imageFileUri: string) { + uploadFile(imageFileUri, RuanseeAbitityStag.appCache.getCarId()) + .then((res) => { + this.dialogController.close() + console.debug(JSON.stringify(res)); + if (res.code == 200) { + if (PCCacheData.pcCacheData.carJson) { + this.carData!.xczp = + RuanseeAbitityStag.convertPhotoUrl(StringUtils.get(res.data?.url, "")) + this.carData!.xczpId = StringUtils.get(res.data?.photoId, ""); + } + this.carXczp = RuanseeAbitityStag.convertPhotoUrl(StringUtils.get(res.data?.url, "")); + this.carXczpStatus = true; + } + }) + .catch((error: AxiosError) => { + this.dialogController.close() + ToastUtils.toastCenter(`上传失败:${error.message}}`) + console.error(error.message); + }) + } + + /** + * 设置关注 + */ + setAttention(value: string, selectLevel: number) { + let param = new Map(); + param.set("focusType", selectLevel + "") + param.set("focusReason", value) + if (this.isCardPoint) { //卡点盘查 + let address = RuanseeAbitityStag.appCache.getCardPointAddress + let x = RuanseeAbitityStag.appCache.getCardPointLocationX() + let y = RuanseeAbitityStag.appCache.getCardPointLocationY() + let as = "" + if (StrUtil.isNotEmpty(x)) { + as = x + } + if (StrUtil.isNotEmpty(y)) { + if (StrUtil.isNotEmpty(as)) { + as = as + ":" + y + } else { + as = y; + } + } + param.set("focusAddress", StringUtils.get(address, as)) + } else { //街面盘查 + let address = RuanseeAbitityStag.appCache.getLocationAddress + let x = RuanseeAbitityStag.appCache.getLocationX() + "" + let y = RuanseeAbitityStag.appCache.getLocationY() + "" + let as = "" + if (StrUtil.isNotEmpty(x)) { + as = x + } + if (StrUtil.isNotEmpty(y)) { + if (StrUtil.isNotEmpty(as)) { + as = as + ":" + y + } else { + as = y; + } + } + param.set("focusAddress", StringUtils.get(address, as)) + } + + let carEntity = new Map(); + carEntity.set("cjh", this.carCJH); + carEntity.set("cllx", this.carZl); + carEntity.set("clpp", this.carPinPai); + carEntity.set("clsyr", this.carSyrName); + carEntity.set("csys", this.carColor); + if (this.zdlxImg) { + if (StringUtils.containsChar(this.zdlxImg[0].zdlx, "正常")) { + carEntity.set("carStatus", "正常"); + } else if (StringUtils.containsChar(this.zdlxImg[0].zdlx, "被盗抢")) { + carEntity.set("carStatus", "被盗抢车辆"); + } else if (StringUtils.containsChar(this.zdlxImg[0].zdlx, "关注")) { + carEntity.set("carStatus", "关注车辆"); + } else if (StringUtils.containsChar(this.zdlxImg[0].zdlx, "临控")) { + carEntity.set("carStatus", "临时控制车辆"); + } else { + carEntity.set("carStatus", "正常"); + } + } + carEntity.set("fdjh", this.carFDJH); + carEntity.set("hphm", this.carNum); + carEntity.set("syrzjhm", this.carSyrIdCard); + + param.set("carInfoEntity", JSONUtil.mapToJsonStr(carEntity)); + this.loadDialogTips = "正在提交关注,请稍后..." + this.dialogController.open() + addFocusCar(param) + .then((res) => { + this.dialogController.close() + if (res.code == 200) { + ToastUtils.toastBottom("关注成功") + this.attentionStatus = selectLevel; + } else { + ToastUtils.toastBottom(`关注失败:${res.msg}`) + } + }) + .catch((e: AxiosError) => { + this.dialogController.close() + ToastUtils.toastBottom(`关注失败:${e.message}`) + }) + } + + showAttentionDialog() { + let attentionDialogController: CustomDialogController = new CustomDialogController({ + builder: AttentionDialog({ + type: 2, + submit: (value, selectLevel) => { + attentionDialogController.close() + this.setAttention(value, selectLevel) + }, + cancel: () => { + attentionDialogController.close() + } + }), + cornerRadius: 3, + autoCancel: false, + backgroundColor: Color.Transparent, // 背景透明 + backgroundBlurStyle: BlurStyle.NONE, // 必须关闭模糊材质 + cancel: () => { + + } + }); + attentionDialogController.open() + } + + /** + * 取消关注 + */ + cancelAttention() { + //操作确认类弹出框 + this.dialogID = DialogHelper.showAlertDialog({ + content: "你确认取消关注该人员吗?", + onAction: (action) => { + if (action == DialogAction.CANCEL) { + ToastUtil.showToast(`您点击了取消按钮`); + } else if (action == DialogAction.SURE) { + ToastUtil.showToast(`您点击了确认按钮`); + updateCarFocus(this.carCJH) + .then((res) => { + if (res) { + if (res.code == 200) { + this.attentionStatus = 0; + ToastUtils.toastCenter("取消关注成功!") + } else { + ToastUtils.toastCenter("取消关注失败!" + res.msg) + } + } + }) + .catch((error: AxiosError) => { + ToastUtils.toastCenter("取消关注失败!" + error.message) + }) + } + } + }) + } + + build() { + Stack() { + //底层背景图 + Column() { + Image($r('app.media.ic_check_bg')) + .width(AppConstants.PERCENTAGE_MAX) + .height('29%') + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Start) + + Column() { + //导航栏 + this.navigationBar() + this.searchUI() + this.functionalDomainUI() + + Text('车辆详情') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('92%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + + this.carInfoUI() + + this.carPhoto() + + this.checkCountBuilder() + + Button('完成', { type: ButtonType.Normal, stateEffect: true }) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_48')) + .margin({ bottom: $r('app.float.default_22') }) + .backgroundColor($r('app.color.colorGreen7')) + .onClick(() => { + this.backOneLevelPage() + }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + + } + + backOneLevelPage() { + if (StrUtil.isNotEmpty(this.carNum)) { + let param: BasePageResult = { + type: 2, + what: this.carData?.isSteal ? 1 : 0, + data: this.carNum + } + router.back({ url: "ui/pages/StreetInspectionPages", params: param }) + } else { + router.back(); + } + } + + //车辆照片展示区 + @Builder + carPhoto() { + Row() { + RelativeContainer() { // 创建相对布局容器 + Image(this.carXczp) + .width($r('app.float.default_98')) + .height($r('app.float.default_110')) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, // 水平居中 + middle: { anchor: '__container__', align: HorizontalAlign.Center } // 垂直居中 + }).id('image') // 设置唯一ID + + // 删除按钮(使用图标) + // Image($r('app.media.icon_delete')) + // .width($r('app.float.default_25'))// 按钮宽度 + // .height($r('app.float.default_25'))// 按钮高度 + // .alignRules({ + // 'top': { anchor: 'image', align: VerticalAlign.Top }, // 顶部对齐图片顶部 + // 'right': { anchor: 'image', align: HorizontalAlign.End } // 右侧对齐图片右侧 + // }) + // .id('deleteBtn') + } + .width($r('app.float.default_110')) // 容器宽度占满父组件 + .height(CommonConstants.PERCENTAGE_MAX) // 容器固定高度 + .margin({ left: $r('app.float.default_10') }) + .visibility(this.carXczpStatus ? Visibility.Visible : Visibility.Hidden) + + Column() { + Image($r('app.media.imp_upload')) + .width($r('app.float.default_50')) + .height($r('app.float.default_48')) + .autoResize(true) + .objectFit(ImageFit.Auto) + + Text("添加照片") + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_10') }) + } + .visibility(this.carXczpStatus ? Visibility.Hidden : Visibility.Visible) + .justifyContent(FlexAlign.Center) + .width($r('app.float.default_98')) + .height('88%') + .onClick(() => { + this.takePhoto() + }) + .border({ + width: $r('app.float.default_1'), + radius: 3, + color: $r('app.color.colorGrey3') + }) + } + .alignItems(VerticalAlign.Center) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .height($r('app.float.default_130')) + .justifyContent(FlexAlign.Start) + .width('92%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .margin({ top: $r('app.float.default_24') }) + + } + + @Builder + carInfoUI() { + Column() { + Row() { + Text("机动车所有人:") + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + Text(this.carSyrName) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_3') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_10'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Text("证件号码:") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + Text(this.carSyrIdCard) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + .copyOption(CopyOptions.InApp) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Row() { + Text("车牌号码:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + + } + .layoutWeight(1) + + Row() { + Text("号牌种类:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carZl) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + .maxLines(1) + .ellipsisMode(EllipsisMode.END) + } + .layoutWeight(1) + + } + .width('90%') + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Row() { + Text("车辆颜色:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carColor) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + + } + .layoutWeight(1) + + Row() { + Text("车辆品牌:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carPinPai) + .maxLines(1) + .ellipsisMode(EllipsisMode.END) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .layoutWeight(1) + + } + .width('90%') + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Text("车架号码:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carCJH) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Row() { + Text("发动机号:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_15')) + Text(this.carFDJH) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_15')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_8'), left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + + Divider() + .width('98%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey1')) + .margin({ left: $r('app.float.default_10'), top: $r('app.float.default_10') }) + + Row() { + + Text('车辆属性:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_15') }) + + List() { + ForEach(this.zdlxImg, (item: ZdlxItem) => { + ListItem() { + Image(getCarStatusIcon(item.zdlx)) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .onClick(() => { + this.showZdxqDialog(item); + }) + }) + } + .alignListItem(ListItemAlign.Center) + .listDirection(Axis.Horizontal) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + + Text('+关注') + .width('66vp') + .height(AppConstants.PERCENTAGE_MAX) + .textAlign(TextAlign.Center) + .backgroundImage($r('app.media.icon_attention_bg')) + .backgroundImageSize({ width: '66vp', height: '38vp' }) + .padding({ left: '12vp' }) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .visibility(this.attentionStatus == 0 ? Visibility.Visible : Visibility.None) + .onClick(() => { + this.showAttentionDialog() + }) + + Image(this.getAttentionRes()) + .width($r('app.float.default_32')) + .visibility(this.attentionStatus > 0 ? Visibility.Visible : Visibility.None) + .height($r('app.float.default_32')) + .margin({ right: $r('app.float.default_8') }) + .onClick(() => { + this.cancelAttention() + }) + + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_38')) + .width(AppConstants.PERCENTAGE_MAX) + + } + .alignItems(HorizontalAlign.Start) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .justifyContent(FlexAlign.Start) + .width('92%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .padding({ bottom: $r('app.float.default_2') }) + + } + + @Builder + navigationBar() { + //导航栏 + Row() { + Image(this.backImage) + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + .padding($r('app.float.default_3')) + .onClick(() => { + this.backOneLevelPage() + }) + .onTouch((event) => { + if (event.type === TouchType.Down) { + this.backImage = $r('app.media.icon_back2'); + } else if (event.type === TouchType.Up) { + this.backImage = $r('app.media.icon_back3'); + } + }) + .margin($r('app.float.default_15')); + + Text("盘查车辆") + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_22')) + .layoutWeight(1) + .textAlign(TextAlign.Center); + + Column() { + + } + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + .margin($r('app.float.default_15')); + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_48')) + .margin({ top: $r('app.float.default_40') }) + } + + //搜索框 + @Builder + searchUI() { + Search({ value: this.searchContent, placeholder: '请输入车牌号码', controller: this.searchController }) + .fontColor($r('app.color.colorGrey2')) + .placeholderColor($r('app.color.colorGrey2')) + .placeholderFont({ size: 14, weight: 400 }) + .textFont({ size: 16, weight: 400 }) + .searchIcon({ color: $r('app.color.colorGrey2') })// .textAlign(TextAlign.Center) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + if (selectionStart !== selectionEnd) { + this.keyEventObserved.isMultiSelect = true; + this.keyEventObserved.notSelectionStart = selectionStart; + this.keyEventObserved.notSelectionEnd = selectionEnd; + } else { + this.keyEventObserved.isMultiSelect = false; + this.keyEventObserved.selectionStart = selectionStart; + this.keyEventObserved.selectionEnd = selectionEnd; + } + this.keyEventObserved.cursorPosition = selectionStart + this.searchController.caretPosition(this.keyEventObserved.cursorPosition); + + }) + .onChange((value: string) => { + // Clear the contents of the search box. + if (value === '') { + this.searchContent = ''; + this.keyEventObserved.inputContent = ''; + } + // Set the focus of the search box. + this.searchController.caretPosition(this.keyEventObserved.cursorPosition); + }) + .onPaste((value: string, event: PasteEvent) => { + if (value === '') { + this.searchContent = ''; + this.keyEventObserved.inputContent = ''; + } else { + this.searchContent = value + this.keyEventObserved.inputContent = value; + } + // Set the focus of the search box. + this.searchController.caretPosition(this.keyEventObserved.cursorPosition); + }) + .width('92%') + .height($r('app.float.default_43')) + .border({ + color: 'rgba(200, 200, 200, 0.3)', + width: $r('app.float.default_1') + }) + .backgroundColor('rgba(1, 1, 1, 0.3)') + .borderRadius(50) + .margin({ + top: $r('app.float.default_25'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .customKeyboard(this.KeyBoardWindow()) + } + + /** + * 功能区 + */ + @Builder + functionalDomainUI() { + Row() { + Row() { + Image($r('app.media.icon_checkcar_pz')) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + Text('拍照') + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey6')) + .margin({ left: $r('app.float.default_5') }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .onClick(() => { + router.pushUrl({url:'ui/pages/OCRCarNumPages'}) + }) + + Divider() + .height('90%') + .width($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey2')) + + Row() { + Image($r('app.media.ic_voice')) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + + Text('语音') + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey6')) + .margin({ left: $r('app.float.default_5') }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .onClick(() => { + this.showVioceRecognDialog() + }) + } + .alignItems(VerticalAlign.Center) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .justifyContent(FlexAlign.Start) + .width('92%') + .height($r('app.float.default_72')) + .margin({ + top: $r('app.float.default_25'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + } + + /** + * 盘查次数 + */ + @Builder + checkCountBuilder() { + Row() { + Text('该车辆已被盘查 ') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + + Text(this.carCheckCount + '') + .fontColor($r('app.color.read')) + .fontSize($r('app.float.text_size_14')); + + Text(' 次') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .visibility(this.carCheckCount >= 0 ? Visibility.Visible : Visibility.Hidden) + .onClick(() => { + let carStatus = this.zdlxImg == null ? "正常" : this.zdlxImg[0].zdlx + let param: SkipCarCountParam = { + what: 0, + carNum: StringUtils.get(this.carNum, ""), + carZL: StringUtils.get(this.carZl, ""), + carPP: StringUtils.get(this.carPinPai, ""), + carJH: StringUtils.get(this.carCJH, ""), + carFDJH: StringUtils.get(this.carFDJH, ""), + carSYR: StringUtils.get(this.carSyrName, ""), + idCardNum: StringUtils.get(this.carSyrIdCard, ""), + carYs: StringUtils.get(this.carColor, ""), + carStatus: carStatus + } + router.pushUrl({ url: "ui/pages/CarCheckDetailsPages", params: param }) + }) + } + + //自定义身份证键盘 + @Builder + KeyBoardWindow() { + Column() { + Row() { + Image($r('app.media.down')) + .objectFit(ImageFit.Contain) + .aspectRatio(CommonConstants.IMAGE_ASPECT_RATIO) + .width($r('app.float.down_image_size')) + .margin({ top: $r('app.float.down_image_margin'), right: CommonConstants.DOWN_IMAGE_RIGHT }) + .onClick(() => this.searchController.stopEditing()) + } + .justifyContent(FlexAlign.End) + .alignItems(VerticalAlign.Center) + .width(CommonConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.keyboard_background_color')) + + // NumberKeyboard() 4:30 - 5:30 7 + if (this.menuType === CommonConstants.KEYBOARD_TYPE_CAR_ENGLISH) { + CarEnglishKeyboard() + } else if (this.menuType === CommonConstants.KEYBOARD_TYPE_CAR_NUM) { + CarNumKeyboard() + } else if (this.menuType === CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE1) { + Province1Keyboard() + } else if (this.menuType === CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE2) { + Province2Keyboard() + } + + } + .backgroundColor(Color.White) + .alignItems(HorizontalAlign.Center) + } + + getAttentionRes(): Resource { + if (this.attentionStatus == 1) { + return $r('app.media.icon_attention_leven1'); + } + if (this.attentionStatus == 2) { + return $r('app.media.icon_attention_leven2'); + } + if (this.attentionStatus == 3) { + return $r('app.media.icon_attention_leven3'); + } + return $r('app.media.icon_attention_leven1'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/CheckGoodsPage.ets b/entry/src/main/ets/ui/pages/CheckGoodsPage.ets new file mode 100644 index 0000000..6d00148 --- /dev/null +++ b/entry/src/main/ets/ui/pages/CheckGoodsPage.ets @@ -0,0 +1,602 @@ +import AppConstants from "../../app/AppConstant" +import { createWaterMark } from "../../view/custom/Watermark" +import { BaseTopBar } from "../../view/custom/BaseTopTar" +import { GoodsBean, GoodsTypeBean } from "../../model/uiModel/GoodsModel" +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil" +import { PCCacheData } from "../../app/PCCacheData" +import { StrUtil } from "@pura/harmony-utils/src/main/ets/utils/StrUtil" +import { bufferToString } from "../../util/BufferUtil" +import { uploadFile } from "../../request/api/Api" +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag" +import { ToastUtils } from "../../util/ToasUtils" +import { fileIo, fileUri } from "@kit.CoreFileKit" +import { camera, cameraPicker } from "@kit.CameraKit" +import { ImageUtil } from "@pura/harmony-utils" +import { LoadingDialog } from "../../view/dialog/LoadingDialog" +import { StringUtils } from "../../util/StringUtils" +import { AxiosError } from "@ohos/axios" +import { AddGoodsDialog } from "../../view/dialog/AddGoodsDialog" +import { DateFormat, DateUtils } from "../../util/DateUtils" +import { router } from "@kit.ArkUI" +import { BasePageResult } from "../../model/uiModel/PageResultModel" +import { FileUtils } from "../../util/FileUtils" + +/** + * 街面盘查 + */ +@Preview +@Component +@Entry +export struct CheckGoodsPage { + @State backImage: Resource = $r('app.media.icon_back3') + @State isShowPopup: boolean = false + @State goodsTypeData: Array = new Array + @State goodsDataList: Array = new Array + // goodsTypeList: ArrayList = new ArrayList() + @State loadDialogTips: string | Resource = $r('app.string.loading_check_people') + @State goodsXczp: string | undefined = undefined + @State goodsXczpId: string | undefined = undefined + @State goodsXczpStatus: boolean = false + @State selectTypeData: GoodsTypeBean | undefined = undefined + @State inputCount: string = ""; + @State remark: string = ""; + goodsId: string = ""; + selectIndex: number = 0; + // allCount: number = 0 + dialogController: CustomDialogController = new CustomDialogController({ + builder: LoadingDialog({ + loadingTips: this.loadDialogTips, + }), + autoCancel: false // 关键参数 + }); + selectGoodsTypeController: CustomDialogController = new CustomDialogController({ + builder: AddGoodsDialog({ + goodsTypeData: this.goodsTypeData, + clickItem: (item, selectIndex) => { + this.selectTypeData = item + this.selectGoodsTypeController.close() + this.isShowPopup = true; + this.selectIndex = selectIndex; + } + }), + cornerRadius: 3, + autoCancel: false, + backgroundColor: Color.Transparent, // 背景透明 + backgroundBlurStyle: BlurStyle.NONE // 必须关闭模糊材质 + }); + + aboutToAppear(): void { + let wpJson = PCCacheData.pcCacheData.goodsJson; + this.getUIContext().getHostContext()?.resourceManager.getRawFileContent('checkData/GoodsTypeData.json') + .then(value => { + let enablementList = JSON.parse(bufferToString(value.buffer)) as GoodsTypeBean[]; + if (StrUtil.isNotEmpty(wpJson) && JSONUtil.isJSONStr(wpJson)) { + this.goodsDataList = JSONUtil.jsonToArray(wpJson) + } + if (this.goodsDataList) { + enablementList.forEach(element => { + if (!this.isContainGoodsType(this.goodsDataList!, element)) { + this.goodsTypeData.push(element); + } + }); + } else { + enablementList.forEach(element => { + this.goodsTypeData.push(element); + }); + } + }) + } + + onPageHide(): void { + if (this.goodsDataList && this.goodsDataList.length > 0) { + PCCacheData.pcCacheData.goodsJson = JSONUtil.beanToJsonStr(this.goodsDataList) + PCCacheData.pcCacheData.wpCount = this.goodsDataList.length + } + } + + onBackPress(): boolean | void { + this.backOneLevelPage() + return true; + } + + backOneLevelPage() { + if (this.goodsDataList && this.goodsDataList.length > 0) { + let param: BasePageResult = { + type: 3, + what: 1, + data: this.goodsDataList.length + } + router.back({ url: "ui/pages/StreetInspectionPages", params: param }) + } else { + router.back(); + } + } + + isContainGoodsType(goodsData: Array, typeBean: GoodsTypeBean): boolean { + for (let i = 0; i < goodsData.length; i++) { + if (goodsData[i].name == typeBean.thingsname) { + return true + } + } + return false; + } + + /** + * 拍照 + */ + async takePhoto() { + this.isShowPopup = false; + let pathDir = FileUtils.IMAGE_DIR; + let fileName = `${new Date().getTime()}.JPEG` + let filePath = `${pathDir}/${fileName}` + let imageFileUri: string | undefined = undefined; + fileIo.createRandomAccessFileSync(filePath, fileIo.OpenMode.CREATE); + + let fileUris = fileUri.getUriFromPath(filePath); + let pickerProfile: cameraPicker.PickerProfile = { + cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK, + saveUri: fileUris, + }; + let result: cameraPicker.PickerResult = + await cameraPicker.pick(getContext(), [cameraPicker.PickerMediaType.PHOTO], + pickerProfile); + console.info(`picker resultCode: ${result.resultCode},resultUri: ${result.resultUri},mediaType: ${result.mediaType}`); + if (result.resultCode == 0) { + if (result.mediaType === cameraPicker.PickerMediaType.PHOTO) { + imageFileUri = result.resultUri + imageFileUri = await ImageUtil.compressPhoto(imageFileUri, 150); + // this.peoplePhoto = imageFileUri; + this.loadDialogTips = "正在上传,请稍后..." + this.dialogController.open() + this.updatePhoto(imageFileUri); + } + } else { + this.isShowPopup = true; + } + } + + /** + * 上传照片 + * @param imageFileUri + */ + updatePhoto(imageFileUri: string) { + uploadFile(imageFileUri, this.goodsId) + .then((res) => { + this.dialogController.close() + this.isShowPopup = true; + console.debug(JSON.stringify(res)); + if (res.code == 200) { + this.goodsXczp = RuanseeAbitityStag.convertPhotoUrl(StringUtils.get(res.data?.url, "")); + this.goodsXczpId = StringUtils.get(res.data?.photoId, ""); + this.goodsXczpStatus = true; + } + }) + .catch((error: AxiosError) => { + this.dialogController.close() + this.isShowPopup = true; + ToastUtils.toastCenter(`上传失败:${error.message}}`) + console.error(error.message); + }) + } + + @Builder + addGoodsPopup() { + Column() { + Stack({ alignContent: Alignment.TopStart }) { + Text("添加物品") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_46')) + .textAlign(TextAlign.Center) + .align(Alignment.Center) + + Row(){ + Image($r('app.media.icon_colse')) + .width($r('app.float.default_22')) + .height($r('app.float.default_22')) + .onClick(() => { + this.isShowPopup = false; + this.goodsId = RuanseeAbitityStag.appCache.getRandomId() + this.inputCount = "" + this.goodsXczp = undefined + this.goodsXczpStatus = false; + }) + } + .alignItems(VerticalAlign.Center) + .padding({ left: $r('app.float.default_15') }) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_46')) + } + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_46')) + + + Divider() + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey3')) + + Text("请选择物品类别:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .height($r('app.float.default_40')) + .width('90%') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Row() { + Text(this.selectTypeData!.thingsname) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .fontWeight(FontWeight.Medium) + .layoutWeight(1) + .textAlign(TextAlign.Start) + .margin({ left: $r("app.float.default_10") }) + .align(Alignment.Start) + + Text("点击选择") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } + .width('90%') + .height($r('app.float.default_46')) + .alignItems(VerticalAlign.Center) + .margin({ + top: $r('app.float.default_5'), left: $r('app.float.default_10'), right: $r('app.float.default_10') + }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey3'), + radius: $r('app.float.default_5') + }) + .onClick(() => { + this.isShowPopup = false; + this.selectGoodsTypeController.open() + }) + + Text("请输入物品数量:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .height($r('app.float.default_40')) + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + + Row() { + TextInput({ text: this.inputCount, placeholder: "请输入数量" }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey3'), + radius: $r('app.float.default_5') + }) + .onChange((res) => { + this.inputCount = res + }) + .type(InputType.Number) + .layoutWeight(1) + + Text(this.selectTypeData!.dwname) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + } + .height($r('app.float.default_48')) + .width('90%') + .alignItems(VerticalAlign.Center) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Text("请输入备注:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .height($r('app.float.default_40')) + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + + TextArea({ text: this.remark, placeholder: "请输入备注信息(50字以内)" }) + .placeholderColor($r('app.color.colorGrey6')) + .placeholderFont({ + size: $r('app.float.text_size_14'), + weight: FontWeight.Normal + }) + .height($r('app.float.default_68')) + .width("90%") + .onChange((res) => { + this.remark = res + }) + .backgroundColor($r('app.color.white')) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey3'), + radius: $r('app.float.default_5') + }) + Text("请拍照:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .height($r('app.float.default_40')) + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + + this.goodsPhoto() + + Button("完成") + .width('80%') + .height($r('app.float.default_40')) + .margin({ top: $r('app.float.default_12'), bottom: $r('app.float.default_12') }) + .onClick(() => { + this.addGoodsCompleted() + }) + // 3 + 3*3*3*4 + } + .height('72%') + .alignItems(HorizontalAlign.Center) + .width("95%") + .backgroundColor($r('app.color.white')) + .overlay(createWaterMark()) + .border({ + radius: { topLeft: $r('app.float.default_20'), topRight: $r('app.float.default_20') } + }) + } + + addGoodsCompleted() { + if (StrUtil.isEmpty(this.inputCount) || this.inputCount === "0") { + ToastUtils.toastBottom("请输入数量!") + return + } + + if (StrUtil.isEmpty(this.goodsXczp)) { + ToastUtils.toastBottom("请拍摄物品照片!") + return + } + + // this.allCount += Number.parseFloat(this.inputCount); + + let bean = new GoodsBean(); + bean.name = StringUtils.get(this.selectTypeData?.thingsname, "") + bean.count = StringUtils.get(this.inputCount, "0") + bean.createTime = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSS) + bean.unit = StringUtils.get(this.selectTypeData?.dwname, "") + bean.dwValue = StringUtils.get(this.selectTypeData?.dwvalue, "") + bean.thingsValue = StringUtils.get(this.selectTypeData?.thingsvalue, "") + bean.remark = StringUtils.get(this.remark, "") + bean.category = StringUtils.get(this.selectTypeData?.thingsname, "") + // bean.dangerLevel = StringUtils.get(this.selectTypeData?.thingsname, "") + bean.photoUrl = StringUtils.get(this.goodsXczp, "") + bean.photoId = StringUtils.get(this.goodsXczpId, "") + bean.userName = RuanseeAbitityStag.userCache.getUserCode + bean.policeName = RuanseeAbitityStag.userCache.getUserName + bean.idCard = RuanseeAbitityStag.userCache.getIdCardNum + bean.deptId = RuanseeAbitityStag.userCache.getDeptCode + bean.deptName = RuanseeAbitityStag.userCache.getDeptName + bean.historyId = RuanseeAbitityStag.appCache.getHistoryId() + bean.uuid = this.goodsId + bean.checkTime = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSS) + + this.goodsDataList.splice(0, 0, bean) + this.isShowPopup = false; + this.goodsTypeData.splice(this.selectIndex, 1); + + this.selectTypeData = this.goodsTypeData[0] + this.goodsId = RuanseeAbitityStag.appCache.getRandomId() + this.inputCount = "" + this.goodsXczp = undefined + this.goodsXczpStatus = false; + } + + @Builder + goodsPhoto() { + Row() { + RelativeContainer() { // 创建相对布局容器 + Image(this.goodsXczp) + .width($r('app.float.default_92')) + .height($r('app.float.default_100')) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, // 水平居中 + middle: { anchor: '__container__', align: HorizontalAlign.Center } // 垂直居中 + }) + .id('image') // 设置唯一ID + + // 删除按钮(使用图标) + // Image($r('app.media.icon_delete')) + // .width($r('app.float.default_25'))// 按钮宽度 + // .height($r('app.float.default_25'))// 按钮高度 + // .alignRules({ + // 'top': { anchor: 'image', align: VerticalAlign.Top }, // 顶部对齐图片顶部 + // 'right': { anchor: 'image', align: HorizontalAlign.End } // 右侧对齐图片右侧 + // }) + // .id('deleteBtn') + } + .width($r('app.float.default_110')) // 容器宽度占满父组件 + .height(AppConstants.PERCENTAGE_MAX) // 容器固定高度 + .margin({ left: $r('app.float.default_10') }) + .visibility(this.goodsXczpStatus ? Visibility.Visible : Visibility.Hidden) + + Column() { + Image($r('app.media.imp_upload')) + .width($r('app.float.default_46')) + .height($r('app.float.default_38')) + .autoResize(true) + .objectFit(ImageFit.Auto) + + Text("添加照片") + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_10') }) + } + .visibility(this.goodsXczpStatus ? Visibility.Hidden : Visibility.Visible) + .justifyContent(FlexAlign.Center) + .width($r('app.float.default_92')) + .height('88%') + .onClick(() => { + this.takePhoto() + }) + .border({ + width: $r('app.float.default_1'), + radius: 3, + color: $r('app.color.colorGrey3') + }) + } + .alignItems(VerticalAlign.Center) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .height($r('app.float.default_110')) + .justifyContent(FlexAlign.Start) + .width('92%') + .margin({ + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .margin({ top: $r('app.float.default_24') }) + + } + + build() { + Column() { + BaseTopBar({ + title: "随行物品", + rightText: "提交", + leftClickEvent: () => { + this.backOneLevelPage() + }, + rightClickEvent: () => { + this.backOneLevelPage() + } + }) + + List() { + ForEach(this.goodsDataList, (item: GoodsBean) => { + ListItem() { + this.goodsItem(item) + } + }) + } + .layoutWeight(1) + .width(AppConstants.PERCENTAGE_MAX) + + Button("点击添加") + .width('89%') + .margin({ bottom: $r('app.float.default_22') }) + .onClick(() => { + if (this.isShowPopup) { + return + } + if (this.goodsTypeData == null || this.goodsTypeData == undefined || this.goodsTypeData.length < 1) { + ToastUtils.toastBottom("获取物品类别失败!") + return + } + if (!this.selectTypeData) { + this.selectTypeData = this.goodsTypeData[0] + this.goodsId = RuanseeAbitityStag.appCache.getRandomId() + this.inputCount = "" + this.goodsXczp = undefined + this.goodsXczpStatus = false; + } + this.isShowPopup = true; + }) + .bindPopup(this.isShowPopup, { + builder: () => this.addGoodsPopup(), + autoCancel: false, + placement: Placement.Top, + mask: { color: 0x80000000 }, + maskColor: 0x80000000, + onStateChange: (v) => { + this.isShowPopup = v.isVisible; + } + }) + .onKeyEvent((event: KeyEvent) => { + if (event.type === KeyType.Down && event.keyCode === 4) { + if (this.isShowPopup) { + // 如果弹窗打开,阻止返回键行为 + return true; // 返回 true 表示已消费该事件 + } + } + return false; // 允许默认行为 + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + @Builder + goodsItem(item: GoodsBean) { + Row() { + Image(item.photoUrl) + .width($r('app.float.default_58')) + .height($r('app.float.default_72')) + .margin({ left: $r('app.float.default_10') }) + + Column() { + Row() { + Text(item.name) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Medium) + + Text(item.count) + .fontColor($r('app.color.colorYellow7')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Medium) + .margin({ left: $r('app.float.default_5'), right: $r('app.float.default_5') }) + + Text(item.unit) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Medium) + + } + .justifyContent(FlexAlign.Start) + + Text(StringUtils.get(item.remark, "暂无")) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_5'), bottom: $r('app.float.default_5') }) + + Text(item.createTime) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .fontWeight(FontWeight.Medium) + + } + .margin({ left: $r('app.float.default_6') }) + .layoutWeight(1) + .height($r('app.float.default_84')) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + } + .justifyContent(FlexAlign.Center) + .width('90%') + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey3'), + radius: $r('app.float.default_3') + }) + .height($r('app.float.default_92')) + .backgroundColor($r('app.color.white')) + .margin({ top: $r('app.float.default_10'), left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } +} + diff --git a/entry/src/main/ets/ui/pages/HandOverPage.ets b/entry/src/main/ets/ui/pages/HandOverPage.ets new file mode 100644 index 0000000..d7f34ca --- /dev/null +++ b/entry/src/main/ets/ui/pages/HandOverPage.ets @@ -0,0 +1,356 @@ +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil"; +import AppConstants from "../../app/AppConstant"; +import { PCCacheData } from "../../app/PCCacheData"; +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { CheckSubmitEntity, CheckSubmitModel } from "../../model/requestModel/CheckRequestModel"; +import { CheckReasonModel } from "../../model/uiModel/GoodsModel"; +import { cardRoundBorderGreyStyle } from "../../style/BorderStyle"; +import { bufferToString } from "../../util/BufferUtil"; +import { DateFormat, DateUtils } from "../../util/DateUtils"; +import { StringUtils } from "../../util/StringUtils"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { SelectCheckReasonDialog } from "../../view/dialog/SelectCheckReasonDialog"; +import router from "@ohos.router"; +import { SkipHandOverParam } from "../../model/uiModel/PageParamModel"; +import { getCoordinateDescription, saveMainHistoryAndChangeStatus } from "../../request/api/Api"; +import { AxiosError } from "@ohos/axios"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { ToastUtil } from "@pura/harmony-utils/src/main/ets/action/ToastUtil"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { geoLocationManager } from "@kit.LocationKit"; +import { AppCache } from "../../app/AppCache"; + +/** + * 移交操作 + */ +@Preview +@Component +@Entry +export struct HandOverPage { + @State checkReasonData: CheckReasonModel[] = [] + @State checkReason: string = "请选择盘查原因" + @State selectCheckReasonValue: string = "1"; + @State inputAddress: string = ""; + @State inputRemark: string = ""; + pageParam: SkipHandOverParam | undefined = undefined; + + //定位状态 + locationStatus:boolean = false; + + aboutToAppear(): void { + this.pageParam = router.getParams() as SkipHandOverParam; + this.getUIContext().getHostContext()?.resourceManager.getRawFileContent('checkData/CheckReason.json') + .then(value => { + this.checkReasonData = JSON.parse(bufferToString(value.buffer)) as CheckReasonModel[]; + if (this.checkReasonData && this.checkReasonData.length > 0) { + this.checkReason = StringUtils.get(this.checkReasonData[0].dictLabel, ""); + this.selectCheckReasonValue = StringUtils.get(this.checkReasonData[0].dictValue, "1"); + } + }) + if(StringUtils.isNullOrEmpty(RuanseeAbitityStag.appCache.getLocationAddress)){ + this.getCurrentLocation() + }else { + this.inputAddress = RuanseeAbitityStag.appCache.getLocationAddress + } + } + + + /** + * 读取缓存的位置 + * @returns + */ + getLastLocation(): geoLocationManager.Location | undefined { + try { + let location = geoLocationManager.getLastLocation(); + return location; + } catch (err) { + console.info("passPage", "errCode:" + err.code + ", message:" + err.message); + return undefined; + } + } + + private locationCallback = (data: geoLocationManager.Location) => { + console.info("passPage", 'current location: ' + JSON.stringify(data)); + AppCache.getAppCache().setLocation(data); + this.getAddressByLongitudeLatitude(data) + } + + onPageHide(): void { + if (this.locationStatus) { + geoLocationManager.off('locationChange', this.locationCallback); + this.locationStatus = false; + } + // 在页面销毁时解除监听 + } + + /** + * 持续定位 获取位置 + */ + getCurrentLocation() { + let request2: geoLocationManager.ContinuousLocationRequest = { + "interval": 60, + "locationScenario": geoLocationManager.UserActivityScenario.SPORT + } + try { + geoLocationManager.on('locationChange', request2,this.locationCallback ) + this.locationStatus = true; + // let request: geoLocationManager.SingleLocationRequest = { + // 'locatingPriority': geoLocationManager.LocatingPriority.PRIORITY_LOCATING_SPEED, + // 'locatingTimeoutMs': 10000 + // } + // geoLocationManager.getCurrentLocation(request) 街面盘查 StreetFront Street level search + // .then((result) => { // 调用getCurrentLocation获取当前设备位置,通过promise接收上报的位置 + // console.info(TAG, 'current location: ' + JSON.stringify(result)); + // }) + // .catch((error: BusinessError) => { // 接收上报的错误码 + // console.info(TAG, 'promise, getCurrentLocation: error=' + JSON.stringify(error)); + // }); + } catch (err) { + console.info("passPage", "errCode:" + JSON.stringify(err)); + } + } + + getAddressByLongitudeLatitude(location :geoLocationManager.Location){ + getCoordinateDescription() + .then((res)=>{ + console.debug(JSONUtil.beanToJsonStr(res)) + if (res&&res.length>0) { + let address = res[0]; + if (address) { + this.inputAddress = StringUtils.get(address.address,""); + if (this.locationStatus) { + geoLocationManager.off('locationChange', this.locationCallback); + this.locationStatus = false; + } + } + } + }) + .catch((error:AxiosError)=>{ + console.error(error.message) + }) + } + + selectCheckReasonController: CustomDialogController = new CustomDialogController({ + builder: SelectCheckReasonDialog({ + checkReasonData: this.checkReasonData, + clickItem: (item, selectIndex) => { + this.checkReason = StringUtils.get(item.dictLabel, ""); + this.selectCheckReasonValue = StringUtils.get(item.dictValue, "1"); + this.selectCheckReasonController.close() + } + }), + cornerRadius: 3, + autoCancel: false, + backgroundColor: Color.Transparent, // 背景透明 + backgroundBlurStyle: BlurStyle.NONE // 必须关闭模糊材质 + }); + + build() { + Column() { + BaseTopBar({ + title: "完善盘查信息" + }) + + Text("盘查原因:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + top: $r('app.float.default_20') + }) + + Row() { + Text(this.checkReason) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .fontWeight(FontWeight.Medium) + .layoutWeight(1) + .textAlign(TextAlign.Start) + .margin({ left: $r("app.float.default_10") }) + .align(Alignment.Start) + + Text("点击选择") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } + .width(`calc(100% - 20vp)`) + .height($r('app.float.default_43')) + .alignItems(VerticalAlign.Center) + .margin({ + top: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderGreyStyle) + .padding({left:$r('app.float.default_8'),right:$r('app.float.default_8')}) + .onClick(() => { + this.selectCheckReasonController.open() + }) + + + Text("盘查地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + top: $r('app.float.default_10') + }) + + TextInput({ text: this.inputAddress, placeholder: "请输入地址" }) + .width(`calc(100% - 20vp)`) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .textAlign(TextAlign.Start) + .align(Alignment.Center) + .height($r('app.float.default_40')) + .backgroundColor($r('app.color.white')) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.default_5'), + bottom: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .onChange((res) => { + this.inputAddress = res; + }) + .border(cardRoundBorderGreyStyle) + + Text("备注信息:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + top: $r('app.float.default_10') + }) + + TextArea({ text: this.inputRemark, placeholder: "请输入备注信息" }) + .width(`calc(100% - 20vp)`) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .textAlign(TextAlign.Start) + .align(Alignment.TopStart) + .height($r('app.float.default_88')) + .backgroundColor($r('app.color.white')) + .margin({ + top: $r('app.float.default_5'), + bottom: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .onChange((res) => { + this.inputRemark = res; + }) + .border(cardRoundBorderGreyStyle) + + Column() + .layoutWeight(1) + + Button('完成', { type: ButtonType.Normal, stateEffect: true }) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_48')) + .margin({ bottom: $r('app.float.default_22') }) + .backgroundColor($r('app.color.colorGreen7')) + .onClick(() => { + this.submit() + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + + } + + /** + * 街面/卡点 + * 车辆类型(重点,正常) + */ + submit() { + let pc = PCCacheData.pcCacheData; + let entity: CheckSubmitEntity = new CheckSubmitEntity(); + entity.peopleCount = pc.zcCount + "" + entity.unusualPeopleCount = pc.yiCount + "" + + entity.unusualCarCount = '' + + if (this.pageParam) { + if (this.pageParam.carNumStatus == 0) { + entity.carCount = "0"; + entity.unusualCarCount = "0"; + } else { + entity.carCount = "1"; + if (this.pageParam.carNumStatus == 1) { + entity.unusualCarCount = "1"; + } else { + entity.unusualCarCount = "0"; + } + } + } + + entity.goodsCount = `${pc.wpCount}` + //type 0 = 街面盘查 1 = 卡点盘查 + entity.type = "0" + entity.checkReason = this.selectCheckReasonValue + entity.checkAddress = this.inputAddress + entity.remark = this.inputRemark + entity.pointX = RuanseeAbitityStag.appCache.getLocationX() + "" + entity.pointY = RuanseeAbitityStag.appCache.getLocationY() + "" + entity.taskId = "" + entity.kkid = "" + entity.mainId = RuanseeAbitityStag.appCache.getHistoryId() + entity.checkTime = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSS) + entity.status = "1" + entity.groupId = "" + entity.yjdw = this.pageParam?.selectDeptId; + entity.yjdwmc = this.pageParam?.selectDeptName; + entity.userName = RuanseeAbitityStag.userCache.getUserCode + entity.idCard = RuanseeAbitityStag.userCache.getIdCardNum + entity.deptId = RuanseeAbitityStag.userCache.getDeptCode + entity.deptName = RuanseeAbitityStag.userCache.getDeptName + entity.orgCode = RuanseeAbitityStag.userCache.getDeptCode + entity.orgName = RuanseeAbitityStag.userCache.getDeptName + entity.policeNum = RuanseeAbitityStag.userCache.getUserCode + entity.policeName = RuanseeAbitityStag.userCache.getUserName + entity.policeIdCard = RuanseeAbitityStag.userCache.getIdCardNum + + let model: CheckSubmitModel = new CheckSubmitModel(); + model.checkHistoryEntity = entity; + model.personIds = this.pageParam?.personIds + model.carIds = new Array + if (this.pageParam?.carId){ + model.carIds.push(this.pageParam.carId) + } + + saveMainHistoryAndChangeStatus(model) + .then((res)=>{ + console.debug(JSON.stringify(res)); + if (res.code == 200) { + let param: BasePageResult = { + type: 5, + what: 1, + data: "提交成功!" + } + router.back({ url: "ui/pages/StreetInspectionPages", params: param }) + }else { + ToastUtil.showToast(res.msg) + } + }) + .catch((error:AxiosError)=>{ + console.error(error.message) + ToastUtil.showToast(error.message) + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/HistoryDetailsPage.ets b/entry/src/main/ets/ui/pages/HistoryDetailsPage.ets new file mode 100644 index 0000000..ee59bf0 --- /dev/null +++ b/entry/src/main/ets/ui/pages/HistoryDetailsPage.ets @@ -0,0 +1,177 @@ +import AppConstants from "../../app/AppConstant"; +import { SkipHistoryDetailsParam } from "../../model/uiModel/PageParamModel"; +import { cardRoundBorderStyle } from "../../style/BorderStyle"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { router } from "@kit.ArkUI"; +import { ToastUtil } from "@pura/harmony-utils"; +import { PeopleListFragment } from "../fragment/PeopleListFragment"; +import { CarListFragment } from "../fragment/CarListFragment"; +import { GoodsListFragment } from "../fragment/GoodsListFragment"; + +@Preview +@Component +@Entry +export struct HistoryDetailsPage { + @State param: SkipHistoryDetailsParam | undefined = undefined + @State selectedIndex: number = 0 + + aboutToAppear(): void { + this.param = router.getParams() as SkipHistoryDetailsParam + if (!this.param) { + ToastUtil.showToast("参数错误!") + router.back() + return + } + } + + build() { + Column() { + BaseTopBar({ + title: $r('app.string.title_history_details'), + }) + this.PanCaDetails() + + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + PeopleListFragment({ mainId: this.param?.mainId }) + }.tabBar(this.tabBuilder('人', 0)) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + CarListFragment({ mainId: this.param?.mainId }) + }.tabBar(this.tabBuilder('车', 1)) + + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + TabContent() { + GoodsListFragment({ mainId: this.param?.mainId,isYj: this.param?.status == 1}) + }.tabBar(this.tabBuilder('物', 2)) + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + } + .onChange(index => { + this.selectedIndex = index + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + @Builder + PanCaDetails() { + Column() { + Row() { + Text("警员姓名:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + Text(this.param?.policename) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')); + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX); + + Row() { + Text("盘查原因:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + Text(this.param?.pcyy) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')); + + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .visibility(this.param?.type == 1 ? Visibility.None : Visibility.Visible) + .width(AppConstants.PERCENTAGE_MAX); + + Row() { + Text("盘查时间:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + Text(this.param?.pctime) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')); + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX); + + Row() { + Text("移交单位:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + Text(this.param?.yjdw) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')); + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX); + + Row() { + Text("任务名称:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + Text(this.param?.taskName) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')); + } + .alignItems(VerticalAlign.Center) + .visibility(this.param?.type == 1 ? Visibility.Visible : Visibility.None) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX); + + Row() { + Text("盘查地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + Text(this.param?.address) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX); + + } + .width("95%") + .justifyContent(FlexAlign.Start) + .padding($r("app.float.default_10")) + .margin($r("app.float.default_10")) + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + } + + @Builder + tabBuilder(title: string, targetIndex: number) { + Column() { + Text(title) + .fontColor(this.selectedIndex === targetIndex ? $r('app.color.bull') : $r('app.color.colorGrey7')) + } + .width('100%') + .alignItems(HorizontalAlign.Center) + .height($r('app.float.default_46')) + .justifyContent(FlexAlign.Center) + .backgroundColor(this.selectedIndex === targetIndex ? $r('app.color.white') : $r('app.color.colorGrey2')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/HistoryMainPage.ets b/entry/src/main/ets/ui/pages/HistoryMainPage.ets new file mode 100644 index 0000000..16d2b30 --- /dev/null +++ b/entry/src/main/ets/ui/pages/HistoryMainPage.ets @@ -0,0 +1,61 @@ +import AppConstants from "../../app/AppConstant"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { CheckPointHistoryFragment } from "../fragment/CheckPointHistoryFragment"; +import { StreetSearchHistoryFragment } from "../fragment/StreetSearchHistoryFragment"; +import router from "@ohos.router"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { common } from "@kit.AbilityKit"; + +/** + * 历史记录主页 + */ +@Preview +@Entry +@Component +export struct HistoryMainPage{ + context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + + onPageShow(): void { + let param :BasePageResult = router.getParams() as BasePageResult; + if (param) { + if (param.type == 1) { + this.context.eventHub.emit("select_task",param.data) + } + } + } + + build() { + Column(){ + BaseTopBar({ + title:"历史记录" + }) + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + CheckPointHistoryFragment() + } + .tabBar(new SubTabBarStyle('卡点核录')) + + TabContent() { + StreetSearchHistoryFragment() + } + .tabBar(new SubTabBarStyle('街面盘查')) + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .layoutWeight(1) + .backgroundColor(0xF1F3F5) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .overlay(createWaterMark()) + .backgroundColor($r('app.color.page_background')) + } + + +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/Index.ets b/entry/src/main/ets/ui/pages/Index.ets new file mode 100644 index 0000000..1274fa7 --- /dev/null +++ b/entry/src/main/ets/ui/pages/Index.ets @@ -0,0 +1,284 @@ +//导入router +import router from '@ohos.router'; +import { common, Want } from '@kit.AbilityKit'; +import data_preferences from '@ohos.data.preferences'; + +import { connection } from '@kit.NetworkKit' +import { BusinessError } from '@kit.BasicServicesKit' +import { buffer, util } from '@kit.ArkTS'; +import { ToastUtils as ToastUtils } from '../../util/ToasUtils'; +import { AppCache } from '../../app/AppCache'; +import { UserCache } from '../../app/UserCache'; +import { createWaterMark } from '../../view/custom/Watermark'; +import { StringUtils } from '../../util/StringUtils'; +import { getPgToken } from '../../request/api/Api'; +import { AxiosError } from '@ohos/axios'; +import { AuthUserModel, IAuthTaskType } from '../../model/uiModel/IAuthTaskType'; +import { RuanseeAbitityStag } from '../../app/RuanseeAbitityStag'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +const H_STORE: string = 'healthAppStore'; + + +interface GeneratedObjectLiteralInterface_1 { + "userName": string; + "realName": string; + "orgName": string; + "orgCode": string; + "idCardNum": string; + "ip": string; +} + +@Entry +@Component +struct Index { + @State message: string = '正在初始化...'; + context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + ipAddress: string | undefined = undefined + + onPageShow(): void { + + } + + onPageHide(): void { + + } + + getToken() { + getPgToken() + .then((res) => { + if (res) { + AppCache.getAppCache().setPgToken = res.access_token; + } + console.info(JSON.stringify(res)); + }) + .catch((error: AxiosError) => { + console.error(JSON.stringify(error)); + }) + } + + aboutToAppear() { + this.getIpAddress(); + this.getToken() + // 100/4 = 25 + + // let date = DateUtils.pastStrDate("2023年10日01日 15:23:33.256"); + // + // let datas = DateUtils.formatDateStr(date,DateFormat.YYYYhMMhDDkHHdMMdSSdSSS); + // + // console.debug("测试日期",datas) + // let preferences = data_preferences.getPreferences(this.context, H_STORE); + // preferences.then((res) => { + // res.get(IS_PRIVACY, false).then((isPrivate) => { + // if (isPrivate === true) { + // this.jumpAdPage(); + // } else { + // + // } + // }); + // }); + } + + handUserInfo(ipAddress: string | undefined) { + + let appCache = AppCache.getAppCache(); + let userCache = UserCache.getUserCache(); + + appCache.setIpOrPort('20.90.2.2', '80', "/ypc_test_out/") + + //设置用户信息,后期改成单点登录获取用户信息 + // userCache.setUserName = "陈乐(测试)" + // userCache.setUserCode = "999013" + // userCache.setDeptName = "测试单位001" + // userCache.setDeptCode = "340012000000" + // userCache.setIdCardNum = "420113199310297548" + // userCache.setUserName = "孙福(测试)" + // userCache.setUserCode = "009906" + // userCache.setDeptName = "科技信息化支队基础设施管理大队" + // userCache.setDeptCode = "340100750300" + // userCache.setIdCardNum = "32030519930422151X" + + //本机IP + appCache.setLocalIp = StringUtils.get(ipAddress, "10.115.101.1"); + + let userInfos = userCache.getUserInfo(); + if (StringUtils.isNullOrEmpty(userInfos)) { + let cs: GeneratedObjectLiteralInterface_1 = { + "userName": userCache.getUserCode, + "realName": userCache.getUserName, + "orgName": userCache.getDeptName, + "orgCode": userCache.getDeptCode, + "idCardNum": userCache.getIdCardNum, + "ip": appCache.setLocalIp + } + let userInfo = JSON.stringify(cs) + let byte = new Uint8Array(buffer.from(userInfo, 'utf-8').buffer); + let baseUserInfo = new util.Base64Helper().encodeToStringSync(byte); + userCache.setUserInfo = JSON.stringify(baseUserInfo); + } + + setTimeout(() => { + this.message = "正在获取用户信息..." + if (appCache.getPermissionsStatus) { + this.jumpAdPage(); + } + }, 100) + } + + //获取IP地址 原因 + getIpAddress() { + let defNet = connection.getDefaultNet() + defNet.then((netHandle: connection.NetHandle) => { + connection.getConnectionProperties(netHandle, (error: BusinessError, data: connection.ConnectionProperties) => { + if (error) { + console.error(`Failed to get connection properties. Code:${error.code}, message:${error.message}`); + ToastUtils.toastBottom("获取IP地址失败!") + this.authLogin(); + return; + } + console.info("Succeeded to get data: " + JSON.stringify(data)); + try { + let ip = data['linkAddresses'][0]['address']['address'] + console.info('本地ip:', ip) + this.ipAddress = ip + this.authLogin(); + } catch (e) { + console.error("e", JSON.stringify(e)); + ToastUtils.toastBottom("获取IP地址失败!") + this.authLogin(); + } + }); + }).catch((error: Error) => { + console.error("e", JSON.stringify(error)); + ToastUtils.toastBottom(error.message) + }) + .finally(() => { + + }) + } + + authLogin() { + let want: Want = { + bundleName: 'hm.anhui.police.auth', + abilityName: 'OhosAuthAbility', + parameters: { + 'action': 'getAuthUser', + 'IAuthTaskType': IAuthTaskType.AUTH_TASK_USER, + 'packageName': 'com.rs.rchl', + 'sysCode': '63431541a00042e0b1ec1e9326c7aca1' + } + }; + try { + this.context.startAbilityForResult(want, (err: BusinessError, result: common.AbilityResult) => { + if (err.code) { + // 处理业务逻辑错误 + console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); + return; + } + // 执行正常业务 + console.info(`startAbility succeed resultCode:${result.resultCode} result:${JSON.stringify(result)} want:${JSON.stringify(want)}`); + if (result.resultCode === -1) { + this.message = '未获取到用户信息'; + return; + } + const iAuthTaskType = result.want?.parameters?.IAuthTaskType + const message = result.want?.parameters?.message + if (iAuthTaskType === IAuthTaskType.AUTH_TASK_USER) { + this.message = `开始处理认证数据`; + let authUser = result.want?.parameters?.authUser; + hilog.info(0x0000, 'carousel', '%{public}s', `authUser:${authUser}`); + if (result.resultCode === 200) { + // 获取到用户信息 + let authUserModel = JSON.parse(StringUtils.get(authUser, "")) as AuthUserModel + if (authUserModel) { + let userCache = RuanseeAbitityStag.userCache + userCache.setUserName = authUserModel.realName + userCache.setUserCode = authUserModel.userNum + userCache.setDeptCode = authUserModel.orgId + userCache.setDeptName = authUserModel.orgName + userCache.setIdCardNum = authUserModel.code + userCache.setAuthToken = authUserModel.token + userCache.setProfilePhoto = StringUtils.get(authUserModel.profilePhoto, "") + this.handUserInfo(this.ipAddress) + }else { + this.loginError("获取用户信息失败!"); + } + } else if (result.resultCode === 100) { + this.message = `用户主动关闭登录页面,未获取到用户信息`; + this.loginError(`用户主动关闭登录页面,未获取到用户信息`); + } else { + this.message = `未获取到用户信息,错误码(${result.resultCode})`; + this.loginError(`未获取到用户信息,错误码(${result.resultCode})`); + } + } else { + this.message = `获取用户信息失败:${result.want?.parameters?.message}`; + this.loginError(`获取用户信息失败:${result.want?.parameters?.message}`); + } + }); + } catch (err) { + // 处理入参错误异常 + let code = (err as BusinessError).code; + let message = (err as BusinessError).message; + console.error(`startAbility failed, code is ${code}, message is ${message}`); + this.loginError(`startAbility failed, code is ${code}, message is ${message}`); + } + } + + loginError(msg:string){ + ToastUtils.toastBottom(msg) + setTimeout(() => { + router.back() + this.context.terminateSelf() + },1500) + } + build() { + Column() { + Image($r('app.media.ic_applogin')) + .width(100) + .aspectRatio(1) + .margin({ top: 190 }); + + Text($r('app.string.EntryAbility_label')) + .fontSize($r('app.float.text_size_24')) + .fontColor($r('app.color.bull')) + .fontWeight(700) + .letterSpacing(1) + .margin({ + top: $r('app.float.default_20'), + bottom: $r('app.float.default_8') + }) + + Text(this.message) + .fontColor($r('app.color.grad')) + .fontSize($r("app.float.text_size_14")) + .margin({ top: 32 }) + + Text($r('app.string.ownership_dept')) + .fontColor($r('app.color.grad')) + .fontSize($r("app.float.text_size_14")) + .height('100%') + .margin({ bottom: $r('app.float.default_20') }) + + } + .width('100%') + .height('100%') + .expandSafeArea([SafeAreaType.SYSTEM]) + .overlay(createWaterMark()) + + } + + exitApp() { + this.context.terminateSelf(); + let preferences = data_preferences.getPreferences(this.context, H_STORE); + preferences.then((res) => { + // res.clearSync(); + }) + } + + jumpAdPage() { + setTimeout(() => { + this.message = "正在跳转..." + router.replaceUrl({ url: 'ui/pages/MainPages' }); + }, 800); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/MainPages.ets b/entry/src/main/ets/ui/pages/MainPages.ets new file mode 100644 index 0000000..bc60802 --- /dev/null +++ b/entry/src/main/ets/ui/pages/MainPages.ets @@ -0,0 +1,692 @@ +import AppConstants from "../../app/AppConstant"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { font, router } from '@kit.ArkUI'; +import { cardRoundBorderStyle } from "../../style/BorderStyle"; +import { ToastUtils } from "../../util/ToasUtils"; +import app from '@system.app'; +import { MainButtonBean } from "../../model/uiModel/MainBean"; +import { abilityAccessCtrl, bundleManager, common, Permissions, } from "@kit.AbilityKit"; +import { geoLocationManager } from "@kit.LocationKit"; +import { AppCache } from "../../app/AppCache"; +import { UserCache } from "../../app/UserCache"; +import { StringUtils } from "../../util/StringUtils"; +import { getCoordinateDescription, getDeptChile, getMainStatistics } from "../../request/api/Api"; +import { hilog } from "@kit.PerformanceAnalysisKit"; +import { AxiosError } from "@ohos/axios"; +import { GetStatisticsModel } from "../../model/requestModel/MainRequestModel"; +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { DateFormat, DateUtils } from "../../util/DateUtils"; +import { SkipCheckPageModel } from "../../model/uiModel/PageParamModel"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { DateUtil, JSONUtil } from "@pura/harmony-utils"; +import { DBUtils } from "../../model/db/DBUtils"; +import { DeptTableEntity } from "../../model/db/TableEntity"; +import { RdbDao } from "rdbstore"; +import { FileUtils } from "../../util/FileUtils"; + +const TAG: string = 'GRLocation'; + +@Component +@Preview +@Entry +export struct MainPages { + @State isRefresh: boolean = false; + // 记录上一次点击时间 + private pretime: number = -1; + private mainButtonArray: Array = new Array() + private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; + @State checkPeopleCount: string = "0"; + @State unusualPeopleCount: string = "0"; + @State carCount: string = "0"; + @State allCount: string = "0"; + + //SafeKeyboard + + aboutToAppear(): void { + font.registerFont({ + familyName: "zdyfont", + familySrc: $rawfile('pangmenzhengdao.ttf') + }) + this.mainButtonArray = [ + { + icon: $r('app.media.icon_point_check'), + name: $r('app.string.str_jmpc'), + routerPage: 'ui/pages/StreetInspectionPages' + }, + { + icon: $r('app.media.icon_scrutiny'), + name: $r('app.string.str_kdhl'), + routerPage: 'ui/pages/SelectTaskAndCardPortPages', + tag: 1 + }, + { + icon: $r('app.media.tab_attention'), + name: $r('app.string.str_my_concerns'), + routerPage: "ui/pages/MyAttentionActivity" + }, + { + icon: $r('app.media.icon_historical_record'), + name: $r('app.string.str_historical_records'), + routerPage: "ui/pages/HistoryMainPage" + }, + { + icon: $r('app.media.icon_about'), + name: $r('app.string.title_About'), + routerPage: "ui/pages/AboutPage" + }, + ] + this.applyForPermission() + setTimeout(()=>{ + this.getDeptData() + },3000) + } + + onBackPress(): boolean | void { + if (-1 == this.pretime) { + // 第一次点击返回键,提示toast + ToastUtils.toastBottom("再按一次退出应用") + this.pretime = new Date().getTime(); + setTimeout(() => { + this.pretime = -1 + }, 2000) + return true; + } else { + let currentTime = new Date().getTime(); + let flag = currentTime - this.pretime; + if (flag > 2000) { + //两次点击时间太长不做处理 + this.pretime = currentTime; + setTimeout(() => { + this.pretime = -1 + }, 2000) + return true; + } else { + app.terminate(); // 2秒内点击,退出当前Ability。 + } + } + return false; + } + + /** + * 获取权限后执行此方法 + */ + initPage() { + FileUtils.createFileDir() + this.getStatistics() + this.getCurrentLocation() + } + + getAddressByLongitudeLatitude(location: geoLocationManager.Location) { + getCoordinateDescription() + .then((res) => { + console.debug(JSONUtil.beanToJsonStr(res)) + if (res && res.length > 0) { + let address = res[0]; + if (address) { + RuanseeAbitityStag.appCache.setLocationAddress = StringUtils.get(address.address, "") + } + } + }) + .catch((error: AxiosError) => { + console.error(error.message) + }) + } + + /** + * 检测权限 + * @param permissionArray + */ + checkPermissionGrant(permissionArray: Array) { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() + // 获取应用程序的accessTokenID + let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION) + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo + let tokenId: number = appInfo.accessTokenId + let wsqPermissionArray = new Array() + for (let i = 0; i < permissionArray.length; i++) { + let grantStatus = atManager.checkAccessTokenSync(tokenId, permissionArray[i]) + if (grantStatus == abilityAccessCtrl.GrantStatus.PERMISSION_DENIED) { + wsqPermissionArray.push(permissionArray[i]) + } + } + if (wsqPermissionArray.length > 0) { + //有未申请的权限,发送到Ability,由 Ability 发起权限申请 + // this.requestPermissionsFromUser(wsqPermissionArray) + this.context.eventHub.emit('ui_event', wsqPermissionArray); + } else { + //权限全部申请 + this.initPage() + this.getCurrentLocation() + } + } + + /** + *AUTHOR:AbnerMing + *INTRODUCE:向用户获取权限授权 + */ + requestPermissionsFromUser(permissions: Array) { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() + atManager.requestPermissionsFromUser(this.context, permissions) + .then((data) => { + let grantStatus: Array = data.authResults; + let length: number = grantStatus.length; + for (let i = 0; i < length; i++) { + if (grantStatus[i] === 0) { + // 用户授权,可以继续访问目标操作 + console.log("===用户授权") + } else { + // 用户拒绝授权,提示用户必须授权才能访问当前页面的功能,并引导用户到系统设置中打开相应的权限 + console.log("===用户拒绝了授权") + return + } + } + console.log("===权限授权成功") + }) + } + + /** + *AUTHOR:AbnerMing + *INTRODUCE:校验应用是否被授予权限 + */ + private getGrantStatus(permissionName: Permissions): abilityAccessCtrl.GrantStatus { + let atManager: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager() + // 获取应用程序的accessTokenID + let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION) + let appInfo: bundleManager.ApplicationInfo = bundleInfo.appInfo + let tokenId: number = appInfo.accessTokenId + //检查权限状态 + let grantStatus = atManager.checkAccessTokenSync(tokenId, permissionName) + return grantStatus + } + + applyForPermission() { + let permissions = new Array(); + permissions.push('ohos.permission.LOCATION') + permissions.push('ohos.permission.APPROXIMATELY_LOCATION') + this.checkPermissionGrant(permissions) + } + + /** + * 读取缓存的位置 + * @returns + */ + getLastLocation(): geoLocationManager.Location | undefined { + try { + let location = geoLocationManager.getLastLocation(); + return location; + } catch (err) { + console.info(TAG, "errCode:" + err.code + ", message:" + err.message); + return undefined; + } + } + + /** + * 持续定位 获取位置 + */ + getCurrentLocation() { + //持续定位 5分钟定位一次 + let request2: geoLocationManager.ContinuousLocationRequest = { + "interval": 300, + "locationScenario": geoLocationManager.UserActivityScenario.SPORT + } + try { + geoLocationManager.on('locationChange', request2, (data) => { + console.info(TAG, 'current location: ' + JSON.stringify(data)); + AppCache.getAppCache().setLocation(data); + this.getAddressByLongitudeLatitude(data) + }) + + // let request: geoLocationManager.SingleLocationRequest = { + // 'locatingPriority': geoLocationManager.LocatingPriority.PRIORITY_LOCATING_SPEED, + // 'locatingTimeoutMs': 10000 + // } + // geoLocationManager.getCurrentLocation(request) 街面盘查 StreetFront Street level search + // .then((result) => { // 调用getCurrentLocation获取当前设备位置,通过promise接收上报的位置 + // console.info(TAG, 'current location: ' + JSON.stringify(result)); + // }) + // .catch((error: BusinessError) => { // 接收上报的错误码 + // console.info(TAG, 'promise, getCurrentLocation: error=' + JSON.stringify(error)); + // }); + } catch (err) { + console.info(TAG, "errCode:" + JSON.stringify(err)); + } + } + + getStatistics() { + let newDay = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDD); + let statisticsModel: GetStatisticsModel = { + sfz: RuanseeAbitityStag.userCache.getIdCardNum, + beginTime: newDay + " 00:00:00", + endTime: newDay + " 23:59:59", + } + + getMainStatistics(statisticsModel) + .then((res) => { + console.debug("mainPage", res) + this.isRefresh = false; + if (res.code != 200) { + ToastUtils.toastCenter(res.msg); + return + } + if (res.data) { + this.checkPeopleCount = + res.data.peopleCount == null || res.data.peopleCount == undefined ? "0" : res.data.peopleCount + ""; + this.unusualPeopleCount = + res.data.unusualPeopleCount == null || res.data.unusualPeopleCount == undefined ? "0" : + res.data.unusualPeopleCount + ""; + this.carCount = res.data.carCount == null || res.data.carCount == undefined ? "0" : res.data.carCount + ""; + this.allCount = res.data.allCount == null || res.data.allCount == undefined ? "0" : res.data.allCount + ""; + } + }) + .catch((error: AxiosError) => { + this.isRefresh = false; + console.error("mainPage", 'getMainStatistics error' + error.message) + }) + } + + /////////////////////////// UI 相关操作 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ + + build() { + Stack({ alignContent: Alignment.TopStart }) { + this.underlyingBackground() + this.mainContent() + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .overlay(createWaterMark()) + .backgroundColor($r('app.color.page_background')) + } + + /** + * 主要内容 + */ + @Builder + mainContent() { + Column() { + Row() { + Image($r('app.media.icon_badges')) + .width($r('app.float.default_43')) + .height($r('app.float.default_43')) + + Text($r('app.string.app_name')) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_42')) + .margin({ left: $r('app.float.default_8') }) + .fontFamily('zdyfont') + + } + .width(AppConstants.PERCENTAGE_MAX) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .margin({ top: $r('app.float.default_68') }) + + Refresh({ refreshing: $$this.isRefresh }) { + Column() { + //个人信息 + Column() { + + //个人信息 + Row() { + Image($r('app.media.icon_photo')) + .width($r('app.float.default_46')) + .height($r('app.float.default_46')) + + Column() { + Text(`${UserCache.getUserCache().getUserName} ( ${UserCache.getUserCache().getUserCode} )`) + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_16')) + Text(UserCache.getUserCache().getDeptName) + .fontColor($r('app.color.grad')) + .fontSize($r('app.float.text_size_14')) + .margin({ top: $r('app.float.default_6') }) + .maxLines(1) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + .margin({ left: $r('app.float.default_15') }) + } + + // 统计模块 + Divider() + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_1')) + .color($r('app.color.colorGrey2')) + .margin({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + top: $r('app.float.default_10'), + bottom: $r('app.float.default_12') + }) + + this.statisticsUI() + } + .alignItems(HorizontalAlign.Start) + .width('90%') + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_28') + }) + .padding({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_18'), + bottom: $r('app.float.default_18') + }) + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + + Divider() + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_1')) + .color($r('app.color.page_background')) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + + this.gridView() + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + .onRefreshing(() => { + //触发刷新操作 + this.getStatistics() + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + + @Builder + statisticsUI() { + Text('今日统计:') + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_14')) + + Row() { + Column() { + Text('核验人员次数') + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.colorBluen7')); + + Text(this.checkPeopleCount) + .width(AppConstants.PERCENTAGE_MAX) + .textAlign(TextAlign.End) + .fontSize($r('app.float.text_size_18')) + .fontColor($r('app.color.read')); + } + .margin({ right: $r('app.float.default_5') }) + .layoutWeight(1) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + top: $r('app.float.default_5') + }) + .alignItems(HorizontalAlign.Start) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), + color: $r('app.color.main_tj_a'), + offsetX: $r('app.float.default_3'), + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .height(AppConstants.PERCENTAGE_MAX); + + Column() { + Text('核验车辆次数') + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.colorGreen6')); + Text(this.carCount) + .width(AppConstants.PERCENTAGE_MAX) + .textAlign(TextAlign.End) + .fontSize($r('app.float.text_size_18')) + .fontColor($r('app.color.read')); + + } + .alignItems(HorizontalAlign.Start) + .margin({ left: $r('app.float.default_5') }) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + top: $r('app.float.default_5') + }) + .layoutWeight(1) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), + color: $r('app.color.main_tj_b'), + offsetX: $r('app.float.default_3'), + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + .height(AppConstants.PERCENTAGE_MAX); + + } + .margin({ top: $r('app.float.default_12'), bottom: $r('app.float.default_10') }) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_52')) + + Row() { + + Column() { + + Text('异常人员次数') + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.colorYellow8')); + + Text(this.unusualPeopleCount) + .width(AppConstants.PERCENTAGE_MAX) + .textAlign(TextAlign.End) + .fontSize($r('app.float.text_size_18')) + .fontColor($r('app.color.read')); + + } + .margin({ right: $r('app.float.default_5') }) + .layoutWeight(1) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + top: $r('app.float.default_5') + }) + .alignItems(HorizontalAlign.Start) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), + color: $r('app.color.main_tj_c'), + offsetX: $r('app.float.default_3'), + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .height(AppConstants.PERCENTAGE_MAX); + + Column() { + Text('盘查提交数') + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.bull')); + Text(this.allCount) + .width(AppConstants.PERCENTAGE_MAX) + .textAlign(TextAlign.End) + .fontSize($r('app.float.text_size_18')) + .fontColor($r('app.color.read')); + } + .alignItems(HorizontalAlign.Start) + .margin({ left: $r('app.float.default_5') }) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + top: $r('app.float.default_5') + }) + .layoutWeight(1) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), + color: $r('app.color.main_tj_d'), + offsetX: $r('app.float.default_3'), + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + .height(AppConstants.PERCENTAGE_MAX); + } + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_52')) + } + + @Builder + gridView() { + Grid() { + ForEach(this.mainButtonArray, (item: MainButtonBean) => { + GridItem() { + this.gridItemUI(item) + } + }) + } + .padding({ left: $r('app.float.default_15'), right: $r('app.float.default_15') }) + .columnsTemplate('1fr 1fr') // 定义两列 + .rowsGap($r('app.float.default_18')) // 行间距 + .columnsGap($r('app.float.default_10')) // 列间距 + } + + @Builder + gridItemUI(item: MainButtonBean) { + Row() { + Image(item.icon) + .width($r('app.float.default_38')) + .height($r('app.float.default_38')) + .margin({ left: $r('app.float.default_26') }) + + Text(item.name) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + + } + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), // 阴影模糊半径 + color: $r('app.color.main_tj_c'), // 阴影颜色 + offsetX: $r('app.float.default_3'), // X轴偏移 + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_72')) + .onClick(() => { + //判断下有没有选择任务 + if (item.tag === 1) { //卡点核录 + if (StringUtils.isNullOrEmpty(AppCache.getAppCache().getTaskId)) { + router.pushUrl({ url: item.routerPage }) + return + } + + let skipModel: SkipCheckPageModel = new SkipCheckPageModel(); + skipModel.titleType = 2 + skipModel.taskId = RuanseeAbitityStag.appCache.getTaskId + skipModel.taskName = RuanseeAbitityStag.appCache.getTaskName + skipModel.cardPointName = RuanseeAbitityStag.appCache.getCardPointName + + let param: BasePageResult = { + type: 1, + what: 1, + data: skipModel + } + router.pushUrl({ url: "ui/pages/StreetInspectionPages", params: param }) + + return + } + + if (!item.routerPage) { + ToastUtils.toastBottom($r('app.string.under_urgent_development')) + return + } + router.pushUrl({ url: item.routerPage }) + }) + } + + /** + * 背景图片 + */ + @Builder + underlyingBackground() { + Column() { + Image($r('app.media.icon_home_bg')) + .width(AppConstants.PERCENTAGE_MAX) + .height('28%') + } + } + + private getDeptData() { + let zzjg = RuanseeAbitityStag.userCache.getDeptCode; + let deptID = `${zzjg.substring(0, 4)}00000000` + let tableDao :RdbDao|null = null + DBUtils.getInstance().getDeptDao() + .then((dao) => { + tableDao = dao; + dao.querySql("SELECT * FROM deptTable ORDER BY updateTime DESC LIMIT 1 ") + .then((bean)=>{ + if (bean) { + let b = bean[0]; + if (b) { + this.getDeptData2(deptID,StringUtils.get(b.updateTime,""),tableDao) + return + } + this.getDeptData2(deptID,"",tableDao) + }else { + this.getDeptData2(deptID,"",tableDao) + } + }) + }) + .catch((e:Error)=>{ + this.getDeptData2(deptID,"",tableDao) + }) + + } + + private getDeptData2(deptId:string,updateTime:string,tableDao :RdbDao|null) { + getDeptChile(deptId, updateTime) + .then((res)=>{ + if (res.code == 200) { + let data = res.data; + if (data && data.length > 0) { + data.forEach((item)=>{ + let updateTime = DateUtils.formatMdyHmA(item.updateTime) + item.updateTime = updateTime; + if (tableDao) { + const queryResult = tableDao.queryRawSqlSync(`delete from deptTable where deptId = ${item.deptId}'`) + tableDao.insert(item) + } + }) + } + } + }) + .catch((e:AxiosError)=>{ + console.error(e.message) + }) + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/MyAttentionActivity.ets b/entry/src/main/ets/ui/pages/MyAttentionActivity.ets new file mode 100644 index 0000000..beaa76b --- /dev/null +++ b/entry/src/main/ets/ui/pages/MyAttentionActivity.ets @@ -0,0 +1,92 @@ +import AppConstants from "../../app/AppConstant"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { MyAttentionCarFragment } from "../fragment/MyAttentionCarFragment"; +import { MyAttentionPersonFragment } from "../fragment/MyAttentionPersonFragment"; + + +/** + * 我的关注的页面 + */ +@Component +@Entry +@Preview +export struct MyAttentionActivity { + private tabsController: TabsController = new TabsController() + @State currentIndex: number = 0 + + build() { + Column() { + BaseTopBar({ + title: "我的关注" + }) + + Tabs({ barPosition: BarPosition.Start }) { + TabContent() { + + MyAttentionPersonFragment(); + + }.tabBar(new SubTabBarStyle('关注人员')) + .onWillShow(() => { + console.info("Pink will show") + }) + .onWillHide(() => { + console.info("Pink will hide") + }) + + TabContent() { + MyAttentionCarFragment(); + }.tabBar(new SubTabBarStyle('关注车辆')) + + .onWillShow(() => { + console.info("Yellow will show") + }) + .onWillHide(() => { + console.info("Yellow will hide") + }) + + } + .vertical(false) + .scrollable(true) + .barMode(BarMode.Fixed) + .onChange((index: number) => { + console.info(index.toString()) + }) + .width('100%') + .backgroundColor(0xF1F3F5) + } + .width(AppConstants.PERCENTAGE_MAX) + .width(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + @ + Builder + TabBuilder(title: + string, targetIndex: + number + ) { + Column() { + Text(title) + .fontColor(this.currentIndex === targetIndex ? $r('app.color.bull') : $r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + } + .width('100%') + .height('48vp') + .border({ + width: $r('app.float.default_1'), + color: this.currentIndex === targetIndex ? $r('app.color.bull') : $r('app.color.colorGrey4'), + radius: $r('app.float.default_2') + }) + .backgroundColor($r('app.color.white')) + .justifyContent(FlexAlign.Center) + .align(Alignment.Center) + .margin({ left: $r('app.float.default_5'), right: $r('app.float.default_5') }) + .alignItems(HorizontalAlign.Center) + .onClick(() => { + this.currentIndex = targetIndex + this.tabsController.changeIndex(this.currentIndex) + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/OCRCarNumPages.ets b/entry/src/main/ets/ui/pages/OCRCarNumPages.ets new file mode 100644 index 0000000..1fe2186 --- /dev/null +++ b/entry/src/main/ets/ui/pages/OCRCarNumPages.ets @@ -0,0 +1,50 @@ + +import { DecodeMode, PlateNumberComponent } from '@kit/tdos'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { JSON } from '@kit.ArkTS'; +import { router } from '@kit.ArkUI'; +import { BasePageResult } from '../../model/uiModel/PageResultModel'; + +/** + * 车牌识别 + */ +@Preview +@Component +@Entry + export struct OCRCarNumPages { + @State interrupt:boolean = false; + + build() { + Column(){ + PlateNumberComponent({ + decodeMode:DecodeMode.AUTO, + interrupt:this.interrupt, + onParseCallback:(plates)=>{ + console.debug("carNumOcr",`识别结果:${JSON.stringify(plates)}`) + if(plates&& plates.length>0){ + let p = plates[0] + if (p) { + this.interrupt = true + let param: BasePageResult = new BasePageResult(); + param.type=2 + param.data=String(p.text) + router.back({url:'ui/pages/CheckCarPage',params:param}); + } + } + }, + onParseError:(error:BusinessError)=>{ + console.error("carNumOcr",`识别结果:${JSON.stringify(error)}`) + + } + }) + .width('100%') + .height('100%') + + } + .width('100%') + .height('100%') + + + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/OCRTestPages.ets b/entry/src/main/ets/ui/pages/OCRTestPages.ets new file mode 100644 index 0000000..f751ce0 --- /dev/null +++ b/entry/src/main/ets/ui/pages/OCRTestPages.ets @@ -0,0 +1,47 @@ +//其中CardRecognitionConfig,CardContentConfig,BankCardConfig从API12开始支持 +import { + CardRecognition, + CallbackParam, + CardType, + CardSide, + ShootingMode, +} from "@kit.VisionKit"; +import { router } from "@kit.ArkUI"; +import { ToastUtils } from "../../util/ToasUtils"; +import { RouterResultModel } from "../../model/uiModel/PageParamModel"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; + +@Component +@Entry +export struct OCRTestPages { + build() { + Column() { + //身份证 + CardRecognition({ + supportType: CardType.CARD_ID, + // 身份证可双面识别 + cardSide: CardSide.FRONT, + cardRecognitionConfig: { + defaultShootingMode: ShootingMode.MANUAL, + isPhotoSelectionSupported: true + }, + callback: ((params: CallbackParam) => { + if (params.code != 200) { + ToastUtils.toastCenter('识别失败!') + router.back() + return + } + let param = new BasePageResult(); + param.type = 8; + let routerResult = new RouterResultModel(); + routerResult.pageTag = "OCR" + routerResult.data = JSON.stringify(params.cardInfo?.front) + param.data = routerResult + router.back({ url: 'ui/pages/StreetInspectionPages', params: param }); + }) + }) + } + .height('100%') + .width('100%') + } +} diff --git a/entry/src/main/ets/ui/pages/PassPage.ets b/entry/src/main/ets/ui/pages/PassPage.ets new file mode 100644 index 0000000..e750e3f --- /dev/null +++ b/entry/src/main/ets/ui/pages/PassPage.ets @@ -0,0 +1,354 @@ +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil"; +import AppConstants from "../../app/AppConstant"; +import { PCCacheData } from "../../app/PCCacheData"; +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { CheckSubmitEntity, CheckSubmitModel } from "../../model/requestModel/CheckRequestModel"; +import { CheckReasonModel } from "../../model/uiModel/GoodsModel"; +import { cardRoundBorderGreyStyle } from "../../style/BorderStyle"; +import { bufferToString } from "../../util/BufferUtil"; +import { DateFormat, DateUtils } from "../../util/DateUtils"; +import { StringUtils } from "../../util/StringUtils"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { SelectCheckReasonDialog } from "../../view/dialog/SelectCheckReasonDialog"; +import router from "@ohos.router"; +import { SkipPassPageParam } from "../../model/uiModel/PageParamModel"; +import { getCoordinateDescription, saveMainHistoryAndChangeStatus } from "../../request/api/Api"; +import { AxiosError } from "@ohos/axios"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { ToastUtil } from "@pura/harmony-utils/src/main/ets/action/ToastUtil"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { geoLocationManager } from "@kit.LocationKit"; +import { AppCache } from "../../app/AppCache"; + +/** + * 通过 + */ +@Preview +@Component +@Entry +export struct PassPage { + @State checkReasonData: CheckReasonModel[] = [] + @State checkReason: string = "请选择盘查原因" + @State selectCheckReasonValue: string = "1"; + @State inputAddress: string = ""; + @State inputRemark: string = ""; + pageParam: SkipPassPageParam | undefined = undefined; + + //定位状态 + locationStatus:boolean = false; + + aboutToAppear(): void { + this.pageParam = router.getParams() as SkipPassPageParam; + this.getUIContext().getHostContext()?.resourceManager.getRawFileContent('checkData/CheckReason.json') + .then(value => { + this.checkReasonData = JSON.parse(bufferToString(value.buffer)) as CheckReasonModel[]; + if (this.checkReasonData && this.checkReasonData.length > 0) { + this.checkReason = StringUtils.get(this.checkReasonData[0].dictLabel, ""); + this.selectCheckReasonValue = StringUtils.get(this.checkReasonData[0].dictValue, "1"); + } + }) + if(StringUtils.isNullOrEmpty(RuanseeAbitityStag.appCache.getLocationAddress)){ + this.getCurrentLocation() + }else { + this.inputAddress = RuanseeAbitityStag.appCache.getLocationAddress + } + + } + + + /** + * 读取缓存的位置 + * @returns + */ + getLastLocation(): geoLocationManager.Location | undefined { + try { + let location = geoLocationManager.getLastLocation(); + return location; + } catch (err) { + console.info("passPage", "errCode:" + err.code + ", message:" + err.message); + return undefined; + } + } + + private locationCallback = (data: geoLocationManager.Location) => { + console.info("passPage", 'current location: ' + JSON.stringify(data)); + AppCache.getAppCache().setLocation(data); + this.getAddressByLongitudeLatitude(data) + } + + onPageHide(): void { + if (this.locationStatus) { + geoLocationManager.off('locationChange', this.locationCallback); + this.locationStatus = false; + } + // 在页面销毁时解除监听 + } + + /** + * 持续定位 获取位置 + */ + getCurrentLocation() { + + let request2: geoLocationManager.ContinuousLocationRequest = { + "interval": 60, + "locationScenario": geoLocationManager.UserActivityScenario.SPORT + } + try { + geoLocationManager.on('locationChange', request2,this.locationCallback ) + this.locationStatus = true; + // let request: geoLocationManager.SingleLocationRequest = { + // 'locatingPriority': geoLocationManager.LocatingPriority.PRIORITY_LOCATING_SPEED, + // 'locatingTimeoutMs': 10000 + // } + // geoLocationManager.getCurrentLocation(request) 街面盘查 StreetFront Street level search + // .then((result) => { // 调用getCurrentLocation获取当前设备位置,通过promise接收上报的位置 + // console.info(TAG, 'current location: ' + JSON.stringify(result)); + // }) + // .catch((error: BusinessError) => { // 接收上报的错误码 + // console.info(TAG, 'promise, getCurrentLocation: error=' + JSON.stringify(error)); + // }); + } catch (err) { + console.info("passPage", "errCode:" + JSON.stringify(err)); + } + } + + getAddressByLongitudeLatitude(location :geoLocationManager.Location){ + getCoordinateDescription() + .then((res)=>{ + console.debug(JSONUtil.beanToJsonStr(res)) + if (res&&res.length>0) { + let address = res[0]; + if (address) { + this.inputAddress = StringUtils.get(address.address,""); + if (this.locationStatus) { + geoLocationManager.off('locationChange', this.locationCallback); + this.locationStatus = false; + } + } + } + }) + .catch((error:AxiosError)=>{ + console.error(error.message) + }) + } + + selectCheckReasonController: CustomDialogController = new CustomDialogController({ + builder: SelectCheckReasonDialog({ + checkReasonData: this.checkReasonData, + clickItem: (item, selectIndex) => { + this.checkReason = StringUtils.get(item.dictLabel, ""); + this.selectCheckReasonValue = StringUtils.get(item.dictValue, "1"); + this.selectCheckReasonController.close() + } + }), + cornerRadius: 3, + autoCancel: false, + backgroundColor: Color.Transparent, // 背景透明 + backgroundBlurStyle: BlurStyle.NONE // 必须关闭模糊材质 + }); + + build() { + Column() { + BaseTopBar({ + title: "完善盘查信息" + }) + + Text("盘查原因:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + top: $r('app.float.default_20') + }) + + Row() { + Text(this.checkReason) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .fontWeight(FontWeight.Medium) + .layoutWeight(1) + .textAlign(TextAlign.Start) + .margin({ left: $r("app.float.default_10") }) + .align(Alignment.Start) + + Text("点击选择") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + } + .width(`calc(100% - 20vp)`) + .height($r('app.float.default_43')) + .alignItems(VerticalAlign.Center) + .margin({ + top: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderGreyStyle) + .padding({left:$r('app.float.default_8'),right:$r('app.float.default_8')}) + .onClick(() => { + this.selectCheckReasonController.open() + }) + + + Text("盘查地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + top: $r('app.float.default_10') + }) + + TextInput({ text: this.inputAddress, placeholder: "请输入地址" }) + .width(`calc(100% - 20vp)`) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .textAlign(TextAlign.Start) + .align(Alignment.Center) + .height($r('app.float.default_40')) + .backgroundColor($r('app.color.white')) + .textAlign(TextAlign.Start) + .margin({ + top: $r('app.float.default_5'), + bottom: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .onChange((res) => { + this.inputAddress = res; + }) + .border(cardRoundBorderGreyStyle) + + Text("备注信息:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('90%') + .textAlign(TextAlign.Start) + .margin({ + left: $r('app.float.default_10'), + bottom: $r('app.float.default_5'), + top: $r('app.float.default_10') + }) + + TextArea({ text: this.inputRemark, placeholder: "请输入备注信息" }) + .width(`calc(100% - 20vp)`) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .textAlign(TextAlign.Start) + .align(Alignment.TopStart) + .height($r('app.float.default_88')) + .backgroundColor($r('app.color.white')) + .margin({ + top: $r('app.float.default_5'), + bottom: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + .onChange((res) => { + this.inputRemark = res; + }) + .border(cardRoundBorderGreyStyle) + + Column() + .layoutWeight(1) + + Button('完成', { type: ButtonType.Normal, stateEffect: true }) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_48')) + .margin({ bottom: $r('app.float.default_22') }) + .backgroundColor($r('app.color.colorGreen7')) + .onClick(() => { + this.submit() + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + + } + + /** + * 街面/卡点 + * 车辆类型(重点,正常) + */ + submit() { + let pc = PCCacheData.pcCacheData; + let entity: CheckSubmitEntity = new CheckSubmitEntity(); + entity.peopleCount = pc.zcCount + "" + entity.unusualPeopleCount = pc.yiCount + "" + + entity.unusualCarCount = '' + + if (this.pageParam) { + if (this.pageParam.carNumStatus == 0) { + entity.carCount = "0"; + entity.unusualCarCount = "0"; + } else { + entity.carCount = "1"; + if (this.pageParam.carNumStatus == 1) { + entity.unusualCarCount = "1"; + } else { + entity.unusualCarCount = "0"; + } + } + } + entity.goodsCount = `${pc.wpCount}` + + //type 0 = 街面盘查 1 = 卡点盘查 + entity.type = "0" + entity.checkReason = this.selectCheckReasonValue + entity.checkAddress = this.inputAddress + entity.remark = this.inputRemark + entity.pointX = RuanseeAbitityStag.appCache.getLocationX() + "" + entity.pointY = RuanseeAbitityStag.appCache.getLocationY() + "" + entity.taskId = "" + entity.kkid = "" + entity.mainId = RuanseeAbitityStag.appCache.getHistoryId() + entity.checkTime = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSS) + entity.status = "0" + entity.groupId = "" + entity.yjdw = "" + entity.userName = RuanseeAbitityStag.userCache.getUserCode + entity.idCard = RuanseeAbitityStag.userCache.getIdCardNum + entity.deptId = RuanseeAbitityStag.userCache.getDeptCode + entity.deptName = RuanseeAbitityStag.userCache.getDeptName + entity.orgCode = RuanseeAbitityStag.userCache.getDeptCode + entity.orgName = RuanseeAbitityStag.userCache.getDeptName + entity.policeNum = RuanseeAbitityStag.userCache.getUserCode + entity.policeName = RuanseeAbitityStag.userCache.getUserName + entity.policeIdCard = RuanseeAbitityStag.userCache.getIdCardNum + + let model: CheckSubmitModel = new CheckSubmitModel(); + model.checkHistoryEntity = entity; + model.personIds = [] + model.carIds = [] + + saveMainHistoryAndChangeStatus(model) + .then((res)=>{ + console.debug(JSON.stringify(res)); + if (res.code == 200) { + let param: BasePageResult = { + type: 5, + what: 1, + data: "提交成功!" + } + router.back({ url: "ui/pages/StreetInspectionPages", params: param }) + }else { + ToastUtil.showToast(res.msg) + } + }) + .catch((error:AxiosError)=>{ + console.error(error.message) + ToastUtil.showToast(error.message) + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/PeopleCheckDetailsPages.ets b/entry/src/main/ets/ui/pages/PeopleCheckDetailsPages.ets new file mode 100644 index 0000000..48b97dd --- /dev/null +++ b/entry/src/main/ets/ui/pages/PeopleCheckDetailsPages.ets @@ -0,0 +1,511 @@ +import router from '@ohos.router'; + +import { AxiosError } from '@ohos/axios'; +import { fileUri } from '@kit.CoreFileKit'; +import { ToastUtils } from '../../util/ToasUtils'; +import { createWaterMark } from '../../view/custom/Watermark'; +import { SkipCheckCountParam } from '../../model/uiModel/PageParamModel'; +import { RequestCheckPeopleRecordModel } from '../../model/requestModel/CheckRequestModel'; +import { CheckPeopleRecordItem, ZdlxItem } from '../../model/resultModel/CheckPeopleResultModel'; +import { ErrorOfEmptyModel } from '../../model/uiModel/BeanModel'; +import { LitheRefresh, RefreshController } from '@abner/lithe_refresh'; +import { JSONUtil, StrUtil, ToastUtil } from '@pura/harmony-utils'; +import AppConstants from '../../app/AppConstant'; +import { StringUtils } from '../../util/StringUtils'; +import { BaseTopBar } from '../../view/custom/BaseTopTar'; +import { getCheckPeopleRecord } from '../../request/api/Api'; +import { cardRoundBorderStyle } from '../../style/BorderStyle'; +import { FileUtils } from '../../util/FileUtils'; +import { getCheckTypeIcon } from '../../util/StatusIconUtils'; + +@Preview +@Entry +@Component +struct PeopleCheckDetailsPages { + // =============== 人员属性 =============== + @State name: string = ""; + @State sex: string = ""; + @State idCardNum: string = ""; + @State birthDate: string = ""; + @State nation: string = ""; + @State address: string = ""; + @State peopleOPhone: string = "" + @State photoData: string | Resource = $r('app.media.photo'); + @State photoStatus: boolean = false + idCardPhtot: string = ""; + xcZpPhtot: string = ""; + //人员重点信息 + @State zdlxImg: Array | undefined = undefined; + //=================== 列表属性 ================== + @State dataSet: Array | null = null; + controller: RefreshController = new RefreshController() + scroller: Scroller = new Scroller() + total: number = 0; + pageNum: number = 1; + isRefreshStatus: number = 0; + + aboutToAppear(): void { + getContext(this).filesDir; + this.analyzePeople(); + setTimeout(() => { + this.controller.isAutoRefresh = true; + }, 800) + } + + /** + * 解析人员数据 + */ + analyzePeople() { + let pageParam = router.getParams() as SkipCheckCountParam; + this.name = pageParam.name; + this.sex = pageParam.sex; + this.idCardNum = pageParam.idCardNum; + this.birthDate = pageParam.birthDate; + this.nation = pageParam.nation; + this.address = pageParam.address; + if (!pageParam.photoData) { + let filePath = FileUtils.ID_CARD_DIR + "/" + this.idCardNum + '.png'; + this.photoData = fileUri.getUriFromPath(filePath) + } else { + this.photoData = pageParam.photoData; + } + + this.zdlxImg = new Array; + if (StrUtil.isNotEmpty(pageParam.zdlx)) { + if (pageParam.zdlx.startsWith("[") && pageParam.zdlx.endsWith("]")) { + let array = JSONUtil.jsonToArray(pageParam.zdlx) + if (array && array.length > 0) { + this.zdlxImg = array; + } + return + } + let strings = pageParam.zdlx.split("、"); + if (strings.length == 0) { + this.zdlxImg.push(new ZdlxItem("正常人员", 1)); + } else { + for (let i = 0; i < strings.length; i++) { + this.zdlxImg.push(new ZdlxItem(strings[i], 1)); + } + } + } + } + + getRecordListData() { + let requestMode: RequestCheckPeopleRecordModel = { + idCardNum: this.idCardNum, + pageNum: this.pageNum, + pageSize: 30 + "" + } + getCheckPeopleRecord(requestMode) + .then((res) => { + if (this.controller.isAutoRefresh) { + this.controller.isAutoRefresh = false; + } + if (res.code == 200) { + let data = res.data; + if (data) { + this.total = data.total; + let list = data.rows; + if (list) { + if (this.isRefreshStatus == 1) { + //刷新 + this.controller.finishRefresh() + this.dataSet = new Array + list.forEach((item) => { + this.dataSet?.push(item) + }) + } + if (this.isRefreshStatus == 2) { + //加载 + this.controller.finishLoadMore() + list.forEach((item) => { + this.dataSet?.push(item) + }) + } + if (this.pageNum * 30 >= this.total) { + this.controller.closeLoadMore = true; + } + this.isRefreshStatus = 0 + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(0, "没有数据!")) + } + } else { + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, StringUtils.get(res.msg, ""))) + } + }) + .catch((error: AxiosError) => { + console.error("请求失败:", JSON.stringify(error)) + this.handlerErrorOrEmpty(new ErrorOfEmptyModel(-1, error.message)) + }) + } + + handlerErrorOrEmpty(model: ErrorOfEmptyModel) { + ToastUtils.toastBottom(model.msg) + if (this.isRefreshStatus == 1) { + //刷新 + this.controller.finishRefresh() + this.dataSet = new Array + } + if (this.isRefreshStatus == 2) { + //加载 + this.controller.finishLoadMore() + } + this.isRefreshStatus = 0 + } + + //066929 + build() { + Column() { + BaseTopBar({ + title: "盘查记录" + }) + this.peopleInfo(); + + Row() { + Image($r('app.media.icon_history_list')) + .height($r('app.float.default_16')) + .width($r('app.float.default_16')) + Text('核查记录') + .fontColor($r('app.float.default_14')) + .fontColor($r('app.color.black')) + .margin({ left: $r('app.float.default_8') }) + } + .width('100%') + .height($r('app.float.default_36')) + .margin({ top: $r('app.float.default_10') }) + .alignItems(VerticalAlign.Center) + .padding({ left: $r('app.float.default_10') }) + + Divider() + .width('100%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.page_background')) + + LitheRefresh({ + scroller: this.scroller, + controller: this.controller, + itemLayout: () => { + this.listView() + }, + onRefresh: () => { + this.controller.closeLoadMore = false; + this.pageNum = 1; + this.isRefreshStatus = 1; + this.getRecordListData() + }, + onLoadMore: () => { + if (this.pageNum * 30 >= this.total) { + this.controller.finishLoadMore() + this.controller.closeLoadMore = true; + ToastUtil.showToast("没有更多数据!") + return + } + this.pageNum++; + this.isRefreshStatus = 2; + this.getRecordListData() + } + }) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + + } + .width('100%') + .height('100%') + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + @Builder + recordListItem(dataItem: CheckPeopleRecordItem) { + Row() { + Image(getCheckTypeIcon(dataItem.checkTypeStr)) + .width($r('app.float.default_38')) + .height($r('app.float.default_38')) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + + Column() { + Row() { + Text("警员:") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + Text(dataItem.policeName) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + Text(dataItem.checkTime) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + .padding({ right: $r('app.float.default_8') }) + + Row() { + Text("单位:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + Text(dataItem.deptName) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text("地址:") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + Text(dataItem.checkAddress) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + } + .margin({ top: $r('app.float.default_5') }) + .width(AppConstants.PERCENTAGE_MAX) + } + .layoutWeight(1) + } + .width('95%') + .margin({ top: $r('app.float.default_10'), right: $r('app.float.default_10'), left: $r('app.float.default_10') }) + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + .padding({ top: $r('app.float.default_8'), bottom: $r('app.float.default_8') }) + + } + + /** + * 刷新列表 + */ + @Builder + listView() { + List({ scroller: this.scroller }) { + ForEach(this.dataSet, (item: CheckPeopleRecordItem) => { + ListItem() { + this.recordListItem(item) + } + }) + } + .listDirection(Axis.Vertical) + .scrollBar(BarState.Off) + .edgeEffect(EdgeEffect.None) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .nestedScroll({ + scrollForward: NestedScrollMode.PARENT_FIRST, + scrollBackward: NestedScrollMode.PARENT_FIRST + }) + } + + /** + * 人员信息 + */ + @Builder + peopleInfo() { + Column() { + Row() { + //信息区域 + Column() { + Row() { + Text('姓名:') + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + Text(this.name) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .width(AppConstants.PERCENTAGE_MAX) + + Row() { + Row() { + Text('民族:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.nation) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .layoutWeight(1.8) + + Row() { + Text('性别:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.sex) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .layoutWeight(1) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('出生日期:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.birthDate) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('手机号码:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(StringUtils.get(this.peopleOPhone,"暂无")) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('身份证号:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.idCardNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('户籍地址:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + + Text(this.address) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .layoutWeight(1) + .margin({ left: $r('app.float.default_2') }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + } + .layoutWeight(1) + .justifyContent(FlexAlign.Start) + .alignItems(HorizontalAlign.Start) + .padding({ + top: $r('app.float.default_10'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + + //照片区域 + Column() { + Image(this.photoData) + .width($r('app.float.default_84')) + .height($r('app.float.default_110')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey4') + }) + .objectFit(ImageFit.Fill) + + Row() { + Text('证件') + .fontColor(this.photoStatus ? $r('app.color.colorBluen7') : $r('app.color.colorGrey3')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .onClick(() => { + this.photoData = this.idCardPhtot + this.photoStatus = true; + }) + + Divider() + .width($r('app.float.default_1')) + .height('96%') + .color($r('app.color.colorGrey3')) + .backgroundColor($r('app.color.colorGrey4')) + + Text('现场') + .fontColor(this.photoStatus ? $r('app.color.colorGrey3') : $r('app.color.colorBluen7')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .onClick(() => { + if (this.xcZpPhtot) { + this.photoData = this.xcZpPhtot + this.photoStatus = false; + } + }) + .textAlign(TextAlign.Center) + } + .width('90%') + .height($r('app.float.default_26')) + .borderRadius(50) + .visibility(StringUtils.isNullOrEmpty(this.xcZpPhtot) ? Visibility.Hidden : Visibility.Visible) + .backgroundColor('rgba(1, 1, 1, 0.4)') + .margin({ top: $r('app.float.default_5') }) + + } + .width($r('app.float.default_120')) + .padding({ top: $r('app.float.default_15'), bottom: $r('app.float.default_10') }) + + } + .alignItems(VerticalAlign.Top) + + Divider() + .width('98%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey1')) + .margin({ left: $r('app.float.default_10'), top: $r('app.float.default_10') }) + + Row() { + Text('人员属性:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_15') }) + + List() { + ForEach(this.zdlxImg, (item: ZdlxItem) => { + ListItem() { + Image(item.getIcon()) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .onClick(() => { + ToastUtils.toastBottom(item.zdlx) + }) + }) + } + .alignListItem(ListItemAlign.Center) + .listDirection(Axis.Horizontal) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_38')) + .width(AppConstants.PERCENTAGE_MAX) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .justifyContent(FlexAlign.Start) + .width('95%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_15'), + right: $r('app.float.default_15') + }) + .padding({ bottom: $r('app.float.default_2') }) + + } +} + diff --git a/entry/src/main/ets/ui/pages/SelectDeptPages.ets b/entry/src/main/ets/ui/pages/SelectDeptPages.ets new file mode 100644 index 0000000..1679c4a --- /dev/null +++ b/entry/src/main/ets/ui/pages/SelectDeptPages.ets @@ -0,0 +1,242 @@ +import { StrUtil, ToastUtil } from "@pura/harmony-utils"; +import { RdbDao } from "rdbstore"; +import AppConstants from "../../app/AppConstant"; +import { DBUtils } from "../../model/db/DBUtils"; +import { DeptTableEntity } from "../../model/db/TableEntity"; +import { cardRoundBorderStyle } from "../../style/BorderStyle"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { KeyCode } from "@kit.InputKit"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { SelectDept } from "../../model/uiModel/HandOverModel"; +import { SelectDeptItem } from "../../view/custom/SelectDeptItem"; +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { StringUtils } from "../../util/StringUtils"; +import { SkipHandOverParam, SkipHandOverSelectDeptParam, SkipPassPageParam } from "../../model/uiModel/PageParamModel"; +import { router } from "@kit.ArkUI"; +import { PCCacheData } from "../../app/PCCacheData"; +import { CheckSubmitEntity, CheckSubmitModel } from "../../model/requestModel/CheckRequestModel"; +import { DateFormat, DateUtils } from "../../util/DateUtils"; +import { saveMainHistoryAndChangeStatus } from "../../request/api/Api"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { AxiosError } from "@ohos/axios"; + +@Component +@Entry +export struct SelectDeptPages{ + @State searchWord:string = "" + @State deptData:Array =[] + dao:RdbDao|undefined + pageParam: SkipHandOverSelectDeptParam | undefined = undefined; + + lastIndex:number = -1; + selectDeptId:string="" + selectDeptName:string="" + + aboutToAppear(): void { + this.pageParam = router.getParams() as SkipHandOverSelectDeptParam; + DBUtils.getInstance().getDeptDao() + .then((dao) => { + this.dao = dao + this.getDeptData(); + }); + } + + getDeptData() { + if (StrUtil.isNotEmpty(this.searchWord)){ + this.dao?.querySql(`SELECT * FROM deptTable WHERE deptName like '%${this.searchWord}%'`) + .then((res)=>{ + if (res) { + this.selectDeptId = "" + this.selectDeptName = "" + this.lastIndex = -1 + this.deptData = new Array + res.forEach(element => { + let bean = new SelectDept(); + bean.randomId = RuanseeAbitityStag.appCache.getRandomId() + bean.deptId = element.deptId + bean.deptName = element.deptName + bean.parentId = element.parentId + bean.updateTime = element.updateTime + this.deptData.push(bean) + }); + }else { + ToastUtil.showToast(`没有数据`) + } + }) + .catch((e:Error)=>{ + ToastUtil.showToast(`查询失败${e.message}`) + }) + }else { + this.dao?.queryAll() + .then((data)=>{ + if (data) { + this.lastIndex = -1 + this.selectDeptId = "" + this.selectDeptName = "" + this.deptData = new Array + data.forEach(element => { + let bean = new SelectDept(); + bean.randomId = RuanseeAbitityStag.appCache.getRandomId() + bean.deptId = element.deptId + bean.deptName = element.deptName + bean.parentId = element.parentId + bean.updateTime = element.updateTime + this.deptData.push(bean) + }); + }else { + ToastUtil.showToast(`没有数据`) + } + }) + .catch((e:Error)=>{ + ToastUtil.showToast(`查询失败${e.message}`) + }) + } + } + + //提交如果是卡点盘查直接提交 + private submit(){ + let pc = PCCacheData.pcCacheData; + let entity: CheckSubmitEntity = new CheckSubmitEntity(); + entity.peopleCount = pc.zcCount + "" + entity.unusualPeopleCount = pc.yiCount + "" + + entity.unusualCarCount = '' + + if (this.pageParam) { + if (this.pageParam.carNumStatus == 0) { + entity.carCount = "0"; + entity.unusualCarCount = "0"; + } else { + entity.carCount = "1"; + if (this.pageParam.carNumStatus == 1) { + entity.unusualCarCount = "1"; + } else { + entity.unusualCarCount = "0"; + } + } + } + + entity.goodsCount = `${pc.wpCount}` + //type 0 = 街面盘查 1 = 卡点盘查 + entity.type = "1" + entity.checkReason = "13" + entity.checkAddress = RuanseeAbitityStag.appCache.getCardPointAddress + entity.remark = "" + entity.pointX = RuanseeAbitityStag.appCache.getCardPointLocationX() + entity.pointY = RuanseeAbitityStag.appCache.getCardPointLocationY() + entity.taskId = RuanseeAbitityStag.appCache.getTaskId + entity.kkid = RuanseeAbitityStag.appCache.getCardPointIdId + entity.mainId = RuanseeAbitityStag.appCache.getHistoryId() + entity.checkTime = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSS) + entity.status = "1" + entity.groupId = "" + entity.yjdw = this.selectDeptId; + entity.yjdwmc = this.selectDeptName; + entity.userName = RuanseeAbitityStag.userCache.getUserCode + entity.idCard = RuanseeAbitityStag.userCache.getIdCardNum + entity.deptId = RuanseeAbitityStag.userCache.getDeptCode + entity.deptName = RuanseeAbitityStag.userCache.getDeptName + entity.orgCode = RuanseeAbitityStag.userCache.getDeptCode + entity.orgName = RuanseeAbitityStag.userCache.getDeptName + entity.policeNum = RuanseeAbitityStag.userCache.getUserCode + entity.policeName = RuanseeAbitityStag.userCache.getUserName + entity.policeIdCard = RuanseeAbitityStag.userCache.getIdCardNum + + let model: CheckSubmitModel = new CheckSubmitModel(); + model.checkHistoryEntity = entity; + model.personIds = this.pageParam?.personIds + model.carIds = new Array + if (this.pageParam?.carId){ + model.carIds.push(this.pageParam.carId) + } + + saveMainHistoryAndChangeStatus(model) + .then((res)=>{ + console.debug(JSON.stringify(res)); + if (res.code == 200) { + let param: BasePageResult = { + type: 5, + what: 1, + data: "提交成功!" + } + router.back({ url: "ui/pages/StreetInspectionPages", params: param }) + }else { + ToastUtil.showToast(res.msg) + } + }) + .catch((error:AxiosError)=>{ + console.error(error.message) + ToastUtil.showToast(error.message) + }) + } + + build() { + Column(){ + BaseTopBar({ + title:"选择单位", + rightText:this.pageParam?.isCardPoint?"提交":"下一步", + rightClickEvent:()=>{ + if(this.pageParam?.isCardPoint){ + this.submit() + }else { + //是街面盘查的跳转完善信息页面 + let param: SkipHandOverParam = new SkipHandOverParam(); + param.isCardPoint = false; + param.carNumStatus = this.pageParam == undefined ?0:this.pageParam.carNumStatus + // param. isCardPoint = this.pageParam == undefined?true:this.pageParam.isCardPoint + param.personIds = this.pageParam == undefined?[]:this.pageParam.personIds; + param.carId = this.pageParam == undefined?"":this.pageParam.carId; + param.selectDeptId = this.selectDeptId; + param.selectDeptName = this.selectDeptName; + router.pushUrl({ url: "ui/pages/HandOverPage", params: param }) + } + } + }) + Search({value:this.searchWord,placeholder: '输入卡点名称进行搜索' }) + .width('95%') + .height($r('app.float.default_43')) + .border(cardRoundBorderStyle) + .margin({ top: $r('app.float.default_10') }) + .onChange((ver) => { + this.searchWord = ver + }) + .onKeyEvent((event:KeyEvent)=>{ + if (event.keyCode === KeyCode.KEYCODE_ENTER) { + // 处理回车键触发的搜索逻辑 + console.log('回车键触发搜索'); + } + }) + .enterKeyType(EnterKeyType.Search) + .onSubmit(()=>{ + this.getDeptData(); + }) + + List(){ + ForEach(this.deptData,(item:SelectDept,index:number)=>{ + ListItem(){ + SelectDeptItem({ item:item }) + } + .onClick(()=>{ + if (this.lastIndex >= 0&&this.deptData.length>=this.lastIndex) { + //上一个已经选择 + this.deptData[this.lastIndex].isSelect = false; + } + this.lastIndex = index; + item.isSelect = true; + this.selectDeptId = StringUtils.get(item.deptId,""); + this.selectDeptName = StringUtils.get(item.deptName,""); + }) + .backgroundColor($r('app.color.white')) + },(item:SelectDept)=>item.randomId) + } + .layoutWeight(1) + .width(AppConstants.PERCENTAGE_MAX) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/SelectHandOverObject.ets b/entry/src/main/ets/ui/pages/SelectHandOverObject.ets new file mode 100644 index 0000000..bab31ec --- /dev/null +++ b/entry/src/main/ets/ui/pages/SelectHandOverObject.ets @@ -0,0 +1,294 @@ +import { AxiosError } from "@ohos/axios"; +import { JSONUtil } from "@pura/harmony-utils/src/main/ets/utils/JSONUtil" +import { ToastUtil } from "@pura/harmony-utils"; +import { StrUtil } from "@pura/harmony-utils/src/main/ets/utils/StrUtil"; +import AppConstants from "../../app/AppConstant"; +import { PCCacheData } from "../../app/PCCacheData"; +import { CarData } from "../../model/resultModel/CheckCarResultModel"; +import { CarItemBean, GoodsItemBean, HanoverItem, PersonItemBean } from "../../model/uiModel/HandOverModel"; +import { getPersonListByMainId } from "../../request/api/Api"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { HandOverSelectCarItem } from "../../view/custom/HandOverSelectCarItem"; +import { HandOverSelectGoodsItem } from "../../view/custom/HandOverSelectGoodsItem"; +import { HandOverSelectPersonItem } from "../../view/custom/HandOverSelectPersonItem"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { GoodsBean } from "../../model/uiModel/GoodsModel" +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { ArrayList } from "@kit.ArkTS"; +import { StringUtils } from "../../util/StringUtils"; +import { router } from "@kit.ArkUI"; +import { SkipHandOverSelectDeptParam, SkipPassPageParam } from "../../model/uiModel/PageParamModel"; + +/** + * 选择移交对象 + */ +@Preview +@Component +@Entry +export struct SelectHandOverObject { + @State pageData: Array = [] + carData: Array = []; + goodsData: Array = []; + personData: Array = []; + + selectPeronId: ArrayList = new ArrayList(); + selectCarId: string = ""; + pageParam: SkipPassPageParam | undefined = undefined; + + aboutToAppear(): void { + this.pageParam = router.getParams() as SkipPassPageParam; + this.hanCacheData() + this.getPersonList(); + } + + onPageShow(): void { + + } + + hanCacheData(): Promise { + return new Promise(resolve => { + let carJson = PCCacheData.pcCacheData.carJson; + if (StrUtil.isNotEmpty(carJson) && JSONUtil.isJSONStr(carJson)) { + let carData: CarData = JSONUtil.jsonToBean(carJson, CarData) as CarData; + if (carData) { + let item = new HanoverItem(); + item.baseType = 1 + item.baseMsg = "通行车辆" + item.id = RuanseeAbitityStag.appCache.getRandomId() + this.carData.push(item); + + let item2 = new HanoverItem(); + item2.baseType = 2 + let carItem = new CarItemBean() + carItem.hphm = carData.hphm + carItem.hpzl = carData.hpzl + carItem.sfzh = carData.sfzh + carItem.carZdlx = "正常车辆" + carItem.id = carData.id; + item2.id = carData.id; + carItem.isSelect = false; + let carZt = carData.zdlxBeanList; + if (carZt) { + for (let i = 0; i < carZt.length; i++) { + carItem.carZdlx = carZt[i].zdlx; + break + } + } + item2.carData = carItem; + this.carData.push(item2); + } + } + let goodsJson = PCCacheData.pcCacheData.goodsJson; + if (StrUtil.isNotEmpty(goodsJson) && JSONUtil.isJSONStr(goodsJson)) { + let goodsList: Array = JSONUtil.jsonToArray(goodsJson) + if (goodsList && goodsList.length > 0) { + let item = new HanoverItem(); + item.baseType = 1 + item.baseMsg = "随行物品" + item.id = RuanseeAbitityStag.appCache.getRandomId() + this.goodsData.push(item); + goodsList.forEach((goodsItem) => { + let item2 = new HanoverItem(); + item2.baseType = 4 + let good = new GoodsItemBean(); + good.name = goodsItem.name + good.count = goodsItem.count + good.id = goodsItem.uuid; + item2.goodsData = good + good.isSelect = true; + item2.id = goodsItem.uuid; + this.goodsData.push(item2); + }) + } + } + }) + } + + /** + * 合并数据 + */ + mergeData() { + if (this.carData && this.carData.length > 0) { + this.pageData = this.pageData.concat(this.carData) + } + if (this.personData && this.personData.length > 0) { + this.pageData = this.pageData.concat(this.personData) + } + if (this.goodsData && this.goodsData.length > 0) { + this.pageData = this.pageData.concat(this.goodsData) + } + } + + getPersonList() { + getPersonListByMainId(1, 80) + .then((res) => { + console.debug(JSONUtil.beanToJsonStr(res)) + if (res.code != 200) { + ToastUtil.showToast(res.msg) + this.mergeData() + return + } + if (res.data) { + // this.total = res.data.total; + let rows = res.data.rows; + if (rows && rows != undefined && rows.length > 0) { + let item = new HanoverItem(); + item.baseType = 1 + item.baseMsg = "随行人员" + item.id = RuanseeAbitityStag.appCache.getRandomId() + this.personData.push(item); + for (let i = 0; i < rows.length; i++) { + let item2 = new HanoverItem(); + item2.baseType = 3 + let personBean = new PersonItemBean() + let bean = rows[i]; + personBean.name = bean.name + personBean.id = bean.uuid + personBean.peopleStatusStr = bean.peopleStatusStr + personBean.sfz = bean.sfz + personBean.isSelect = false; + item2.personData = personBean + item2.id = bean.uuid + this.personData.push(item2); + } + this.mergeData() + } else { + ToastUtil.showToast("未查询到数据!") + this.mergeData() + return + } + } else { + ToastUtil.showToast("未查询到数据!") + this.mergeData() + return + } + }) + .catch((e: AxiosError) => { + console.error(e.message) + ToastUtil.showToast(e.message) + this.mergeData() + }) + } + + build() { + Column() { + BaseTopBar({ + title: '处置对象' + }) + + List() { + ForEach(this.pageData, (item: HanoverItem) => { + if (item.baseType == 1) { + ListItem() { + this.labelItem(item) + } + .width(AppConstants.PERCENTAGE_MAX) + } else if (item.baseType == 2) { + ListItem() { + HandOverSelectCarItem({ item: item.carData }) + } + .width(AppConstants.PERCENTAGE_MAX) + .onClick(() => { + if (item.carData) { + if (item.carData.isSelect) { + item.carData.isSelect = false; + this.selectCarId = "" + } else { + item.carData.isSelect = true; + this.selectCarId = StringUtils.get(item.id,"") + } + } + }) + } else if (item.baseType == 3) { + ListItem() { + HandOverSelectPersonItem({ item: item.personData }) + } + .width(AppConstants.PERCENTAGE_MAX) + .onClick(() => { + if (item.personData) { + if (item.personData.isSelect) { + item.personData.isSelect = false; + this.selectPeronId.remove(item.id) + } else { + item.personData.isSelect = true; + this.selectPeronId.add(item.id) + } + } + }) + } else if (item.baseType == 4) { + ListItem() { + HandOverSelectGoodsItem({ item: item.goodsData }) + } + .width(AppConstants.PERCENTAGE_MAX) + } + + }, (itme: HanoverItem) => itme.id) + + } + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + + Row() { + Image($r('app.media.ic_light')) + .width($r('app.float.default_18')) + .height($r('app.float.default_18')) + + Text("物品默认全部选中") + .fontColor($r('app.color.read')) + .fontSize($r('app.float.text_size_12')) + + } + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX) + .padding({ left: $r('app.float.default_15'), right: $r('app.float.default_15') }) + + Button("下一步") + .width('89%') + .margin({ top: $r('app.float.default_8'), bottom: $r('app.float.default_22') }) + .onClick(() => { + if((!this.selectPeronId||this.selectPeronId.length<1)&&StrUtil.isEmpty(this.selectCarId)){ + ToastUtil.showToast("请先选择移交对象!") + return + } + let param : SkipHandOverSelectDeptParam = { + carNumStatus: this.pageParam?.carNumStatus == undefined?0:this.pageParam?.carNumStatus, + isCardPoint: this.pageParam?.isCardPoint, + personIds:Array.from(this.selectPeronId), + carId:this.selectCarId + } + router.pushUrl({url:"ui/pages/SelectDeptPages",params:param}) + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + @Builder + labelItem(item: HanoverItem) { + Row() { + Blank() + .width($r('app.float.default_5')) + .height($r('app.float.default_16')) + .color($r('app.color.bull')) + .border({ radius: $r('app.float.default_2') }); + + Text(item.baseMsg) + .margin({ left: $r('app.float.default_8') }) + .fontColor($r('app.color.colorGrey7')) + .fontSize($r('app.float.text_size_16')); + + } + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_36')) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .margin({ top: $r('app.float.default_10') }) + .backgroundColor($r('app.color.white')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/SelectTaskAndCardPortPages.ets b/entry/src/main/ets/ui/pages/SelectTaskAndCardPortPages.ets new file mode 100644 index 0000000..9a12748 --- /dev/null +++ b/entry/src/main/ets/ui/pages/SelectTaskAndCardPortPages.ets @@ -0,0 +1,299 @@ +import AppConstants from "../../app/AppConstant"; +import { CardProtModel, SelectTaskModel } from "../../model/uiModel/SelectTask"; +import { cardRoundBorderStyle } from "../../style/BorderStyle"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { StringUtils } from "../../util/StringUtils"; +import { ToastUtils } from "../../util/ToasUtils"; +import { router } from "@kit.ArkUI"; +import { AppCache } from "../../app/AppCache"; +import { CardPortListItem } from "../../view/custom/CardPortListItem"; +import { SkipCheckPageModel } from "../../model/uiModel/PageParamModel"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { LoadingDialog } from "../../view/dialog/LoadingDialog"; +import { getCardPointList, getTaskList } from "../../request/api/Api"; +import { AxiosError } from "@ohos/axios"; +import { DateUtil } from "@pura/harmony-utils"; + +/** + * 选择任务和卡点的页面 + */ +@Component +@Entry +@Preview +export struct SelectTaskAndCardPortPages { + @State text: string = "请选择" + @State index: number = -1 + @State arrowPosition: ArrowPosition = ArrowPosition.END + @State selectValue: Array = new Array(); + @State taskDescription: string | undefined = undefined + @State cardPortArray: Array = new Array() + selectTaskName: string | undefined = ""; + selectTaskId: string | undefined = ""; + selectCardName: string | undefined = ""; + selectCardId: string | undefined = ""; + cardPointAddress?: string + cardPointPointX?: string + cardPointPointY?: string + @State loadDialogTips: string | Resource = $r('app.string.loading_hint') + //加载弹框 + dialogController: CustomDialogController = new CustomDialogController({ + builder: LoadingDialog({ + loadingTips: this.loadDialogTips, + }) + }); + + aboutToAppear(): void { + + } + + onPageShow(): void { + this.getTaskListData(); + } + + getTaskListData() { + this.loadDialogTips = $r('app.string.loading_hint') + this.dialogController.open() + getTaskList("",1,DateUtil.getFormatDateStr(new Date())) + .then((res) => { + this.dialogController.close() + console.debug(JSON.stringify(res)) + this.selectValue = new Array; + let mode = new SelectTaskModel(); + mode.value = "请选择" + mode.id = "-1" + mode.description = "请先选择任务" + this.selectValue.push(mode) + if (res.code != 200) { + ToastUtils.toastBottom(res.msg!) + return + } + let dataList = res.rows; + if (dataList == null || dataList.length < 1) { + ToastUtils.toastBottom("暂无任务请联系管理员添加任务") + return + } + dataList!.forEach(element => { + let mode = new SelectTaskModel(); + mode.value = StringUtils.get(element.name, ""); + mode.id = StringUtils.get(element.id, ""); + mode.description = StringUtils.get(element.description, ""); + this.selectValue.push(mode) + }); + ToastUtils.toastBottom("点击“请选择”选择任务") + }) + .catch((e: AxiosError) => { + this.dialogController.close() + this.selectValue = new Array; + let mode = new SelectTaskModel(); + mode.value = "请选择" + mode.id = "-1" + mode.description = "请先选择任务" + ToastUtils.toastBottom(`获取任务失败:${e.message}`) + }) + } + + createCard() { + this.loadDialogTips = $r('app.string.loading_hint') + this.dialogController.open() + getCardPointList(StringUtils.get(this.selectTaskId, "")) + .then((res) => { + this.dialogController.close() + console.debug(JSON.stringify(res)) + this.cardPortArray = new Array() + if (res.code != 200) { + ToastUtils.toastBottom(StringUtils.get(res.msg, "")) + return + } + let dateList = res.data; + if (dateList) { + dateList.forEach((item) => { + let model = new CardProtModel(); + model.orgName = item.name + model.id = item.id + model.address = item.address + model.pointX = item.pointX + model.pointY = item.pointY + this.cardPortArray.push(model) + }) + } else { + ToastUtils.toastBottom("未获取到卡点,请联系管理员添加卡点"); + } + }) + .catch((e: AxiosError) => { + this.dialogController.close() + ToastUtils.toastBottom(`获取卡点失败:${e.message}`) + }) + + } + + build() { + Column() { + BaseTopBar({ + title: "选择任务卡点", + leftClickEvent: () => { + } + }) + + Text('选择任务') + .fontSize($r('app.float.text_size_14')) + .width('95%') + .textAlign(TextAlign.Start) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_10'), left: $r('app.float.default_10') }) + + Select(this.selectValue) + .selected(this.index) + .width('95%') + .height($r('app.float.default_48')) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_10') + }) + .value(this.text) + .border(cardRoundBorderStyle) + .font({ size: 16, weight: 500 }) + .fontColor($r('app.color.colorGrey8')) + .selectedOptionFont({ size: 16, weight: 400 }) + .optionFont({ size: 16, weight: 400 }) + .arrowPosition(this.arrowPosition) + .menuAlign(MenuAlignType.CENTER, { dx: 0, dy: 0 }) + .optionWidth(OptionWidthMode.FIT_TRIGGER) + .optionHeight($r('app.float.default_400')) + .divider(null) + .onSelect((index: number, text?: string | undefined) => { + console.info('Select:' + index) + if (index == 0) { + return + } + this.taskDescription = this.selectValue[index].description; + this.selectTaskId = this.selectValue[index].id + this.selectTaskName = this.selectValue[index].value + this.index = index; + if (text) { + this.text = text; + } + this.createCard() + }) + + Row() { + Text('要求:') + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.colorGrey6')) + + Text(this.taskDescription) + .layoutWeight(1) + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.colorGrey6')) + .visibility(StringUtils.isNullOrEmpty(this.taskDescription) ? Visibility.Hidden : Visibility.Visible) + } + .width(AppConstants.PERCENTAGE_MAX) + .padding({ left: $r('app.float.default_15'), right: $r('app.float.default_10') }) + .margin({ top: $r('app.float.default_10') }) + + Divider() + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey3')) + .margin({ top: $r('app.float.default_10') }) + + Text('选择执勤卡点') + .fontSize($r('app.float.text_size_14')) + .width('95%') + .textAlign(TextAlign.Start) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_10'), left: $r('app.float.default_10') }) + + Search({ placeholder: '输入卡点名称进行搜索' }) + .width('95%') + .height($r('app.float.default_43')) + .border(cardRoundBorderStyle) + .margin({ top: $r('app.float.default_10') }) + .onChange((ver) => { + + }) + + List() { + ForEach(this.cardPortArray, (item: CardProtModel) => { + ListItem() { + CardPortListItem({ + item: item, + onSelect: (item) => { + this.selectCardId = item.id + this.selectCardName = item.orgName + this.cardPointAddress = item.address + this.cardPointPointX = item.pointX + this.cardPointPointY = item.pointY + this.updateCardDataStatus(item); + } + }) + } + }, (item: CardProtModel) => item.id) + } + .width('95%') + // .divider({ + // strokeWidth: $r('app.float.default_1'), + // color: $r('app.color.colorGrey2') + // }) + .backgroundColor($r('app.color.white')) + .layoutWeight(1) + .padding({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10') }) + .border(cardRoundBorderStyle) + .margin({ + top: $r('app.float.default_5'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + bottom: $r('app.float.default_10') + }) + + Button('开始盘查') + .fontColor($r('app.color.white')) + .width('95%') + .fontSize($r('app.float.text_size_16')) + .backgroundColor($r('app.color.bull')) + .onClick(() => { + if (StringUtils.isNullOrEmpty(this.selectTaskName) || StringUtils.isNullOrEmpty(this.selectTaskId)) { + ToastUtils.toastBottom("请先选择任务!") + return + } + AppCache.getAppCache().setTaskName = this.selectTaskName; + AppCache.getAppCache().setTaskId = this.selectTaskId; + if (StringUtils.isNullOrEmpty(this.selectCardName) || StringUtils.isNullOrEmpty(this.selectCardId?.toString())) { + ToastUtils.toastBottom("请选择卡点!") + return + } + AppCache.getAppCache().setCardPointId = this.selectCardId; + AppCache.getAppCache().setCardPointName = this.selectCardName; + AppCache.getAppCache().setCardLocation(StringUtils.get(this.cardPointPointX, "0.0"), + StringUtils.get(this.cardPointPointY, "0.0"), StringUtils.get(this.cardPointAddress, "")) + + let skipModel: SkipCheckPageModel = new SkipCheckPageModel(); + skipModel.titleType = 2 + skipModel.taskId = this.selectTaskId + skipModel.taskName = this.selectTaskName + skipModel.cardPointName = this.selectCardName + + let param: BasePageResult = { + type: 1, + what: 1, + data: skipModel + } + router.replaceUrl({ url: 'ui/pages/StreetInspectionPages', params: param }) + }) + .margin({ bottom: $r('app.float.default_32') }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + updateCardDataStatus(item: CardProtModel) { + // 遍历所有项,只将当前选中的项设为true,其他设为false + this.cardPortArray.forEach(selectedItem => { + selectedItem.isSelect = (item.id === selectedItem.id); + }); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/SelectTaskListPage.ets b/entry/src/main/ets/ui/pages/SelectTaskListPage.ets new file mode 100644 index 0000000..35e8fe9 --- /dev/null +++ b/entry/src/main/ets/ui/pages/SelectTaskListPage.ets @@ -0,0 +1,174 @@ +import { AxiosError } from "@ohos/axios"; +import { ToastUtil } from "@pura/harmony-utils"; +import AppConstants from "../../app/AppConstant"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { SelectTaskObservedModel } from "../../model/uiModel/SelectTask"; +import { getTaskList } from "../../request/api/Api"; +import { cardRoundBorderGreyStyle } from "../../style/BorderStyle"; +import { StringUtils } from "../../util/StringUtils"; +import { ToastUtils } from "../../util/ToasUtils"; +import { BaseTopBar } from "../../view/custom/BaseTopTar"; +import { EmptyOrErrorItemView } from "../../view/custom/EmptyOrErrorItemView"; +import { SelectTaskListItem } from "../../view/custom/SelectTaskListItem"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { LoadingDialog } from "../../view/dialog/LoadingDialog"; +import { router } from "@kit.ArkUI"; + +/** + * 选择任务 + */ +@Entry +@Component +export struct SelectTaskListPage { + @State inputContent: string | undefined = undefined + @State selectValue: Array = new Array(); + @State loadDialogTips: string | Resource = $r('app.string.loading_hint') + private selectItem: SelectTaskObservedModel | undefined; + //加载弹框 + dialogController: CustomDialogController = new CustomDialogController({ + builder: LoadingDialog({ + loadingTips: this.loadDialogTips, + }) + }); + + aboutToAppear(): void { + + } + + onPageShow(): void { + this.getTaskListData(); + } + + getTaskListData() { + this.loadDialogTips = $r('app.string.loading_hint') + this.dialogController.open() + getTaskList(StringUtils.get(this.inputContent,""), 1) + .then((res) => { + this.dialogController.close() + console.debug(JSON.stringify(res)) + this.selectValue = new Array; + if (res.code != 200) { + this.handErrorOrEmPty(-1, StringUtils.get(res.msg, "")) + return + } + let dataList = res.rows; + if (dataList == null || dataList.length < 1) { + this.handErrorOrEmPty(0, "暂无任务") + return + } + dataList!.forEach(element => { + let mode = new SelectTaskObservedModel(); + mode.taskName = StringUtils.get(element.name, ""); + mode.taskId = StringUtils.get(element.id, ""); + this.selectValue.push(mode) + }); + }) + .catch((e: AxiosError) => { + this.dialogController.close() + this.handErrorOrEmPty(-1, `查询任务失败:${e.message}`) + }) + } + + /** + * 错误或空处理 + */ + handErrorOrEmPty(type: number, msg: string) { + ToastUtils.toastBottom(msg) + let bean = new SelectTaskObservedModel() + bean.baseType = type; + bean.taskName = msg; + this.selectValue = new Array(); + this.selectValue.push(bean) + } + + submit() { + if (!this.selectItem) { + ToastUtil.showLong("请先选择任务") + return + } + let param = new BasePageResult() + param.type =1; + param.data = this.selectItem + router.back({url:"ui/pages/HistoryMainPage",params:param}) + } + + build() { + Column() { + BaseTopBar({ + title: $r('app.string.title_select_task'), + }) + + TextInput({ text: this.inputContent, placeholder: "请输入任务名称进行搜索" }) + .placeholderColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.colorGrey8')) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_10') + }) + .padding({ + left: $r('app.float.default_5'), + right: $r('app.float.default_5'), + }) + .onChange((text: string) => { + this.inputContent = text; + }) + .height($r('app.float.default_40')) + .width('96%') + .textAlign(TextAlign.Start) + .border(cardRoundBorderGreyStyle) + .enterKeyType(EnterKeyType.Search)// 设置为搜索按钮 + .onSubmit((enterKey: EnterKeyType, event: SubmitEvent) => { + // 点击搜索按钮时触发 + this.getTaskListData() + }); + + List() { + ForEach(this.selectValue, (item: SelectTaskObservedModel, index: number) => { + if (item.baseType == 0 || item.baseType == -1) { + EmptyOrErrorItemView({ type: item.baseType, msg: item.taskName }) + } else { + SelectTaskListItem({ + item: item, + onSelect: (item: SelectTaskObservedModel) => { + this.selectItem = item; + this.updateCardDataStatus(item) + } + }) + } + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + + Button("完成", { type: ButtonType.Normal, stateEffect: true }) + .fontSize($r('app.float.text_size_16')) + .fontColor($r('app.color.white')) + .backgroundColor($r('app.color.bull')) + .borderRadius(8) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + bottom: $r('app.float.default_28'), + }) + .onClick(() => { + this.submit(); + }) + .width('95%'); + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + } + + + updateCardDataStatus(item: SelectTaskObservedModel) { + // 遍历所有项,只将当前选中的项设为true,其他设为false + this.selectValue.forEach(selectedItem => { + selectedItem.isSelect = (item.taskId === selectedItem.taskId); + }); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/StaticPortraitPage.ets b/entry/src/main/ets/ui/pages/StaticPortraitPage.ets new file mode 100644 index 0000000..1cd6c34 --- /dev/null +++ b/entry/src/main/ets/ui/pages/StaticPortraitPage.ets @@ -0,0 +1,424 @@ +import { camera, cameraPicker as picker } from '@kit.CameraKit' + +import { faceDetector } from '@kit.CoreVisionKit'; +import { image } from '@kit.ImageKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { fileIo, fileUri } from '@kit.CoreFileKit'; +import { ToastUtils } from '../../util/ToasUtils'; +import { BaseTopBar } from '../../view/custom/BaseTopTar'; +import { createWaterMark } from '../../view/custom/Watermark'; +import { PixelMapUtils } from '../../util/PixelMapUtils'; +import { comparisonFace } from '../../request/api/Api'; +import { FileUtils } from '../../util/FileUtils'; +import { FaceItem, PeopleFaceRequestModel } from '../../model/uiModel/PeopleFaceRequestModel'; +import { ComparisonFaceDialog } from '../../view/dialog/ComparisonFaceDialog'; +import AppConstants from '../../app/AppConstant'; +import { StringUtils } from '../../util/StringUtils'; +import { BasePageResult } from '../../model/uiModel/PageResultModel'; +import { router } from '@kit.ArkUI'; + +/** + * 静态人像 + */ +@Component +@Entry +export struct StaticPortraitPage { + @State imageFileUri: string | undefined = undefined; + @State chooseImage: PixelMap | undefined = undefined; + @State faceArray: Array = new Array() + @State resultData: Array = new Array() + @State loadDialogTips: string | Resource = $r('app.string.loading_detection_face') + + dialogController?:CustomDialogController + //结果状态 1 = 识别人脸成功,展示识别结果, 2 = 比对成功展示比对结果 + @State resultStatus :number= 0; + + aboutToAppear(): void { + this.takePhoto(); + } + + /** + * 显示提醒框 + * @param imageFileUri + */ + showComparisonDialog(imageFileUri: string|image.PixelMap){ + this.dialogController = new CustomDialogController({ + builder: ComparisonFaceDialog({ + loadingTips: this.loadDialogTips, + photoPath: imageFileUri + }), + customStyle:true, + autoCancel: false, // 关键参数 + backgroundColor:Color.Transparent, + // maskColor: 0x00000000, // 关键参数:透明遮罩 + alignment: DialogAlignment.Center + }); + this.dialogController.open() + } + + /** + * 拍照 + */ + async takePhoto() { + let pathDir = FileUtils.IMAGE_DIR + let fileName = `${new Date().getTime()}.JPEG` + let filePath = `${pathDir}/${fileName}` + fileIo.createRandomAccessFileSync(filePath, fileIo.OpenMode.CREATE); + + let fileUris = fileUri.getUriFromPath(filePath); + let pickerProfile: picker.PickerProfile = { + cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK, + saveUri: fileUris + }; + this.resultStatus = 0; + let result: picker.PickerResult = + await picker.pick(getContext(), [picker.PickerMediaType.PHOTO, picker.PickerMediaType.VIDEO], + pickerProfile); + console.info(`picker resultCode: ${result.resultCode},resultUri: ${result.resultUri},mediaType: ${result.mediaType}`); + if (result.resultCode == 0) { + if (result.mediaType === picker.PickerMediaType.PHOTO) { + this.faceArray =[] + this.resultStatus = 1; + this.imageFileUri = result.resultUri + this.createPixelMap() + .then((res) => { + this.detectionFace(res) + }) + } + } + } + + async createPixelMap(): Promise { + let imageSource: image.ImageSource | undefined = undefined; + let fileSource = await fileIo.open(this.imageFileUri!, fileIo.OpenMode.READ_ONLY); + imageSource = image.createImageSource(fileSource.fd); + return await imageSource.createPixelMap(); + } + + /** + * 检测人脸 + * @param chooseImage + */ + detectionFace(chooseImage: PixelMap) { + this.loadDialogTips = $r('app.string.loading_detection_face') + this.showComparisonDialog(this.imageFileUri!) + faceDetector.init(); + let visionInfo: faceDetector.VisionInfo = { + pixelMap: chooseImage! + }; + + // Call the face detection API. + faceDetector.detect(visionInfo) + .then(async (data: faceDetector.Face[]) => { + this.dialogController?.close() + if (data.length === 0) { + hilog.error(0x0000, 'faceDetectorSample', '未检测到人脸'); + ToastUtils.toastCenter("未检测到人脸!") + // this.dataValues = "No face is detected in the image. Select an image that contains a face."; + } else { + let faceString = JSON.stringify(data); + hilog.info(0x0000, 'faceDetectorSample', "faceString data is " + faceString); + // this.dataValues = faceString; + for (let i = 0; i < data.length; i++) { + let sbl = data[i].probability; + if (sbl > 0.7) { + let rect = data[i].rect; + let dcjChooseImage = await this.createPixelMap(); + await this.cropImage(dcjChooseImage, rect.left, rect.top, rect.width, rect.height) + } + } + if (this.faceArray.length < 1) { + ToastUtils.toastBottom("未捕获到人脸,请重新拍摄!") + return + } + if (this.faceArray.length == 1) { + this.compareFaces(this.faceArray[0]); + } + } + }) + .catch((error: BusinessError) => { + this.dialogController?.close() + hilog.error(0x0000, 'faceDetectorSample', + `Face detection failed. Code: ${error.code}, message: ${error.message}`); + ToastUtils.toastCenter("未检测到人脸!") + // this.dataValues = `Error: ${error.message}`; + }); + faceDetector.release(); + } + + /** + * 裁剪人脸 + * @param chooseImage + * @param x + * @param y + * @param w + * @param h + */ + async cropImage(chooseImage: PixelMap, x: number, y: number, w: number, h: number) { + await chooseImage?.crop({ + x: x, + y: y, + size: { + height: h, + width: w, + } + }).then(() => { + this.faceArray.push(chooseImage) + }) + .catch((error: Error) => { + hilog.error(0x0000, 'faceDetectorSample', `Face detection failed. message: ${error.message}`); + ToastUtils.toastCenter("裁剪失败!") + }); + } + + /** + * 比对人脸 + * @param pixelMap + */ + async compareFaces(pixelMap: image.PixelMap) { + this.loadDialogTips = $r('app.string.loading_comparison_face') + this.showComparisonDialog(pixelMap) + let base64 = await PixelMapUtils.pixelMapToBase64(pixelMap); + + let param:PeopleFaceRequestModel = { + listLibIds: '1618379821036', + start: '1', + size: '9', + similarityMin: '0.9', + picBase64: base64, + } + + comparisonFace(param) + .then((values) => { + this.resultStatus = 2; + this.dialogController?.close() + console.warn('请求结果:', JSON.stringify(values)); + if (values.code == 0) { + let data = values.data; + if (data) { + let list = data.list; + if (list&&list.length>0) { + this.resultStatus = 2 + this.resultData = list; + }else { + ToastUtils.toastBottom(`未比中人脸!`) + } + }else { + ToastUtils.toastBottom(`未比中人脸!`) + } + }else { + ToastUtils.toastBottom(`比对失败!${values.msg}`) + } + }) + .catch((error: Error) => { + this.dialogController?.close() + console.warn('请求结果:', JSON.stringify(error)); + ToastUtils.toastBottom(`比对失败!${error.message}`) + }) + } + + build() { + Column() { + BaseTopBar({ + title: "静态人像", + rightText: "重新拍摄", + rightClickEvent: () => { + this.takePhoto(); + } + }) + Stack({ alignContent:Alignment.TopStart }) { + Image(this.imageFileUri) + .width('100%') + .height('100%') + .opacity(0.15) + + Column() { + Text('请点击需要比对的人脸') + .width('100%') + .fontColor($r('app.color.colorRed9')) + .fontSize($r('app.float.text_size_16')) + .margin({ top: $r('app.float.default_68') }) + .visibility(this.resultStatus == 1? Visibility.Visible:Visibility.None) + .textAlign(TextAlign.Center) + if (this.resultStatus == 1) { + List() { + ForEach(this.faceArray, (item: PixelMap) => { + ListItem() { + Image(item) + .width('100%') + .height($r('app.float.default_120')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.grad') + }) + .margin({ top: $r('app.float.default_10') }) + .onClick(() => { + this.compareFaces(item); + }) + } + }) + } .width('100%') + .friction(0.6) + .margin({ top: $r('app.float.default_20') }) + .lanes({ minLength: 80, maxLength: 80 }) + .alignListItem(ListItemAlign.Center) + .visibility(this.resultStatus == 1? Visibility.Visible:Visibility.None) + .scrollBar(BarState.Off) + } + if (this.resultStatus == 2) { + List(){ + if (this.resultData.length > 0) { + ListItem() { + this.resultOne(this.resultData[0]) + } + .onClick(()=>{ + let param = new BasePageResult(); + param.type = 7; + param.data = this.resultData[0] + router.back({url:'ui/pages/StreetInspectionPages',params:param}) + }) + } + + ForEach(this.getPairedData(), (item: FaceItem[],index:number) => { + ListItem() { + Row(){ + this.resultOthers(item[0]) + + if (item.length>1) { + this.resultOthers(item[1]) + } else { + // 空白占位符保持布局整齐 + Blank() + .width('46%') + .margin({ left: $r('app.float.default_8'), right: $r('app.float.default_8') }) + } + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + + }) + } + .width('100%') + .margin({ top: $r('app.float.default_10') }) + .alignListItem(ListItemAlign.Center) + .visibility(this.resultStatus == 2? Visibility.Visible:Visibility.None) + .scrollBar(BarState.Off) + } + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + } + .width('100%') + .layoutWeight(1) + } + .backgroundColor($r('app.color.page_background')) + .width('100%') + .height('100%') + .overlay(createWaterMark()) + } + + @Builder + resultOne(item: FaceItem){ + Stack({ alignContent: Alignment.TopStart }) { + Column(){ + Image(item.facePicUrl.replace("http://53.1.243.135:30080/components", "http://20.90.2.2/st_idcard_img_out")) + .width($r('app.float.default_100')) + .height($r('app.float.default_130')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.grad') + }) + .margin({ top: $r('app.float.default_10') }) + + Text(item.credentialsNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Bold) + .margin({ top: $r('app.float.default_15') ,bottom: $r('app.float.default_10')}) + + Text(StringUtils.convertToPercentage(item.similarity)) + .fontColor($r('app.color.colorYellow8')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Bold) + } + .padding({top: $r('app.float.default_10'),bottom: $r('app.float.default_10')}) + .width('98%') + .alignItems(HorizontalAlign.Center) + .backgroundColor($r('app.color.white')) + .margin({ left: $r('app.float.default_2'), top: $r('app.float.default_2') }) + .border({ + width:$r('app.float.default_1'), + color:$r('app.color.white'), + radius:$r('app.float.default_3') + }) + + Row(){ + Image($r('app.media.icon_max_sbl')) + .width('90vp') + .height('30vp') + } + .alignItems(VerticalAlign.Top) + .justifyContent(FlexAlign.Start) + + } + .width('95%') + + } + + //其他 + @Builder + resultOthers(item: FaceItem) { + Column(){ + Image(item.facePicUrl.replace("http://53.1.243.135:30080/components", "http://20.90.2.2/st_idcard_img_out")) + .width($r('app.float.default_100')) + .height($r('app.float.default_130')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.grad') + }) + .margin({ top: $r('app.float.default_10') }) + + Text(item.credentialsNum) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Bold) + .margin({ top: $r('app.float.default_15') ,bottom: $r('app.float.default_10')}) + + Text(StringUtils.convertToPercentage(item.similarity)) + .fontColor($r('app.color.colorYellow8')) + .fontSize($r('app.float.text_size_16')) + .fontWeight(FontWeight.Bold) + } + .width('46%') + .padding({top: $r('app.float.default_10'),bottom: $r('app.float.default_10')}) + .alignItems(HorizontalAlign.Center) + .backgroundColor($r('app.color.white')) + .margin({ left: $r('app.float.default_8'), right: $r('app.float.default_8'), top: $r('app.float.default_10') }) + .border({ + width:$r('app.float.default_1'), + color:$r('app.color.white'), + radius:$r('app.float.default_3') + }) + .onClick(()=>{ + let param =new BasePageResult(); + param.type = 7; + param.data = item + router.back({url:'ui/pages/StreetInspectionPages',params:param}) + }) + } + // 在 StaticPortraitPage 组件中添加辅助方法 + private getPairedData(): FaceItem[][] { + const result: FaceItem[][] = []; + for (let i = 1; i < this.resultData.length; i += 2) { + const pair: FaceItem[] = [this.resultData[i]]; + if (i + 1 < this.resultData.length) { + pair.push(this.resultData[i + 1]); + } + result.push(pair); + } + return result; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/ui/pages/StreetInspectionPages.ets b/entry/src/main/ets/ui/pages/StreetInspectionPages.ets new file mode 100644 index 0000000..222339b --- /dev/null +++ b/entry/src/main/ets/ui/pages/StreetInspectionPages.ets @@ -0,0 +1,1786 @@ +import AppConstants from "../../app/AppConstant"; +import CommonConstants from "../../view/keyboard/data/CommonConstants"; +import { KeyEventObserved } from "../../view/keyboard/KeyEventObserved"; +import { IdCardNumKeyboard } from "../../view/keyboard/keylayout/IdCardNumKeyBoard"; +import { StringUtils } from "../../util/StringUtils"; +import { + RouterResultModel, + SkipCheckCardModel, + SkipCheckCountParam, + SkipCheckPageModel, + SkipPassPageParam +} from "../../model/uiModel/PageParamModel"; +import { IdCardNumUtils } from "../../util/IdCardNumUtils"; +import { ToastUtils } from "../../util/ToasUtils"; +import { + addFocusPerson, + addFocusPersonPhone, + checkPerson, + checkPersonCount, + saveCzcs, + saveGoodsData, + saveMainHistoryAndChangeStatus, + updateFocus, + uploadFile +} from "../../request/api/Api"; +import { AxiosError } from "@ohos/axios"; +import { LoadingDialog } from "../../view/dialog/LoadingDialog"; +import { router } from "@kit.ArkUI"; +import { + CheckPeopleResultModel, + CheckPersonEntity, + LocalLkryData, + NationPoint, + OCRIdCardNumResultModel, + PeopleData, + ZdlxItem, + ZdrData, + ZdXqItem +} from "../../model/resultModel/CheckPeopleResultModel"; +import { BitMapUtils } from "../../util/BitMapUtils"; +import { fileIo, fileUri } from "@kit.CoreFileKit"; +import { DateFormat, DateUtils } from "../../util/DateUtils"; +import { VibratorUtils } from "../../util/VibratorUtils"; +import { hilog } from "@kit.PerformanceAnalysisKit"; +import { PCCacheData } from "../../app/PCCacheData"; +import { createWaterMark } from "../../view/custom/Watermark"; +import { camera, cameraPicker as picker } from '@kit.CameraKit' +import { image } from "@kit.ImageKit"; +import { ImageUtil, JSONUtil, ToastUtil } from "@pura/harmony-utils"; +import { DialogAction, DialogHelper } from "@pura/harmony-dialog/Index"; +import { RuanseeAbitityStag } from "../../app/RuanseeAbitityStag"; +import { ImportanceInfoDialog } from "../../view/dialog/ImportanceInfoDialog"; +import { StrUtil } from "@pura/harmony-utils/src/main/ets/utils/StrUtil"; +import { BasePageResult } from "../../model/uiModel/PageResultModel"; +import { CheckSubmitEntity, CheckSubmitModel } from "../../model/requestModel/CheckRequestModel"; +import { AttentionDialog } from "../../view/dialog/AttentionDialog"; +import { CustomUnionType } from "../../app/JointType"; +import { FileUtils } from "../../util/FileUtils"; +import { FaceItem } from "../../model/uiModel/PeopleFaceRequestModel"; +import { VoiceRecognitionDialog } from "../../view/dialog/VoiceRecognitionDialog"; + +/** + * 街面盘查 + */ +@Preview +@Component +@Entry +export struct StreetInspectionPages { + @State backImage: Resource = $r('app.media.icon_back3') + @Provide searchContent: string = ""; + //输入法键盘模式 + @Provide menuType: number = CommonConstants.KEYBOARD_TYPE_ID_CARD_NUM; + private searchController: SearchController = new SearchController(); + @Provide keyEventObserved: KeyEventObserved = new KeyEventObserved(this.searchController); + ////////////////////////////////// 人员信息 ///////////////////////// + @State peopleName: string = ''; + @State peopleSex: string = ''; + @State peopleNation: string = ''; + @State peopleAddress: string = ''; + @State peopleBirth: string = ''; + @State peopleIdCard: string = ''; + @State peopleOPhone: string = ''; + @State peoplePhoto: string | Resource = $r('app.media.photo'); + //人员重点类型 + peopleStatus: string = ""; + //控制电话号码后面的修改是否显示的 + @State isUpdatePhone: boolean = false; + //关注状态 0:未关注(显示文字) 1: 关注等级1 2: 关注等级2 3: 关注等级3 + @State attentionStatus: number = 0; + //人员查询次数 + @State peopleCheckCount: number = 0; + @State private statusType: number = 1; + @State titleName: string = "街面盘查"; + @State cardName: string = ''; + @State goodsNum: string = '添加违禁物品'; + @State carNum: string = '添加随行车辆'; + // 值为0 表示没有查询车辆 1 表示异常车辆 2 表示正常车辆 + @State carNumStatus: number = 0; + @State zdlxImg: Array | undefined = undefined; + @State checkCount: number = 0; + @State errorCount: number = 0; + //照片状态 true 表示证件 false 表示现场 + @State photoStatus: boolean = true; + //当前人员状态 true表示异常人员,false表示正常人员 + currentPersonStatus: boolean = false; + @State loadDialogTips: string | Resource = $r('app.string.loading_check_people') + //The '@ObjectLink' property cannot be specified a default value. + + czcsContent: string = ""; + uiCacheData: PCCacheData = PCCacheData.pcCacheData; + dialogID: string = ""; + isShowZdlxDialog: boolean = false; + //加载弹框 + dialogController: CustomDialogController = new CustomDialogController({ + builder: LoadingDialog({ + loadingTips: this.loadDialogTips, + }) + }); + showCarTypeDialogController: CustomDialogController | null = null + + /** + * 页面初始化 + * TODO BasePageResult.code 说明: + * 1:首页跳转参数 + * 2:车辆返回参数 + * 3:物品返回参数 + * 4:暂未使用 + * 5:提交通过返回 + * 6:NFC返回参数(暂未使用) + * 7:人像返回参数(暂定) + * 8:OCR返回参数(暂定) + * 9:语音返回参数(暂定) + */ + aboutToAppear(): void { + this.uiCacheData.clear(); + RuanseeAbitityStag.appCache.getHistoryId() + + this.keyEventObserved.onSearchKeyMethod = (value) => { + this.searchController.stopEditing() + this.queryPeople(value, AppConstants.CHECK_TYPE_INPUT); + }; + + let param: BasePageResult = router.getParams() as BasePageResult; + if (param) { + if (param.type == 1) { //首页跳转参数 + RuanseeAbitityStag.appCache.resetIds(); + let data: SkipCheckPageModel = param.data; + if (data) { + if (data.titleType == 1) { + this.titleName = "街面盘查"; + } else { + this.titleName = StringUtils.get(data.taskName, "卡点核录"); + this.cardName = StringUtils.get(data.cardPointName, ""); + this.statusType = 2; + } + } + return + } + } + } + + /** + * 页面显示时执行* + * TODO BasePageResult.code 说明: + * 1:首页跳转参数 + * 2:车辆返回参数 + * 3:物品返回参数 + * 4:暂未使用 + * 5:提交通过返回 + * 6:NFC返回参数(暂未使用) + * 7:人像返回参数(暂定) + * 8:OCR返回参数(暂定) + * 9:语音返回参数(暂定) + */ + onPageShow(): void { + let param: BasePageResult = router.getParams() as BasePageResult; + if (param) { + if (param.type == 2) { //车辆返回参数 + let data: string = param.data; + if (StrUtil.isNotEmpty(data)) { + this.carNum = data + this.carNumStatus = param.what == 1 ? -1 : param.what == 0 ? 2 : 0 + } + return + } + if (param.type == 3) { //物品返回参数 + if (param.data) { + this.goodsNum = param.data + ""; + } + return + } + if (param.type == 5) { //提交通过返回 + if (param.data) { + ToastUtils.toastCenter(param.data); + } + this.pageClear(); + return + } + if (param.type == 7) { //人像返回参数 + let data: FaceItem = param.data as FaceItem; + if (data) { + this.searchContent = data.credentialsNum + this.keyEventObserved.inputContent = data.credentialsNum + this.queryPeople(data.credentialsNum, AppConstants.CHECK_TYPE_FACE) + } + return + } + if (param.type == 8) { //OCR返回参数 + let data: RouterResultModel = param.data; + if (data) { + let jsonData = data.data; + if (jsonData) { + let model: OCRIdCardNumResultModel = JSON.parse(jsonData) as OCRIdCardNumResultModel + this.searchContent = model.idNumber + this.keyEventObserved.inputContent = model.idNumber + this.peopleName = model.name + this.peopleSex = model.sex + this.peopleNation = model.nationality + this.peopleBirth = model.birth + this.peopleIdCard = model.idNumber + this.peopleAddress = model.address + this.peoplePhoto = model.cardImageUri + // this.peoplePhoto = model.originalImageUri + this.queryPeople(model.idNumber, AppConstants.CHECK_TYPE_OCR) + } + } + return + } + } + } + + /** + * 页面隐藏时执行 + */ + onPageHide(): void { + + } + + /** + * 数据未提交提醒框 + */ + showNotSubmittedDialog() { + let dialogID = DialogHelper.showAlertDialog({ + content: "您本次盘查结果还未提交,请选择通过或者放弃本次盘查结果!", + onAction: (action) => { + if (action == DialogAction.ONE) { //取消 + DialogHelper.closeDialog(dialogID) + this.pageClear() + } else if (action == DialogAction.TWO) { //确定 + DialogHelper.closeDialog(dialogID) + this.pass() + } + }, + primaryButton: { + value: "放弃盘查", + fontColor: $r('app.color.colorGrey7'), + }, + secondaryButton: { + value: "通过", + fontColor: $r('app.color.bull'), + }, + }) + } + + /** + * 语音识别弹框 + */ + showVioceRecognDialog() { + let dialogController = new CustomDialogController({ + builder: VoiceRecognitionDialog({ + controller: this.dialogController, + type: "idCardNum", + onResult: (value) => { + console.log(value) + this.searchContent = value + this.keyEventObserved.inputContent = value + this.queryPeople(value, AppConstants.CHECK_TYPE_AUDIO) + dialogController.close() + } + }) + }); + dialogController.open() + } + + // 重点信息弹框 + showZdxqDialog(item: ZdlxItem) { + if (item.styleType == 1) { + ToastUtils.toastBottom(item.zdlx) + return + } + if (item.zdxqArray == null || item.zdxqArray == undefined || item.zdxqArray.length < 1) { + ToastUtils.toastBottom(`${item.zdlx}:暂无详细信息!`) + return + } + if (this.isShowZdlxDialog) { + return + } + this.showCarTypeDialogController = new CustomDialogController({ + builder: ImportanceInfoDialog({ + zdlx: item, + controller: this.showCarTypeDialogController!, + isSetCzcs: true, + czcsContent: this.czcsContent, + submitClick: (value) => { + this.isShowZdlxDialog = false; + this.setCzcs(value); + + } + }), + cornerRadius: 3, + autoCancel: false, + backgroundColor: Color.Transparent, // 背景透明 + backgroundBlurStyle: BlurStyle.NONE, // 必须关闭模糊材质 + cancel: () => { + this.isShowZdlxDialog = false; + + } + }); + this.showCarTypeDialogController.open() + this.isShowZdlxDialog = true; + } + + /** + * 设置关注 + */ + setAttention(value: string, selectLevel: number) { + let param = new Map(); + param.set("focusType", selectLevel + "") + param.set("focusReason", value) + if (StrUtil.isNotEmpty(this.cardName)) { //卡点盘查 + let address = RuanseeAbitityStag.appCache.getCardPointAddress + let x = RuanseeAbitityStag.appCache.getCardPointLocationX() + let y = RuanseeAbitityStag.appCache.getCardPointLocationY() + let as = "" + if (StrUtil.isNotEmpty(x)) { + as = x + } + if (StrUtil.isNotEmpty(y)) { + if (StrUtil.isNotEmpty(as)) { + as = as + ":" + y + } else { + as = y; + } + } + param.set("focusAddress", StringUtils.get(address, as)) + } else { //街面盘查 + let address = RuanseeAbitityStag.appCache.getLocationAddress + let x = RuanseeAbitityStag.appCache.getLocationX() + "" + let y = RuanseeAbitityStag.appCache.getLocationY() + "" + let as = "" + if (StrUtil.isNotEmpty(x)) { + as = x + } + if (StrUtil.isNotEmpty(y)) { + if (StrUtil.isNotEmpty(as)) { + as = as + ":" + y + } else { + as = y; + } + } + param.set("focusAddress", StringUtils.get(address, as)) + } + + let personEntity = new Map(); + personEntity.set("address", this.peopleAddress) + personEntity.set("birthDate", this.peopleBirth) + personEntity.set("idCardNum", this.peopleIdCard) + personEntity.set("mz", this.peopleNation) + personEntity.set("realName", this.peopleName) + personEntity.set("unusualType", this.peopleStatus) + personEntity.set("sex", this.peopleSex) + param.set("peopleEntity", JSONUtil.mapToJsonStr(personEntity)); + this.loadDialogTips = "正在提交关注,请稍后..." + this.dialogController.open() + addFocusPerson(param) + .then((res) => { + this.dialogController.close() + if (res.code == 200) { + ToastUtils.toastBottom("关注成功") + this.attentionStatus = selectLevel; + } else { + ToastUtils.toastBottom(`关注失败:${res.msg}`) + } + }) + .catch((e: AxiosError) => { + this.dialogController.close() + ToastUtils.toastBottom(`关注失败:${e.message}`) + }) + } + + showAttentionDialog() { + let attentionDialogController: CustomDialogController = new CustomDialogController({ + builder: AttentionDialog({ + type: 1, + submit: (value, selectLevel) => { + attentionDialogController.close() + this.setAttention(value, selectLevel) + }, + cancel: () => { + attentionDialogController.close() + } + }), + cornerRadius: 3, + autoCancel: false, + backgroundColor: Color.Transparent, // 背景透明 + backgroundBlurStyle: BlurStyle.NONE, // 必须关闭模糊材质 + cancel: () => { + + } + }); + attentionDialogController.open() + } + + /** + * 设置处置措施 + * @param value + */ + setCzcs(value: string) { + if (StringUtils.isNullOrEmpty(value)) { + ToastUtils.toastBottom("您未输入处置措施,将会参数提醒数据!") + return + } + saveCzcs(value) + .then((res) => { + if (res.code == 200) { + ToastUtils.toastBottom("保存成功") + this.czcsContent = value; + } else { + ToastUtils.toastBottom(`保存处置措施失败:${res.msg}`) + } + }) + .catch((e: AxiosError) => { + ToastUtils.toastBottom(`保存处置措施失败:${e.message}`) + }) + } + + /** + * 修改手机号 + */ + showUpdatePhone() { + // let dialog = new AlertDialog(); + DialogHelper.showTextInputDialog({ + title: "登记手机", + text: this.peopleOPhone, + fontColor: $r('app.color.colorGrey8'), + placeholderColor: $r('app.color.colorGrey6'), + placeholder: "请输入联系电话", + onChange: (res) => { + // this.peopleOPhone = res; + }, + onAction: (action, dialogId, content) => { + if (action == DialogAction.SURE) { + this.updatePhone(content) + } + } + }) + } + + updatePhone(phone: string) { + if (!phone) { + return + } + if (phone === this.peopleOPhone) { + return + } + let param = new Map(); + param.set("address", this.peopleAddress) + param.set("birthDate", this.peopleBirth) + param.set("idCardNum", this.peopleIdCard) + param.set("mz", this.peopleNation) + param.set("realName", this.peopleName) + param.set("unusualType", this.peopleStatus) + param.set("sex", this.peopleSex) + param.set("phone", phone); + let paramJson = JSONUtil.mapToJsonStr(param); + this.loadDialogTips = "正在提交关注,请稍后..." + this.dialogController.open() + + addFocusPersonPhone(paramJson) + .then((res) => { + console.debug(JSON.stringify(res)); + this.dialogController.close() + if (res.code == 200) { + this.peopleOPhone = phone; // 获取最终输入内容 + } + + }) + .catch((e: AxiosError) => { + console.error(e.message); + this.dialogController.close() + ToastUtils.toastBottom(`失败:${e.message}`) + + }) + + + } + + /** + * 拍照 + */ + async takePhoto() { + let pathDir = FileUtils.IMAGE_DIR; + let fileName = `${new Date().getTime()}.JPEG` + let filePath = `${pathDir}/${fileName}` + let imageFileUri: string | undefined = undefined; + fileIo.createRandomAccessFileSync(filePath, fileIo.OpenMode.CREATE); + + let fileUris = fileUri.getUriFromPath(filePath); + let pickerProfile: picker.PickerProfile = { + cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK, + saveUri: fileUris, + }; + let result: picker.PickerResult = + await picker.pick(getContext(), [picker.PickerMediaType.PHOTO], + pickerProfile); + console.info(`picker resultCode: ${result.resultCode},resultUri: ${result.resultUri},mediaType: ${result.mediaType}`); + if (result.resultCode == 0) { + if (result.mediaType === picker.PickerMediaType.PHOTO) { + imageFileUri = result.resultUri + imageFileUri = await ImageUtil.compressPhoto(imageFileUri, 150); + // this.peoplePhoto = imageFileUri; + this.loadDialogTips = "正在上传,请稍后..." + this.dialogController.open() + this.updatePhoto(imageFileUri); + } + } + } + + /** + * 上传照片 + * 随行人员 + * @param imageFileUri + */ + updatePhoto(imageFileUri: string) { + uploadFile(imageFileUri, RuanseeAbitityStag.appCache.getPeopleId()) + .then((res) => { + this.dialogController.close() + console.debug(JSON.stringify(res)); + if (res.code == 200) { + this.uiCacheData.xczpUrl = RuanseeAbitityStag.convertPhotoUrl(StringUtils.get(res.data?.url, "")); + this.uiCacheData.xczpId = StringUtils.get(res.data?.photoId, ""); + this.uiCacheData.isXczp = true; + this.photoStatus = false + this.peoplePhoto = this.uiCacheData.xczpUrl + } + }) + .catch((error: AxiosError) => { + this.dialogController.close() + ToastUtils.toastCenter(`上传失败:${error.message}}`) + console.error(error.message); + }) + } + + async createPixelMap(imageFileUri: string | undefined): Promise { + let imageSource: image.ImageSource | undefined = undefined; + let fileSource = await fileIo.open(imageFileUri!, fileIo.OpenMode.READ_ONLY); + imageSource = image.createImageSource(fileSource.fd); + return await imageSource.createPixelMap(); + } + + /** + * 页面元素清空 + */ + pageClear() { + this.carNum = '添加随行车辆' + this.goodsNum = '添加违禁物品' + this.peopleName = "" + this.peopleSex = "" + this.peopleCheckCount = 0 + this.peopleNation = "" + this.peopleBirth = "" + this.peopleOPhone = "" + this.peopleIdCard = "" + this.peopleAddress = "" + this.peopleStatus = "" + this.peoplePhoto = $r('app.media.photo') + this.photoStatus = true + this.zdlxImg = undefined + this.searchContent = "" + this.attentionStatus = 0 + this.isUpdatePhone = false + this.carNumStatus = 0 + this.checkCount = 0 + this.errorCount = 0 + this.currentPersonStatus = false + + if (StrUtil.isNotEmpty(this.uiCacheData.goodsJson)) { + this.saveGoodsDataJson(this.uiCacheData.goodsJson) + } + //清除缓存 + this.uiCacheData.clear() + //重置所有ID + RuanseeAbitityStag.appCache.resetIds(); + } + + /** + * 发送物品数据到后台 + * @param goodsJson + */ + saveGoodsDataJson(goodsJson: string) { + saveGoodsData(goodsJson) + .then((res) => { + console.debug("save goods", res) + + }) + .catch((e: AxiosError) => { + console.error("save goods", e.message) + + }) + } + + /** + * 查询人员 + * @param value + */ + queryPeople(value: string, checkType: number) { + if (!IdCardNumUtils.validateIdCardNum(value)) { + ToastUtils.toastCenter("请检查证件号码是否正确!") + return + } + if (this.uiCacheData.isCheck(value)) { + ToastUtils.toastCenter("本次已经盘查过该人员!") + return + } + this.loadDialogTips = $r('app.string.loading_check_people') + this.dialogController.open() + checkPerson(checkType, value, StrUtil.isNotEmpty(this.cardName), undefined) + .then((result) => { + console.log(JSON.stringify(result)); + this.dialogController.close() + if (result.code != 200) { + ToastUtils.toastCenter(StringUtils.get(result.msg, "查询失败!")); + return + } + let data = result.data; + if (data == null || data == undefined) { + ToastUtils.toastCenter("查询失败!"); + return + } + + if (data.focusType) { + this.attentionStatus = data.focusType + } + + let peopleData = data.peopleData; + if (peopleData == null || peopleData == undefined) { + ToastUtils.toastCenter("查询失败!"); + return + } + if (data.checkPersonEntity) { + let js = StringUtils.toJsonParaphrase(JSON.stringify(data.checkPersonEntity)); + let entity = JSON.parse(js) as CheckPersonEntity; + if (entity) { + this.peopleStatus = entity.peopleStatus; + } + } + RuanseeAbitityStag.appCache.temporarilyPeopleIdEffect() + this.handPeopleUI(peopleData); + this.zdlxImg = undefined; + this.handZdlxUI(data); + this.queryCheckCount() + + }) + .catch((error: AxiosError) => { + this.dialogController.close() + ToastUtils.toastCenter(`查询失败!${error.message}`); + console.error(error.message) + }) + } + + /** + * 查询人员状态 + */ + queryCheckCount() { + checkPersonCount(this.peopleIdCard) + .then((value) => { + if (value.code == 200) { + let data = value.data; + if (data) { + this.peopleCheckCount = data.count == undefined ? 0 : data.count + if (!StringUtils.isNullOrEmpty(data.peoplePhone)) { + this.peopleOPhone = data.peoplePhone! + if (StringUtils.isNullOrEmpty(this.peopleOPhone)) { + this.isUpdatePhone = false + } else { + this.isUpdatePhone = true + } + return + } + } + this.isUpdatePhone = false; + } else { + ToastUtils.toastCenter(`查询盘查次数失败:${value.msg!}`) + this.isUpdatePhone = false; + } + }) + .catch((error: AxiosError) => { + ToastUtils.toastCenter(`查询盘查次数失败:${error.message}`) + hilog.error(0x003, "queryCheckCount", `查询失败:${error.message}`) + }) + } + + addZdlx(item: ZdlxItem) { + if (this.zdlxImg == null || this.zdlxImg == undefined) { + this.zdlxImg = new Array() + } + this.zdlxImg.push(item) + if (item.isShow && !this.isShowZdlxDialog) { + this.showZdxqDialog(item) + } + } + + /** + * 处理重点人员数据 342422199911161712 + * 涉毒:340603200606224014 + * 在逃:342423199101275976 + * @param resultModel 人员数据 + */ + handZdlxUI(resultModel: CheckPeopleResultModel) { + let isZcry = true; + + if (resultModel.NationPoint) { + let js = StringUtils.toJsonParaphrase(JSON.stringify(resultModel.NationPoint)); + let nationPoint = JSON.parse(js) as NationPoint; + if (nationPoint!.status == "000") { + let nationPointResult = nationPoint!.result; + if (nationPointResult != null) { + for (let i = 0; i < nationPointResult.length; i++) { + let zdlxF = nationPointResult[i]; + if (zdlxF != null) { + let lx = zdlxF.zdrylbbj; + if (lx == null) { + continue + } + let lxA = lx.substring(0, 7); + for (let index = 0; index < 7; index++) { + let element = lxA.substring(index, index + 1); + let zdlxItme: ZdlxItem | undefined = undefined; + if (new Number(element) == 1) { + switch (index) { + case 0: + isZcry = false; + zdlxItme = new ZdlxItem("涉恐人员", 3) + break + case 1: + isZcry = false; + zdlxItme = new ZdlxItem("涉稳人员", 2); + break + case 2: + isZcry = false; + zdlxItme = new ZdlxItem("在逃人员", 3) + break + case 3: + isZcry = false; + zdlxItme = new ZdlxItem("涉毒人员", 3) + break + case 4: + isZcry = false; + zdlxItme = new ZdlxItem("前科人员", 2) + break + case 5: + isZcry = false; + zdlxItme = new ZdlxItem("精神病人", 2) + break + case 6: + isZcry = false; + zdlxItme = new ZdlxItem("非访人员", 2) + break + } + if (zdlxItme != undefined) { + zdlxItme.addXQ(new ZdXqItem("重点人员细类", zdlxF.ZDRYXL, $r('app.color.colorYellow7'))) + zdlxItme.addXQ(new ZdXqItem("立案单位", StringUtils.get(zdlxF.LADW, "暂无"), $r('app.color.black'))) + zdlxItme.addXQ(new ZdXqItem("立案时间", StringUtils.get(zdlxF.ZJLASJ, "暂无"), + $r('app.color.black'))) + zdlxItme.isShow = true; + this.addZdlx(zdlxItme) + } + } + } + } + } + } + } + } + + if (resultModel.newLKRY) { + let newLkry = JSONUtil.jsonToArray(JSON.stringify(resultModel.newLKRY)) + if (newLkry && newLkry.length > 0) { + let locatLk = newLkry[0] + let zdlx = new ZdlxItem("本地临控", 3); + zdlx.addXQ(new ZdXqItem("处置措施", locatLk.czcs, $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("布控原因", locatLk.sqyy, $r('app.color.read'))) + // zdlx.addXQ(new ZdXqItem("布控终止日期", DateUtils.formatDateStr(new Date(zzfq), DateFormat.YYYYhMMhDD), + // $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("联系民警", locatLk.lxdh, $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("民警电话", locatLk.lxmj, $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("民警电话QQ/微信", locatLk.lxmjQQ, $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("备注", locatLk.remark, $r('app.color.black'))) + zdlx.isShow = locatLk.show + this.addZdlx(zdlx) + isZcry = false; + } + } + if (resultModel.zdr) { + let zdrL = JSON.parse(resultModel.zdr) as ZdrData; + if (zdrL) { + let zdlx = new ZdlxItem("治安重点人", 3) + zdlx.addXQ(new ZdXqItem("人员类型", StringUtils.get(zdrL.peopleType, "治安重点人"), $r('app.color.read'))) + zdlx.addXQ(new ZdXqItem("联系电话", StringUtils.get(zdrL.xyrPhone, "暂无"), $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("责任民警", StringUtils.get(zdrL.zrPoliceName, "暂无"), $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("责任民警电话", StringUtils.get(zdrL.policePhone, "暂无"), $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("管控事由", StringUtils.get(zdrL.reason, "暂无"), $r('app.color.black'))) + zdlx.addXQ(new ZdXqItem("现住址", StringUtils.get(zdrL.householdAddress, "暂无"), $r('app.color.black'))) + this.addZdlx(zdlx) + isZcry = false; + } + } + + this.uiCacheData.addZcPeople() + if (isZcry) { + this.addZdlx(new ZdlxItem("正常人员", 1)) + this.currentPersonStatus = false; + } else { + this.uiCacheData.addYcPeople() + VibratorUtils.startVibrator() + this.currentPersonStatus = true; + } + this.checkCount = this.uiCacheData.zcCount + this.errorCount = this.uiCacheData.yiCount + } + + /** + * 处理人员信息显示 + * @param peopleData 人员数据 + */ + handPeopleUI(peopleData: PeopleData) { + this.czcsContent = ""; + this.peopleName = peopleData.xm; + let mzs = peopleData.mz; + if (peopleData.type == "nation") { + this.peopleNation = PeopleData.getMzChan(StringUtils.get(mzs, "")) + if ("1" == peopleData.xb) { + this.peopleSex = "男" + } else if ("2" == peopleData.xb) { + this.peopleSex = "女"; + } + } else { + this.peopleNation = StringUtils.get(mzs, "未知") + this.peopleSex = StringUtils.get(peopleData.xb, "未知") + } + let csrqs = StringUtils.get(peopleData.csrq, "").replace("-", "").replaceAll("-", ""); + if (csrqs.length < 8) { + this.peopleBirth = csrqs; + } else { + this.peopleBirth = csrqs.substring(0, 4) + "年" + csrqs.substring(4, 6) + "月" + csrqs.substring(6, 8) + "日" + } + this.peopleIdCard = peopleData.sfz + this.peopleAddress = peopleData.peopleHJDZ + let pz = peopleData.zp; + if (pz == "") { + ToastUtils.toastBottom("获取照片失败!") + this.peoplePhoto = $r('app.media.photo'); + } else { + let fileDir = FileUtils.ID_CARD_DIR; + BitMapUtils.writeFile(pz, fileDir, this.peopleIdCard + ".png") + .then((res) => { + console.info('保存成功:', res); + let uri = fileUri.getUriFromPath(res) + console.info('保存成功:', uri); + this.peoplePhoto = uri + this.uiCacheData.idCardPhoto = this.peoplePhoto + }) + .catch((error: Error) => { + console.error('捕获到异常:', JSON.stringify(error)); + this.peoplePhoto = "data:image/gif;base64," + pz + this.uiCacheData.idCardPhoto = this.peoplePhoto + }) + } + this.uiCacheData.xczpUrl = "" + this.uiCacheData.xczpId = "" + this.uiCacheData.isXczp = false + this.uiCacheData.saveQuerySfzh(this.peopleIdCard) + } + + onBackPress(): boolean | void { + if (!this.uiCacheData.isCanExit(this.carNum)) { + this.showNotSubmittedDialog() + return true + } + return false; + } + + /** + * 移交操作 + */ + handOver() { + if (this.uiCacheData.isCanExit(this.carNum)) { + ToastUtils.toastBottom("您还未开始盘查!") + return + } + if (this.currentPersonStatus && !this.uiCacheData.isXczp) { + ToastUtils.toastBottom("当前人员为异常人员,请拍摄现场照片!") + return + } + //是街面盘查的跳转完善信息页面 + let param: SkipPassPageParam = new SkipPassPageParam(); + param.isCardPoint = StrUtil.isNotEmpty(this.cardName); + param.carNumStatus = this.carNumStatus + + router.pushUrl({ url: "ui/pages/SelectHandOverObject", params: param }) + } + + /** + * 通过操作 + */ + pass() { + if (this.uiCacheData.isCanExit(this.carNum)) { + ToastUtils.toastBottom("您还未开始盘查!") + return + } + if (this.currentPersonStatus && !this.uiCacheData.isXczp) { + ToastUtils.toastBottom("当前人员为异常人员,请拍摄现场照片!") + return + } + + if (StrUtil.isNotEmpty(this.cardName)) { //是卡点盘查的直接提交通过 + this.submit() + return + } + //是街面盘查的跳转完善信息页面 + let param: SkipPassPageParam = new SkipPassPageParam(); + param.isCardPoint = false; + param.carNumStatus = this.carNumStatus + + router.pushUrl({ url: "ui/pages/PassPage", params: param }) + } + + /** + * 街面/卡点 + * 车辆类型(重点,正常) + */ + submit() { + let pc = PCCacheData.pcCacheData; + let entity: CheckSubmitEntity = new CheckSubmitEntity(); + entity.peopleCount = pc.zcCount + "" + entity.unusualPeopleCount = pc.yiCount + "" + + entity.unusualCarCount = '' + + if (this.carNumStatus == 0) { + entity.carCount = "0"; + entity.unusualCarCount = "0"; + } else { + entity.carCount = "1"; + if (this.carNumStatus == 1) { + entity.unusualCarCount = "1"; + } else { + entity.unusualCarCount = "0"; + } + } + entity.goodsCount = `${this.uiCacheData.wpCount}` + //type 0 = 街面盘查 1 = 卡点盘查 + entity.type = "1" + entity.checkReason = "13" + entity.checkAddress = RuanseeAbitityStag.appCache.getCardPointAddress + entity.remark = "" + entity.pointX = RuanseeAbitityStag.appCache.getCardPointLocationX() + entity.pointY = RuanseeAbitityStag.appCache.getCardPointLocationY() + entity.taskId = RuanseeAbitityStag.appCache.getTaskId + entity.kkid = RuanseeAbitityStag.appCache.getCardPointIdId + entity.mainId = RuanseeAbitityStag.appCache.getHistoryId() + entity.checkTime = DateUtils.formatDateStr(new Date(), DateFormat.YYYYhMMhDDkHHdMMdSS) + entity.status = "0" + entity.groupId = "" + entity.yjdw = "" + entity.userName = RuanseeAbitityStag.userCache.getUserCode + entity.idCard = RuanseeAbitityStag.userCache.getIdCardNum + entity.deptId = RuanseeAbitityStag.userCache.getDeptCode + entity.deptName = RuanseeAbitityStag.userCache.getDeptName + entity.orgCode = RuanseeAbitityStag.userCache.getDeptCode + entity.orgName = RuanseeAbitityStag.userCache.getDeptName + entity.policeNum = RuanseeAbitityStag.userCache.getUserCode + entity.policeName = RuanseeAbitityStag.userCache.getUserName + entity.policeIdCard = RuanseeAbitityStag.userCache.getIdCardNum + + let model: CheckSubmitModel = new CheckSubmitModel(); + model.checkHistoryEntity = entity; + model.personIds = [] + model.carIds = [] + + saveMainHistoryAndChangeStatus(model) + .then((res) => { + console.debug(JSON.stringify(res)); + if (res.code == 200) { + ToastUtils.toastCenter("提交成功"); + this.pageClear(); + } else { + ToastUtil.showToast(res.msg) + } + }) + .catch((error: AxiosError) => { + console.error(error.message) + ToastUtil.showToast(error.message) + }) + } + + /** + * 取消关注 + */ + cancelAttention() { + //操作确认类弹出框 + this.dialogID = DialogHelper.showAlertDialog({ + content: "你确认取消关注该人员吗?", + onAction: (action) => { + if (action == DialogAction.CANCEL) { + ToastUtil.showToast(`您点击了取消按钮`); + } else if (action == DialogAction.SURE) { + ToastUtil.showToast(`您点击了确认按钮`); + updateFocus(this.peopleIdCard) + .then((res) => { + if (res) { + if (res.code == 200) { + this.attentionStatus = 0; + ToastUtils.toastCenter("取消关注成功!") + } else { + ToastUtils.toastCenter("取消关注失败!" + res.msg) + } + } + }) + .catch((error: AxiosError) => { + ToastUtils.toastCenter("取消关注失败!" + error.message) + }) + } + } + }) + } + + //////////////////////////// UI 部分 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ + build() { + + Stack() { + //底层背景图 + Column() { + Image($r('app.media.ic_check_bg')) + .width(AppConstants.PERCENTAGE_MAX) + .height('29%') + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Start) + + Column() { + //导航栏 + this.navigationBar() + this.searchUI() + this.functionalDomainUI() + + Text('人员详情') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('92%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + + this.peopleInfoUI() + + this.correlationStatisticArea() + + this.checkCountBuilder() + + Row() { + + Button('移交', { type: ButtonType.Normal, stateEffect: true }) + .layoutWeight(1) + .backgroundColor($r('app.color.bull')) + .borderRadius(1) + .onClick(() => { + this.handOver(); + }) + + Button('通过', { type: ButtonType.Normal, stateEffect: true }) + .layoutWeight(1) + .backgroundColor($r('app.color.colorGreen7')) + .onClick(() => { + this.pass(); + }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_84')) + + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.page_background')) + .overlay(createWaterMark()) + + } + + @Builder + navigationBar() { + //导航栏 + Row() { + Image(this.backImage) + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + .padding($r('app.float.default_3')) + .onClick(() => { + if (!this.uiCacheData.isCanExit(this.carNum)) { + this.showNotSubmittedDialog() + return + } + router.back(); + }) + .onTouch((event) => { + if (event.type === TouchType.Down) { + this.backImage = $r('app.media.icon_back2'); + } else if (event.type === TouchType.Up) { + this.backImage = $r('app.media.icon_back3'); + } + }) + .margin($r('app.float.default_15')); + + Column() { + + Text(this.titleName) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_22')) + .layoutWeight(1) + .textAlign(TextAlign.Center); + + Text(this.cardName) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .visibility(StringUtils.isNullOrEmpty(this.cardName) ? Visibility.None : Visibility.Visible) + .margin({ top: $r('app.float.default_3') }); + + } + .layoutWeight(1); + + Column() { + Text('退出任务') + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_14')) + .visibility(this.statusType == 2 ? Visibility.Visible : Visibility.None); + } + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + .margin($r('app.float.default_15')) + .onClick(() => { + if (!this.uiCacheData.isCanExit(this.carNum)) { + ToastUtils.toastBottom("当前盘查数据未提交,请先提交在退出!") + return + } + RuanseeAbitityStag.appCache.setTaskId = "" + RuanseeAbitityStag.appCache.setTaskName = "" + RuanseeAbitityStag.appCache.setCardPointId = "" + RuanseeAbitityStag.appCache.setCardPointName = "" + RuanseeAbitityStag.appCache.setCardLocation("0.0", "0.0", "") + router.back() + }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_48')) + .margin({ top: $r('app.float.default_40') }) + } + + /** + * 盘查次数 + */ + @Builder + checkCountBuilder() { + Row() { + Text('该人员已被盘查 ') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + + Text(this.peopleCheckCount + '') + .fontColor($r('app.color.read')) + .fontSize($r('app.float.text_size_14')); + + Text(' 次') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')); + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .width(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .visibility(this.peopleCheckCount > 0 ? Visibility.Visible : Visibility.Hidden) + .onClick(() => { + let param: SkipCheckCountParam = { + what: 0, + name: StringUtils.get(this.peopleName, ""), + sex: this.peopleSex, + idCardNum: this.peopleIdCard, + birthDate: this.peopleBirth, + nation: this.peopleNation, + address: this.peopleAddress, + photoData: "", + zdlx: this.peopleStatus, + } + router.pushUrl({ url: "ui/pages/PeopleCheckDetailsPages", params: param }) + }) + } + + //搜索框 + @Builder + searchUI() { + Search({ value: this.searchContent, placeholder: '请输入身份证号', controller: this.searchController }) + .fontColor($r('app.color.colorGrey2')) + .placeholderColor($r('app.color.colorGrey2')) + .placeholderFont({ size: 14, weight: 400 }) + .textFont({ size: 16, weight: 400 }) + .searchIcon({ color: $r('app.color.colorGrey2') })// .textAlign(TextAlign.Center) + .onTextSelectionChange((selectionStart: number, selectionEnd: number) => { + if (selectionStart !== selectionEnd) { + this.keyEventObserved.isMultiSelect = true; + this.keyEventObserved.notSelectionStart = selectionStart; + this.keyEventObserved.notSelectionEnd = selectionEnd; + } else { + this.keyEventObserved.isMultiSelect = false; + this.keyEventObserved.selectionStart = selectionStart; + this.keyEventObserved.selectionEnd = selectionEnd; + } + this.keyEventObserved.cursorPosition = selectionStart + this.searchController.caretPosition(this.keyEventObserved.cursorPosition); + + }) + .onChange((value: string) => { + // Clear the contents of the search box. + if (value === '') { + this.searchContent = ''; + this.keyEventObserved.inputContent = ''; + } + // Set the focus of the search box. + this.searchController.caretPosition(this.keyEventObserved.cursorPosition); + }) + .onPaste((value: string, event: PasteEvent) => { + if (value === '') { + this.searchContent = ''; + this.keyEventObserved.inputContent = ''; + } else { + this.searchContent = value + this.keyEventObserved.inputContent = value; + } + // Set the focus of the search box. + this.searchController.caretPosition(this.keyEventObserved.cursorPosition); + }) + .width('92%') + .height($r('app.float.default_43')) + .border({ + color: 'rgba(200, 200, 200, 0.3)', + width: $r('app.float.default_1') + }) + .backgroundColor('rgba(1, 1, 1, 0.3)') + .borderRadius(50) + .margin({ + top: $r('app.float.default_25'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .customKeyboard(this.KeyBoardWindow()) + } + + /** + * 功能区 + */ + @Builder + functionalDomainUI() { + Row() { + Column() { + Image($r('app.media.ic_nfc')) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + Text('NFC') + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .onClick(() => { + ToastUtils.toastCenter("NFC功能暂未开放!") + }) + + Column() { + Image($r('app.media.ic_face')) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + + Text('人像') + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .onClick(() => { + router.pushUrl({ url: "ui/pages/StaticPortraitPage", params: { what: 1 } }) + }) + .layoutWeight(1) + + Column() { + Image($r('app.media.ic_ocr')) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + + Text('OCR') + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .onClick(() => { + router.pushUrl({ url: "ui/pages/OCRTestPages" }) + }) + + Column() { + Image($r('app.media.ic_voice')) + .width($r('app.float.default_32')) + .height($r('app.float.default_32')) + + Text('语音') + .fontSize($r('app.float.text_size_12')) + .fontColor($r('app.color.colorGrey6')) + .margin({ top: $r('app.float.default_5') }) + } + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .onClick(() => { + this.showVioceRecognDialog() + // router.pushUrl({ url: "ui/pages/OCRTestPages" }) + }) + + } + .alignItems(VerticalAlign.Center) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .justifyContent(FlexAlign.Start) + .width('92%') + .height($r('app.float.default_72')) + .margin({ + top: $r('app.float.default_25'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + } + + /** + * 人员信息 + */ + @Builder + peopleInfoUI() { + Column() { + Row() { + //信息区域 + Column() { + Row() { + Text('姓名:') + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + Text(this.peopleName) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .width(AppConstants.PERCENTAGE_MAX) + + Row() { + Row() { + Text('民族:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.peopleNation) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .layoutWeight(1.8) + + Row() { + Text('性别:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.peopleSex) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .layoutWeight(1) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('出生日期:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.peopleBirth) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('手机号码:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.peopleOPhone) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + + Text(this.isUpdatePhone ? "(修改)" : "(添加)") + .fontColor($r('app.color.colorBluen7')) + .fontSize($r('app.float.text_size_16')) + .visibility(StrUtil.isNotEmpty(this.peopleIdCard) ? Visibility.Visible : Visibility.Hidden) + .onClick(() => { + this.showUpdatePhone() + }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('身份证号:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + Text(this.peopleIdCard) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_2') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + Row() { + Text('户籍地址:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + + Text(this.peopleAddress) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .layoutWeight(1) + .margin({ left: $r('app.float.default_2') }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_5') }) + + } + .layoutWeight(1) + .justifyContent(FlexAlign.Start) + .alignItems(HorizontalAlign.Start) + .padding({ + top: $r('app.float.default_10'), + left: $r('app.float.default_10'), + right: $r('app.float.default_10') + }) + + //照片区域 + Column() { + + Image(this.peoplePhoto) + .width($r('app.float.default_84')) + .height($r('app.float.default_110')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey4') + }) + .objectFit(ImageFit.Fill) + + Row() { + Text('证件') + .fontColor(this.photoStatus ? $r('app.color.colorBluen7') : $r('app.color.colorGrey3')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .onClick(() => { + if (StringUtils.isNullOrEmpty(this.peopleIdCard)) { + ToastUtils.toastCenter("请先盘查人员!") + return + } + this.peoplePhoto = this.uiCacheData.idCardPhoto + this.photoStatus = true; + }) + + Divider() + .width($r('app.float.default_1')) + .height('96%') + .color($r('app.color.colorGrey3')) + .backgroundColor($r('app.color.colorGrey4')) + + Text('现场') + .fontColor(this.photoStatus ? $r('app.color.colorGrey3') : $r('app.color.colorBluen7')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + .onClick(() => { + if (StringUtils.isNullOrEmpty(this.peopleIdCard)) { + ToastUtils.toastCenter("请先盘查人员!") + return + } + if (this.uiCacheData.isXczp) { + this.peoplePhoto = this.uiCacheData.xczpUrl + this.photoStatus = false; + return + } + this.takePhoto() + }) + .textAlign(TextAlign.Center) + + } + .width('90%') + .height($r('app.float.default_26')) + .borderRadius(50) + .backgroundColor('rgba(1, 1, 1, 0.4)') + .margin({ top: $r('app.float.default_5') }) + + } + .width($r('app.float.default_120')) + .padding({ top: $r('app.float.default_15'), bottom: $r('app.float.default_10') }) + + } + .alignItems(VerticalAlign.Top) + + Divider() + .width('98%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey1')) + .margin({ left: $r('app.float.default_10'), top: $r('app.float.default_10') }) + + Row() { + Text('人员属性:') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: $r('app.float.default_15') }) + + List() { + ForEach(this.zdlxImg, (item: ZdlxItem) => { + ListItem() { + Image(item.getIcon()) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + } + .onClick(() => { + this.showZdxqDialog(item); + }) + }) + } + .alignListItem(ListItemAlign.Center) + .listDirection(Axis.Horizontal) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + + Text('+关注') + .width('66vp') + .height(AppConstants.PERCENTAGE_MAX) + .textAlign(TextAlign.Center) + .backgroundImage($r('app.media.icon_attention_bg')) + .backgroundImageSize({ width: '66vp', height: '38vp' }) + .padding({ left: '12vp' }) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_14')) + .visibility(this.attentionStatus == 0 ? Visibility.Visible : Visibility.None) + .onClick(() => { + this.showAttentionDialog() + }) + + Image(this.getAttentionRes()) + .width($r('app.float.default_32')) + .visibility(this.attentionStatus > 0 ? Visibility.Visible : Visibility.None) + .height($r('app.float.default_32')) + .margin({ right: $r('app.float.default_8') }) + .onClick(() => { + this.cancelAttention() + }) + + } + .alignItems(VerticalAlign.Center) + .height($r('app.float.default_38')) + .width(AppConstants.PERCENTAGE_MAX) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor($r('app.color.white')) + .borderRadius(5) + .justifyContent(FlexAlign.Start) + .width('92%') + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + .padding({ bottom: $r('app.float.default_2') }) + } + + /** + * 关联统计区域 + */ + @Builder + correlationStatisticArea() { + Row() { + Column() { + Text('同行人员') + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + + Row() { + Text(`总数:${this.checkCount}`) + .fontColor($r('app.color.colorBluen7')) + .fontSize($r('app.float.text_size_12')) + Text(`异常:${this.errorCount}`) + .fontColor($r('app.color.read')) + .fontSize($r('app.float.text_size_12')) + .margin({ left: $r('app.float.default_5') }) + } + .width(AppConstants.PERCENTAGE_MAX) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .margin({ top: $r('app.float.default_5') }) + } + .height(AppConstants.PERCENTAGE_MAX) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .layoutWeight(1) + .margin({ right: $r('app.float.default_5') }) + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), // 阴影模糊半径 + color: $r('app.color.main_tj_c'), // 阴影颜色 + offsetX: $r('app.float.default_3'), // X轴偏移 + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .onClick(() => { + if (this.uiCacheData.zcCount == 0) { + ToastUtils.toastBottom("请先盘查人员!") + return + } + router.pushUrl({ url: "ui/pages/AccompPersonPage" }) + }) + + Column() { + Text('同行车辆') + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Text(this.carNum) + .fontColor(this.carNumStatus == 2 ? $r('app.color.bull') : + this.carNumStatus == 1 ? $r('app.color.read') : $r('app.color.colorGrey5')) + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_5') }) + + } + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .height(AppConstants.PERCENTAGE_MAX) + .layoutWeight(1) + .onClick(() => { + let param: SkipCheckCardModel = { + isCardPoint: StrUtil.isNotEmpty(this.cardName) + } + router.pushUrl({ url: "ui/pages/CheckCarPage", params: param }) + }) + .backgroundColor($r('app.color.white')) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), // 阴影模糊半径 + color: $r('app.color.main_tj_c'), // 阴影颜色 + offsetX: $r('app.float.default_3'), // X轴偏移 + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .margin({ right: $r('app.float.default_5'), left: $r('app.float.default_5') }) + + Column() { + Text('随行物品') + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + + Text(this.goodsNum) + .fontColor('添加违禁物品' === this.goodsNum ? $r('app.color.colorGrey5') : $r('app.color.read')) + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_5') }) + + } + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .layoutWeight(1) + .height(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.white')) + .onClick(() => { + router.pushUrl({ url: "ui/pages/CheckGoodsPage" }); + }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.page_background'), + radius: $r('app.float.default_5') + }) + // 阴影效果 + .shadow({ + radius: $r('app.float.default_5'), // 阴影模糊半径 + color: $r('app.color.main_tj_c'), // 阴影颜色 + offsetX: $r('app.float.default_3'), // X轴偏移 + offsetY: $r('app.float.default_3') // Y轴偏移 + }) + .margin({ left: $r('app.float.default_5') }) + } + .width('92%') + .height($r('app.float.default_72')) + .margin({ + top: $r('app.float.default_15'), + left: $r('app.float.default_25'), + right: $r('app.float.default_25') + }) + } + + getAttentionRes(): Resource { + if (this.attentionStatus == 1) { + return $r('app.media.icon_attention_leven1'); + } + if (this.attentionStatus == 2) { + return $r('app.media.icon_attention_leven2'); + } + if (this.attentionStatus == 3) { + return $r('app.media.icon_attention_leven3'); + } + return $r('app.media.icon_attention_leven1'); + } + + //自定义身份证键盘 + @Builder + KeyBoardWindow() { + Column() { + Row() { + Image($r('app.media.down')) + .objectFit(ImageFit.Contain) + .aspectRatio(CommonConstants.IMAGE_ASPECT_RATIO) + .width($r('app.float.down_image_size')) + .margin({ top: $r('app.float.down_image_margin'), right: CommonConstants.DOWN_IMAGE_RIGHT }) + .onClick(() => this.searchController.stopEditing()) + } + .justifyContent(FlexAlign.End) + .alignItems(VerticalAlign.Center) + .width(CommonConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.keyboard_background_color')) + + if (this.menuType === CommonConstants.KEYBOARD_TYPE_ID_CARD_NUM) { + IdCardNumKeyboard() + } + } + .backgroundColor(Color.White) + .alignItems(HorizontalAlign.Center) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/util/ArrayListUtils.ets b/entry/src/main/ets/util/ArrayListUtils.ets new file mode 100644 index 0000000..7c7935b --- /dev/null +++ b/entry/src/main/ets/util/ArrayListUtils.ets @@ -0,0 +1,10 @@ +import { ArrayList } from "@kit.ArkTS"; + +export class ArrayListUtils { + static contain(dataList: ArrayList, data: T): boolean { + return dataList.has(data); + } + + +} + diff --git a/entry/src/main/ets/util/BitMapUtils.ets b/entry/src/main/ets/util/BitMapUtils.ets new file mode 100644 index 0000000..7aeb0ac --- /dev/null +++ b/entry/src/main/ets/util/BitMapUtils.ets @@ -0,0 +1,44 @@ +import { buffer } from '@kit.ArkTS'; +import { fileIo } from '@kit.CoreFileKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { image } from '@kit.ImageKit'; + +export class BitMapUtils{ + + static async writeFile(data: string, filesDir :string,fileName:string): Promise { + let fileAbsolutelyPath ="" + try { + let filePath = filesDir+"/" + fileName; + // uri = fileUri.getUriFromPath(filePath); + fileAbsolutelyPath = filePath + let file = fileIo.openSync(filePath, fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE); + console.info("file fd: " + file.fd); + const reg = new RegExp("data:image/\\w+;base64,") + const base64 = data.replace(reg, ""); + console.log("base64flag", base64) + const dataBuffer = buffer.from(base64, 'base64') + let writeLen = fileIo.writeSync(file.fd, dataBuffer.buffer); + hilog.info(0xA0c0d0,'文件长度',writeLen+"") + fileIo.closeSync(file); + } catch (Error) { + hilog.error(0xA0c0d0,'Error',Error.code) + } + return fileAbsolutelyPath; + } + + static async copyPixelMap(pm: image.PixelMap): Promise { + const imageInfo: image.ImageInfo = await pm.getImageInfo(); + const buffer: ArrayBuffer = new ArrayBuffer(pm.getPixelBytesNumber()); + // TODO 知识点:通过readPixelsToBuffer实现PixelMap的深拷贝,其中readPixelsToBuffer输出为BGRA_8888 + await pm.readPixelsToBuffer(buffer); + // TODO 知识点:readPixelsToBuffer输出为BGRA_8888,此处createPixelMap需转为RGBA_8888 + const opts: image.InitializationOptions = { + editable: true, + pixelFormat: image.PixelMapFormat.RGBA_F16, + size: { height: imageInfo.size.height, width: imageInfo.size.width } + }; + return await image.createPixelMap(buffer, opts); + } + +} +// data为需要转换的base64字符串,返回沙箱路径uri \ No newline at end of file diff --git a/entry/src/main/ets/util/BufferUtil.ets b/entry/src/main/ets/util/BufferUtil.ets new file mode 100644 index 0000000..98c736b --- /dev/null +++ b/entry/src/main/ets/util/BufferUtil.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { util } from '@kit.ArkTS'; + +export function bufferToString(buffer: ArrayBufferLike): string { + let textDecoder = util.TextDecoder.create('utf-8', { + ignoreBOM: true + }); + let result = textDecoder.decodeToString(new Uint8Array(buffer), { + stream: true + }); + return result; +} \ No newline at end of file diff --git a/entry/src/main/ets/util/Constant.ets b/entry/src/main/ets/util/Constant.ets new file mode 100644 index 0000000..9ff5332 --- /dev/null +++ b/entry/src/main/ets/util/Constant.ets @@ -0,0 +1,6 @@ +export class Constant{ + public static REFRESH_PULL_TO_REFRESH : string = "下拉可以刷新"; + public static REFRESH_FREE_TO_REFRESH :string = "释放立即刷新" + public static REFRESH_REFRESHING :string ="正在刷新"; + public static REFRESH_SUCCESS :string="刷新成功" +} \ No newline at end of file diff --git a/entry/src/main/ets/util/DateUtils.ts b/entry/src/main/ets/util/DateUtils.ts new file mode 100644 index 0000000..512b569 --- /dev/null +++ b/entry/src/main/ets/util/DateUtils.ts @@ -0,0 +1,380 @@ +export enum DateFormat { + //'yyyy-mm-dd' + YYYYhMMhDD, + //'yyyy-mm-dd HH:mm:ss' + YYYYhMMhDDkHHdMMdSS, + //'yyyy-mm-dd HH:mm:ss.sss' + YYYYhMMhDDkHHdMMdSSdSSS, + //yyyy/mm/dd + YYYYxMMxDD, + //yyyy/mm/dd HH:mm:ss + YYYYxMMxDDkHHdMMdSS, + //yyyy/mm/dd HH:mm:ss.sss + YYYYxMMxDDkHHdMMdSSdSSS, + //yyyy年mm月dd + YYYYnMMyDDr, + //yyyy年mm月dd日 HH:mm:ss + YYYYnMMyDDrkHHdMMdSS, + //yyyy年mm月dd日 HH:mm:ss.sss + YYYYnMMyDDrkHHdMMdSSdSSS, +} + +export class DateUtils { + static formatDateStr(nowData: Date | undefined | null, format: DateFormat | undefined | null): string { + if (nowData == null || nowData == undefined) { + nowData = new Date(); + } + //年 + let year = nowData.getFullYear() + //月 + let month = ("0" + (nowData.getMonth() + 1)).slice(-2); // 月份是从0开始计数的,所以需要加1 + //日 + let day = ("0" + nowData.getDate()).slice(-2); // 为了保证始终是两位数,不足两位前面补0 + //时 + let hours = nowData.getHours()>9?nowData.getHours():`0${nowData.getHours()}`; + //分 + let minutes = nowData.getMinutes()>9?nowData.getMinutes():`0${nowData.getMinutes()}`; + //秒 + let seconds = nowData.getSeconds()>9?nowData.getSeconds():`0${nowData.getSeconds()}`; + //毫秒 + let milliSeconds = nowData.getMilliseconds(); + if (format == null || format == undefined) { + format = DateFormat.YYYYhMMhDDkHHdMMdSS + } + if (format == DateFormat.YYYYhMMhDD) { + return year + "-" + month + "-" + day + } + if (format == DateFormat.YYYYhMMhDDkHHdMMdSS) { + return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + } + if (format == DateFormat.YYYYhMMhDDkHHdMMdSSdSSS) { + return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds + "." + milliSeconds + } + if (format == DateFormat.YYYYxMMxDD) { + return year + "/" + month + "/" + day + } + if (format == DateFormat.YYYYxMMxDDkHHdMMdSS) { + return year + "/" + month + "/" + day + " " + hours + ":" + minutes + ":" + seconds + } + if (format == DateFormat.YYYYxMMxDDkHHdMMdSSdSSS) { + return year + "/" + month + "/" + day + " " + hours + ":" + minutes + ":" + seconds + "." + milliSeconds + } + if (format == DateFormat.YYYYnMMyDDr) { + return year + "年" + month + "月" + day + "日" + } + if (format == DateFormat.YYYYnMMyDDrkHHdMMdSS) { + return year + "年" + month + "月" + day + "日 " + hours + ":" + minutes + ":" + seconds + } + if (format == DateFormat.YYYYnMMyDDrkHHdMMdSSdSSS) { + return year + "年" + month + "月" + day + "日 " + hours + ":" + minutes + ":" + seconds + "." + milliSeconds + } + return year + "-" + month + "-" + day + } + + static pastStrDate(strDate: string | null): Date | null { + if (strDate == null) { + return null; + } + let formatting = strDate.trim() + // .replaceAll(' ', '') + // .replace(' ', '') + // .replaceAll('-', "") + // .replace('-', "") + // .replaceAll('.', "") + // .replace('.', "") + // .replaceAll('/', "") + // .replace('/', "") + // .replace('年', "") + // .replace('月', "") + // .replace('日', "") + // .replaceAll(':', "") + // .replace(':', "") + // .replaceAll('—', "") + // .replace('—', "") + // .replaceAll(':', "") + // .replace(':', "") + // .replaceAll('。', "") + // .replace('。', "") + // .trim() + + let f = new Array(); + for (let i = 0; i < formatting.length; i++) { + let s = formatting.charAt(i); + if (!this.isNum(s)) { + f.push(s) + } + } + + for (let i = 0; i < f.length; i++) { + formatting = formatting.replace(f[i], "") + } + + switch (formatting.length) { + case 4: + return new Date(formatting) + case 6: //202306 + let y = formatting.substring(0, 4) + let m = formatting.substring(4, 6) + return new Date(y + "-" + m) + case 8: //20230612 + y = formatting.substring(0, 4) + m = formatting.substring(4, 6) + let d = formatting.substring(6, 8) + return new Date(y + "-" + m + "-" + d) + case 10: //2023061211 + y = formatting.substring(0, 4) + m = formatting.substring(4, 6) + d = formatting.substring(6, 8) + let h = formatting.substring(8, 10) + return new Date(y + "-" + m + "-" + d + " " + h) + case 12: //2023061211 + y = formatting.substring(0, 4) + m = formatting.substring(4, 6) + d = formatting.substring(6, 8) + h = formatting.substring(8, 10) + let f = formatting.substring(10, 12) + return new Date(y + "-" + m + "-" + d + " " + h + ":" + f) + case 14: //20230612101533 + y = formatting.substring(0, 4) + m = formatting.substring(4, 6) + d = formatting.substring(6, 8) + h = formatting.substring(8, 10) + f = formatting.substring(10, 12) + let ms = formatting.substring(12, 14) + return new Date(y + "-" + m + "-" + d + " " + h + ":" + f + ":" + ms) + case 17: //20230612101533333 + y = formatting.substring(0, 4) + m = formatting.substring(4, 6) + d = formatting.substring(6, 8) + h = formatting.substring(8, 10) + f = formatting.substring(10, 12) + ms = formatting.substring(12, 14) + let hms = formatting.substring(14, 17) + return new Date(y + "-" + m + "-" + d + " " + h + ":" + f + ":" + ms + '.' + hms) + default : + return null + } + } + + /** + * 将 "M/D/YY, h:mm A" 时间格式字符 转换成 "yyyy-MM-dd HH:mm:ss" + * @param dateStr 8/12/25, 3:23 PM + * @returns 2025-08-12 15:23:00 + */ + static formatMdyHmA(dateStr: string): string { + if (dateStr == null||dateStr == undefined ||dateStr.toString().trim().length<1) { + return ""; + } + // 解析原始时间字符串 + const [datePart, timePart] = dateStr.split(", "); + const [month, day, year] = datePart.split("/").map(Number); + const [time, period] = timePart.split(" "); + const [hoursStr, minutesStr] = time.split(":"); + let hours = parseInt(hoursStr, 10); + const minutes = parseInt(minutesStr, 10); + + // 处理 AM/PM + if (period === "PM" && hours < 12) hours += 12; + if (period === "AM" && hours === 12) hours = 0; + + // 补零操作 + const pad = (num: number) => num.toString().padStart(2, "0"); + return "yyyy-MM-dd HH:mm:ss" + .replace("yyyy", `${2000 + year}`) // 假设年份简写为后两位(如25表示2025) + .replace("MM", pad(month)) + .replace("dd", pad(day)) + .replace("HH", pad(hours)) + .replace("mm", pad(minutes)) + .replace("ss", "00"); // 秒数未提供,默认补零 + } + + /** + * 数字验证 + * + * @param val 需要验证的字符串 + */ + public static isNum(val: string): boolean { + const reg = new RegExp('^[0-9]*$'); + return val != null && "" != (val) && reg.test(val); + } + + /** + * 获取日期字符 + * @param nowData 日期 + * @returns yyyy-MM-dd + */ + static getNowDats(nowData: Date | null): string { + if (!nowData) { + nowData = new Date(); + } + let year = nowData.getFullYear() + let month = ("0" + (nowData.getMonth() + 1)).slice(-2); // 月份是从0开始计数的,所以需要加1 + let day = ("0" + nowData.getDate()).slice(-2); // 为了保证始终是两位数,不足两位前面补0 + return year + "-" + month + "-" + day + } + + /** + * 当获取指定日期工作周的第一天 + * @param nowData + * @returns yyyy-MM-dd + */ + static getWeekFirstDay(nowData: Date | null): string { + if (!nowData) { + nowData = new Date(); + } + const currentDay = nowData.getDay(); // 0(星期日)到 6(星期六) + let firstDay = new Date() + firstDay.setDate(nowData.getDate() - currentDay + 1) + + return firstDay.getFullYear() + "-" + ("0" + (firstDay.getMonth() + 1)).slice(-2) + "-" + + ("0" + firstDay.getDate()).slice(-2); + } + + /** + * 当获取指定日期工作周的最后一天时间 + * @param nowData + * @returns yyyy-MM-dd + */ + static getWeekLastDay(nowData: Date | null): string { + if (!nowData) { + nowData = new Date(); + } + const currentDay = nowData.getDay(); // 0(星期日)到 6(星期六) + let lastDay = new Date() + lastDay.setDate(nowData.getDate() + (6 - currentDay + 1)) + + return lastDay.getFullYear() + "-" + ("0" + (lastDay.getMonth() + 1)).slice(-2) + "-" + + ("0" + lastDay.getDate()).slice(-2); + + } + + /** + * 获取指定日期所在月份的最后一天 + * @param nowData + * @returns yyyy-MM-dd + */ + static getLastDayOfMonth(nowData: Date | null): string { + if (!nowData) { + nowData = new Date(); + } + let year = nowData.getFullYear(); // 获取当前年份 + let month = nowData.getMonth(); // 获取当前月份(从0开始) + // 创建一个表示当前月份最后一天的Date对象 + let lastDayOfMonth = new Date(year, month + 1, 0); + return lastDayOfMonth.getFullYear() + "-" + ("0" + (lastDayOfMonth.getMonth() + 1)).slice(-2) + "-" + + ("0" + lastDayOfMonth.getDate()).slice(-2); + } + + /** + * 获取当前日期是第几周 + * @param dateTime 当前传入的日期值 + * @returns 返回第几周数字值 + */ + static getWeek(dateTime: Date): number { + const temptTime = new Date(dateTime); + const weekday = temptTime.getDay() || 7; // 周几 (0-6,0代表星期天) + + // 调整日期到上周一 + temptTime.setDate(temptTime.getDate() - weekday + 1); + const firstDay = new Date(temptTime.getFullYear(), 0, 1); + + // 获取第一周的第一天 + const dayOfWeek = firstDay.getDay(); + const spendDay = dayOfWeek === 0 ? 7 : 7 - dayOfWeek + 1; + + // 计算周数 + const startOfYear = new Date(temptTime.getFullYear(), 0, 1 + spendDay); + const days = Math.ceil((temptTime.getTime() - startOfYear.getTime()) / 86400000); + return Math.ceil(days / 7); + } + + /** + * 将时间转换为 `几秒前`、`几分钟前`、`几小时前`、`几天前` + * @param param 当前时间,new Date() 格式或者字符串时间格式 + * @param format 需要转换的时间格式字符串 + * @returns 返回拼接后的时间字符串 + */ + static formatPast(param: string | Date, format: string = 'YYYY-mm-dd'): string { + const time = new Date().getTime(); + let t = typeof param === 'string' || param instanceof Date ? new Date(param).getTime() : param; + const diff = time - t; + + if (diff < 10000) { + return '刚刚'; + } // 10秒内 + if (diff < 60000) { + return `${Math.floor(diff / 1000)}秒前`; + } // 少于1分钟 + if (diff < 3600000) { + return `${Math.floor(diff / 60000)}分钟前`; + } // 少于1小时 + if (diff < 86400000) { + return `${Math.floor(diff / 3600000)}小时前`; + } // 少于24小时 + if (diff < 259200000) { + return `${Math.floor(diff / 86400000)}天前`; + } // 少于3天 + + return DateUtils.formatDate(new Date(param), format); // 超过3天 + } + + /** + * 时间日期转换 + * @param date 当前时间,new Date() 格式 + * @param format 需要转换的时间格式字符串 + * @returns 返回拼接后的时间字符串 + */ + static formatDate(date: Date, format: string): string { + const week: { [key: string]: string } = { + '0': '日', + '1': '一', + '2': '二', + '3': '三', + '4': '四', + '5': '五', + '6': '六', + }; + const quarter: { [key: string]: string } = { + '1': '一', + '2': '二', + '3': '三', + '4': '四' + }; + + const we = date.getDay(); // 星期 + const z = DateUtils.getWeek(date); // 周 + const qut = Math.floor((date.getMonth() + 3) / 3).toString(); // 季度 + + const opt: { [key: string]: string } = { + 'Y+': date.getFullYear().toString(), + 'm+': (date.getMonth() + 1).toString(), + 'd+': date.getDate().toString(), + 'H+': date.getHours().toString(), + 'M+': date.getMinutes().toString(), + 'S+': date.getSeconds().toString(), + 'q+': quarter[qut], // 季度 + }; + + // 处理格式中的特殊标记 + format = format.replace(/(W+)/, (match) => match.length > 1 ? `周${week[we]}` : week[we]); + format = format.replace(/(Q+)/, (match) => match.length === 4 ? `第${quarter[qut]}季度` : quarter[qut]); + format = format.replace(/(Z+)/, (match) => match.length === 3 ? `第${z}周` : `${z}`); + + // 替换日期格式中的部分 + Object.keys(opt).forEach((key) => { + const reg = new RegExp(`(${key})`); + format = format.replace(reg, (match) => match.length === 1 ? opt[key] : opt[key].padStart(match.length, '0')); + }); + + return format; + } + + /** + * 补零操作 + * @param num + * @returns + */ + public static padZero(num: number): string { + return num.toString().padStart(2, "0"); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/util/FileUtils.ets b/entry/src/main/ets/util/FileUtils.ets new file mode 100644 index 0000000..71847f4 --- /dev/null +++ b/entry/src/main/ets/util/FileUtils.ets @@ -0,0 +1,41 @@ +import { FileUtil } from "@pura/harmony-utils"; + +export class FileUtils { + public static ROOT_DIR: string + public static ID_CARD_DIR: string + public static FILE_DIR: string + public static IMAGE_DIR: string + public static LOG_DIR: string + + constructor() { + } + + /** + * 初始化应用路径 + * @param uiContext + */ + public static init(context: Context) { + if (context) { + FileUtils.ROOT_DIR = context.filesDir; + FileUtils.ID_CARD_DIR = context.filesDir + "/IdCardPhoto"; + FileUtils.FILE_DIR = context.filesDir + "/File"; + FileUtils.IMAGE_DIR = context.filesDir + "/Image"; + FileUtils.LOG_DIR = context.filesDir + "/Log"; + } + } + + public static createFileDir() { + if (!FileUtil.accessSync(FileUtils.ID_CARD_DIR)) { + FileUtil.mkdirSync(FileUtils.ID_CARD_DIR) + } + if (!FileUtil.accessSync(FileUtils.FILE_DIR)) { + FileUtil.mkdirSync(FileUtils.FILE_DIR) + } + if (!FileUtil.accessSync(FileUtils.IMAGE_DIR)) { + FileUtil.mkdirSync(FileUtils.IMAGE_DIR) + } + if (!FileUtil.accessSync(FileUtils.LOG_DIR)) { + FileUtil.mkdirSync(FileUtils.LOG_DIR) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/util/IdCardNumUtils.ets b/entry/src/main/ets/util/IdCardNumUtils.ets new file mode 100644 index 0000000..5fada6e --- /dev/null +++ b/entry/src/main/ets/util/IdCardNumUtils.ets @@ -0,0 +1,143 @@ +import { StringUtils } from "./StringUtils"; + +export class IdCardNumUtils { + /** + * 验证身份证号 + * @param idCardNum 身份证号 + * @returns true or false + */ + public static validateIdCardNum(idCardNum: string): boolean { + if (idCardNum == null) { + return false; + } + let idCardNumS = idCardNum.trim(); + if (idCardNumS.length != 18) { + return false; + } + if (!IdCardNumUtils.checkCode(idCardNumS)) { + return false + } + const date = idCardNumS.substring(6, 14) + if (!IdCardNumUtils.checkDate(date)) { + return false + } + if (IdCardNumUtils.checkProv(idCardNumS.substring(0, 2))) { + return true + } + + return false; + } + + /** + * 数字验证 + * + * @param val 需要验证的字符串 + */ + public static isNum(val: string): boolean { + const reg = new RegExp('^[0-9]*$'); + return val != null && "" != (val) && reg.test(val); + } + + // 省份 + public static checkProv(val: string) { + const pattern = /^[1-9][0-9]/ + const provs: Record = { + 11: '北京', + 12: '天津', + 13: '河北', + 14: '山西', + 15: '内蒙古', + 21: '辽宁', + 22: '吉林', + 23: '黑龙江 ', + 31: '上海', + 32: '江苏', + 33: '浙江', + 34: '安徽', + 35: '福建', + 36: '江西', + 37: '山东', + 41: '河南', + 42: '湖北 ', + 43: '湖南', + 44: '广东', + 45: '广西', + 46: '海南', + 50: '重庆', + 51: '四川', + 52: '贵州', + 53: '云南', + 54: '西藏 ', + 61: '陕西', + 62: '甘肃', + 63: '青海', + 64: '宁夏', + 65: '新疆', + 71: '台湾', + 81: '香港', + 82: '澳门' + } + if (pattern.test(val)) { + if (provs[val]) { + return true + } + } + return false + } + + // 出生日期 + private static checkDate(val: string) { + const pattern = + /^(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)$/ + if (pattern.test(val)) { + const year = val.substring(0, 4) + const month = val.substring(4, 6) + const date = val.substring(6, 8) + const date2 = new Date(year + '-' + month + '-' + date) + if (date2 && date2.getMonth() === parseInt(month) - 1) { + return true + } + } + return false + } + + // 校验码校验 + private static checkCode(val: string) { + const p = + /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/ + const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] + const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2] + const code = val.substring(17) + if (p.test(val)) { + let sum = 0 + for (let i = 0; i < 17; i++) { + sum += Number(val.charAt(i)) * factor[i] + } + if (parity[sum % 11].toString() === code.toUpperCase()) { + return true + } + } + return false + } + + + + public static isCarNumberNO(carNumber: string): boolean { + if (StringUtils.isNullOrEmpty(carNumber)) { + return false; + } + //两车同用 + const carTreg = + /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([ADF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[ADF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})$/ + return carTreg.test(carNumber); + } + + //简称 + public static isJc(cph: string): boolean { + if (StringUtils.isNullOrEmpty(cph)) { + return false; + } + const ss = /^[A-Z]$/; + return ss.test(cph); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/util/IdGeneratedUtils.ets b/entry/src/main/ets/util/IdGeneratedUtils.ets new file mode 100644 index 0000000..6a176e0 --- /dev/null +++ b/entry/src/main/ets/util/IdGeneratedUtils.ets @@ -0,0 +1,37 @@ +import { util } from "@kit.ArkTS"; +import { StrUtil } from "@pura/harmony-utils/src/main/ets/utils/StrUtil"; +import { systemTime } from "@kit.BasicServicesKit"; + +export class IdGeneratedUtils { + private static idGeneratedUtils = new IdGeneratedUtils(""); + private static idCardNum: string = ""; + + private constructor(idCardNum: string) { + IdGeneratedUtils.idCardNum = idCardNum + } + + public static getInstance(idCardNum: string): IdGeneratedUtils { + if (IdGeneratedUtils.idGeneratedUtils == null || IdGeneratedUtils.idCardNum !== idCardNum) { + IdGeneratedUtils.idGeneratedUtils = new IdGeneratedUtils(idCardNum) + } + return IdGeneratedUtils.idGeneratedUtils; + } + + public generatedRandomID(): string { + let uuid = util.generateRandomUUID(false).replaceAll("-", "").replaceAll("-", ""); + if (StrUtil.isNotEmpty(IdGeneratedUtils.idCardNum)) { + let start = IdGeneratedUtils.idCardNum.substring(0, IdGeneratedUtils.idCardNum.length - 1); + let end = IdGeneratedUtils.idCardNum.substring(IdGeneratedUtils.idCardNum.length - 1); + let startStr = parseInt(start).toString(16).toUpperCase() + return startStr + end + uuid + (this.getRandomInt(1,1000) + 1000); + }else { + return Date.now()+uuid+ (this.getRandomInt(1,1000) + 1000); + } + } + + // 生成指定范围的随机整数 + getRandomInt(min: number, max: number): number { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/util/PixelMapUtils.ets b/entry/src/main/ets/util/PixelMapUtils.ets new file mode 100644 index 0000000..2d4d555 --- /dev/null +++ b/entry/src/main/ets/util/PixelMapUtils.ets @@ -0,0 +1,27 @@ +import image from '@ohos.multimedia.image'; +import fileio from '@ohos.fileio'; +import buffer from '@ohos.buffer'; + +export class PixelMapUtils { + static async pixelMapToBase64(pixelMap: image.PixelMap): Promise { + // 1. 创建图像打包器 + const imagePacker = image.createImagePacker(); + + // 2. 设置打包选项 (PNG格式) + const packOpts: image.PackingOption = { + format: "image/png", + quality: 100 // 最高质量 + }; + + // 3. 打包到内存缓冲区 + const arrayBuffer = await imagePacker.packing(pixelMap, packOpts); + + // 4. 转换为Base64 + const base64Data = buffer.from(arrayBuffer).toString('base64'); + + // 5. 添加Data URL前缀 + return base64Data; + } + + +} \ No newline at end of file diff --git a/entry/src/main/ets/util/StatusIconUtils.ets b/entry/src/main/ets/util/StatusIconUtils.ets new file mode 100644 index 0000000..dd1efa6 --- /dev/null +++ b/entry/src/main/ets/util/StatusIconUtils.ets @@ -0,0 +1,97 @@ +import { StringUtils } from "./StringUtils" + + +export const getPersonStatusIcon = (peopleStatus: string | undefined) => { + if (peopleStatus == null || peopleStatus == undefined) { + return $r("app.media.ic_type_normal"); + } + if (peopleStatus.startsWith("涉稳")) { + return $r("app.media.ic_type_stability") + } + if (peopleStatus.startsWith("涉恐")) { + return $r("app.media.ic_type_fear") + } + if (peopleStatus.startsWith("关注")) { + return $r("app.media.ic_type_focus") + } + if (peopleStatus.startsWith("云控")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(peopleStatus, "精神")) { + return $r("app.media.ic_type_fine") + } + if (peopleStatus.startsWith("非访")) { + return $r("app.media.ic_type_non") + } + if (peopleStatus.startsWith("前科")) { + return $r("app.media.ic_type_criminal_record") + } + if (StringUtils.containsChar(peopleStatus, "毒")) { + return $r("app.media.ic_type_poison") + } + if (StringUtils.containsChar(peopleStatus, "临")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(peopleStatus, "逃")) { + return $r("app.media.ic_type_escape") + } + return $r("app.media.ic_type_normal"); +} + +export const getCarStatusIcon = (carStatus: string) => { + if (StringUtils.isNullOrEmpty(carStatus)) { + return $r("app.media.ic_type_normal"); + } + if (StringUtils.containsChar(carStatus, "被盗枪")) { + return $r("app.media.ic_type_bdq") + } + if (carStatus.startsWith("关注")) { + return $r("app.media.ic_type_focus") + } + if (carStatus.startsWith("云控")) { + return $r("app.media.ic_type_control") + } + if (StringUtils.containsChar(carStatus, "临")) { + return $r("app.media.ic_type_control") + } + return $r("app.media.ic_type_normal"); +} + +export const getGoodsStatusIcon = (goodsName: string) => { + if (StringUtils.containsChar(goodsName, "车牌")) { + return $r('app.media.log_tp') + } + if (StringUtils.containsChar(goodsName, "枪")) { + return $r('app.media.log_qz') + } + if (StringUtils.containsChar(goodsName, "炸药") || StringUtils.containsChar(goodsName, "雷管")) { + return $r('app.media.log_zylg') + } + if (StringUtils.containsChar(goodsName, "烟火")) { + return $r('app.media.log_yhbz') + } + if (StringUtils.containsChar(goodsName, "危化物品")) { + return $r('app.media.log_whwp') + } + return $r('app.media.icon_qtwp') +} + + +export const getCheckTypeIcon = (checkTypeStr: string) => { + if (StringUtils.containsChar(checkTypeStr, "NFC")) { + return $r('app.media.ic_nfc') + } + if (StringUtils.containsChar(checkTypeStr, "OCR")) { + return $r('app.media.ic_ocr') + } + if (StringUtils.containsChar(checkTypeStr, "人像")) { + return $r('app.media.ic_face') + } + if (StringUtils.containsChar(checkTypeStr, "语音")) { + return $r('app.media.ic_voice') + } + if (StringUtils.containsChar(checkTypeStr, "拍照")) { + return $r('app.media.icon_checkcar_pz') + } + return $r('app.media.ic_keyboard') +} diff --git a/entry/src/main/ets/util/StringUtils.ets b/entry/src/main/ets/util/StringUtils.ets new file mode 100644 index 0000000..9eb76cb --- /dev/null +++ b/entry/src/main/ets/util/StringUtils.ets @@ -0,0 +1,224 @@ +import { resourceManager } from "@kit.LocalizationKit"; + +export class StringUtils { + /** + * 获取字符串, 如果为空则返回默认值, 如果非空则返回该值并拼接endStr到末尾 + * @param value 要获取的字符串 + * @param defValue 默认值 + * @param endStr 要拼接的字符串 + * @returns value+endStr || defValue + */ + static get(value: string | Object | undefined | null, defValue: string, endStr?: string): string { + if (StringUtils.isNullOrEmpty(value)) { + return defValue; + } + if (endStr) { + return String(value) + endStr; + } + return String(value); + } + + /** + * 判断值是否为空 + * @param value + * @returns + */ + static isNullOrEmpty(value: string | Object | undefined | null): boolean { + return value == null || value == undefined || value.toString().trim().length < 1; + } + + /** + * + * @param str 待查找源字符串 + * @param char 待匹配的目标 + * @returns true 表示包含 false 表示不包含 + */ + static containsChar(str: string, char: string): boolean { + //当 str 内含有 char 则返回 char所在位置索引 即 返回值大与 -1 + return str.indexOf(char) > -1; + } + + /** + * 去除JSON字符串 转义字符 + * @param value 需要转译的字符 + * @return 转译后的JSON格式数据 + */ + public static toJsonParaphrase(value: string): string { + if (value == null || value.length < 1) { + return ""; + } + let isJx = true; + while (isJx) { + //去除 \\ + if (StringUtils.containsChar(value, "\\\\")) { + value = value.replace("\\\\", "").replaceAll("\\\\", ""); + } + isJx = StringUtils.containsChar(value, "\\\\"); + } + isJx = true; + while (isJx) { + //转 \" 替换为 " + if (StringUtils.containsChar(value, "\\\"")) { + value = value.replace("\\\"", "\"").replaceAll("\\\"", "\""); + } + isJx = StringUtils.containsChar(value, "\\\""); + } + isJx = true; + while (isJx) { + //转 "{ 替换为 { + if (StringUtils.containsChar(value, "\"{")) { + value = value.replace("\"{", "{").replaceAll("\"{", "{"); + } + isJx = StringUtils.containsChar(value, "\"{"); + } + isJx = true; + while (isJx) { + //转 }" 替换为 } + if (StringUtils.containsChar(value, "}\"")) { + value = value.replace("}\"", "}").replaceAll("}\"", "}"); + } + isJx = StringUtils.containsChar(value, "}\""); + } + isJx = true; + while (isJx) { + //转 "[ 替换为 [ + if (StringUtils.containsChar(value, "\"[")) { + value = value.replace("\"[", "[").replaceAll("\"[", "["); + } + isJx = StringUtils.containsChar(value, "\"["); + } + isJx = true; + while (isJx) { + //转 ]" 替换为 ] + if (StringUtils.containsChar(value, "]\"")) { + value = value.replace("]\"", "]").replaceAll("]\"", "]"); + } + isJx = StringUtils.containsChar(value, "]\""); + } + return value; + } + + /** + * 生成指定范围内的随机数 + * @param min 最小数(包含) + * @param max 最大数(不包含) + * @return 随机数 + */ + public static randomNumber(min: number, max: number): number { + return Math.floor(Math.random() * (max - min) + min); + } + + + public static getResourceString(context: Context, resource: Resource): string { + let resourceString: string = ''; + try { + resourceString = context.resourceManager.getStringSync(resource.id); + } catch (error) { + console.error('getResourceString err:' + JSON.stringify(error)); + } + return resourceString; + } + + /** + * 将小数转换为百分比 + * @param decimalString 0.521 + * @returns 52.10% + */ + public static convertToPercentage(decimalString: string): string { + // 将字符串转换为数字 + const decimalNumber = parseFloat(decimalString); + + // 转换为百分比并保留两位小数 + const percentage = (decimalNumber * 100).toFixed(2); + + // 添加百分号 + return `${percentage}%`; + } + + /** + * 转译身份证号 + */ + public static translationIdCardNum(value: string): string { + if (StringUtils.isNullOrEmpty(value)) { + return ""; + } + return value + .replaceAll("一", "1") + .replaceAll("义", "1") + .replaceAll("二", "2") + .replaceAll("三", "3") + .replaceAll("四", "4") + .replaceAll("是", "4") + .replaceAll("五", "5") + .replaceAll("六", "6") + .replaceAll("七", "7") + .replaceAll("八", "8") + .replaceAll("吧", "8") + .replaceAll("九", "9") + .replaceAll("十", "10") + .replaceAll("零", "0") + .replaceAll("壹", "1") + .replaceAll("贰", "2") + .replaceAll("叁", "3") + .replaceAll("肆", "4") + .replaceAll("伍", "5") + .replaceAll("陆", "6") + .replaceAll("柒", "7") + .replaceAll("捌", "8") + .replaceAll("玖", "9") + .replaceAll("拾", "10") + .replaceAll("领", "0") + .replaceAll("零", "0") + .replaceAll("腰", "1") + .replaceAll("妖", "1") + .replaceAll("幺", "1") + .replaceAll("腰", "1") + .replaceAll("叉", "X") + .replaceAll("×", "X") + .toUpperCase() + } + + /** + * 转译车牌号码 + */ + public static translationCarNum(value: string): string { + if (StringUtils.isNullOrEmpty(value)) { + return ""; + } + return value + .replaceAll("一", "1") + .replaceAll("义", "1") + .replaceAll("二", "2") + .replaceAll("三", "3") + .replaceAll("四", "4") + .replaceAll("是", "4") + .replaceAll("五", "5") + .replaceAll("六", "6") + .replaceAll("七", "7") + .replaceAll("八", "8") + .replaceAll("吧", "8") + .replaceAll("九", "9") + .replaceAll("十", "10") + .replaceAll("零", "0") + .replaceAll("壹", "1") + .replaceAll("贰", "2") + .replaceAll("叁", "3") + .replaceAll("肆", "4") + .replaceAll("伍", "5") + .replaceAll("陆", "6") + .replaceAll("柒", "7") + .replaceAll("捌", "8") + .replaceAll("玖", "9") + .replaceAll("拾", "10") + .replaceAll("领", "0") + .replaceAll("零", "0") + .replaceAll("腰", "1") + .replaceAll("妖", "1") + .replaceAll("幺", "1") + .replaceAll("腰", "1") + .replaceAll("埃克斯", "X") + .replaceAll("叉", "X") + .replaceAll("×", "X") + .toUpperCase() + } +} \ No newline at end of file diff --git a/entry/src/main/ets/util/ToasUtils.ets b/entry/src/main/ets/util/ToasUtils.ets new file mode 100644 index 0000000..c59c3d6 --- /dev/null +++ b/entry/src/main/ets/util/ToasUtils.ets @@ -0,0 +1,19 @@ +import { promptAction } from "@kit.ArkUI"; + +export class ToastUtils{ + + public static toastCenter(msg:string|Resource){ + promptAction.showToast({ + message: msg, + duration: 1200, + alignment:Alignment.Center + }) + } + public static toastBottom(msg:string|Resource){ + promptAction.showToast({ + message: msg, + duration: 1200, + bottom: 100 + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/util/VibratorUtils.ets b/entry/src/main/ets/util/VibratorUtils.ets new file mode 100644 index 0000000..d35a358 --- /dev/null +++ b/entry/src/main/ets/util/VibratorUtils.ets @@ -0,0 +1,26 @@ + +import vibrator from "@ohos.vibrator" +export class VibratorUtils{ + + static startVibrator(){ + vibrator.startVibration({type:"time",duration:1000},{usage:'alarm'}) + .then(()=>{ + console.warn("开始震动成功!") + }) + .catch((error:Error)=>{ + console.error("开始震动失败:"+JSON.stringify(error)) + }) + } + + static stopVibrator(){ + vibrator.stopVibration() + .then(()=>{ + console.warn("停止震动成功!") + }) + .catch((error:Error)=>{ + console.error("停止震动失败:"+JSON.stringify(error)) + }) + } + + +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/BaseTopTar.ets b/entry/src/main/ets/view/custom/BaseTopTar.ets new file mode 100644 index 0000000..4abde72 --- /dev/null +++ b/entry/src/main/ets/view/custom/BaseTopTar.ets @@ -0,0 +1,85 @@ +import { router } from "@kit.ArkUI" +import AppConstants from "../../app/AppConstant" +import { StringUtils } from "../../util/StringUtils" + +@Component +export struct BaseTopBar{ + @State title:string|Resource='' + // @State subtitle:string|null=null + @State leftText:string|null=null + @State leftImage:Resource = $r('app.media.icon_back3') + + @State rightText:string|Resource|null=null + @State rightImage:Resource |null =null + + //回退 + leftClickEvent?:()=>void + //右边按钮 + rightClickEvent?:()=>void + + build() { + Row() { + Row(){ + Image(this.leftImage) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + + Text(this.leftText) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_14')) + .visibility(StringUtils.isNullOrEmpty(this.leftText)?Visibility.None:Visibility.Visible) + } + .height(AppConstants.PERCENTAGE_MAX) + .width($r('app.float.default_68')) + .alignItems(VerticalAlign.Bottom) + .padding({ left:$r('app.float.default_10') }) + .onTouch((event) => { + if (event.type === TouchType.Down) { + this.leftImage = $r('app.media.icon_back2'); + } else if (event.type === TouchType.Up) { + this.leftImage = $r('app.media.icon_back3'); + } + }) + .onClick(() => { + if (this.leftClickEvent) { + this.leftClickEvent() + } + router.back() + }) + + Text(this.title) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_18')) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .margin({ bottom: $r('app.float.default_2'), left: $r('app.float.default_10') ,right: $r('app.float.default_10') }) + + Row(){ + Image(this.rightImage) + .width($r('app.float.default_24')) + .height($r('app.float.default_24')) + .visibility(this.rightImage == null?Visibility.None:Visibility.Visible) + + Text(this.rightText) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_14')) + .visibility(StringUtils.isNullOrEmpty(this.rightText)?Visibility.None:Visibility.Visible) + + } + .alignItems(VerticalAlign.Bottom) + .height(AppConstants.PERCENTAGE_MAX) + .width($r('app.float.default_68')) + .padding({ right: $r('app.float.default_10') }) + .onClick(() => { + if (this.rightClickEvent) { + this.rightClickEvent() + } + }) + } + .alignItems(VerticalAlign.Bottom) + .padding({ bottom: 10 }) + .width('100%') + .backgroundColor($r('app.color.bull')) + .height($r('app.float.default_88')) + } +} diff --git a/entry/src/main/ets/view/custom/CardPortListItem.ets b/entry/src/main/ets/view/custom/CardPortListItem.ets new file mode 100644 index 0000000..1293619 --- /dev/null +++ b/entry/src/main/ets/view/custom/CardPortListItem.ets @@ -0,0 +1,53 @@ +import AppConstants from "../../app/AppConstant"; +import { CardProtModel } from "../../model/uiModel/SelectTask"; + +//64855357 + +@Component +export struct CardPortListItem { + @ObjectLink item: CardProtModel; + onSelect?: (item: CardProtModel) => void + + build() { + Row() { + Text(this.item.orgName) + .layoutWeight(1) + .fontColor(this.item.isSelect ? $r('app.color.colorBluen8') : $r('app.color.colorGrey7')) + .fontSize($r('app.float.text_size_14')) + .onClick(() => { + // 点击文本时触发选择 + if (this.onSelect) { + this.onSelect(this.item) + } + }) + + Radio({ + value: 'Radio1', group: 'radioGroup', + indicatorType: RadioIndicatorType.TICK + }) + .checked(this.item.isSelect) + .height($r('app.float.default_20')) + .width($r('app.float.default_20')) + .onChange((isChecked: boolean) => { + // 只有选中时才触发选择事件,实现单选 + if (isChecked && this.onSelect) { + this.onSelect(this.item) + } + }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .padding({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_6'), + bottom: $r('app.float.default_6') + }) + // 添加按压效果提升用户体验 + .useEffect(true) + .backgroundColor(this.item.isSelect + ? $r('app.color.colorBluen1') + : Color.Transparent) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/EmptyOrErrorItemView.ets b/entry/src/main/ets/view/custom/EmptyOrErrorItemView.ets new file mode 100644 index 0000000..6204f0e --- /dev/null +++ b/entry/src/main/ets/view/custom/EmptyOrErrorItemView.ets @@ -0,0 +1,30 @@ +import AppConstants from "../../app/AppConstant" + +/** + * 空数据或者错误Item + */ +@Component +export struct EmptyOrErrorItemView { + @State type: number= 0 + @State msg: string= "暂无数据" + + + build() { + Column() { + Image(this.type == 0 ? $r('app.media.icon_empty') : $r('app.media.icon_error2')) + .width($r('app.float.default_80')) + .height($r('app.float.default_80')) + + Text(this.msg) + .fontSize($r('app.float.text_size_14')) + .fontColor($r('app.color.colorGrey6')) + .textAlign(TextAlign.Center) + .margin({ top: $r('app.float.default_10') }) + + } + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .width(AppConstants.PERCENTAGE_MAX) + .height(AppConstants.PERCENTAGE_MAX) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/HandOverSelectCarItem.ets b/entry/src/main/ets/view/custom/HandOverSelectCarItem.ets new file mode 100644 index 0000000..06c5718 --- /dev/null +++ b/entry/src/main/ets/view/custom/HandOverSelectCarItem.ets @@ -0,0 +1,50 @@ +import AppConstants from "../../app/AppConstant"; +import { CarItemBean } from "../../model/uiModel/HandOverModel"; +import { getCarStatusIcon } from "../../util/StatusIconUtils"; + + +@Component +export struct HandOverSelectCarItem { + @ObjectLink item: CarItemBean; + + build() { + Row() { + Image(getCarStatusIcon(this.item.carZdlx)) + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + + Column() { + Text(this.item.hphm) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .layoutWeight(1) + Text(this.item.hpzl) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + Text(this.item.sfzh) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + } + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) + .align(Alignment.TopStart) + .margin({left:$r('app.float.default_8'),right:$r('app.float.default_8')}) + .layoutWeight(1) + .height($r('app.float.default_68')) + + Image(this.item.isSelect?$r('app.media.check_box'):$r('app.media.icon_item_defautle')) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + + } + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .justifyContent(FlexAlign.Start) + .padding({ top: $r('app.float.default_5'), bottom: $r('app.float.default_5') }) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .width(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.white')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/HandOverSelectGoodsItem.ets b/entry/src/main/ets/view/custom/HandOverSelectGoodsItem.ets new file mode 100644 index 0000000..3efd27c --- /dev/null +++ b/entry/src/main/ets/view/custom/HandOverSelectGoodsItem.ets @@ -0,0 +1,48 @@ +import AppConstants from "../../app/AppConstant"; +import { GoodsItemBean } from "../../model/uiModel/HandOverModel"; +import { getGoodsStatusIcon } from "../../util/StatusIconUtils"; + + +@Component +export struct HandOverSelectGoodsItem { + @ObjectLink item: GoodsItemBean; + + build() { + Row() { + Image(getGoodsStatusIcon(this.item.name)) + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + + Column() { + Text(this.item.name) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .layoutWeight(1) + + Text(this.item.count) + .fontColor($r('app.color.colorRed9')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + + } + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) + .margin({left:$r('app.float.default_8'),right:$r('app.float.default_8')}) + .align(Alignment.TopStart) + .layoutWeight(1) + .height($r('app.float.default_48')) + + Image($r('app.media.check_box')) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + + } + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .justifyContent(FlexAlign.Start) + .width(AppConstants.PERCENTAGE_MAX) + .padding({ top: $r('app.float.default_5'), bottom: $r('app.float.default_5') }) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .backgroundColor($r('app.color.white')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/HandOverSelectPersonItem.ets b/entry/src/main/ets/view/custom/HandOverSelectPersonItem.ets new file mode 100644 index 0000000..0b54d42 --- /dev/null +++ b/entry/src/main/ets/view/custom/HandOverSelectPersonItem.ets @@ -0,0 +1,49 @@ +import AppConstants from "../../app/AppConstant"; +import { PersonItemBean } from "../../model/uiModel/HandOverModel"; +import { getPersonStatusIcon } from "../../util/StatusIconUtils"; + +@Component +export struct HandOverSelectPersonItem { + @ObjectLink item: PersonItemBean; + + build() { + Row() { + Image(getPersonStatusIcon(this.item.peopleStatusStr)) + .width($r('app.float.default_36')) + .height($r('app.float.default_36')) + + Column() { + Text(this.item.name) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .layoutWeight(1) + // Text(this.item.hpzl) + // .fontColor($r('app.color.colorGrey6')) + // .fontSize($r('app.float.text_size_14')) + // .layoutWeight(1) + Text(this.item.sfz) + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .layoutWeight(1) + } + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) + .align(Alignment.TopStart) + .layoutWeight(1) + .margin({left:$r('app.float.default_8'),right:$r('app.float.default_8')}) + .height($r('app.float.default_52')) + + Image(this.item.isSelect?$r('app.media.check_box'):$r('app.media.icon_item_defautle')) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + + } + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .justifyContent(FlexAlign.Start) + .padding({ top: $r('app.float.default_5'), bottom: $r('app.float.default_5') }) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .backgroundColor($r('app.color.white')) + .width(AppConstants.PERCENTAGE_MAX) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/LoadingView.ets b/entry/src/main/ets/view/custom/LoadingView.ets new file mode 100644 index 0000000..59c6d88 --- /dev/null +++ b/entry/src/main/ets/view/custom/LoadingView.ets @@ -0,0 +1,33 @@ + +@Component +export struct LoadingView{ + @State loadingTips: string|Resource = '正在加载中...' + build() { + Stack() { + Column() { + LoadingProgress() + .width($r('app.float.default_48')) + .width($r('app.float.default_48')) + // Image($r('app.media.ic_load')) + // .height(50) + // .width(50) + // .rotate({angle: this.rotateAngle }) + // .animation({ + // duration: 800, + // iterations: -1, + // curve: Curve.Friction + // }).onAppear(() => { + // this.rotateAngle = 360 + // }) + Text(this.loadingTips) + .fontSize($r('app.float.text_size_15')) + .margin({ top: $r('app.float.default_10') ,left: $r('app.float.default_24'),right: $r('app.float.default_24')}) + } + .justifyContent(FlexAlign.Center) + } + .height($r('app.float.default_150')) + .width($r('app.float.default_200')) + + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/ObservedArray.ets b/entry/src/main/ets/view/custom/ObservedArray.ets new file mode 100644 index 0000000..21ebe44 --- /dev/null +++ b/entry/src/main/ets/view/custom/ObservedArray.ets @@ -0,0 +1,10 @@ +@Observed +export class ObservedArray extends Array { + constructor(args?: T[]) { + if (args instanceof Array) { + super(...args); + } else { + super(); + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/SelectDeptItem.ets b/entry/src/main/ets/view/custom/SelectDeptItem.ets new file mode 100644 index 0000000..79688ff --- /dev/null +++ b/entry/src/main/ets/view/custom/SelectDeptItem.ets @@ -0,0 +1,32 @@ +import AppConstants from "../../app/AppConstant"; +import { SelectDept } from "../../model/uiModel/HandOverModel"; + + +@Component +export struct SelectDeptItem { + @ObjectLink item: SelectDept; + + build() { + Row() { + Text(this.item.deptName) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .layoutWeight(1) + .margin({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .layoutWeight(1) + .height($r('app.float.default_48')) + + Image(this.item.isSelect ? $r('app.media.check_box') : $r('app.media.icon_item_defautle')) + .width($r('app.float.default_26')) + .height($r('app.float.default_26')) + + } + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + .justifyContent(FlexAlign.Start) + .padding({ top: $r('app.float.default_5'), bottom: $r('app.float.default_5') }) + .padding({ left: $r('app.float.default_10'), right: $r('app.float.default_10') }) + .width(AppConstants.PERCENTAGE_MAX) + .backgroundColor($r('app.color.white')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/SelectTaskListItem.ets b/entry/src/main/ets/view/custom/SelectTaskListItem.ets new file mode 100644 index 0000000..501629a --- /dev/null +++ b/entry/src/main/ets/view/custom/SelectTaskListItem.ets @@ -0,0 +1,51 @@ +import AppConstants from "../../app/AppConstant"; +import { SelectTaskObservedModel } from "../../model/uiModel/SelectTask"; + +@Component +export struct SelectTaskListItem { + @ObjectLink item: SelectTaskObservedModel; + onSelect?: (item: SelectTaskObservedModel) => void + + build() { + Row() { + Text(this.item.taskName) + .layoutWeight(1) + .fontColor(this.item.isSelect ? $r('app.color.colorBluen8') : $r('app.color.colorGrey7')) + .fontSize($r('app.float.text_size_14')) + .onClick(() => { + // 点击文本时触发选择 + if (this.onSelect) { + this.onSelect(this.item) + } + }) + + Radio({ + value: 'Radio1', group: 'radioGroup', + indicatorType: RadioIndicatorType.TICK + }) + .checked(this.item.isSelect) + .height($r('app.float.default_20')) + .width($r('app.float.default_20')) + .onChange((isChecked: boolean) => { + // 只有选中时才触发选择事件,实现单选 + if (isChecked && this.onSelect) { + this.onSelect(this.item) + } + }) + + } + .width(AppConstants.PERCENTAGE_MAX) + .padding({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_6'), + bottom: $r('app.float.default_6') + }) + // 添加按压效果提升用户体验 + .useEffect(true) + .backgroundColor(this.item.isSelect + ? $r('app.color.colorBluen1') + : Color.Transparent) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/SpinnerComponent.ets b/entry/src/main/ets/view/custom/SpinnerComponent.ets new file mode 100644 index 0000000..08aa046 --- /dev/null +++ b/entry/src/main/ets/view/custom/SpinnerComponent.ets @@ -0,0 +1,50 @@ +import { GoodsTypeBean } from '../../model/uiModel/GoodsModel'; + +@Component +export struct SpinnerComponent { + @State selectedValue: string = '请选择' + @State isExpanded: boolean = false + @State goodsTypeData: Array|undefined =undefined; + @Prop selectType:GoodsTypeBean|undefined = undefined; + + + build() { + Column() { + // 触发按钮 + Button(this.selectedValue) + .width(200) + .onClick(() => { + animateTo({ duration: 200 }, () => { + this.isExpanded = !this.isExpanded + }) + }) + + // 下拉列表 + if(this.isExpanded) { + List({ space: 10 }) { + ForEach(this.goodsTypeData, (item: GoodsTypeBean) => { + ListItem() { + Text(item.thingsname) + .width(200) + .height(40) + .backgroundColor(Color.White) + .onClick(() => { + animateTo({ duration: 200 }, () => { + this.selectedValue = item.thingsname + this.selectType = item; + this.isExpanded = false + }) + }) + } + }) + } + .width(200) + .constraintSize({ + maxHeight:$r('app.float.default_300') + }) + .border({ width: 1, color: Color.Gray }) + .backgroundColor(Color.White) + } + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/custom/Watermark.ets b/entry/src/main/ets/view/custom/Watermark.ets new file mode 100644 index 0000000..43ce210 --- /dev/null +++ b/entry/src/main/ets/view/custom/Watermark.ets @@ -0,0 +1,52 @@ +import { UserCache } from "../../app/UserCache" +import { DateFormat, DateUtils } from "../../util/DateUtils" +import { StringUtils } from "../../util/StringUtils" + +/** + * 水印模块 + * 水印内容: + * 应用名称 + * 警号(姓名) + * 当前日期(yyyy年MM月dd日) + */ +@Component +@Entry +export struct Watermark { + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Canvas(this.context) + .width("100%") + .height("100%") + .hitTestBehavior(HitTestMode.Transparent) + .onReady(() => { + this.context.fillStyle = '#50AEAEAE' + this.context.font = "14vp" + this.context.textAlign = "left" + this.context.textBaseline = "middle" + + // 在这里绘制文字水印,也可以是图片水印 + for (let i = 0; i < this.context.width / 100; i++) { + this.context.translate(100 + (i * 30), 0) + let j = 0 + for (; j < this.context.height / 100; j++) { + this.context.rotate(-Math.PI / 180 * 30) + // 此处水印数据是写死的,具体请替换为自己的水印 + this.context.fillText(StringUtils.getResourceString(getContext(this), $r('app.string.app_name')), -60, -60) + this.context.fillText(`${UserCache.getUserCache().getUserName}(${UserCache.getUserCache().getUserCode})`, -60, -40) + this.context.fillText(DateUtils.formatDateStr(null, DateFormat.YYYYnMMyDDr), -60, -20) + this.context.rotate(Math.PI / 180 * 30) + this.context.translate(0, 150) + } + this.context.translate(0, -180 * j) + } + }) + } +} + +@Builder +export function createWaterMark() { + Watermark() + .hitTestBehavior(HitTestMode.None) // 必须设置其触摸测试为None或Transparent,否则正常组件无法响应事件 +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/AddGoodsDialog.ets b/entry/src/main/ets/view/dialog/AddGoodsDialog.ets new file mode 100644 index 0000000..70aed36 --- /dev/null +++ b/entry/src/main/ets/view/dialog/AddGoodsDialog.ets @@ -0,0 +1,38 @@ +import { it } from "@ohos/hypium"; +import { GoodsTypeBean } from "../../model/uiModel/GoodsModel"; + +/** + * 重点信息弹框 + */ +@CustomDialog +export struct AddGoodsDialog { + controller: CustomDialogController + @State goodsTypeData: Array | undefined = undefined; + + clickItem?:(bean:GoodsTypeBean,selectIndex:number)=>void + + build() { + Column() { + List() { + ForEach(this.goodsTypeData, (item: GoodsTypeBean,index:number) => { + ListItem() { + Text(item.thingsname) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + .height($r('app.float.default_40')) + } + .width('98%') + .onClick(() => { + if(this.clickItem){ + this.clickItem(item,index) + } + }) + }) + } + } + .backgroundColor($r('app.color.white')) + .padding($r('app.float.default_20')) + .width('88%') + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/AttentionDialog.ets b/entry/src/main/ets/view/dialog/AttentionDialog.ets new file mode 100644 index 0000000..a8117a8 --- /dev/null +++ b/entry/src/main/ets/view/dialog/AttentionDialog.ets @@ -0,0 +1,218 @@ +import AppConstants from "../../app/AppConstant" +import { cardRoundBorderStyle } from "../../style/BorderStyle" +import { matrix4 } from "@kit.ArkUI" +import { StringUtils } from "../../util/StringUtils" +import { ToastUtil } from "@pura/harmony-utils" + + +/** + * 重点信息弹框 + */ +@CustomDialog +export struct AttentionDialog { + //弹窗控制器 340702198906237510 + controller: CustomDialogController + //类型 1 = 人 2 = 车 + @Prop type: number = 1 + // 对应关注等级 + @State selectIndex: number = 1; + @State promptInfo: string | Resource = "" + @State inputText: string = ""; + + @State imageYT:Resource = $r('app.float.default_36') + @State imageFD:Resource = $r('app.float.default_43') + + submit?: (value: string,level:number) => void + cancel?: () => void + + aboutToAppear(): void { + if (this.type == 1) { + this.promptInfo = $r('app.string.attention_person_explanation1') + } else { + this.promptInfo = $r('app.string.attention_car_explanation1') + } + } + + build() { + Column() { + Text("提示信息") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .width('95%') + .height($r('app.float.default_46')) + .textAlign(TextAlign.Center) + + Divider() + .width('95%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey2')) + + Text("请选择关注类型") + .fontColor($r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_14')) + .width('95%') + .height($r('app.float.default_46')) + .textAlign(TextAlign.Start) + .margin({ top: $r('app.float.default_8') }) + + Row() { + Column() { + Image(this.selectIndex == 1 ? $r('app.media.icon_attention_leven1') : + $r('app.media.icon_attention_leven1_def')) + .width(this.selectIndex == 1 ? this.imageFD:this.imageYT) + .height(this.selectIndex == 1 ? this.imageFD:this.imageYT) + + Text("普通关注") + .fontColor(this.selectIndex == 1 ? $r('app.color.colorYellow7') : $r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_8') }) + } + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .layoutWeight(1) + .onClick(() => { + if (this.selectIndex == 1) { + return + } + this.selectIndex = 1 + if (this.type == 1) { + this.promptInfo = $r('app.string.attention_person_explanation1') + } else { + this.promptInfo = $r('app.string.attention_car_explanation1') + } + }) + + Column() { + Image(this.selectIndex == 2 ? $r('app.media.icon_attention_leven2') : + $r('app.media.icon_attention_leven2_def')) + .width(this.selectIndex == 2 ? this.imageFD:this.imageYT) + .height(this.selectIndex == 2 ? this.imageFD:this.imageYT) + + Text("一般关注") + .fontColor(this.selectIndex == 2 ? $r('app.color.colorYellow7') : $r('app.color.colorGrey6')) + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_8') }) + } + .justifyContent(FlexAlign.Center) + .align(Alignment.Center) + .alignItems(HorizontalAlign.Center) + .layoutWeight(1) + .onClick(() => { + if (this.selectIndex == 2) { + return + } + this.selectIndex = 2 + if (this.type == 1) { + this.promptInfo = $r('app.string.attention_person_explanation2') + } else { + this.promptInfo = $r('app.string.attention_car_explanation2') + } + }) + + Column() { + Image(this.selectIndex == 3 ? $r('app.media.icon_attention_leven3') : + $r('app.media.icon_attention_leven3_def')) + .width(this.selectIndex == 3 ? this.imageFD:this.imageYT) + .height(this.selectIndex == 3 ? this.imageFD:this.imageYT) + + Text("重点关注") + .fontSize($r('app.float.text_size_12')) + .margin({ top: $r('app.float.default_8') }) + .fontColor(this.selectIndex == 3 ? $r('app.color.colorYellow7') : $r('app.color.colorGrey6')) + } + .justifyContent(FlexAlign.Center) + .align(Alignment.Center) + .alignItems(HorizontalAlign.Center) + .layoutWeight(1) + .onClick(() => { + if (this.selectIndex == 3) { + return + } + this.selectIndex = 3 + if (this.type == 1) { + this.promptInfo = $r('app.string.attention_person_explanation3') + } else { + this.promptInfo = $r('app.string.attention_car_explanation3') + } + }) + + } + .width('95%') + .margin({ top: $r('app.float.default_8') }) + + Text(this.promptInfo) + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_14')) + .width('95%') + .height($r('app.float.default_46')) + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .margin({ top: $r('app.float.default_8') }) + + TextArea({ text: this.inputText, placeholder: "请输入关注原因" }) + .placeholderColor($r('app.color.colorGrey6')) + .placeholderFont({ + size: $r('app.float.text_size_14'), + weight: FontWeight.Normal + }) + .width("90%") + .height($r('app.float.default_68')) + .onChange((res) => { + this.inputText = res + }) + .backgroundColor($r('app.color.colorGrey1')) + .margin({ + left: $r('app.float.default_10'), + right: $r('app.float.default_10'), + top: $r('app.float.default_8') + }) + .border({ + width: $r('app.float.default_1'), + color: $r('app.color.colorGrey3'), + radius: $r('app.float.default_5') + }) + + Row() { + Button("确定", { type: ButtonType.Normal }) + .borderRadius(8) + .width($r('app.float.default_72')) + .height($r('app.float.default_40')) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_14')) + .margin({ right: $r('app.float.default_20') }) + .backgroundColor($r('app.color.bull')) + .onClick(() => { + if (StringUtils.isNullOrEmpty(this.inputText)) { + ToastUtil.showToast("请输入关注原因!") + return + } + if (this.submit) { + this.submit(this.inputText,this.selectIndex) + } + }) + + Button("取消", { type: ButtonType.Normal }) + .borderRadius(8) + .width($r('app.float.default_72')) + .height($r('app.float.default_40')) + .fontColor($r('app.color.white')) + .margin({ left: $r('app.float.default_20') }) + .fontSize($r('app.float.text_size_14')) + .backgroundColor($r('app.color.bull')) + .onClick(() => { + if (this.cancel) { + this.cancel() + } + }) + } + .margin({ top: $r('app.float.default_8') }) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .width("95%") + } + .width('95%') + .backgroundColor($r('app.color.white')) + .padding({ bottom: $r('app.float.default_12') }) + .border(cardRoundBorderStyle) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/ComparisonFaceDialog.ets b/entry/src/main/ets/view/dialog/ComparisonFaceDialog.ets new file mode 100644 index 0000000..ab0c858 --- /dev/null +++ b/entry/src/main/ets/view/dialog/ComparisonFaceDialog.ets @@ -0,0 +1,51 @@ +import AppConstants from "../../app/AppConstant" +import { cardRoundBorderStyle } from "../../style/BorderStyle" +import { image } from "@kit.ImageKit" + +/** + * 人像弹框 + */ +@CustomDialog +export struct ComparisonFaceDialog { + controller: CustomDialogController + @State photoPath:string|image.PixelMap = "" + @Prop loadingTips: string|Resource + // pixelMap: image.PixelMap + build() { + Column(){ + Text('温馨提示') + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_40')) + .textAlign(TextAlign.Center) + .fontColor($r('app.color.black')) + .fontSize($r('app.float.default_16')) + Divider() + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.colorGrey2')) + + Image(this.photoPath) + .width($r('app.float.default_200')) + .height($r('app.float.default_280')) + .margin({ top: $r('app.float.default_10'), bottom: $r('app.float.default_10')}) + + Row(){ + LoadingProgress() + .width($r('app.float.default_38')) + .width($r('app.float.default_38')) + Text(this.loadingTips) + .fontSize($r('app.float.text_size_15')) + .margin({ left: $r('app.float.default_8')}) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .width(AppConstants.PERCENTAGE_MAX) + } + .alignItems(HorizontalAlign.Center) + .width($r('app.float.default_280')) + .height($r('app.float.default_400')) + .backgroundColor($r('app.color.white')) + .border(cardRoundBorderStyle) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/ImportanceInfoDialog.ets b/entry/src/main/ets/view/dialog/ImportanceInfoDialog.ets new file mode 100644 index 0000000..0804245 --- /dev/null +++ b/entry/src/main/ets/view/dialog/ImportanceInfoDialog.ets @@ -0,0 +1,120 @@ +import AppConstants from "../../app/AppConstant" +import { ZdlxItem, ZdXqItem } from "../../model/resultModel/CheckPeopleResultModel" + + +/** + * 重点信息弹框 + */ +@CustomDialog +export struct ImportanceInfoDialog { + //弹窗控制器 340702198906237510 + controller: CustomDialogController + @Prop zdlx: ZdlxItem + + @State isSetCzcs:boolean= false; + + @State czcsContent :string=""; + + //回退 + submitClick?:(value:string)=>void + + + @State zdxqArray: Array | undefined = undefined + inputController: TextInputController = new TextInputController() + + aboutToAppear(): void { + this.zdxqArray = this.zdlx.zdxqArray + } + + build() { + Column() { + Text(this.zdlx?.zdlx) + .fontSize($r('app.float.text_size_18')) + .fontColor($r('app.color.white')) + .backgroundColor($r('app.color.bull')) + .width('100%') + .textAlign(TextAlign.Center) + .height($r('app.float.default_43')) + Divider() + .width('100%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.page_background')) + List() { + ForEach(this.zdxqArray, (item: ZdXqItem) => { + ListItem() { + Row() { + Text(item.key + ":") + .fontColor($r('app.color.grad')) + .fontSize($r('app.float.text_size_14')) + Text(item.value) + .fontColor(item.textColor) + .fontSize($r('app.float.text_size_14')) + } + .height($r('app.float.default_40')) + .margin({left:$r('app.float.default_10'),right:$r('app.float.default_10')}) + .width('100%') + } + }) + } + .layoutWeight(1) + .divider({ + strokeWidth:$r('app.float.default_1'), + color:$r('app.color.colorGrey3') + }) + + this.setCzcs() + + Button("提交") + .width('90%') + .height($r('app.float.default_40')) + .margin({bottom:$r('app.float.default_12')}) + .onClick(()=>{ + this.controller.close() + if (this.submitClick) { + this.submitClick(this.czcsContent); + } + }) + + } + .height($r('app.float.default_350')) + .width('88%') + .backgroundColor($r('app.color.white')) + } + + @Builder + setCzcs() { + Column(){ + TextArea({ text: this.czcsContent, placeholder: '请输入处置措施', controller: this.inputController }) + .placeholderColor(Color.Grey) + .placeholderFont({ size: 14, weight: 400 }) + .caretColor(Color.Blue) + .textAlign(TextAlign.Start) + .align(Alignment.TopStart) + .backgroundColor($r('app.color.colorGrey2')) + .width('90%') + .border({ + width:$r('app.float.default_1'), + color:$r('app.color.colorGrey3'), + radius:$r('app.float.default_5') + }) + .height($r('app.float.default_58')) + .margin({left:$r('app.float.default_20'),right:$r('app.float.default_20')}) + .fontSize($r('app.float.text_size_14')) + .fontColor(Color.Black) + .onChange((value: string) => { + this.czcsContent = value + }) + Text('异常人员未输入的将会产生提醒数据!') + .fontColor($r('app.color.colorYellow7')) + .fontSize($r('app.float.text_size_12')) + .width('90%') + .margin({left:$r('app.float.default_25')}) + .textAlign(TextAlign.Start) + } + .width(AppConstants.PERCENTAGE_MAX) + .alignItems(HorizontalAlign.Start) + .margin({bottom:$r('app.float.default_10')}) + .visibility(this.isSetCzcs?Visibility.Visible:Visibility.Hidden) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/LimitDateDialog.ets b/entry/src/main/ets/view/dialog/LimitDateDialog.ets new file mode 100644 index 0000000..095e14e --- /dev/null +++ b/entry/src/main/ets/view/dialog/LimitDateDialog.ets @@ -0,0 +1,47 @@ + +import hilog from '@ohos.hilog' + +/** + * 限制日期弹框 + */ +@CustomDialog +export struct LimitDateDialog{ + + @Prop date:string + + @State loadingTips: string ="该应用为测试应用," + // @State rotateAngle: number = 0 + //弹窗控制器 + controller: CustomDialogController + private tag: string = 'LoadingDialog' + + aboutToAppear() { + hilog.debug(0xFFFF, this.tag ,"Loading展示》》》》》") + } + + build() { + Stack() { + Column() { + Text("重要提示") + .fontSize($r('app.float.text_size_18')) + .fontColor($r('app.color.black')) + .margin({ top: $r('app.float.default_10') ,left: $r('app.float.default_24'),right: $r('app.float.default_24')}) + + Divider() + .width('100%') + .height($r('app.float.default_1')) + .backgroundColor($r('app.color.page_background')) + .margin({top:$r('app.float.default_15')}) + + + Text(this.loadingTips+this.date+" 后禁止使用!") + .fontSize($r('app.float.text_size_15')) + .margin({ top: $r('app.float.default_10') ,left: $r('app.float.default_24'),right: $r('app.float.default_24')}) + .margin({top:$r('app.float.default_15'),bottom:$r('app.float.default_15')}) + } + .justifyContent(FlexAlign.Center) + } + .height($r('app.float.default_150')) + .width($r('app.float.keyboard_height')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/LoadingDialog.ets b/entry/src/main/ets/view/dialog/LoadingDialog.ets new file mode 100644 index 0000000..5dfaf2f --- /dev/null +++ b/entry/src/main/ets/view/dialog/LoadingDialog.ets @@ -0,0 +1,43 @@ + +import hilog from '@ohos.hilog' + +@CustomDialog +export struct LoadingDialog{ + + @Prop loadingTips: string|Resource + // @State rotateAngle: number = 0 + //弹窗控制器 + controller: CustomDialogController + private tag: string = 'LoadingDialog' + + aboutToAppear() { + hilog.debug(0xFFFF, this.tag ,"Loading展示》》》》》") + } + + build() { + Stack() { + Column() { + LoadingProgress() + .width($r('app.float.default_48')) + .width($r('app.float.default_48')) + // Image($r('app.media.ic_load')) + // .height(50) + // .width(50) + // .rotate({angle: this.rotateAngle }) + // .animation({ + // duration: 800, + // iterations: -1, + // curve: Curve.Friction + // }).onAppear(() => { + // this.rotateAngle = 360 + // }) + Text(this.loadingTips) + .fontSize($r('app.float.text_size_15')) + .margin({ top: $r('app.float.default_10') ,left: $r('app.float.default_24'),right: $r('app.float.default_24')}) + } + .justifyContent(FlexAlign.Center) + } + .height($r('app.float.default_150')) + .width($r('app.float.default_200')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/SelectCarDialog.ets b/entry/src/main/ets/view/dialog/SelectCarDialog.ets new file mode 100644 index 0000000..50968b3 --- /dev/null +++ b/entry/src/main/ets/view/dialog/SelectCarDialog.ets @@ -0,0 +1,144 @@ +import { ResultCallBack } from "../../callbcak/ResultCallback"; +import { CarData } from "../../model/resultModel/CheckCarResultModel"; +import { ToastUtils } from "../../util/ToasUtils"; +import { ObservedArray } from "../custom/ObservedArray"; + + +@CustomDialog +export struct SelectCarDialog { + //弹窗控制器 + controller: CustomDialogController + // carDatas?:Array + + @ObjectLink observeData: ObservedArray | null; + selectCarData?: CarData; + resultCallback?: ResultCallBack; + + aboutToAppear(): void { + // this.observeData = new ObservedArray(); + // if (this.carDatas) { + // this.carDatas.forEach((car)=>{ + // this.observeData?.push(car) + // }) + // } + + } + + build() { + Column() { + Text('请选择车辆') + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_18')) + .width('100%') + .margin({ top: 12 }) + .textAlign(TextAlign.Center) + + Divider() + .width('100%') + .height(2) + .color($r('app.color.page_background')) + .margin({ top: 12 }) + + if (this.observeData) { + List() { + ForEach(this.observeData, (car: CarData, index: number) => { + ListItem() { + ItemView({ + carData: car, event: () => { + this.clickItem(index) + } + }) + } + .padding({ left: 20, right: 20 }) + }) + } + } + + Button("确定") + .width('90%') + .height(38) + .margin({ top: 12, bottom: 20 }) + .fontColor($r('app.color.white')) + .fontSize($r('app.float.text_size_18')) + .backgroundColor($r('app.color.bull')) + .onClick(() => { + if (this.selectCarData) { + if (this.resultCallback) { + this.resultCallback.onResult(this.selectCarData) + this.controller.close() + } + } else { + ToastUtils.toastBottom("请先选择车辆") + } + }) + } + } + + clickItem(indexF: number) { + if (this.observeData) { + for (let i = 0; i < this.observeData.length; i++) { + let car = this.observeData[i]; + if (indexF == i) { + car.isSelect = true + this.selectCarData = car + }else { + car.isSelect = false + } + } + } + } +} + +@Component +struct ItemView { + @Prop carData: CarData + event: Callback | null = null + + build() { + if (this.carData.isSelect) { + this.selectStatus() + } else { + this.notSelectStatus() + } + } + + @Builder + selectStatus() { + Row() { + Text(this.carData.hpzl) + .fontColor($r('app.color.black')) + .fontSize($r('app.float.text_size_16')) + .margin({ left: 10, right: 12 }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .width('100%') + .height(42) + .margin({ top: 10 }) + .border({ + width: 1.5, + color: $r('app.color.bull') + }) + .onClick(this.event) + } + + @Builder + notSelectStatus() { + Row() { + Text(this.carData.hpzl) + .fontColor($r('app.color.grad')) + .fontSize($r('app.float.text_size_14')) + .margin({ left: 10, right: 12 }) + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .width('100%') + .height(42) + .margin({ top: 10 }) + .border({ + width: 1.5, + color: $r('app.color.page_background') + }) + .onClick(this.event) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/SelectCheckReasonDialog.ets b/entry/src/main/ets/view/dialog/SelectCheckReasonDialog.ets new file mode 100644 index 0000000..3dbc5b5 --- /dev/null +++ b/entry/src/main/ets/view/dialog/SelectCheckReasonDialog.ets @@ -0,0 +1,37 @@ +import { CheckReasonModel } from "../../model/uiModel/GoodsModel"; + +/** + * 选择盘查原因 + */ +@CustomDialog +export struct SelectCheckReasonDialog { + controller: CustomDialogController + @State checkReasonData: Array | undefined = undefined; + + clickItem?:(bean:CheckReasonModel,selectIndex:number)=>void + + + build() { + Column() { + List() { + ForEach(this.checkReasonData, (item: CheckReasonModel,index:number) => { + ListItem() { + Text(item.dictLabel) + .fontColor($r('app.color.bull')) + .fontSize($r('app.float.text_size_16')) + .height($r('app.float.default_40')) + } + .width('98%') + .onClick(() => { + if(this.clickItem){ + this.clickItem(item,index) + } + }) + }) + } + } + .backgroundColor($r('app.color.white')) + .padding($r('app.float.default_20')) + .width('88%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/SelectGoodsTypeDialog.ets b/entry/src/main/ets/view/dialog/SelectGoodsTypeDialog.ets new file mode 100644 index 0000000..52a88b5 --- /dev/null +++ b/entry/src/main/ets/view/dialog/SelectGoodsTypeDialog.ets @@ -0,0 +1,46 @@ +import AppConstants from "../../app/AppConstant" + + +/** + * 选择物品弹框 + */ +@CustomDialog +export struct ImportanceInfoDialog { + + controller: CustomDialogController + + /** + * [{"dwvalue":"10","thingsname":"管制刀具","thingsvalue":"10","ordersort":1,"dwname":"把"}, + * {"dwvalue":"11","thingsname":"非法出版物","thingsvalue":"11","ordersort":2,"dwname":"件"}, + * {"dwvalue":"8","thingsname":"危化物品","thingsvalue":"8","ordersort":3,"dwname":"千克"}, + * {"dwvalue":"9","thingsname":"毒品","thingsvalue":"9","ordersort":4,"dwname":"克"}, + * {"dwvalue":"1","thingsname":"假套车牌","thingsvalue":"1","ordersort":5,"dwname":"套"}, + * {"dwvalue":"3","thingsname":"仿真枪","thingsvalue":"3","ordersort":6,"dwname":"支"}, + * {"dwvalue":"4","thingsname":"子弹","thingsvalue":"4","ordersort":7,"dwname":"发"}, + * {"dwvalue":"12","thingsname":"低慢小目标","thingsvalue":"12","ordersort":8,"dwname":"个"},{"dwvalue":"7","thingsname":"烟花爆竹","thingsvalue":"7","ordersort":9,"dwname":"头"},{"dwvalue":"2","thingsname":"枪支","thingsvalue":"2","ordersort":10,"dwname":"支"},{"dwvalue":"5","thingsname":"炸药","thingsvalue":"5","ordersort":11,"dwname":"千克"},{"dwvalue":"6","thingsname":"雷管","thingsvalue":"6","ordersort":12,"dwname":"枚"},{"dwvalue":"13","thingsname":"其他","thingsvalue":"13","ordersort":13,"dwname":"备注"}] + */ + + + build() { + Column(){ + Text("选择物品类型") + .fontColor($r('app.color.colorGrey8')) + .fontSize($r('app.float.text_size_16')) + .width(AppConstants.PERCENTAGE_MAX) + .height($r('app.float.default_40')) + .textAlign(TextAlign.Center) + .align(Alignment.Center) + + List(){ + + } + } + .width('80%') + } + + @Builder + itemView(){ + + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/view/dialog/VoiceRecognitionDialog.ets b/entry/src/main/ets/view/dialog/VoiceRecognitionDialog.ets new file mode 100644 index 0000000..f1d6263 --- /dev/null +++ b/entry/src/main/ets/view/dialog/VoiceRecognitionDialog.ets @@ -0,0 +1,260 @@ +import { speechRecognizer } from '@kit.CoreSpeechKit' +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { StringUtils } from '../../util/StringUtils'; +import AudioCapturer from '../../model/AudioCapturer'; + +const TAG = 'VoiceRecognitionDialog' + +@CustomDialog +export struct VoiceRecognitionDialog { + controller: CustomDialogController + @State recognitionText: string = "请先点击开始识别" + @State resultText: string = "" + @State isListening: boolean = false + // 定义识别结果回调 + onResult?: (text: string) => void + asrEngine: speechRecognizer.SpeechRecognitionEngine | null = null + @State sessionId: string = Date.now().toString(); + @State sessionId2: string = Date.now().toString(); + private mAudioCapturer = new AudioCapturer(); + /** + * 识别类型 身份证号或者车牌号码 + * 默认身份证号 + */ + @Prop type: string = "idCardNum" + + aboutToAppear() { + this.initRecognitionEngine() + } + + aboutToDisappear(): void { + if (this.asrEngine) { + try { + this.asrEngine!.finish(this.sessionId) + } catch (e) { + hilog.error(0x0000, TAG, `Failed to finish. Code: ${e.code}, message: ${e.message}.`); + } finally { + try { + this.asrEngine!.cancel(this.sessionId) + } catch (e) { + hilog.error(0x0000, TAG, `Failed to finish. Code: ${e.code}, message: ${e.message}.`); + } + } + } + } + + private initRecognitionEngine() { + let extraParam: Record = { "locate": "CN", "recognizerMode": "short" }; + let initParamsInfo: speechRecognizer.CreateEngineParams = { + language: 'zh-CN', + online: 1, + extraParams: extraParam + }; + // 调用createEngine方法 + speechRecognizer.createEngine(initParamsInfo, (err: BusinessError, speechRecognitionEngine: + speechRecognizer.SpeechRecognitionEngine) => { + if (!err) { + hilog.info(0x0000, TAG, 'Succeeded in creating engine.'); + // 接收创建引擎的实例 + this.asrEngine = speechRecognitionEngine; + this.setListener() + } else { + // 无法创建引擎时返回错误码1002200001,原因:语种不支持、模式不支持、初始化超时、资源不存在等导致创建引擎失败 + // 无法创建引擎时返回错误码1002200006,原因:引擎正在忙碌中,一般多个应用同时调用语音识别引擎时触发 + // 无法创建引擎时返回错误码1002200008,原因:引擎已被销毁 + hilog.error(0x0000, TAG, `Failed to create engine. Code: ${err.code}, message: ${err.message}.`); + } + }); + } + + // 设置回调 + private setListener() { + // 保存 this 引用 + const self = this; + // 创建回调对象 + let setListener: speechRecognizer.RecognitionListener = { + // 开始识别成功回调 340123199 + onStart(sessionId: string, eventMessage: string) { + hilog.info(0x0000, TAG, `onStart, sessionId: ${sessionId} eventMessage: ${eventMessage}`); + }, + // 事件回调 + onEvent(sessionId: string, eventCode: number, eventMessage: string) { + if (eventCode == 3) { + self.recognitionText = '识别已结束,请重新点击开始识别!' + self.isListening = false; + } + //speech stopped + hilog.info(0x0000, TAG, + `onEvent, sessionId: ${sessionId} eventCode: ${eventCode} eventMessage: ${eventMessage}`); + }, + // 识别结果回调,包括中间结果和最终结果 + onResult(sessionId: string, result: speechRecognizer.SpeechRecognitionResult) { + if (StringUtils.isNullOrEmpty(result.result)) { + return + } + if (self.isListening) { + if (self.type === "idCardNum") { + self.resultText = StringUtils.translationIdCardNum(result.result); + } else if (self.type === "carNum") { + self.resultText = StringUtils.translationCarNum(result.result); + } + + } + hilog.info(0x0000, TAG, `onResult, sessionId: ${sessionId} sessionId: ${JSON.stringify(result)}`); + }, + // 识别完成回调 + onComplete(sessionId: string, eventMessage: string) { + hilog.info(0x0000, TAG, `onComplete, sessionId: ${sessionId} eventMessage: ${eventMessage}`); + }, + // 错误回调,错误码通过本方法返回 + // 返回错误码1002200002,开始识别失败,重复启动startListening方法时触发 + // 更多错误码请参考错误码参考 Write audio failed because the start listening is failed + onError(sessionId: string, errorCode: number, errorMessage: string) { + //Write audio failed because the start listening is failed. + hilog.error(0x0000, TAG, + `onError, sessionId: ${sessionId} errorCode: ${errorCode} errorMessage: ${errorMessage}`); + }, + } + // 设置回调 + this.asrEngine!.setListener(setListener); + }; + + // 麦克风语音转文本 + private async startRecording() { + this.startListeningForRecording(); + // 录音获取音频 + let data: ArrayBuffer; + hilog.info(0x0000, TAG, 'create capture success'); + this.mAudioCapturer.init((dataBuffer: ArrayBuffer) => { + hilog.info(0x0000, TAG, 'start write'); + hilog.info(0x0000, TAG, 'ArrayBuffer ' + JSON.stringify(dataBuffer)); + data = dataBuffer + let uint8Array: Uint8Array = new Uint8Array(data); + hilog.info(0x0000, TAG, 'ArrayBuffer uint8Array ' + JSON.stringify(uint8Array)); + + try { + this.startListeningForWriteAudio(); + this.asrEngine!.writeAudio(this.sessionId, uint8Array); + this.countDownLatch(5); + } catch (e) { + + } + + // 写入音频流 + this.asrEngine!.writeAudio(this.sessionId2, uint8Array); + }); + }; + + // 开始识别 + private startListeningForWriteAudio() { + // 设置开始识别的相关参数 + let recognizerParams: speechRecognizer.StartParams = { + sessionId: this.sessionId, + audioInfo: { + audioType: 'pcm', + sampleRate: 16000, + soundChannel: 1, + sampleBit: 16 + } //audioInfo参数配置请参考AudioInfo + } + // 调用开始识别方法 + this.asrEngine!.startListening(recognizerParams); + }; + + private startListeningForRecording() { + let audioParam: speechRecognizer.AudioInfo = { + audioType: 'pcm', + sampleRate: 16000, + soundChannel: 1, + sampleBit: 16 + } + let extraParam: Record = { + "recognitionMode": 0, + "vadBegin": 2000, + "vadEnd": 3000, + "maxAudioDuration": 20000 + } + let recognizerParams: speechRecognizer.StartParams = { + sessionId: this.sessionId, + audioInfo: audioParam, + extraParams: extraParam + } + hilog.info(0x0000, TAG, 'startListening start'); + this.asrEngine!.startListening(recognizerParams); + }; + + // 计时 + public async countDownLatch(count: number) { + while (count > 0) { + await this.sleep(40); + count--; + } + } + + // 睡眠 + private sleep(ms: number): Promise { + return new Promise(resolve => setTimeout(resolve, ms)); + } + + /** + * 录音开始/结束 + */ + toggleRecognition(): void { + if (this.isListening) { + this.isListening = false + this.asrEngine!.finish(this.sessionId); + if (this.onResult) { + if (this.type === "idCardNum") { + this.onResult(StringUtils.translationIdCardNum(this.resultText)); + } else if (this.type === "carNum") { + this.onResult(StringUtils.translationCarNum(this.resultText)); + } + } + } else { + this.startRecording(); + this.recognitionText = '识别已开始,请说出你想识别的文字' + this.isListening = true + } + } + + build() { + Column() { + Text('语音识别') + .fontColor($r('app.color.colorGrey8')) + .height($r('app.float.default_20')) + .fontSize(18) + + Divider() + .width('100%') + .height(1) + .margin({ top: $r('app.float.default_20') }) + .backgroundColor($r('app.color.colorGrey1')) + + // 识别结果展示 + Text(this.recognitionText) + .fontColor($r('app.color.colorGrey8')) + .fontSize(18) + .margin({ top: 20 }) + + // 语音动画指示器 + LoadingProgress() + .width($r('app.float.default_60')) + .height($r('app.float.default_60')) + .color(this.isListening ? Color.Blue : Color.Gray) + .enableLoading(this.isListening) + + // 识别结果展示 + Text(this.resultText) + .fontColor($r('app.color.colorGrey8')) + .fontSize(18) + .margin({ top: 20 }) + + // 操作按钮 + Button(this.isListening ? '停止识别' : '开始识别') + .onClick(() => this.toggleRecognition()) + .margin({ top: 30 }) + } + .padding(20) + } +} diff --git a/entry/src/main/ets/view/keyboard/KeyEventListen.ets b/entry/src/main/ets/view/keyboard/KeyEventListen.ets new file mode 100644 index 0000000..998d9c1 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/KeyEventListen.ets @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { promptAction } from '@kit.ArkUI'; +import CommonConstants from './data/CommonConstants'; + +/** + * Keyboard tool class. + * 被观察 + */ +class KeyEventListen { + public isMultiSelect: boolean = false; + public selectionStart: number = CommonConstants.COMMON_INITIAL_VALUE; + public selectionEnd: number = CommonConstants.COMMON_INITIAL_VALUE; + public notSelectionStart: number = CommonConstants.COMMON_INITIAL_VALUE; + public notSelectionEnd: number = CommonConstants.COMMON_INITIAL_VALUE; + public cursorPosition: number = CommonConstants.CURSOR_POSITION_INIT; + public inputContent: string = ''; + static keyEventListen: KeyEventListen; + + private searchController: SearchController|null = null;; + + public onSearchKeyMethod? :(value:string) => void; + + static getInstance() { + if (KeyEventListen.keyEventListen == null) { + KeyEventListen.keyEventListen = new KeyEventListen(); + } + return KeyEventListen.keyEventListen; + } + + //调用此方法去除选中状态 + changeCursorPosition(index:number){ + this.isMultiSelect = false; + if (index == 1) {//向右移动 + if (this.selectionStart>= this.inputContent.length) { + return + } + if (this.selectionEnd>= this.inputContent.length) { + return + } + this.selectionStart++; + this.selectionEnd++; + this.cursorPosition++; + }else if (index == -1){ + // 向左移动 + if (this.selectionStart<=0) { + return + } + if (this.selectionEnd<=0) { + return + } + this.selectionStart--; + this.selectionEnd--; + this.cursorPosition--; + } + if (this.searchController) { + this.searchController.caretPosition(this.cursorPosition) + } + } + + /** + * Keyboard method. + * + * @param action Keyboard input status. + * @param content Input value. + * @returns + */ + onKeyboardMethod(action: string, content?: string): string { + // Sets the position of the cursor in the search box. + if (action === CommonConstants.DELETE_CHARACTERS) {//点击删除按钮事件 + if (content !== undefined) { + // multiple-choice deletion. + if (this.isMultiSelect) { //如果输入框内容是被选择状态 + this.inputContent = content.replace(content?.substring(this.notSelectionStart, this.notSelectionEnd), ''); + this.cursorPosition = this.notSelectionStart; + } else if (content.length === this.selectionStart && content.length === this.selectionEnd) { + // Deletes a character from the front or middle. + this.inputContent = content?.substring(0, content.length - 1); + this.cursorPosition = this.selectionEnd - 1; + } else if (this.selectionStart === this.selectionEnd && content.length > this.selectionEnd) { + // Deletes a character from the front or middle. + this.inputContent = content.replace(content?.substring(this.selectionStart - 1, this.selectionEnd), ''); + this.cursorPosition = this.selectionStart - 1; + }else{ + this.inputContent = content; + } + } + } else if (action === CommonConstants.CLEAR_CHARACTERS) { + this.inputContent = ''; + this.cursorPosition = 0; + }else if (action == CommonConstants.TEXT_SEARCH){ + if (this.onSearchKeyMethod) { + this.onSearchKeyMethod(this.inputContent) + } + } + else if (this.inputContent.length >= CommonConstants.MAXIMUM_NUMBER_INPUTS) { + promptAction.showToast({ + message: $r('app.string.search_box_prompt') + }); + return this.inputContent; + } else if (action === CommonConstants.STRING_CHARACTERS && content !== undefined) { + if (this.isMultiSelect) { + // Obtains the characters in the current search box. + let currentContent = this.inputContent; + // Obtains the selected deleted characters. + currentContent = currentContent.replace(currentContent?.substring(this.notSelectionStart, + this.notSelectionEnd), ''); + // Add Characters. + this.inputContent = currentContent.slice(0, this.notSelectionStart) + + content + currentContent.slice(this.notSelectionStart); + this.cursorPosition = this.notSelectionStart + content.length; + } else if (this.selectionStart === this.selectionEnd && this.selectionStart < this.inputContent.length) { + if (this.selectionStart === 0 && this.selectionEnd === 0) { + // Add a character from the front. + this.inputContent = content + this.inputContent; + this.cursorPosition = content.length; + } else { + // Add a character from the middle. + this.inputContent = this.inputContent.slice(0, this.selectionStart) + + content + this.inputContent.slice(this.selectionStart); + this.cursorPosition = this.selectionStart + content.length; + } + } else { + // Add a character from the last. + this.inputContent += content; + this.cursorPosition = this.selectionEnd + content.length; + } + } + return this.inputContent; + } +} + +export default KeyEventListen.getInstance(); \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/KeyEventObserved.ets b/entry/src/main/ets/view/keyboard/KeyEventObserved.ets new file mode 100644 index 0000000..3d64f98 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/KeyEventObserved.ets @@ -0,0 +1,122 @@ +import CommonConstants from "./data/CommonConstants"; +import { promptAction } from "@kit.ArkUI"; + +export class KeyEventObserved{ + public isMultiSelect: boolean = false; + public selectionStart: number = CommonConstants.COMMON_INITIAL_VALUE; + public selectionEnd: number = CommonConstants.COMMON_INITIAL_VALUE; + public notSelectionStart: number = CommonConstants.COMMON_INITIAL_VALUE; + public notSelectionEnd: number = CommonConstants.COMMON_INITIAL_VALUE; + public cursorPosition: number = CommonConstants.CURSOR_POSITION_INIT; + public inputContent: string = ''; + + private searchController: SearchController|undefined; + + public onSearchKeyMethod? :(value:string) => void; + + constructor(searchController: SearchController | undefined) { + this.searchController = searchController; + } + + //调用此方法去除选中状态 + changeCursorPosition(index:number){ + this.isMultiSelect = false; + if (index == 1) {//向右移动 + if (this.selectionStart>= this.inputContent.length) { + return + } + if (this.selectionEnd>= this.inputContent.length) { + return + } + this.selectionStart++; + this.selectionEnd++; + this.cursorPosition++; + }else if (index == -1){ + // 向左移动 + if (this.selectionStart<=0) { + return + } + if (this.selectionEnd<=0) { + return + } + this.selectionStart--; + this.selectionEnd--; + this.cursorPosition--; + } + if (this.searchController) { + this.searchController.caretPosition(this.cursorPosition) + } + } + + /** + * Keyboard method. + * + * @param action Keyboard input status. + * @param content Input value. + * @returns + */ + onKeyboardMethod(action: string, content?: string): string { + // Sets the position of the cursor in the search box. + if (action === CommonConstants.DELETE_CHARACTERS) {//点击删除按钮事件 + if (content !== undefined) { + // multiple-choice deletion. + if (this.isMultiSelect) { //如果输入框内容是被选择状态 + this.inputContent = content.replace(content?.substring(this.notSelectionStart, this.notSelectionEnd), ''); + this.cursorPosition = this.notSelectionStart; + } else if (content.length === this.selectionStart && content.length === this.selectionEnd) { + // Deletes a character from the front or middle. + this.inputContent = content?.substring(0, content.length - 1); + this.cursorPosition = this.selectionEnd - 1; + } else if (this.selectionStart === this.selectionEnd && content.length > this.selectionEnd) { + // Deletes a character from the front or middle. + this.inputContent = content.replace(content?.substring(this.selectionStart - 1, this.selectionEnd), ''); + this.cursorPosition = this.selectionStart - 1; + }else{ + this.inputContent = content; + } + } + } else if (action === CommonConstants.CLEAR_CHARACTERS) { + this.inputContent = ''; + this.cursorPosition = 0; + }else if (action == CommonConstants.TEXT_SEARCH){ + if (this.onSearchKeyMethod) { + this.onSearchKeyMethod(this.inputContent) + } + } + else if (this.inputContent.length >= CommonConstants.MAXIMUM_NUMBER_INPUTS) { + promptAction.showToast({ + message: $r('app.string.search_box_prompt') + }); + return this.inputContent; + } else if (action === CommonConstants.STRING_CHARACTERS && content !== undefined) { + if (this.isMultiSelect) { + // Obtains the characters in the current search box. + let currentContent = this.inputContent; + // Obtains the selected deleted characters. + currentContent = currentContent.replace(currentContent?.substring(this.notSelectionStart, + this.notSelectionEnd), ''); + // Add Characters. + this.inputContent = currentContent.slice(0, this.notSelectionStart) + + content + currentContent.slice(this.notSelectionStart); + this.cursorPosition = this.notSelectionStart + content.length; + } else if (this.selectionStart === this.selectionEnd && this.selectionStart < this.inputContent.length) { + if (this.selectionStart === 0 && this.selectionEnd === 0) { + // Add a character from the front. + this.inputContent = content + this.inputContent; + this.cursorPosition = content.length; + } else { + // Add a character from the middle. + this.inputContent = this.inputContent.slice(0, this.selectionStart) + + content + this.inputContent.slice(this.selectionStart); + this.cursorPosition = this.selectionStart + content.length; + } + } else { + // Add a character from the last. + this.inputContent += content; + this.cursorPosition = this.selectionEnd + content.length; + } + } + return this.inputContent; + } + +} \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/data/CommonConstants.ets b/entry/src/main/ets/view/keyboard/data/CommonConstants.ets new file mode 100644 index 0000000..e4f8a61 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/data/CommonConstants.ets @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Common constants for all features. + */ +export default class CommonConstants { + + //截止日期 2025-03-21 18:00:00 + static readonly LIMIT_DATE :number = 1742551200000 + + /** + * Maximum width. + */ + static readonly PERCENTAGE_MAX: string = '100%'; + + /** + * Ninety percent. + */ + static readonly NINETY_PERCENT_WIDTH: string = '90%'; + + /** + * Width of the search box. + */ + static readonly SEARCH_BOX_WIDTH: string = '91.1%'; + + /** + * Turn off the outside right margin of the keyboard picture. + */ + static readonly DOWN_IMAGE_RIGHT: string = '6.8%'; + + /** + * Search logic. + */ + static readonly TEXT_SEARCH: string = '搜索'; + + /** + * Space logic. + */ + static readonly TEXT_SPACE: string = '空格'; + + /** + * Switch to Securities Keyboard. + */ + static readonly TEXT_DIGIT: string = '123'; + + /** + * Clear logic. + */ + static readonly TEXT_CLEAR: string = '清空'; + + /** + * Switch to English keyboard. + */ + static readonly TEXT_ENGLISH: string = 'ABC'; + /** + * Switch to English keyboard. + */ + static readonly TEXT_PROVINCE1: string = '省份'; + /** + * Switch to English keyboard. + */ + static readonly TEXT_PROVINCE2: string = '下页'; + + /** + * Add text box content. + */ + static readonly ADD_CHARACTERS: string = 'add'; + + /** + * Delete text box content. + */ + static readonly DELETE_CHARACTERS: string = 'delete'; + + /** + * Clear the text box. + */ + static readonly CLEAR_CHARACTERS: string = 'clear'; + + /** + * Add logic. + */ + static readonly STRING_CHARACTERS: string = 'string'; + + /** + * Type of the user-defined input method. The options are as follows: + * 0: securities keyboard; + * 1: English keyboard. + */ + static readonly KEYBOARD_TYPE_DIGIT: number = 0; + + /** + * Type of the user-defined input method. The options are as follows: + * 0: securities keyboard; + * 1: English keyboard. + */ + static readonly KEYBOARD_TYPE_ENGLISH: number = 1; + + + + /** + * Type of the user-defined input method. The options are as follows: + * 0: 身份证键盘; + */ + static readonly KEYBOARD_TYPE_ID_CARD_NUM: number = 0; + + /** + * Type of the user-defined input method. The options are as follows: + * 1: 车牌数字键盘. + */ + static readonly KEYBOARD_TYPE_CAR_NUM: number = 1; + + /** + * Type of the user-defined input method. The options are as follows: + * 2: 车牌英文键盘 + */ + static readonly KEYBOARD_TYPE_CAR_ENGLISH: number = 2; + + /** + * Type of the user-defined input method. The options are as follows: + * 3: 车牌英文键盘 省份 + */ + static readonly KEYBOARD_TYPE_CAR_PROVINCE1: number = 3; + + /** + * Type of the user-defined input method. The options are as follows: + * 3: 车牌英文键盘 省份 + */ + static readonly KEYBOARD_TYPE_CAR_PROVINCE2: number = 4; + + + + /** + * Initializes the position of the cursor in the search box. + */ + static readonly CURSOR_POSITION_INIT: number = 0; + + /** + * Common initial value. + */ + static readonly COMMON_INITIAL_VALUE: number = 0; + + /** + * Maximum number of characters that can be entered in the text box. + */ + static readonly MAXIMUM_NUMBER_INPUTS: number = 18; + + /** + * Aspect ratio of the image component. + */ + static readonly IMAGE_ASPECT_RATIO: number = 1; + + /** + * The proportion weight is 1. + */ + static readonly LAYOUT_WEIGHT_ONE: number = 1; + + /** + * The proportion weight is 2. + */ + static readonly LAYOUT_WEIGHT_TWO: number = 2; + /** + * The proportion weight is 2. 三 + */ + static readonly LAYOUT_WEIGHT_THREE: number = 3; +} \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/data/MenuData.ets b/entry/src/main/ets/view/keyboard/data/MenuData.ets new file mode 100644 index 0000000..a5bd726 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/data/MenuData.ets @@ -0,0 +1,590 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface SourceListType { + content: Resource | string, + isSpecial?: boolean +} + +export interface KeySourceListType { + title: Resource | string, + content: Resource | string, + upperContent: Resource | string, +} + +export let keySourceListData: KeySourceListType[] = [ + { + title: '1', + content: 'q', + upperContent: 'Q' + }, + { + title: '2', + content: 'w', + upperContent: 'W' + }, + { + title: '3', + content: 'e', + upperContent: 'E' + }, + { + title: '4', + content: 'r', + upperContent: 'R' + }, + { + title: '5', + content: 't', + upperContent: 'T' + }, + { + title: '6', + content: 'y', + upperContent: 'Y' + }, + { + title: '7', + content: 'u', + upperContent: 'U' + }, + { + title: '8', + content: 'i', + upperContent: 'I' + }, + { + title: '9', + content: 'o', + upperContent: 'O' + }, + { + title: '0', + content: 'p', + upperContent: 'P' + }, + { + title: String.fromCharCode(126), + content: 'a', + upperContent: 'A' + }, + { + title: String.fromCharCode(33), + content: 's', + upperContent: 'S' + }, + { + title: '@', + content: 'd', + upperContent: 'D' + }, + { + title: String.fromCharCode(35), + content: 'f', + upperContent: 'F' + }, + { + title: '%', + content: 'g', + upperContent: 'G' + }, + { + title: String.fromCharCode(39), + content: 'h', + upperContent: 'H' + }, + { + title: '&', + content: 'j', + upperContent: 'J' + }, + { + title: '*', + content: 'k', + upperContent: 'K' + }, + { + title: '?', + content: 'l', + upperContent: 'L' + }, + { + title: String.fromCharCode(72), + content: 'z', + upperContent: 'Z' + }, + { + title: String.fromCharCode(73), + content: 'x', + upperContent: 'X' + }, + { + title: String.fromCharCode(175), + content: 'c', + upperContent: 'C' + }, + { + title: String.fromCharCode(95), + content: 'v', + upperContent: 'V' + }, + { + title: String.fromCharCode(58), + content: 'b', + upperContent: 'B' + }, + { + title: String.fromCharCode(59), + content: 'n', + upperContent: 'N' + }, + { + title: String.fromCharCode(47), + content: 'm', + upperContent: 'M' + }, + { + title: '省份', + content: '省份', + upperContent: '省份' + }, + { + title: $r('app.string.text_clear'), + content: $r('app.string.text_clear'), + upperContent: $r('app.string.text_clear') + }, + { + title: $r('app.string.text_search'), + content: $r('app.string.text_search'), + upperContent: $r('app.string.text_search') + } +] + +export let numberSourceListData: SourceListType[] = [ + { + content: '300', + isSpecial: true + }, + { + content: '600', + isSpecial: true + }, + { + content: '000', + isSpecial: true + }, + { + content: '001', + isSpecial: true + }, + + { + content: '1' + }, + { + content: '4' + }, + { + content: '7' + }, + { + content: 'ABC', + isSpecial: true + }, + + { + content: '2' + }, + { + content: '5' + }, + { + content: '8' + }, + { + content: '0' + }, + + + { + content: '3' + }, + { + content: '6' + }, + { + content: '9' + }, + { + content: '002', + isSpecial: true + }, + + + { + content: $r('app.string.text_clear'), + isSpecial: true + }, + { + content: $r('app.string.text_search'), + isSpecial: true + } +] + +export let IcCardNumSourceListData: SourceListType[] = [ + { + content: '1' + }, + { + content: '4' + }, + { + content: '7' + }, + { + content: 'X' + }, + + { + content: '2' + }, + { + content: '5' + }, + { + content: '8' + }, + { + content: '0' + }, + + { + content: '3' + }, + { + content: '6' + }, + { + content: '9' + }, + { + content: $r('app.string.text_clear'), + isSpecial:true + }, + + { + content: '-155', + isSpecial: true + }, + + { + content: $r('app.string.text_clear'), + isSpecial: true + }, + { + content: '-222', + isSpecial: true + }, + { + content: $r('app.string.text_search'), + isSpecial:true + } +] + +export let CarNumSourceListData:SourceListType[]=[ + {content:"1"}, + {content:"4"}, + {content:"7"}, + {content:"ABC", + isSpecial:true}, + + {content:"2"}, + {content:"5"}, + {content:"8"}, + {content:"0"}, + + {content:"3"}, + {content:"6"}, + {content:"9"}, + {content:"省份", + isSpecial:true}, + + {content:"-115", + isSpecial:true}, + {content: $r('app.string.text_clear'), + isSpecial:true}, + {content: $r('app.string.text_search'), + isSpecial:true}, + + +] + +export let CarKeySourceListData: KeySourceListType[] = [ + { + title: '1', + content: 'q', + upperContent: 'Q' + }, + { + title: '2', + content: 'w', + upperContent: 'W' + }, + { + title: '3', + content: 'e', + upperContent: 'E' + }, + { + title: '4', + content: 'r', + upperContent: 'R' + }, + { + title: '5', + content: 't', + upperContent: 'T' + }, + { + title: '6', + content: 'y', + upperContent: 'Y' + }, + { + title: '7', + content: 'u', + upperContent: 'U' + }, + { + title: '8', + content: 'i', + upperContent: 'I' + }, + { + title: '9', + content: 'o', + upperContent: 'O' + }, + { + title: '0', + content: 'p', + upperContent: 'P' + }, + + + { + title: String.fromCharCode(126), + content: 'a', + upperContent: 'A' + }, + { + title: String.fromCharCode(33), + content: 's', + upperContent: 'S' + }, + { + title: '@', + content: 'd', + upperContent: 'D' + }, + { + title: String.fromCharCode(35), + content: 'f', + upperContent: 'F' + }, + { + title: '%', + content: 'g', + upperContent: 'G' + }, + { + title: String.fromCharCode(39), + content: 'h', + upperContent: 'H' + }, + { + title: '&', + content: 'j', + upperContent: 'J' + }, + { + title: '*', + content: 'k', + upperContent: 'K' + }, + { + title: '?', + content: 'l', + upperContent: 'L' + }, + + + { + title: String.fromCharCode(72), + content: 'z', + upperContent: 'Z' + }, + { + title: String.fromCharCode(73), + content: 'x', + upperContent: 'X' + }, + { + title: String.fromCharCode(175), + content: 'c', + upperContent: 'C' + }, + { + title: String.fromCharCode(95), + content: 'v', + upperContent: 'V' + }, + { + title: String.fromCharCode(58), + content: 'b', + upperContent: 'B' + }, + { + title: String.fromCharCode(59), + content: 'n', + upperContent: 'N' + }, + { + title: String.fromCharCode(47), + content: 'm', + upperContent: 'M' + }, + { + title: '123', + content: '123', + upperContent: '123' + }, + { + title: $r('app.string.text_space'), + content: $r('app.string.text_space'), + upperContent: $r('app.string.text_space') + }, + { + title: $r('app.string.text_search'), + content: $r('app.string.text_search'), + upperContent: $r('app.string.text_search') + } +] + +export let ProvinceSourceListData1:SourceListType[] =[ + {content:'皖A' }, + {content:'苏' }, + {content:'陕' }, + {content:'黑' }, + {content:'ABC', + isSpecial:true}, + + {content:'皖' }, + {content:'浙' }, + {content:'津' }, + {content:'吉' }, + {content:'123', + isSpecial:true}, + + {content:'京' }, + {content:'鲁' }, + {content:'渝' }, + {content:'晋' }, + {content:'下页', + isSpecial:true}, + + {content:'沪' }, + {content:'新' }, + {content:'冀' }, + {content:'删除', + isSpecial:true }, + {content:$r('app.string.text_search'), + isSpecial:true}, +] + + +export let ProvinceSourceListData2:SourceListType[] =[ + {content:'青'}, + {content:'鄂'}, + {content:'川'}, + {content:'贵'}, + {content:'豫'}, + + + {content:'云'}, + {content:'桂'}, + {content:'藏'}, + {content:'赣'}, + {content:'辽'}, + + {content:'粤'}, + {content:'闽'}, + {content:'台'}, + {content:'琼'}, + {content:'蒙'}, + + + {content:'港'}, + {content:'澳'}, + {content:'宁'}, + {content:'甘'}, + {content:'湘'}, + + {content:'ABC', + isSpecial:true}, + {content:'123', + isSpecial:true}, + {content:'省份', + isSpecial:true}, + {content:$r('app.string.text_search'), + isSpecial:true}, +] + +export interface MapKeyData{ + key:T, + value:E +} + +export class CustomMap{ + private array:Array> = new Array(); + + addData(data:MapKeyData){ + this.array.push(data) + } + + getData(index:number):MapKeyData|null{ + if (index<0||index>=this.array.length) { + return null; + } + return this.array[index]; + } + + getDataByKey(key:T):MapKeyData|null{ + for (let i = 0; i < this.array.length; i++) { + let data = this.array[i]; + if (data.key === key) { + return data; + } + } + return null; + } + +} + +// 皖A 皖 京 沪 +// 苏 浙 鲁 新 +// 陕 津 渝 冀 +// 黑 吉 晋 删除 +//ABC 123 下页 完成 \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/keylayout/CarEnglishKeyBoard.ets b/entry/src/main/ets/view/keyboard/keylayout/CarEnglishKeyBoard.ets new file mode 100644 index 0000000..15bb20e --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/CarEnglishKeyBoard.ets @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import CommonConstants from '../data/CommonConstants'; +import { keySourceListData, KeySourceListType } from '../data/MenuData'; +import { DeleteKey } from './DeleteKey'; +import { EnglishKeyItem } from './EnglishKeyItem'; + +@Component +export struct CarEnglishKeyboard { + @State upper: boolean = true; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + //第一行 qwertyuiop + ForEach(keySourceListData.slice(0, 10), (item: KeySourceListType) => { + EnglishKeyItem({ + keyValue: item, + upper: $upper + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: KeySourceListType) => item.content as string) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_12'), bottom: $r('app.float.default_6') }) + + + //第二行 asdfghjkl + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + ForEach(keySourceListData.slice(10, 19), (item: KeySourceListType) => { + EnglishKeyItem({ + keyValue: item, + upper: $upper + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: KeySourceListType) => item.content as string) + } + .width(CommonConstants.NINETY_PERCENT_WIDTH) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + + //第三行 123 ZXCVBNM 删除 + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + // ShiftKey({ + // upper: $upper + // }) + // .margin({ + // right: $r('app.float.default_5'), + // left: $r('app.float.default_2') + // }) + EnglishKeyItem({ + keyValue:{ + title: '123', + content: '123', + upperContent: '123' + }, + upper: $upper, + color: $r('app.color.state_styles_normal') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + + ForEach(keySourceListData.slice(19, 26), (item: KeySourceListType) => { + EnglishKeyItem({ + keyValue: item, + upper: $upper + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: KeySourceListType) => item.content as string) + DeleteKey().margin({ left: $r('app.float.default_5') }) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + + //第四行 省份,清空 完成 + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + //省份 + EnglishKeyItem({ + keyValue: keySourceListData.slice(26)[0], + upper: $upper, + color: $r('app.color.state_styles_normal') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + .layoutWeight(1.5) + //清空 + EnglishKeyItem({ + keyValue: keySourceListData.slice(27)[0], + upper: $upper, + color: $r('app.color.state_styles_normal') + }) + .margin({ + right: $r('app.float.default_5'), + left: $r('app.float.default_5') + }) + .layoutWeight(1.5) + + //搜索 + EnglishKeyItem({ + keyValue: keySourceListData.slice(28)[0], + upper: $upper, + color: $r('app.color.search_background_normal') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + .layoutWeight(2) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + } + .height($r('app.float.keyboard_height')) + .padding({top:$r('app.float.default_10'),bottom:$r('app.float.default_16')}) + .backgroundColor($r('app.color.keyboard_background_color')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/keylayout/CarNumKeyBoard.ets b/entry/src/main/ets/view/keyboard/keylayout/CarNumKeyBoard.ets new file mode 100644 index 0000000..4a6707c --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/CarNumKeyBoard.ets @@ -0,0 +1,109 @@ +import CommonConstants from '../data/CommonConstants'; +import { CarNumSourceListData, SourceListType } from '../data/MenuData'; +import { DeleteKey } from './DeleteKey'; +import { NumberKeyItem } from './NumberKeyItem'; + +@Component +export struct CarNumKeyboard { + + aboutToAppear(): void { + + } + + build() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(CarNumSourceListData.slice(0, 4), (item: SourceListType) => { + // 第一列 1 4 7 X + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(CarNumSourceListData.slice(4, 8), (item: SourceListType) => { + // 第二列 2 5 8 0 + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(CarNumSourceListData.slice(8, 12), (item: SourceListType, index: number) => { + // if (index == 3) { + // // 第三列 3 6 9 清空 + // NumberKeyItem({ + // keyValue: { + // content: this.dynamicContent + // }, + // color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + // }) + // } else { + // 第三列 3 6 9 清空 + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + // } + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + // Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + // ForEach(CarNumSourceListData.slice(12, 16), (item: SourceListType) => { + // // 第一列 3 6 9 清空 + // NumberKeyItem({ + // keyValue: item, + // color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + // }) + // }, (item: string) => JSON.stringify(item)) + // } + // .margin({ right: $r('app.float.default_5') }) + // 第四列 3 6 9 清空 + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + DeleteKey() + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + // ArrowKey({ arrowDirection: ArrowDirection.LEFT }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + // .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + // ArrowKey({ arrowDirection: ArrowDirection.RIGHT }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + // .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + NumberKeyItem({ + keyValue: CarNumSourceListData.slice(13)[0], + color: $r('app.color.state_styles_normal') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_10') }) + NumberKeyItem({ + keyValue: CarNumSourceListData.slice(14)[0], + color: $r('app.color.search_background_normal') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_TWO) + .margin({ bottom: $r('app.float.default_10') }) + // NumberKeyItem({ + // keyValue: CarNumSourceListData.slice(16)[0], + // color: $r('app.color.state_styles_normal') + // }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + // .margin({ bottom: $r('app.float.default_10') }) + // NumberKeyItem({ + // keyValue: CarNumSourceListData.slice(17)[0], + // color: $r('app.color.search_background_normal') + // }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_TWO) + // .margin({ bottom: $r('app.float.default_10') }) + } + } + .padding({top:$r('app.float.default_10'),bottom:$r('app.float.default_16'),right:$r('app.float.default_6'),left:$r('app.float.default_6')}) + .height($r('app.float.keyboard_height')) + .backgroundColor($r('app.color.keyboard_background_color')) + } +} diff --git a/entry/src/main/ets/view/keyboard/keylayout/DeleteKey.ets b/entry/src/main/ets/view/keyboard/keylayout/DeleteKey.ets new file mode 100644 index 0000000..eaebdab --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/DeleteKey.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. 箭头 + */ +import CommonConstants from "../data/CommonConstants"; +import { KeyEventObserved } from "../KeyEventObserved"; + + +@Component +export struct DeleteKey { + @Consume searchContent: string; + @Consume keyEventObserved:KeyEventObserved + + @Styles + pressedStyles() { + .backgroundColor($r('app.color.state_styles_pressed')) + } + + @Styles + normalStyles() { + .backgroundColor($r('app.color.state_styles_normal')) + } + + build() { + Stack() { + Image($r('app.media.delete')) + .width($r('app.float.delete_image_size')) + .aspectRatio(CommonConstants.IMAGE_ASPECT_RATIO) + } + .backgroundColor($r('app.color.delete_key_background')) + .borderRadius($r('app.float.comm_image_radius')) + .onClick(() => { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.DELETE_CHARACTERS, this.searchContent); + }) + .width(CommonConstants.PERCENTAGE_MAX) + .height(CommonConstants.PERCENTAGE_MAX) + .stateStyles({ + normal: this.normalStyles, + pressed: this.pressedStyles + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/keylayout/EnglishKeyItem.ets b/entry/src/main/ets/view/keyboard/keylayout/EnglishKeyItem.ets new file mode 100644 index 0000000..8d5c7a8 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/EnglishKeyItem.ets @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import CommonConstants from "../data/CommonConstants"; +import { KeySourceListType } from "../data/MenuData"; +import { KeyEventObserved } from "../KeyEventObserved"; + +// import KeyEventListen from "../KeyEventListen"; + +@Component +export struct EnglishKeyItem { + private keyValue: KeySourceListType | undefined = undefined; + private color: ResourceStr = $r('app.color.font_background_white'); + @Link upper: boolean; + @Consume searchContent: string; + @Consume menuType: number; + @Consume keyEventObserved:KeyEventObserved + + @Styles + pressedStyles() { + .backgroundColor($r('app.color.state_styles_pressed')) + } + + @Styles + normalStyles() { + .backgroundColor(this.color) + } + + getResourceString(resource: Resource): string { + let resourceString: string = ''; + try { + resourceString = getContext(this).resourceManager.getStringSync(resource.id); + } catch (error) { + console.error('getResourceString err:' + JSON.stringify(error)); + } + return resourceString; + } + + getTextColor() : ResourceColor{ + //$r('app.string.text_space') + if ( this.getResourceString(this.keyValue?.content as Resource) === this.getResourceString($r('app.string.text_search'))) { + return $r('app.color.font_background_white') + } + return $r('app.color.font_color') + } + build() { + Text(this.upper ? this.keyValue?.upperContent : this.keyValue?.content) + .fontSize($r('app.float.text_size_20')) + .fontColor(this.getTextColor()) + .textAlign(TextAlign.Center) + .borderRadius($r('app.float.comm_image_radius')) + .width(CommonConstants.PERCENTAGE_MAX) + .height(CommonConstants.PERCENTAGE_MAX) + .onClick(() => { + if (this.keyValue?.content === CommonConstants.TEXT_PROVINCE1) { + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE1; + } else if (this.keyValue?.content === CommonConstants.TEXT_PROVINCE2) { + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE2; + } else if (this.keyValue?.content === CommonConstants.TEXT_DIGIT) { + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_NUM; + } else if (this.getResourceString(this.keyValue?.content as Resource) === + this.getResourceString($r('app.string.text_clear'))) { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.CLEAR_CHARACTERS); + } else if (this.getResourceString(this.keyValue?.content as Resource) === + this.getResourceString($r('app.string.text_space'))) { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.STRING_CHARACTERS, ' '); + } else if (this.getResourceString(this.keyValue?.content as Resource) === + this.getResourceString($r('app.string.text_search'))) { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.TEXT_SEARCH, this.searchContent); + return; + } else { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.STRING_CHARACTERS, this.upper ? + this.keyValue?.upperContent as string : this.keyValue?.content as string); + } + }) + .stateStyles({ normal: this.normalStyles, pressed: this.pressedStyles }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/keylayout/IdCardNumKeyBoard.ets b/entry/src/main/ets/view/keyboard/keylayout/IdCardNumKeyBoard.ets new file mode 100644 index 0000000..bdbc278 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/IdCardNumKeyBoard.ets @@ -0,0 +1,111 @@ +import CommonConstants from '../data/CommonConstants'; +import { IcCardNumSourceListData, SourceListType } from '../data/MenuData'; +import { DeleteKey } from './DeleteKey'; +import { NumberKeyItem } from './NumberKeyItem'; + +@Component +export struct IdCardNumKeyboard { + private dynamicContent: string = '3400' + + aboutToAppear(): void { + this.dynamicContent = '3401' + + } + + build() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(IcCardNumSourceListData.slice(0, 4), (item: SourceListType) => { + // 第一列 1 4 7 X + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(IcCardNumSourceListData.slice(4, 8), (item: SourceListType) => { + // 第二列 2 5 8 0 + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(IcCardNumSourceListData.slice(8, 12), (item: SourceListType, index: number) => { + if (index == 3) { + // 第三列 3 6 9 清空 + NumberKeyItem({ + keyValue: { + content: this.dynamicContent + }, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + } else { + // 第三列 3 6 9 清空 + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + } + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + // Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + // ForEach(IcCardNumSourceListData.slice(12, 16), (item: SourceListType) => { + // // 第一列 3 6 9 清空 + // NumberKeyItem({ + // keyValue: item, + // color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + // }) + // }, (item: string) => JSON.stringify(item)) + // } + // .margin({ right: $r('app.float.default_5') }) + // 第四列 3 6 9 清空 + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + DeleteKey() + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + // ArrowKey({ arrowDirection: ArrowDirection.LEFT }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + // .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + // ArrowKey({ arrowDirection: ArrowDirection.RIGHT }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + // .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + NumberKeyItem({ + keyValue: IcCardNumSourceListData.slice(13)[0], + color: $r('app.color.state_styles_normal') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_10') }) + NumberKeyItem({ + keyValue: IcCardNumSourceListData.slice(15)[0], + color: $r('app.color.search_background_normal') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_TWO) + .margin({ bottom: $r('app.float.default_10') }) + // NumberKeyItem({ + // keyValue: IcCardNumSourceListData.slice(16)[0], + // color: $r('app.color.state_styles_normal') + // }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + // .margin({ bottom: $r('app.float.default_10') }) + // NumberKeyItem({ + // keyValue: IcCardNumSourceListData.slice(17)[0], + // color: $r('app.color.search_background_normal') + // }) + // .layoutWeight(CommonConstants.LAYOUT_WEIGHT_TWO) + // .margin({ bottom: $r('app.float.default_10') }) + } + } + .padding({top:$r('app.float.default_10'),bottom:$r('app.float.default_20'),right:$r('app.float.default_6'),left:$r('app.float.default_6')}) + .height($r('app.float.keyboard_height')) + .backgroundColor($r('app.color.keyboard_background_color')) + } +} diff --git a/entry/src/main/ets/view/keyboard/keylayout/NumberKeyItem.ets b/entry/src/main/ets/view/keyboard/keylayout/NumberKeyItem.ets new file mode 100644 index 0000000..3a6dd79 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/NumberKeyItem.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License,Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import CommonConstants from "../data/CommonConstants"; +import { SourceListType } from "../data/MenuData"; +import { KeyEventObserved } from "../KeyEventObserved"; + +// import KeyEventListen from "../KeyEventListen"; + +@Component +export struct NumberKeyItem { + @Consume searchContent: string; + @Consume menuType: number; + private keyValue: SourceListType | undefined = undefined; + private color: ResourceStr = $r('app.color.font_background_white'); + @Consume keyEventObserved:KeyEventObserved + + @Styles + pressedStyles() { + .backgroundColor($r('app.color.state_styles_pressed')) + } + + @Styles + normalStyles() { + .backgroundColor(this.color) + } + + getResourceString(resource: Resource): string { + let resourceString: string = ''; + try { + resourceString = getContext(this).resourceManager.getStringSync(resource.id); + } catch (error) { + console.error('getResourceString err:' + JSON.stringify(error)); + } + return resourceString; + } + + getTextColor(): ResourceColor { + //$r('app.string.text_space') + if (this.getResourceString(this.keyValue?.content as Resource) === + this.getResourceString($r('app.string.text_search'))) { + return $r('app.color.font_background_white') + } + return $r('app.color.font_color') + } + + build() { + Text(this.keyValue?.content) + .fontSize($r('app.float.text_size_20')) + .fontColor(this.getTextColor()) + .textAlign(TextAlign.Center) + .borderRadius($r('app.float.comm_image_radius')) + .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }) + .width(CommonConstants.PERCENTAGE_MAX) + .height(CommonConstants.PERCENTAGE_MAX) + .onClick(() => { + if (this.keyValue?.content === CommonConstants.TEXT_PROVINCE1) {//切换省份 + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE1; + } else if (this.keyValue?.content === CommonConstants.TEXT_DIGIT) {//切换数字 + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_NUM; + } else if (this.keyValue?.content === CommonConstants.TEXT_PROVINCE2) {//切换下一页 + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_PROVINCE2; + } else if (this.keyValue?.content === CommonConstants.TEXT_ENGLISH) {//切换英文 + this.menuType = CommonConstants.KEYBOARD_TYPE_CAR_ENGLISH; + } else if (this.getResourceString(this.keyValue?.content as Resource) === + this.getResourceString($r('app.string.text_clear'))) { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.CLEAR_CHARACTERS); + } else if (this.getResourceString(this.keyValue?.content as Resource) === + this.getResourceString($r('app.string.text_search'))) { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.TEXT_SEARCH, this.searchContent); + return; + } else { + this.searchContent = this.keyEventObserved.onKeyboardMethod(CommonConstants.STRING_CHARACTERS, + this.keyValue?.content as string); + } + }) + .stateStyles({ normal: this.normalStyles, pressed: this.pressedStyles }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/keyboard/keylayout/Province1KeyBoard.ets b/entry/src/main/ets/view/keyboard/keylayout/Province1KeyBoard.ets new file mode 100644 index 0000000..99a4e75 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/Province1KeyBoard.ets @@ -0,0 +1,115 @@ +import CommonConstants from '../data/CommonConstants'; +import { CustomMap, ProvinceSourceListData1, SourceListType } from '../data/MenuData'; +import { DeleteKey } from './DeleteKey'; +import { NumberKeyItem } from './NumberKeyItem'; + +@Component +export struct Province1Keyboard { + private dynamicContent: string = '皖A' + private pzcl: CustomMap = new CustomMap(); + + aboutToAppear(): void { + this.pzcl.addData({ key: "3400", value: '皖A' }) + this.pzcl.addData({ key: "3401", value: '皖A' }) + this.pzcl.addData({ key: "3402", value: '皖B' }) + this.pzcl.addData({ key: "3403", value: '皖C' }) + this.pzcl.addData({ key: "3404", value: '皖D' }) + this.pzcl.addData({ key: "3405", value: '皖E' }) + this.pzcl.addData({ key: "3406", value: '皖F' }) + this.pzcl.addData({ key: "3407", value: '皖G' }) + this.pzcl.addData({ key: "3408", value: '皖H' }) + this.pzcl.addData({ key: "3410", value: '皖J' }) + this.pzcl.addData({ key: "3411", value: '皖M' }) + this.pzcl.addData({ key: "3412", value: '皖K' }) + this.pzcl.addData({ key: "3413", value: '皖L' }) + this.pzcl.addData({ key: "3415", value: '皖N' }) + this.pzcl.addData({ key: "3416", value: '皖S' }) + this.pzcl.addData({ key: "3417", value: '皖R' }) + this.pzcl.addData({ key: "3418", value: '皖P' }) + + this.dynamicContent = '皖A' + //TODO 这里动态处理 dynamicContent 的值 + //根据用户 组织机构获取 简称 + } + + build() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + // 第一列 3 6 9 清空 + ForEach(ProvinceSourceListData1.slice(0, 5), (item: SourceListType, index: number) => { + if (index == 0) { + NumberKeyItem({ + keyValue: { + content: this.dynamicContent + }, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + } else { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + } + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + // 第二列 + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(ProvinceSourceListData1.slice(5, 10), (item: SourceListType) => { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + // 第三列 + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(ProvinceSourceListData1.slice(10, 15), (item: SourceListType) => { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + }, (item: string) => JSON.stringify(item)) + } + .margin({ right: $r('app.float.default_5') }) + + // 第四列 + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { + NumberKeyItem({ + keyValue: ProvinceSourceListData1.slice(15)[0], + color: $r('app.color.font_background_white') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_10') }); + NumberKeyItem({ + keyValue: ProvinceSourceListData1.slice(16)[0], + color: $r('app.color.font_background_white') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_10') }) + NumberKeyItem({ + keyValue: ProvinceSourceListData1.slice(17)[0], + color: $r('app.color.font_background_white') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_10') }) + + DeleteKey() + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_5'), top: $r('app.float.default_5') }); + + NumberKeyItem({ + keyValue: ProvinceSourceListData1.slice(19)[0], + color: $r('app.color.search_background_normal') + }) + .layoutWeight(CommonConstants.LAYOUT_WEIGHT_ONE) + .margin({ bottom: $r('app.float.default_10') }) + } + } + .padding({top:$r('app.float.default_10'),bottom:$r('app.float.default_16'),right:$r('app.float.default_6'),left:$r('app.float.default_6')}) + .height($r('app.float.keyboard_height_2')) + .backgroundColor($r('app.color.keyboard_background_color')) + } +} diff --git a/entry/src/main/ets/view/keyboard/keylayout/Province2Keyboard.ets b/entry/src/main/ets/view/keyboard/keylayout/Province2Keyboard.ets new file mode 100644 index 0000000..07149f2 --- /dev/null +++ b/entry/src/main/ets/view/keyboard/keylayout/Province2Keyboard.ets @@ -0,0 +1,131 @@ +import CommonConstants from "../data/CommonConstants" +import { ProvinceSourceListData2, SourceListType } from "../data/MenuData" +import { NumberKeyItem } from "./NumberKeyItem" + +@Component +export struct Province2Keyboard { + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + //第一行 qwertyuiop + ForEach(ProvinceSourceListData2.slice(0, 5), (item: SourceListType) => { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: SourceListType) => item.content as string) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_12'), bottom: $r('app.float.default_6') }) + + + //第二行 asdfghjkl + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + ForEach(ProvinceSourceListData2.slice(5, 10), (item: SourceListType) => { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: SourceListType) => item.content as string) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + + //第三行 asdfghjkl + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + ForEach(ProvinceSourceListData2.slice(10, 15), (item: SourceListType) => { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: SourceListType) => item.content as string) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + + //第四行 asdfghjkl + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + ForEach(ProvinceSourceListData2.slice(15, 20), (item: SourceListType) => { + NumberKeyItem({ + keyValue: item, + color: item.isSpecial ? $r('app.color.state_styles_normal') : $r('app.color.font_background_white') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + }, (item: SourceListType) => item.content as string) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + + + //第五行 省份,清空 完成 + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + //ABC + NumberKeyItem({ + keyValue: ProvinceSourceListData2.slice(20)[0], + color: $r('app.color.state_styles_normal') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + .layoutWeight(1) + //123 + NumberKeyItem({ + keyValue: ProvinceSourceListData2.slice(21)[0], + color: $r('app.color.state_styles_normal') + }) + .margin({ + right: $r('app.float.default_5'), + left: $r('app.float.default_5') + }) + .layoutWeight(1) + + //省份 + NumberKeyItem({ + keyValue: ProvinceSourceListData2.slice(22)[0], + color: $r('app.color.state_styles_normal') + }) + .margin({ + right: $r('app.float.default_5'), + left: $r('app.float.default_5') + }) + .layoutWeight(1) + + //搜索 + NumberKeyItem({ + keyValue: ProvinceSourceListData2.slice(23)[0], + color: $r('app.color.search_background_normal') + }) + .margin({ + right: $r('app.float.default_2'), + left: $r('app.float.default_2') + }) + .layoutWeight(2) + } + .width(CommonConstants.PERCENTAGE_MAX) + .margin({ top: $r('app.float.default_6'), bottom: $r('app.float.default_6') }) + + } + .height($r('app.float.keyboard_height_2')) + .padding({top:$r('app.float.default_10'),bottom:$r('app.float.default_16'),right:$r('app.float.default_6'),left:$r('app.float.default_6')}) + .backgroundColor($r('app.color.keyboard_background_color')) + } + + +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000..29a5fec --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,134 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "srcEntry": './ets/app/RuanseeAbitityStag.ets', + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "requestPermissions": [ + { + "name":"ohos.permission.MICROPHONE", + "reason":"$string:app_name", + "usedScene":{ + "abilities":[ + ".EntryAbility" + ], + "when":"inuse" + } + }, + { + "name":"ohos.permission.ACCELEROMETER", + "reason":"$string:app_name", + "usedScene":{ + "abilities":[ + ".EntryAbility" + ], + "when":"inuse" + } + }, + { + "name": "ohos.permission.INTERNET", + "usedScene": { + "when": "always" + } + }, + { + "name": "ohos.permission.GET_NETWORK_INFO" + }, + // 震动权限 GQ6666 GQ8888 + { + "name": 'ohos.permission.VIBRATE', + "reason":"$string:app_name", + "usedScene":{ + "abilities":[ + ".EntryAbility" + ], + "when":"inuse" + } + }, + { + "name": "ohos.permission.CAMERA", + "reason": "$string:app_name", + "usedScene": { + "abilities":["EntryAbility"] + } + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "$string:app_name", + "usedScene": { + "abilities":["EntryAbility"]} + }, + { + "name": "ohos.permission.WRITE_MEDIA", + "reason": "$string:app_name", + "usedScene": { + "abilities":["EntryAbility"]} + }, + {"name": "ohos.permission.LOCATION", + "reason": "$string:app_name", + "usedScene": { + "abilities":["EntryAbility"], + "when": "inuse" + } + }, + {"name": "ohos.permission.APPROXIMATELY_LOCATION", + "reason": "$string:app_name", + "usedScene": { + "abilities":["EntryAbility"], + "when": "inuse" + } + }, + {"name": "ohos.permission.LOCATION_IN_BACKGROUND", + "reason": "$string:app_name", + "usedScene": { + "abilities":["EntryAbility"], + "when": "inuse" + } + } + ], + + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:ic_applogin", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:ic_applogin", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000..2be24a5 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,301 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "total_background", + "value": "#FF1954EE" + }, + { + "name": "hc_an_bk", + "value": "#FF2170eb" + }, + { + "name": "hc_an_bj", + "value": "#12ffffff" + }, + { + "name": "page_background", + "value": "#F4F8FA" + }, + { + "name": "divider_background", + "value": "#FFB8B8B8" + }, + { + "name": "time_background", + "value": "#a0C7CDD0" + }, + { + "name": "read", + "value": "#FFEE1939" + }, + { + "name": "white", + "value": "#FFFFFF" + }, + { + "name": "green", + "value": "#FF19EE35" + }, + { + "name": "grad", + "value": "#FF646464" + }, + { + "name": "black", + "value": "#FF1D1D1D" + }, + { + "name": "bull", + "value": "#1264DE" + }, + { + "name": "colorRed9", + "value": "#e63119" + }, + { + "name": "colorBluen12", + "value": "#5BC5D5E2" + }, + { + "name": "detailsBackdrop", + "value": "#fff4f8fa" + }, + { + "name": "peopletype1", + "value": "#c8f49f" + }, + { + "name": "peopletype2", + "value": "#a3d273" + }, + { + "name": "peopletype3", + "value": "#06e45f" + }, + { + "name": "peopletype4", + "value": "#fae2ba" + }, + { + "name": "peopletype5", + "value": "#e9bf95" + }, + { + "name": "peopletype6", + "value": "#e4872a" + }, + { + "name": "peopletype7", + "value": "#FFE99595" + }, + { + "name": "peopletype8", + "value": "#FFE42A2A" + }, + { + "name": "state_styles_pressed", + "value": "#868B95" + }, + { + "name": "state_styles_normal", + "value": "#B5B7BF" + }, + { + "name": "delete_key_background", + "value": "#A8ABB7" + }, + { + "name": "delete_key_shadow", + "value": "#76787C" + }, + { + "name": "search_background_normal", + "value": "#0A59F7" + }, + { + "name": "font_background_white", + "value": "#FFFFFF" + }, + { + "name": "keyboard_background_color", + "value": "#DADFE6" + }, + { + "name": "search_background_color", + "value": "#F2F2F2" + }, + { + "name": "search_font_color", + "value": "#000000" + }, + { + "name": "font_color", + "value": "#222222" + }, + { + "name": "main_tj_a", + "value": "#FFD5EBF5" + }, + { + "name": "main_tj_b", + "value": "#E9FDE5" + }, + { + "name": "main_tj_c", + "value": "#FDF9E5" + }, + { + "name": "main_tj_d", + "value": "#FF93C1F1" + }, + { + "name": "colorBluen8", + "value": "#0A87CC" + }, + { + "name": "colorBluen7", + "value": "#0785c9" + }, + { + "name": "colorBluen6", + "value": "#1f94d3" + }, + { + "name": "colorBluen5", + "value": "#67bdec" + }, + { + "name": "colorBluen4", + "value": "#67bbe9" + }, + { + "name": "colorBluen3", + "value": "#80cdf7" + }, + { + "name": "colorBluen2", + "value": "#a7defc" + }, + { + "name": "colorBluen1", + "value": "#e1f3fd" + }, + { + "name": "colorBluen", + "value": "#E6F5FF" + }, + { + "name": "colorGreen1", + "value": "#e8f5e9" + }, + { + "name": "colorGreen2", + "value": "#c8e6c9" + }, + { + "name": "colorGreen3", + "value": "#a5d6a7" + }, + { + "name": "colorGreen4", + "value": "#81c784" + }, + { + "name": "colorGreen5", + "value": "#66bb6a" + }, + { + "name": "colorGreen6", + "value": "#43a047" + }, + { + "name": "colorGreen7", + "value": "#388e3c" + }, + { + "name": "colorGreen", + "value": "#2DED36" + }, + + { + "name": "colorYellow", + "value": "#F19149" + }, + { + "name": "colorYellow1", + "value": "#fff3e0" + }, + + { + "name": "colorYellow2", + "value": "#ffe0b2" + }, + { + "name": "colorYellow3", + "value": "#ffcc80" + }, + + { + "name": "colorYellow4", + "value": "#ffb74d" + }, + { + "name": "colorYellow5", + "value": "#ffa726" + }, + + { + "name": "colorYellow6", + "value": "#fb8c00" + }, + { + "name": "colorYellow7", + "value": "#f57c00" + }, + { + "name": "colorYellow8", + "value": "#ff8304" + }, + + { + "name": "colorGrey1", + "value": "#f5f5f5" + }, + { + "name": "colorGreyte", + "value": "#e5e5e5" + }, + { + "name": "colorGrey2", + "value": "#eeeeee" + }, + { + "name": "colorGrey3", + "value": "#e8e8e8" + }, + { + "name": "colorGrey4", + "value": "#b2b2b2" + }, + { + "name": "colorGrey5", + "value": "#888888" + }, + { + "name": "colorGrey6", + "value": "#626262" + }, + { + "name": "colorGrey7", + "value": "#323232" + }, + { + "name": "colorGrey8", + "value": "#fe131313" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000..1080611 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,300 @@ +{ + "float": [ + { + "name": "down_image_size", + "value": "36vp" + }, + { + "name": "down_image_margin", + "value": "10vp" + }, + { + "name": "search_height", + "value": "40vp" + }, + { + "name": "search_margin", + "value": "16vp" + }, + { + "name": "search_border_radius", + "value": "20vp" + }, + { + "name": "default_1", + "value": "1vp" + }, + { + "name": "default_2", + "value": "2vp" + }, + { + "name": "default_3", + "value": "3vp" + }, + { + "name": "default_5", + "value": "5vp" + }, + { + "name": "default_6", + "value": "6vp" + }, + { + "name": "default_8", + "value": "8vp" + }, + { + "name": "default_10", + "value": "10vp" + }, + { + "name": "default_12", + "value": "12vp" + }, + { + "name": "default_14", + "value": "14vp" + }, + { + "name": "default_15", + "value": "15vp" + }, + { + "name": "default_16", + "value": "16vp" + }, + { + "name": "default_18", + "value": "18vp" + }, + { + "name": "default_20", + "value": "20vp" + }, + { + "name": "default_22", + "value": "22vp" + }, + { + "name": "default_24", + "value": "24vp" + }, + { + "name": "default_25", + "value": "25vp" + }, + { + "name": "default_26", + "value": "26vp" + }, + { + "name": "default_28", + "value": "28vp" + }, + { + "name": "default_30", + "value": "30vp" + }, + { + "name": "default_32", + "value": "32vp" + }, + { + "name": "default_36", + "value": "36vp" + }, + { + "name": "default_38", + "value": "38vp" + }, + { + "name": "default_40", + "value": "40vp" + }, + { + "name": "default_43", + "value": "43vp" + }, + { + "name": "default_46", + "value": "46vp" + }, + { + "name": "default_48", + "value": "48vp" + }, + { + "name": "default_52", + "value": "52vp" + }, + { + "name": "default_50", + "value": "50vp" + }, + { + "name": "default_58", + "value": "58vp" + }, + { + "name": "default_60", + "value": "60vp" + }, + { + "name": "default_63", + "value": "63vp" + }, + { + "name": "default_68", + "value": "68vp" + }, + { + "name": "default_66", + "value": "66vp" + }, + { + "name": "default_72", + "value": "72vp" + }, + { + "name": "default_80", + "value": "80vp" + }, + { + "name": "default_84", + "value": "84vp" + }, + { + "name": "default_88", + "value": "88vp" + }, + { + "name": "default_92", + "value": "92vp" + }, + { + "name": "default_98", + "value": "98vp" + }, + { + "name": "default_100", + "value": "100vp" + }, + { + "name": "default_110", + "value": "110vp" + }, + { + "name": "default_115", + "value": "115vp" + }, + { + "name": "default_120", + "value": "120vp" + }, + { + "name": "default_125", + "value": "125vp" + }, + { + "name": "default_130", + "value": "130vp" + }, + { + "name": "default_150", + "value": "150vp" + }, + { + "name": "default_200", + "value": "200vp" + }, + { + "name": "default_280", + "value": "280vp" + }, + { + "name": "default_300", + "value": "300vp" + }, + { + "name": "default_350", + "value": "350vp" + }, + { + "name": "default_400", + "value": "400vp" + }, + { + "name": "delete_image_size", + "value": "30vp" + }, + { + "name": "shift_image_size", + "value": "30vp" + }, + { + "name": "keyboard_height", + "value": "255vp" + }, + { + "name": "keyboard_height_2", + "value": "290vp" + }, + { + "name": "comm_image_radius", + "value": "4vp" + }, + { + "name": "text_size_10", + "value": "10fp" + }, + { + "name": "text_size_12", + "value": "12fp" + }, + { + "name": "text_size_14", + "value": "14fp" + }, + { + "name": "text_size_15", + "value": "15fp" + }, + { + "name": "text_size_16", + "value": "16fp" + }, + { + "name": "text_size_18", + "value": "18fp" + }, + { + "name": "text_size_20", + "value": "20fp" + }, + { + "name": "text_size_22", + "value": "22fp" + }, + { + "name": "text_size_24", + "value": "24fp" + }, + { + "name": "text_size_28", + "value": "28fp" + }, + { + "name": "text_size_32", + "value": "32fp" + }, + { + "name": "text_size_38", + "value": "38fp" + }, + { + "name": "text_size_42", + "value": "42fp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000..b34ed38 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,127 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "人车物核验" + }, + { + "name": "ownership_dept", + "value": "安徽省公安厅" + }, + { + "name": "search_box_prompt", + "value": "最多可输入18个字符" + }, + { + "name": "text_search", + "value": "搜索" + }, + { + "name": "text_space", + "value": "空格" + }, + { + "name": "text_clear", + "value": "清空" + }, + { + "name": "under_urgent_development", + "value": "正在紧急开发中..." + }, + { + "name": "loading_check_people", + "value": "正在核查人员信息,请稍后..." + }, + { + "name": "loading_hint", + "value": "正在加载,请稍后..." + }, + { + "name": "no_data_yet", + "value": "暂无数据!" + }, + { + "name": "input_idCardNum_error", + "value": "请检查身份证号是否正确!" + }, + { + "name": "str_jmpc", + "value": "街面盘查" + }, + { + "name": "str_kdhl", + "value": "卡点核录" + }, + { + "name": "title_select_task", + "value": "选择任务" + }, + { + "name": "str_historical_records", + "value": "历史记录" + }, + { + "name": "str_my_concerns", + "value": "我的关注" + }, + { + "name": "check_reason", + "value": "例行盘查,体貌可疑,眼神可疑," + }, + { + "name": "attention_person_explanation1", + "value": "此类关注表示此人员被多次盘查,有可疑行径设为关注" + }, + { + "name": "attention_person_explanation2", + "value": "此类关注表示此人员疑似问题人员,可能是案件相关人员" + }, + { + "name": "attention_person_explanation3", + "value": "此类关注表示此人员高度可疑,需重点关注" + }, + { + "name": "attention_car_explanation1", + "value": "此类关注表示此车辆被多次盘查,有可疑行径设为关注" + }, + { + "name": "attention_car_explanation2", + "value": "此类关注表示此车辆疑似问题车辆,可能是案件相关车辆" + }, + { + "name": "attention_car_explanation3", + "value": "此类关注表示此车辆高度可疑,需重点关注" + }, + { + "name": "title_history_details", + "value": "历史记录详情" + }, + { + "name": "title_About", + "value": "关于" + }, + { + "name": "title_accompan_person", + "value": "随行人员" + }, { + "name": "loading_detection_face", + "value": "正在检测人脸..." + }, + { + "name": "loading_comparison_face", + "value": "正在比对人脸..." + }, + { + "name": "title_right_submit", + "value": "提交" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000..f939c9f Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/check_box.png b/entry/src/main/resources/base/media/check_box.png new file mode 100644 index 0000000..aab0a12 Binary files /dev/null and b/entry/src/main/resources/base/media/check_box.png differ diff --git a/entry/src/main/resources/base/media/delete.svg b/entry/src/main/resources/base/media/delete.svg new file mode 100644 index 0000000..446ab28 --- /dev/null +++ b/entry/src/main/resources/base/media/delete.svg @@ -0,0 +1,7 @@ + + + ic_celiakeyboard_delete + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/down.svg b/entry/src/main/resources/base/media/down.svg new file mode 100644 index 0000000..7bb57b9 --- /dev/null +++ b/entry/src/main/resources/base/media/down.svg @@ -0,0 +1,15 @@ + + + + 画板 + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000..4483dda Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/ic_check_bg.png b/entry/src/main/resources/base/media/ic_check_bg.png new file mode 100644 index 0000000..838f3b5 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_check_bg.png differ diff --git a/entry/src/main/resources/base/media/ic_face.png b/entry/src/main/resources/base/media/ic_face.png new file mode 100644 index 0000000..c35b0e9 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_face.png differ diff --git a/entry/src/main/resources/base/media/ic_keyboard.png b/entry/src/main/resources/base/media/ic_keyboard.png new file mode 100644 index 0000000..c4e7b53 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_keyboard.png differ diff --git a/entry/src/main/resources/base/media/ic_light.png b/entry/src/main/resources/base/media/ic_light.png new file mode 100644 index 0000000..5b71b43 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_light.png differ diff --git a/entry/src/main/resources/base/media/ic_nfc.png b/entry/src/main/resources/base/media/ic_nfc.png new file mode 100644 index 0000000..6004d26 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_nfc.png differ diff --git a/entry/src/main/resources/base/media/ic_ocr.png b/entry/src/main/resources/base/media/ic_ocr.png new file mode 100644 index 0000000..51efdbc Binary files /dev/null and b/entry/src/main/resources/base/media/ic_ocr.png differ diff --git a/entry/src/main/resources/base/media/ic_row_right.png b/entry/src/main/resources/base/media/ic_row_right.png new file mode 100644 index 0000000..df3d505 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_row_right.png differ diff --git a/entry/src/main/resources/base/media/ic_type_bdq.png b/entry/src/main/resources/base/media/ic_type_bdq.png new file mode 100644 index 0000000..4410b11 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_bdq.png differ diff --git a/entry/src/main/resources/base/media/ic_type_case.png b/entry/src/main/resources/base/media/ic_type_case.png new file mode 100644 index 0000000..984d147 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_case.png differ diff --git a/entry/src/main/resources/base/media/ic_type_control.png b/entry/src/main/resources/base/media/ic_type_control.png new file mode 100644 index 0000000..719e685 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_control.png differ diff --git a/entry/src/main/resources/base/media/ic_type_criminal_record.png b/entry/src/main/resources/base/media/ic_type_criminal_record.png new file mode 100644 index 0000000..b5e978a Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_criminal_record.png differ diff --git a/entry/src/main/resources/base/media/ic_type_escape.png b/entry/src/main/resources/base/media/ic_type_escape.png new file mode 100644 index 0000000..0098e28 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_escape.png differ diff --git a/entry/src/main/resources/base/media/ic_type_fear.png b/entry/src/main/resources/base/media/ic_type_fear.png new file mode 100644 index 0000000..e3d5fe2 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_fear.png differ diff --git a/entry/src/main/resources/base/media/ic_type_fine.png b/entry/src/main/resources/base/media/ic_type_fine.png new file mode 100644 index 0000000..2becf15 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_fine.png differ diff --git a/entry/src/main/resources/base/media/ic_type_focus.png b/entry/src/main/resources/base/media/ic_type_focus.png new file mode 100644 index 0000000..01423b4 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_focus.png differ diff --git a/entry/src/main/resources/base/media/ic_type_non.png b/entry/src/main/resources/base/media/ic_type_non.png new file mode 100644 index 0000000..3f97a91 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_non.png differ diff --git a/entry/src/main/resources/base/media/ic_type_normal.png b/entry/src/main/resources/base/media/ic_type_normal.png new file mode 100644 index 0000000..f8a4c24 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_normal.png differ diff --git a/entry/src/main/resources/base/media/ic_type_poison.png b/entry/src/main/resources/base/media/ic_type_poison.png new file mode 100644 index 0000000..21a85ea Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_poison.png differ diff --git a/entry/src/main/resources/base/media/ic_type_stability.png b/entry/src/main/resources/base/media/ic_type_stability.png new file mode 100644 index 0000000..5726674 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_type_stability.png differ diff --git a/entry/src/main/resources/base/media/ic_voice.png b/entry/src/main/resources/base/media/ic_voice.png new file mode 100644 index 0000000..9973b85 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_voice.png differ diff --git a/entry/src/main/resources/base/media/icon_about.png b/entry/src/main/resources/base/media/icon_about.png new file mode 100644 index 0000000..a3305e5 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_about.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_bg.png b/entry/src/main/resources/base/media/icon_attention_bg.png new file mode 100644 index 0000000..483b694 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_bg.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_leven1.png b/entry/src/main/resources/base/media/icon_attention_leven1.png new file mode 100644 index 0000000..af64fab Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_leven1.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_leven1_def.png b/entry/src/main/resources/base/media/icon_attention_leven1_def.png new file mode 100644 index 0000000..a987f37 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_leven1_def.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_leven2.png b/entry/src/main/resources/base/media/icon_attention_leven2.png new file mode 100644 index 0000000..7e71f3d Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_leven2.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_leven2_def.png b/entry/src/main/resources/base/media/icon_attention_leven2_def.png new file mode 100644 index 0000000..659b07d Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_leven2_def.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_leven3.png b/entry/src/main/resources/base/media/icon_attention_leven3.png new file mode 100644 index 0000000..5091d17 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_leven3.png differ diff --git a/entry/src/main/resources/base/media/icon_attention_leven3_def.png b/entry/src/main/resources/base/media/icon_attention_leven3_def.png new file mode 100644 index 0000000..85c1d7a Binary files /dev/null and b/entry/src/main/resources/base/media/icon_attention_leven3_def.png differ diff --git a/entry/src/main/resources/base/media/icon_back2.png b/entry/src/main/resources/base/media/icon_back2.png new file mode 100644 index 0000000..d8ca19a Binary files /dev/null and b/entry/src/main/resources/base/media/icon_back2.png differ diff --git a/entry/src/main/resources/base/media/icon_back3.png b/entry/src/main/resources/base/media/icon_back3.png new file mode 100644 index 0000000..39478c5 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_back3.png differ diff --git a/entry/src/main/resources/base/media/icon_badges.png b/entry/src/main/resources/base/media/icon_badges.png new file mode 100644 index 0000000..e174082 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_badges.png differ diff --git a/entry/src/main/resources/base/media/icon_checkcar_pz.png b/entry/src/main/resources/base/media/icon_checkcar_pz.png new file mode 100644 index 0000000..f737d91 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_checkcar_pz.png differ diff --git a/entry/src/main/resources/base/media/icon_colse.png b/entry/src/main/resources/base/media/icon_colse.png new file mode 100644 index 0000000..d8ed009 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_colse.png differ diff --git a/entry/src/main/resources/base/media/icon_delete.png b/entry/src/main/resources/base/media/icon_delete.png new file mode 100644 index 0000000..3a73840 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_delete.png differ diff --git a/entry/src/main/resources/base/media/icon_empty.svg b/entry/src/main/resources/base/media/icon_empty.svg new file mode 100644 index 0000000..371e01e --- /dev/null +++ b/entry/src/main/resources/base/media/icon_empty.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/icon_error.svg b/entry/src/main/resources/base/media/icon_error.svg new file mode 100644 index 0000000..35f229e --- /dev/null +++ b/entry/src/main/resources/base/media/icon_error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/icon_error2.png b/entry/src/main/resources/base/media/icon_error2.png new file mode 100644 index 0000000..6f3c01b Binary files /dev/null and b/entry/src/main/resources/base/media/icon_error2.png differ diff --git a/entry/src/main/resources/base/media/icon_error_image.png b/entry/src/main/resources/base/media/icon_error_image.png new file mode 100644 index 0000000..605db3b Binary files /dev/null and b/entry/src/main/resources/base/media/icon_error_image.png differ diff --git a/entry/src/main/resources/base/media/icon_historical_record.png b/entry/src/main/resources/base/media/icon_historical_record.png new file mode 100644 index 0000000..7577829 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_historical_record.png differ diff --git a/entry/src/main/resources/base/media/icon_history_list.png b/entry/src/main/resources/base/media/icon_history_list.png new file mode 100644 index 0000000..2723e9d Binary files /dev/null and b/entry/src/main/resources/base/media/icon_history_list.png differ diff --git a/entry/src/main/resources/base/media/icon_home_bg.png b/entry/src/main/resources/base/media/icon_home_bg.png new file mode 100644 index 0000000..455c526 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_home_bg.png differ diff --git a/entry/src/main/resources/base/media/icon_idcard_photo.png b/entry/src/main/resources/base/media/icon_idcard_photo.png new file mode 100644 index 0000000..e48cb0c Binary files /dev/null and b/entry/src/main/resources/base/media/icon_idcard_photo.png differ diff --git a/entry/src/main/resources/base/media/icon_item_defautle.png b/entry/src/main/resources/base/media/icon_item_defautle.png new file mode 100644 index 0000000..2860f8e Binary files /dev/null and b/entry/src/main/resources/base/media/icon_item_defautle.png differ diff --git a/entry/src/main/resources/base/media/icon_load_image.png b/entry/src/main/resources/base/media/icon_load_image.png new file mode 100644 index 0000000..cefa214 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_load_image.png differ diff --git a/entry/src/main/resources/base/media/icon_max_sbl.png b/entry/src/main/resources/base/media/icon_max_sbl.png new file mode 100644 index 0000000..56dbcef Binary files /dev/null and b/entry/src/main/resources/base/media/icon_max_sbl.png differ diff --git a/entry/src/main/resources/base/media/icon_photo.png b/entry/src/main/resources/base/media/icon_photo.png new file mode 100644 index 0000000..a30ad62 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_photo.png differ diff --git a/entry/src/main/resources/base/media/icon_point_check.png b/entry/src/main/resources/base/media/icon_point_check.png new file mode 100644 index 0000000..cdcaba3 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_point_check.png differ diff --git a/entry/src/main/resources/base/media/icon_qtwp.png b/entry/src/main/resources/base/media/icon_qtwp.png new file mode 100644 index 0000000..8e5bd12 Binary files /dev/null and b/entry/src/main/resources/base/media/icon_qtwp.png differ diff --git a/entry/src/main/resources/base/media/icon_scrutiny.png b/entry/src/main/resources/base/media/icon_scrutiny.png new file mode 100644 index 0000000..f931aaf Binary files /dev/null and b/entry/src/main/resources/base/media/icon_scrutiny.png differ diff --git a/entry/src/main/resources/base/media/imp_upload.png b/entry/src/main/resources/base/media/imp_upload.png new file mode 100644 index 0000000..92050f3 Binary files /dev/null and b/entry/src/main/resources/base/media/imp_upload.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000..fb49920 --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/log_qz.png b/entry/src/main/resources/base/media/log_qz.png new file mode 100644 index 0000000..feb61f5 Binary files /dev/null and b/entry/src/main/resources/base/media/log_qz.png differ diff --git a/entry/src/main/resources/base/media/log_rl.png b/entry/src/main/resources/base/media/log_rl.png new file mode 100644 index 0000000..341e835 Binary files /dev/null and b/entry/src/main/resources/base/media/log_rl.png differ diff --git a/entry/src/main/resources/base/media/log_tp.png b/entry/src/main/resources/base/media/log_tp.png new file mode 100644 index 0000000..1cc0dfa Binary files /dev/null and b/entry/src/main/resources/base/media/log_tp.png differ diff --git a/entry/src/main/resources/base/media/log_whwp.png b/entry/src/main/resources/base/media/log_whwp.png new file mode 100644 index 0000000..9923f6d Binary files /dev/null and b/entry/src/main/resources/base/media/log_whwp.png differ diff --git a/entry/src/main/resources/base/media/log_yhbz.png b/entry/src/main/resources/base/media/log_yhbz.png new file mode 100644 index 0000000..f1d541d Binary files /dev/null and b/entry/src/main/resources/base/media/log_yhbz.png differ diff --git a/entry/src/main/resources/base/media/log_zd.png b/entry/src/main/resources/base/media/log_zd.png new file mode 100644 index 0000000..6ad5bad Binary files /dev/null and b/entry/src/main/resources/base/media/log_zd.png differ diff --git a/entry/src/main/resources/base/media/log_zylg.png b/entry/src/main/resources/base/media/log_zylg.png new file mode 100644 index 0000000..9e56146 Binary files /dev/null and b/entry/src/main/resources/base/media/log_zylg.png differ diff --git a/entry/src/main/resources/base/media/photo.png b/entry/src/main/resources/base/media/photo.png new file mode 100644 index 0000000..d085832 Binary files /dev/null and b/entry/src/main/resources/base/media/photo.png differ diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000..205ad8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/media/tab_attention.png b/entry/src/main/resources/base/media/tab_attention.png new file mode 100644 index 0000000..241a1ec Binary files /dev/null and b/entry/src/main/resources/base/media/tab_attention.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000..78f40ae --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000..5183598 --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,25 @@ +{ + "src": [ + "ui/pages/Index", + "ui/pages/MainPages", + "ui/pages/StreetInspectionPages", + "ui/pages/SelectTaskAndCardPortPages", + "ui/pages/CheckCarPage", + "ui/pages/CheckGoodsPage", + "ui/pages/AccompPersonPage", + "ui/pages/PassPage", + "ui/pages/MyAttentionActivity", + "ui/pages/AboutPage", + "ui/pages/SelectHandOverObject", + "ui/pages/SelectDeptPages", + "ui/pages/HandOverPage", + "ui/pages/HistoryMainPage", + "ui/pages/PeopleCheckDetailsPages", + "ui/pages/CarCheckDetailsPages", + "ui/pages/HistoryDetailsPage", + "ui/pages/StaticPortraitPage", + "ui/pages/OCRTestPages", + "ui/pages/OCRCarNumPages", + "ui/pages/SelectTaskListPage" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..2859384 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "皖警云核查" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/checkData/CheckReason.json b/entry/src/main/resources/rawfile/checkData/CheckReason.json new file mode 100644 index 0000000..351d925 --- /dev/null +++ b/entry/src/main/resources/rawfile/checkData/CheckReason.json @@ -0,0 +1,171 @@ +[ + { + "dictCode": "1828701921579589634", + "dictSort": 1, + "dictLabel": "例行盘查", + "dictValue": "1", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "例行盘查", + "createTime": "2024-08-28 15:51:28" + }, + { + "dictCode": "1828701999681724417", + "dictSort": 2, + "dictLabel": "体貌可疑", + "dictValue": "2", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "体貌可疑", + "createTime": "2024-08-28 15:51:47" + }, + { + "dictCode": "1828702061862281218", + "dictSort": 3, + "dictLabel": "眼神可疑", + "dictValue": "3", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "眼神可疑", + "createTime": "2024-08-28 15:52:01" + }, + { + "dictCode": "1828702140123799553", + "dictSort": 4, + "dictLabel": "口音可疑", + "dictValue": "4", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "口音可疑", + "createTime": "2024-08-28 15:52:20" + }, + { + "dictCode": "1828702256050167809", + "dictSort": 5, + "dictLabel": "行迹可疑", + "dictValue": "5", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "行迹可疑", + "createTime": "2024-08-28 15:52:48" + }, + { + "dictCode": "1828702314715897857", + "dictSort": 6, + "dictLabel": "携带可疑身份证", + "dictValue": "6", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "携带可疑身份证", + "createTime": "2024-08-28 15:53:02" + }, + { + "dictCode": "1828702476947382273", + "dictSort": 7, + "dictLabel": "携带可疑物品", + "dictValue": "7", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "携带可疑物品", + "createTime": "2024-08-28 15:53:40" + }, + { + "dictCode": "1828702585265283073", + "dictSort": 8, + "dictLabel": "所乘交通工具可疑", + "dictValue": "8", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "所乘交通工具可疑", + "createTime": "2024-08-28 15:54:06" + }, + { + "dictCode": "1828702643381559297", + "dictSort": 9, + "dictLabel": "无证驾驶", + "dictValue": "9", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "无证驾驶", + "createTime": "2024-08-28 15:54:20" + }, + { + "dictCode": "1828702747274469378", + "dictSort": 10, + "dictLabel": "牌照污损", + "dictValue": "10", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "牌照污损", + "createTime": "2024-08-28 15:54:45" + }, + { + "dictCode": "1828702814051983362", + "dictSort": 11, + "dictLabel": "身染可疑痕迹", + "dictValue": "11", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "身染可疑痕迹", + "createTime": "2024-08-28 15:55:01" + }, + { + "dictCode": "1828702896268730369", + "dictSort": 12, + "dictLabel": "其他可疑", + "dictValue": "12", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "其他可疑", + "createTime": "2024-08-28 15:55:20" + }, + { + "dictCode": "1828702971233525762", + "dictSort": 13, + "dictLabel": "卡点盘查", + "dictValue": "13", + "dictType": "app_check_reason", + "cssClass": null, + "listClass": "", + "isDefault": "N", + "status": null, + "remark": "卡点盘查", + "createTime": "2024-08-28 15:55:38" + } +] \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/checkData/GoodsTypeData.json b/entry/src/main/resources/rawfile/checkData/GoodsTypeData.json new file mode 100644 index 0000000..0e9f87c --- /dev/null +++ b/entry/src/main/resources/rawfile/checkData/GoodsTypeData.json @@ -0,0 +1,93 @@ +[ + { + "dwvalue": "10", + "thingsname": "管制刀具", + "thingsvalue": "10", + "ordersort": 1, + "dwname": "把" + }, + { + "dwvalue": "11", + "thingsname": "非法出版物", + "thingsvalue": "11", + "ordersort": 2, + "dwname": "件" + }, + { + "dwvalue": "8", + "thingsname": "危化物品", + "thingsvalue": "8", + "ordersort": 3, + "dwname": "千克" + }, + { + "dwvalue": "9", + "thingsname": "毒品", + "thingsvalue": "9", + "ordersort": 4, + "dwname": "克" + }, + { + "dwvalue": "1", + "thingsname": "假套车牌", + "thingsvalue": "1", + "ordersort": 5, + "dwname": "套" + }, + { + "dwvalue": "3", + "thingsname": "仿真枪", + "thingsvalue": "3", + "ordersort": 6, + "dwname": "支" + }, + { + "dwvalue": "4", + "thingsname": "子弹", + "thingsvalue": "4", + "ordersort": 7, + "dwname": "发" + }, + { + "dwvalue": "12", + "thingsname": "低慢小目标", + "thingsvalue": "12", + "ordersort": 8, + "dwname": "个" + }, + { + "dwvalue": "7", + "thingsname": "烟花爆竹", + "thingsvalue": "7", + "ordersort": 9, + "dwname": "头" + }, + { + "dwvalue": "2", + "thingsname": "枪支", + "thingsvalue": "2", + "ordersort": 10, + "dwname": "支" + }, + { + "dwvalue": "5", + "thingsname": "炸药", + "thingsvalue": "5", + "ordersort": 11, + "dwname": "千克" + }, + { + "dwvalue": "6", + "thingsname": "雷管", + "thingsvalue": "6", + "ordersort": 12, + "dwname": "枚" + }, + { + "dwvalue": "13", + "thingsname": "其他", + "thingsvalue": "13", + "ordersort": 13, + "dwname": "备注" + } +] \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/pangmenzhengdao.ttf b/entry/src/main/resources/rawfile/pangmenzhengdao.ttf new file mode 100644 index 0000000..61d491d Binary files /dev/null and b/entry/src/main/resources/rawfile/pangmenzhengdao.ttf differ diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..3694533 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,57 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "人车物核验" + }, + + { + "name": "ownership_dept", + "value": "安徽省公安厅" + }, + { + "name": "search_box_prompt", + "value": "最多可输入18个字符" + }, + { + "name": "text_search", + "value": "搜索" + }, + { + "name": "text_space", + "value": "空格" + }, + { + "name": "text_clear", + "value": "清空" + }, + { + "name": "loading_check_people", + "value": "正在盘查人员信息,请稍后..." + }, + { + "name": "loading_detection_face", + "value": "正在检测人脸..." + }, + { + "name": "loading_comparison_face", + "value": "正在比对人脸..." + }, + { + "name": "no_data_yet", + "value": "暂无数据!" + }, + { + "name": "input_idCardNum_error", + "value": "请检查身份证号是否正确!" + } + ] +} \ No newline at end of file diff --git a/entry/src/mock/mock-config.json5 b/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/DbHelper.test.ets b/entry/src/ohosTest/ets/test/DbHelper.test.ets new file mode 100644 index 0000000..a6a2cfd --- /dev/null +++ b/entry/src/ohosTest/ets/test/DbHelper.test.ets @@ -0,0 +1,31 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function DbHelperTest() { + describe('DbHelperTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertEqual', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test') + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..49f9b7e --- /dev/null +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,11 @@ +import MyAttentionPersonFragmentTest from './MyAttentionPersonFragment.test' +import MainPagesTest from './MainPages.test' +import DbHelperTest from './DbHelper.test' +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); + DbHelperTest() + MainPagesTest() + MyAttentionPersonFragmentTest() +} \ No newline at end of file diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000..509a3a2 --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/entry/src/test/List.test.ets b/entry/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/entry/src/test/LocalUnit.test.ets b/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000..06b2783 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000..f3cb9f1 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000..81f79f0 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,78 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@abner/lithe_refresh@^1.0.3": "@abner/lithe_refresh@1.0.3", + "@ohos/axios@^2.2.5": "@ohos/axios@2.2.5", + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.19": "@ohos/hypium@1.0.19", + "@pura/harmony-dialog@^1.0.7": "@pura/harmony-dialog@1.1.8", + "@pura/harmony-utils@^1.3.7": "@pura/harmony-utils@1.3.7", + "@pura/spinkit@^1.0.5": "@pura/spinkit@1.0.5", + "rdbstore@^1.0.7": "rdbstore@1.0.7" + }, + "packages": { + "@abner/lithe_refresh@1.0.3": { + "name": "@abner/lithe_refresh", + "version": "1.0.3", + "integrity": "sha512-yvhvqz9MCGhcYfiVXo2cuV0f9fOxDopc8JK+OREjy1y/mFomAHTAUT+PtQtuWW5ptHWE3h9T6rlrTclDH5gulg==", + "resolved": "https://repo.harmonyos.com/ohpm/@abner/lithe_refresh/-/lithe_refresh-1.0.3.har", + "registryType": "ohpm" + }, + "@ohos/axios@2.2.5": { + "name": "@ohos/axios", + "version": "2.2.5", + "integrity": "sha512-fTqwg2qzlPHiEwpHz+V3ArP7Of76FX7q1RHBwD5ENy9eBopK4PPJgRrVwb4V8AgZrWzkjcLFS/R/eXjk6/cd9A==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/axios/-/axios-2.2.5.har", + "registryType": "ohpm" + }, + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.19": { + "name": "@ohos/hypium", + "version": "1.0.19", + "integrity": "sha512-cEjDgLFCm3cWZDeRXk7agBUkPqjWxUo6AQeiu0gEkb3J8ESqlduQLSIXeo3cCsm8U/asL7iKjF85ZyOuufAGSQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.19.har", + "registryType": "ohpm" + }, + "@pura/harmony-dialog@1.1.8": { + "name": "@pura/harmony-dialog", + "version": "1.1.8", + "integrity": "sha512-IG2BJti8LBvJvkAD7yLwk6F2D66BGYPt6mae2yqAB9hMU5HnOTslWJbrReN9qPQl+ssIjSahMC7aJexEFYm5Dw==", + "resolved": "https://repo.harmonyos.com/ohpm/@pura/harmony-dialog/-/harmony-dialog-1.1.8.har", + "registryType": "ohpm", + "dependencies": { + "@pura/spinkit": "^1.0.5" + } + }, + "@pura/harmony-utils@1.3.7": { + "name": "@pura/harmony-utils", + "version": "1.3.7", + "integrity": "sha512-P/Sbd7A4Ci+Bi+n0+KfsQuXovy7K4gJoFuvUu3JN2lXG/yDmzE1pjo5laKQElTCNpXcRH1ZuEAcyDIxwcswWfw==", + "resolved": "https://repo.harmonyos.com/ohpm/@pura/harmony-utils/-/harmony-utils-1.3.7.har", + "registryType": "ohpm" + }, + "@pura/spinkit@1.0.5": { + "name": "@pura/spinkit", + "version": "1.0.5", + "integrity": "sha512-EKG+yzbCj/owI5zUYukIZV+YMRbeS/Ymd281Dj5asCKQHTWoEUVGmow3HCo7rl2Bdh8yliIT/StxPokUf8a6bQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@pura/spinkit/-/spinkit-1.0.5.har", + "registryType": "ohpm" + }, + "rdbstore@1.0.7": { + "name": "rdbstore", + "version": "1.0.7", + "integrity": "sha512-3rS9jdCHud58NHHZFMS3iWUbHi9ZfEveL388+X+V+LVzrYse+FiMj4Fd5AuyUirkpECtQW+1YPCOwEy3NQHJ4Q==", + "resolved": "https://repo.harmonyos.com/ohpm/rdbstore/-/rdbstore-1.0.7.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000..fdf909d --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,16 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + "@ohos/axios": "^2.2.5", + "@pura/harmony-utils": "^1.3.7", + "@pura/harmony-dialog": "^1.0.7", + "@abner/lithe_refresh": "^1.0.3", + "rdbstore": "^1.0.7" + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + }, + "dynamicDependencies": {} +} \ No newline at end of file diff --git a/人车物核验V1.0.1.hap b/人车物核验V1.0.1.hap new file mode 100644 index 0000000..db083f6 Binary files /dev/null and b/人车物核验V1.0.1.hap differ