fix: 更新多个组件中的类型声明和逻辑,提升代码一致性
This commit is contained in:
parent
b1264c19e8
commit
51a2e53fde
@ -6,7 +6,7 @@ import { MarkRule } from '../../judgeSDK/api/judgeSDK.d';
|
||||
import { writeObjectOut } from '../../../api/judge';
|
||||
import JudgeTask from '../../judgeSDK/utils/judgeTask';
|
||||
import FilePhoto from '../../judgeSDK/utils/filePhoto';
|
||||
import { CarInfoType, MASYSSETTableType } from '../../../model';
|
||||
import { CarInfoType, MASYSSETTableType, RegulatoryInterfaceParams, User } from '../../../model';
|
||||
import { GetCurrentTime } from '../../../utils/Common';
|
||||
import FileUtils from '../../../utils/FileUtils';
|
||||
import { GetSyncData } from '../../../utils/table/Operation';
|
||||
@ -16,6 +16,14 @@ interface SEL {
|
||||
bgColor: string
|
||||
}
|
||||
|
||||
interface kfdmItemType {
|
||||
xmdm: number,
|
||||
kfdm: string,
|
||||
markreal: number,
|
||||
markcatalog: string
|
||||
score: number
|
||||
}
|
||||
|
||||
//考前模拟人工扣分
|
||||
@Component
|
||||
export default struct DeductedPopup {
|
||||
@ -28,14 +36,8 @@ export default struct DeductedPopup {
|
||||
@State kslx: string = ''
|
||||
@State ksxl: string = ''
|
||||
@State score: number = 100;
|
||||
@State judgeConfigObj: { [k: string]: any } = {}
|
||||
@State kfdmArr: {
|
||||
xmdm: number,
|
||||
kfdm: string,
|
||||
markreal: number,
|
||||
markcatalog: string
|
||||
score: number
|
||||
}[] = []
|
||||
@State judgeConfigObj: Record<string, string> = {}
|
||||
@State kfdmArr: kfdmItemType[] = []
|
||||
//开始考试前判绕车一周评判是否开启
|
||||
@State isOpen: boolean = false
|
||||
//监管序列号
|
||||
@ -52,7 +54,7 @@ export default struct DeductedPopup {
|
||||
@State universalMarkRules: MarkRule[] = []
|
||||
@State manualMarkRules: MarkRule[] = []
|
||||
@State lineBg: Array<string> = ['#4D4136', '#26231E']
|
||||
@State selectedLine: number = undefined
|
||||
@State selectedLine: number = -1
|
||||
@State carInfo: CarInfoType = {
|
||||
carId: '',
|
||||
examinationRoomId: '',
|
||||
@ -131,7 +133,7 @@ export default struct DeductedPopup {
|
||||
async pointsDedute() {
|
||||
const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex;
|
||||
const mark = this.universalMarkRules[index * 7 + this.selectedLine];
|
||||
const { judgeConfigObj, kssycs, avPlayer, judgeTask } = this;
|
||||
// const { judgeConfigObj, kssycs, avPlayer, judgeTask } = this;
|
||||
this.kfdmArr.push({
|
||||
xmdm: 1,
|
||||
kfdm: mark.markserial,
|
||||
@ -148,89 +150,44 @@ export default struct DeductedPopup {
|
||||
}, 0);
|
||||
this.score = score
|
||||
|
||||
this.confirmMark(this.kfdmArr.map((kf) => ({
|
||||
xmdm: kf.xmdm,
|
||||
kfdm: kf.kfdm,
|
||||
})))
|
||||
// this.confirmMark(this.kfdmArr.map((kf) => ({
|
||||
// xmdm: kf.xmdm.toString(),
|
||||
// kfdm: kf.kfdm,
|
||||
// })))
|
||||
|
||||
if (judgeConfigObj['418'] == '1' || JudgeConfig.kfVoiceOpen) {
|
||||
avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`, `voice/mark_${Math.abs(mark.score)}.mp3`], false, () => {
|
||||
this.closePopup(true)
|
||||
});
|
||||
if (this.judgeConfigObj['418'] == '1' || JudgeConfig.kfVoiceOpen) {
|
||||
this.avPlayer.playAudio([`voice/${mark.markcatalog}.mp3`, `voice/mark_${Math.abs(mark.score)}.mp3`], false,
|
||||
() => {
|
||||
this.closePopup(true)
|
||||
});
|
||||
return
|
||||
}
|
||||
this.closePopup();
|
||||
return;
|
||||
|
||||
if (score < 90) {
|
||||
this.closePopup(true)
|
||||
avPlayer.playAudio(['voice/exam_waiting.mp3', `voice/kfdesc.mp3`])
|
||||
judgeTask.addTask(async () => {
|
||||
//扣分
|
||||
await this.kfFn();
|
||||
}, { isDelay: true })
|
||||
|
||||
judgeTask.addTask(async () => {
|
||||
//项目结束
|
||||
await this.endProject();
|
||||
}, { isDelay: true })
|
||||
|
||||
judgeTask.addTask(async () => {
|
||||
//结束考试
|
||||
await this.endFn()
|
||||
}, { isDelay: true })
|
||||
}
|
||||
;
|
||||
|
||||
let voiceURL =
|
||||
score < 90 ? `voice/${kssycs == '1' ? 'exam_no_pass_finish' : 'exam_no_pass'}.mp3` : 'voice/exam_pass.mp3'
|
||||
|
||||
let kfScore = 0;
|
||||
if (kfdmArr.length) {
|
||||
kfdmArr.forEach((kf, index) => {
|
||||
kfScore += Math.abs(Number(kf.markreal));
|
||||
if (kfScore <= 100) {
|
||||
judgeTask.addTask(() => {
|
||||
if (index === kfdmArr.length - 1) {
|
||||
avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`, voiceURL], false, () => {
|
||||
this.endLoading(true)
|
||||
})
|
||||
} else {
|
||||
avPlayer.playAudio([`voice/${kf.markcatalog}.mp3`])
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.confirmMark(this.kfdmArr.map((kf) => ({
|
||||
xmdm: kf.xmdm,
|
||||
kfdm: kf.kfdm,
|
||||
})))
|
||||
|
||||
}
|
||||
|
||||
//项目开始
|
||||
async beginProject() {
|
||||
//项目开始 //过程照片 //扣分 //结束考试
|
||||
const carInfo: CarInfoType = this.carInfo;
|
||||
const { examSubject, plateNo } = carInfo;
|
||||
const { serialNumber, lsh, idCard, ksxl, kslx, ksdd } = this
|
||||
// const carInfo: CarInfoType = this.carInfo;
|
||||
// const { examSubject, plateNo } = carInfo;
|
||||
// const { serialNumber, lsh, idCard, ksxl, kslx, ksdd } = this
|
||||
const time = GetCurrentTime();
|
||||
const beginData = {
|
||||
const beginData: RegulatoryInterfaceParams = {
|
||||
xtlb: '17',
|
||||
jkxlh: serialNumber,
|
||||
jkxlh: this.serialNumber.toString(),
|
||||
jkid: '17C52',
|
||||
drvexam: {
|
||||
// 考试科目 身份证号码
|
||||
lsh,
|
||||
kskm: examSubject,
|
||||
sfzmhm: idCard,
|
||||
lsh: this.lsh,
|
||||
kskm: this.carInfo.examSubject,
|
||||
sfzmhm: this.idCard,
|
||||
ksxm: '40100',
|
||||
ksxl,
|
||||
kchp: decodeURI(plateNo),
|
||||
ksdd: decodeURI(ksdd),
|
||||
kslx: decodeURI(kslx) || '',
|
||||
ksxl: this.ksxl,
|
||||
kchp: decodeURI(this.carInfo.plateNo),
|
||||
ksdd: decodeURI(this.ksdd),
|
||||
kslx: decodeURI(this.kslx) || '',
|
||||
kssj: time
|
||||
},
|
||||
}
|
||||
@ -243,27 +200,27 @@ export default struct DeductedPopup {
|
||||
|
||||
//过程照片
|
||||
async uploadProgressPhoto() {
|
||||
const { serialNumber, lsh, idCard, ksdd, kfdmArr, getPhoto } = this;
|
||||
const carInfo = this.carInfo;
|
||||
const { examSubject, plateNo, carNo } = carInfo;
|
||||
// const { serialNumber, lsh, idCard, ksdd, kfdmArr, getPhoto } = this;
|
||||
// const carInfo = this.carInfo;
|
||||
// const { examSubject, plateNo, carNo } = carInfo;
|
||||
const time = GetCurrentTime();
|
||||
console.info('surenjun uploadProgressPhoto',)
|
||||
const photoBase64 = await getPhoto()
|
||||
const photoData = {
|
||||
const photoBase64 = await this.getPhoto()
|
||||
const photoData: RegulatoryInterfaceParams = {
|
||||
xtlb: '17',
|
||||
jkxlh: serialNumber,
|
||||
jkxlh: this.serialNumber.toString(),
|
||||
jkid: '17C54',
|
||||
drvexam: {
|
||||
lsh,
|
||||
kskm: examSubject,
|
||||
lsh: this.lsh,
|
||||
kskm: this.carInfo.examSubject,
|
||||
ksxm: '40100',
|
||||
sfzmhm: idCard,
|
||||
kchp: decodeURI(plateNo),
|
||||
sfzmhm: this.idCard,
|
||||
kchp: decodeURI(this.carInfo.plateNo),
|
||||
zpsj: time,
|
||||
// zp: encodeURIComponent(photoBase64),
|
||||
zp: photoBase64,
|
||||
cs: 0,
|
||||
ksdd: decodeURI(ksdd)
|
||||
ksdd: decodeURI(this.ksdd)
|
||||
}
|
||||
};
|
||||
const code = await writeObjectOut(photoData);
|
||||
@ -272,27 +229,24 @@ export default struct DeductedPopup {
|
||||
|
||||
// 扣分
|
||||
async kfFn() {
|
||||
const { serialNumber, lsh, idCard, ksdd, kfdmArr } = this;
|
||||
const kfLen = kfdmArr.length;
|
||||
const kf = kfdmArr[kfLen -1];
|
||||
const carInfo: CarInfoType = this.carInfo;
|
||||
const { examSubject } = this.carInfo;
|
||||
const kfLen = this.kfdmArr.length;
|
||||
const kf = this.kfdmArr[kfLen -1];
|
||||
const time = GetCurrentTime();
|
||||
const kfData = {
|
||||
const kfData: RegulatoryInterfaceParams = {
|
||||
xtlb: '17',
|
||||
jkxlh: serialNumber,
|
||||
jkxlh: this.serialNumber.toString(),
|
||||
jkid: '17C53',
|
||||
drvexam: {
|
||||
lsh,
|
||||
kskm: examSubject,
|
||||
lsh: this.lsh,
|
||||
kskm: this.carInfo.examSubject,
|
||||
// 通用评判科二10000,科三30000
|
||||
ksxm: 40100,
|
||||
ksxm: "40100",
|
||||
kfxm: kf.markcatalog,
|
||||
kfxmmx: `${'1'},${kf.kfdm}`,
|
||||
sfzmhm: idCard,
|
||||
kchp: decodeURI(carInfo.plateNo),
|
||||
sfzmhm: this.idCard,
|
||||
kchp: decodeURI(this.carInfo.plateNo),
|
||||
kffs: 2,
|
||||
ksdd: decodeURI(ksdd),
|
||||
ksdd: decodeURI(this.ksdd),
|
||||
kfsj: time
|
||||
}
|
||||
}
|
||||
@ -301,24 +255,21 @@ export default struct DeductedPopup {
|
||||
|
||||
// 项目结束
|
||||
async endProject() {
|
||||
const carInfo = this.carInfo;
|
||||
const { examSubject, plateNo, carNo } = carInfo;
|
||||
const { lsh, idCard, serialNumber, ksdd, kslx, ksxl, } = this;
|
||||
const time = GetCurrentTime();
|
||||
const endProjectData = {
|
||||
const endProjectData: RegulatoryInterfaceParams = {
|
||||
xtlb: '17',
|
||||
jkxlh: serialNumber,
|
||||
jkxlh: this.serialNumber.toString(),
|
||||
jkid: '17C55',
|
||||
drvexam: {
|
||||
lsh,
|
||||
kskm: examSubject,
|
||||
sfzmhm: idCard,
|
||||
lsh: this.lsh,
|
||||
kskm: this.carInfo.examSubject,
|
||||
sfzmhm: this.idCard,
|
||||
ksxm: '40100',
|
||||
czlx: '1',
|
||||
ksxl,
|
||||
kchp: decodeURI(plateNo),
|
||||
ksdd: decodeURI(ksdd),
|
||||
kslx: encodeURI(kslx) || '',
|
||||
ksxl: this.ksxl,
|
||||
kchp: decodeURI(this.carInfo.plateNo),
|
||||
ksdd: decodeURI(this.ksdd),
|
||||
kslx: encodeURI(this.kslx) || '',
|
||||
jssj: time
|
||||
}
|
||||
}
|
||||
@ -327,24 +278,21 @@ export default struct DeductedPopup {
|
||||
|
||||
//考试结束
|
||||
async endFn() {
|
||||
const { serialNumber, lsh, idCard, score, getPhoto } = this;
|
||||
const carInfo: CarInfoType = this.carInfo;
|
||||
const { examSubject, plateNo } = carInfo;
|
||||
const time = GetCurrentTime();
|
||||
const photoBase64 = await getPhoto();
|
||||
const endData = {
|
||||
const photoBase64 = await this.getPhoto()
|
||||
const endData: RegulatoryInterfaceParams = {
|
||||
xtlb: '17',
|
||||
jkxlh: serialNumber,
|
||||
jkxlh: this.serialNumber.toString(),
|
||||
jkid: '17C56',
|
||||
drvexam: {
|
||||
lsh,
|
||||
kchp: decodeURI(plateNo),
|
||||
kskm: examSubject,
|
||||
sfzmhm: idCard,
|
||||
lsh: this.lsh,
|
||||
kchp: decodeURI(this.carInfo.plateNo),
|
||||
kskm: this.carInfo.examSubject,
|
||||
sfzmhm: this.idCard,
|
||||
// zp: encodeURIComponent(photoBase64),
|
||||
zp: photoBase64,
|
||||
jssj: time,
|
||||
kscj: (score * 1) > 0 ? score : 0,
|
||||
kscj: (this.score * 1) > 0 ? this.score : 0,
|
||||
kslc: 0,
|
||||
dwlc: '',
|
||||
}
|
||||
@ -359,11 +307,11 @@ export default struct DeductedPopup {
|
||||
syssetParams.forEach(sys => {
|
||||
//监管序列号
|
||||
if (sys.v_no == '901') {
|
||||
this.serialNumber = sys.v_value || '123456'
|
||||
this.serialNumber = Number(sys.v_value) || 123456
|
||||
}
|
||||
//364 绕车一周评判时机(1-开始考试后判 2-开始考试前判)
|
||||
if (sys.v_no == '364') {
|
||||
const isOpen = sys.v_value == 2
|
||||
const isOpen = sys.v_value == "2"
|
||||
if (isOpen) {
|
||||
this.avPlayer.playAudio(['voice/上车准备.mp3'])
|
||||
}
|
||||
@ -374,9 +322,9 @@ export default struct DeductedPopup {
|
||||
|
||||
//获取markrule表数据
|
||||
async initMarkRules(markRules ?: MarkRule[]) {
|
||||
const markRuleParams = markRules || (await getSyncData('MA_MARKRULE') as MarkRule[])
|
||||
const markRuleParams = markRules || (await GetSyncData('MA_MARKRULE') as MarkRule[])
|
||||
markRuleParams.forEach(mark => {
|
||||
const tempObj = {
|
||||
const tempObj: MarkRule = {
|
||||
itemno: mark.itemno * 1,
|
||||
markcatalog: mark.markcatalog,
|
||||
markshow: decodeURI(mark.markshow),
|
||||
@ -391,9 +339,18 @@ export default struct DeductedPopup {
|
||||
|
||||
if (mark.itemno == 1 && Number(mark.markserial) > 100 && Number(mark.markserial) < 200) {
|
||||
this.markRuleListObj[`${mark.itemno}_${mark.markserial}`] = {
|
||||
...tempObj,
|
||||
itemno: tempObj.itemno,
|
||||
markcatalog: tempObj.markcatalog,
|
||||
markshow: tempObj.markshow,
|
||||
markreal: tempObj.markreal,
|
||||
markstandard: tempObj.markstandard,
|
||||
markserial: mark.markserial,
|
||||
kfxh: tempObj.kfxh,
|
||||
OnlyOneKind: tempObj.OnlyOneKind,
|
||||
NoCancelId: tempObj.NoCancelId,
|
||||
GPS_SID: tempObj.GPS_SID,
|
||||
};
|
||||
|
||||
this.universalMarkRules.push(tempObj)
|
||||
}
|
||||
|
||||
@ -403,22 +360,22 @@ export default struct DeductedPopup {
|
||||
|
||||
// 获取考生信息
|
||||
async initStudent() {
|
||||
const students = await getSyncData('USER')
|
||||
const stuInfo = students[0] || {};
|
||||
const students = await GetSyncData<User>('USER')
|
||||
const stuInfo: User = students[0];
|
||||
|
||||
const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl } = stuInfo;
|
||||
this.name = xm || '测试考生';
|
||||
this.idCard = sfzmhm || '01234567891010';
|
||||
this.lsh = lsh;
|
||||
this.kszp = kszp;
|
||||
this.ksdd = ksdd;
|
||||
this.kssycs = kssycs;
|
||||
this.kslx = kslx;
|
||||
this.ksxl = ksxl;
|
||||
// const { xm, sfzmhm, lsh, kszp, ksdd, kssycs, kslx, ksxl } = stuInfo;
|
||||
this.name = stuInfo.xm || '测试考生';
|
||||
this.idCard = stuInfo.sfzmhm || '01234567891010';
|
||||
this.lsh = stuInfo.lsh;
|
||||
this.kszp = stuInfo.kszp;
|
||||
this.ksdd = stuInfo.ksdd;
|
||||
this.kssycs = stuInfo.kssycs;
|
||||
this.kslx = stuInfo.kslx;
|
||||
this.ksxl = stuInfo.ksxl;
|
||||
}
|
||||
|
||||
//上一页 下一页
|
||||
goPage(typeIndex) {
|
||||
goPage(typeIndex: number) {
|
||||
const currentIndex = this.currentIndex
|
||||
if (currentIndex) {
|
||||
//通用评判
|
||||
@ -430,26 +387,24 @@ export default struct DeductedPopup {
|
||||
}
|
||||
|
||||
//选中扣分项
|
||||
getSelectedLine(index) {
|
||||
const { selectedLine, selectedLineStyle, lineBg } = this;
|
||||
if (selectedLine === index) {
|
||||
return selectedLineStyle.bgColor
|
||||
getSelectedLine(index: number) {
|
||||
if (this.selectedLine === index) {
|
||||
return this.selectedLineStyle.bgColor
|
||||
}
|
||||
if (index % 2 === 0) {
|
||||
return lineBg[0]
|
||||
return this.lineBg[0]
|
||||
} else {
|
||||
return lineBg[1]
|
||||
return this.lineBg[1]
|
||||
}
|
||||
}
|
||||
|
||||
//获取当前页的数据
|
||||
getCurrentMarkRuleList() {
|
||||
const { currentIndex, currentUniversalPageIndex, currentPageIndex, universalMarkRules } = this;
|
||||
if (currentIndex) {
|
||||
if (this.currentIndex) {
|
||||
//通用评判
|
||||
return universalMarkRules.slice(currentUniversalPageIndex * 7, (currentUniversalPageIndex + 1) * 7)
|
||||
return this.universalMarkRules.slice(this.currentUniversalPageIndex * 7, (this.currentUniversalPageIndex + 1) * 7)
|
||||
} else {
|
||||
return universalMarkRules.slice(currentPageIndex * 7, (currentPageIndex + 1) * 7)
|
||||
return this.universalMarkRules.slice(this.currentPageIndex * 7, (this.currentPageIndex + 1) * 7)
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,7 +414,7 @@ export default struct DeductedPopup {
|
||||
Column() {
|
||||
Row() {
|
||||
Row() {
|
||||
ForEach(['人工评判'], (text, index) => {
|
||||
ForEach(['人工评判'], (text: string, index) => {
|
||||
|
||||
Row() {
|
||||
Text(text)
|
||||
@ -549,7 +504,7 @@ export default struct DeductedPopup {
|
||||
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
|
||||
|
||||
Column() {
|
||||
ForEach(this.getCurrentMarkRuleList(), (item, index) => {
|
||||
ForEach(this.getCurrentMarkRuleList(), (item: MarkRule, index) => {
|
||||
Row() {
|
||||
Text(`${item.markshow} (${item.markcatalog})`).fontColor('#FFF').fontSize(this.fontSize).fontWeight(500)
|
||||
Row() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user