diff --git a/entry/src/main/ets/pages/Judge_bak.ets b/entry/src/main/ets/pages/Judge_bak.ets deleted file mode 100644 index 6b3ec5b..0000000 --- a/entry/src/main/ets/pages/Judge_bak.ets +++ /dev/null @@ -1,333 +0,0 @@ -import router from '@ohos.router' -import util from '@ohos.util'; - -import EndPoPup from './compontents/judge/end-popup' -import LoadingPopup from './compontents/judge/loading-popup' -import {getCurrentTime,formatTime,chunkArr} from '../common/utils/tools' -import Judge from './judgeSDK/judge' -import {Project,ProjectObj,MarkRule} from './judgeSDK/api/judgeSDK.d' -import AccountTable from '../common/database/tables/AccountTable'; - -import USER from '../common/constants/USER'; -import MA_MARKRULE from '../common/constants/MA_MARKRULE'; -import MA_SYSTEMPARM from '../common/constants/MA_SYSTEMPARM'; -import MA_SYSSET from '../common//constants/MA_SYSSET'; - -import fileAccess from '@ohos.file.fileAccess'; -import { - examJudgeEndExam, -} from './judgeSDK/api/index' - -interface JudgeData{ - xmmcStr:string, - carztStr:string, - kfArr:{xmmcStr:string,desc}[] -} - -@Entry -@Component -struct Index { - //页面通用字体大小 - @State FONTSIZE:number = 23 - @State BIGFONTSIZE:number = 25 - - //结束考试弹窗 - @State endPopupVisible:boolean = false - //等待弹窗(考试及格,考试不及格使用) - @State loadingPopupVisible:boolean = false - - @State time:string = '' - //考试用时 - @State examTime:number= 0 - //开始时间 - @State startTime:string = '00:00:00' - @State xmmcStr:string = '' - @State carztStr:string = '' - @State kfArr:{xmmcStr?:string,desc?:string}[] = [] - @State name:string = '' - @State idCard:string = '' - - //模拟考试项目 - @State projects:Project[] = [] - @State projectsObj:ProjectObj = {} - @State markRuleListObj:MarkRule ={} - @State timer:number = 0 - //流水号 - @State lsh:string = '' - @State kszp:string = '' - //已考的考试项目 - - //监管接口序列号 - @State serialNumber:number = 0 - scroller: Scroller = new Scroller() - - //初始化 - async aboutToAppear(){ - - //@ts-ignore - // const wantInfos = await fileAccess.getFileAccessAbilityInfo(); - // console.log('surenjun123' + JSON.stringify(wantInfos)); - // let fileAccessHelper = null; - // // wantInfos 从getFileAccessAbilityInfo()获取 - // // 创建只连接媒体库服务的helper对象 - // - // try { - // // this.context 是EntryAbility 传过来的context - // console.log('globalThis.context' + JSON.stringify(globalThis.context)); - // fileAccessHelper = fileAccess.createFileAccessHelper(globalThis.context); - // if (!fileAccessHelper) - // console.error("aaa createFileAccessHelper interface returns an undefined object"); - // } catch (error) { - // console.error("aaa createFileAccessHelper failed, errCode:" + error.code + ", errMessage:" + error.message); - // } - - - - // const workerInstance = new worker.ThreadWorker("entry/ets/workers/worker.ts"); - // - // workerInstance.onmessage = function(e) { - // console.log("onmessage" + JSON.stringify(e.data)); - // } - windowClass.setWindowSystemBarEnable(['']) - const time = await getCurrentTime() - this.startTime = time.split(' ')[1] - setInterval(async()=>{ - this.time = await getCurrentTime(); - this.examTime += 1; - },1000); - //初始化考生 - this.initStudent(); - await this.initMarkRules(); - //初始化项目 - await this.initProjectInfo(); - // 初始化sysset表 - await this.initSysset() - //初始化评判 - this.initJudge(); - - } - - //获取考生信息 - async initStudent(){ - const that = this; - const db = new AccountTable(()=>{},USER); - // that.sfzmhm = 'surenjun'; - db.getRdbStore(()=>{ - db.query('0', (result) => { - const stuInfo = result[0] || {}; - const {xm,sfzmhm,lsh,kszp} = stuInfo; - that.name = xm; - that.idCard = sfzmhm; - that.lsh = lsh; - that.kszp = kszp; - }, true); - }); - } - - //获取项目信息 - async initProjectInfo(){ - const that = this; - const db = new AccountTable(()=>{},MA_SYSTEMPARM); - db.getRdbStore(()=>{ - db.query('0', (systemParamsArr) => { - //获取缓存的考试项目信息 - const filterProjectsArr = systemParamsArr.filter(item => item.no1 == 6) - - that.projects = filterProjectsArr.map(project => { - const currentProject = { - name:decodeURI(project.txt1), - abbreviation:decodeURI(project.txt3), - projectCode:decodeURI(project.no2), - projectCodeCenter:decodeURI(project.txt2), - type:'1' - } - that.projectsObj[project.no2] = currentProject - return currentProject - }); - - }, true); - }); - } - - //获取扣分代码信息 - async initMarkRules(){ - const that = this; - const db = new AccountTable(()=>{},MA_MARKRULE); - db.getRdbStore(()=>{ - db.query('0', (markRuleParams) => { - markRuleParams.forEach(mark=>{ - that.markRuleListObj[mark.markserial] = { - markcatalog:mark.markcatalog, - markshow:decodeURI(mark.markshow), - markstandard:mark.markstandard, - markserial:mark.markserial - }; - }) - }) - }) - } - - //获取sysset表信息 - async initSysset(){ - const that = this; - const db = new AccountTable(()=>{},MA_SYSSET); - db.getRdbStore(()=>{ - db.query('0', (syssetParams) => { - //TODO 监管接口序列号 目前环境没有 - const serialNumberArr = syssetParams.filter(sys => sys.v_no === '901') - that.serialNumber = serialNumberArr || '1234567' - }) - }) - } - - //评判相关初始化 - async initJudge(){ - const judge = new Judge(this); - await judge.onJudgeFn(async (judgeData)=>{ - const {xmmcStr,carztStr,kfArr} = judgeData; - this.xmmcStr = xmmcStr; - this.carztStr = carztStr; - //TODO 单次项目扣分 - this.kfArr = kfArr; - }); - } - - build() { - Column() { - Row() { - Row(){ - Image($rawfile('judge/signal_logoS.png')).width(35).height(25) - Text(this.time).fontColor('#CCB48F').fontSize(this.FONTSIZE).padding({left:10,right:5}) - Image($rawfile('judge/xh_green.png')).width(25).height(20) - } - Row(){ - Text(`当前项目:${this.xmmcStr || '无'} `).fontColor('#E5CCA1').fontSize(this.FONTSIZE) - } - } - .width('100%').height('50').backgroundColor('#001A33').padding({left:15,right:15}).justifyContent(FlexAlign.SpaceBetween).alignItems(VerticalAlign.Center) - - Row(){ - Row(){ - Column(){ - Row(){ - Column(){ - Row(){ - Text('考生姓名:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) - Text(this.name).fontColor('#FFF').fontSize(this.FONTSIZE) - }.margin({bottom:10}) - Row(){ - Text('开始时间:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) - Text(this.startTime).fontColor('#FFF').fontSize(this.FONTSIZE) - } - }.width('45%').alignItems(HorizontalAlign.Start) - Column(){ - Row(){ - Text('身份证号:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) - Text(this.idCard).fontColor('#FFF').fontSize(this.FONTSIZE) - }.margin({bottom:10}) - Row(){ - Text('考试用时:').fontColor('#E5CCA1').fontSize(this.FONTSIZE) - Text(formatTime(this.examTime)).fontColor('#FFF').fontSize(this.FONTSIZE) - } - }.alignItems(HorizontalAlign.Start) - }.width('100%') - - Column(){ - Text(this.carztStr).fontColor('#FFA500').fontSize(this.FONTSIZE) - Row(){ - Column(){ - ForEach(this.kfArr,(item)=>{ - Column(){ - Row(){ - Text(item.xmmcStr).fontSize(this.BIGFONTSIZE).fontColor('#FFF') - Text(`${item.score}分`).fontSize(this.BIGFONTSIZE).fontColor('#FFF') - }.width('100%').backgroundColor('#38260B').justifyContent(FlexAlign.SpaceBetween).padding({top:12,bottom:12,left:15,right:15}) - Text(item.desc).fontSize(this.BIGFONTSIZE).fontColor('#E5CBA1').margin(10) - }.margin({top:15}).alignItems(HorizontalAlign.Start) - - }) - - }.backgroundImage($rawfile('judge/score_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('40%').height('100%').padding(25) - - Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row,justifyContent:FlexAlign.SpaceBetween}){ - List({}){ - ForEach(chunkArr(this.projects,2),(item)=>{ - ListItem(){ - Row(){ - Row(){ - //#FF7566 #00FFD5 #E6DECF - // Text(this.projectsObj[item[0].projectCode]) - Text(item[0].abbreviation).fontSize(item[0].abbreviation.length > 5?20:27).fontColor(this.getProjectColor(this.projectsObj[item[0].projectCode].type)) - }.backgroundImage($rawfile('judge/project_item.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('48%').height(90).margin({bottom:10}).justifyContent(FlexAlign.Center) - if(item[1]){ - Row(){ - //#FF7566 #00FFD5 #E6DECF - Text(item[1].abbreviation).fontSize(item[1].abbreviation.length > 5?20:27).fontColor(this.getProjectColor(this.projectsObj[item[1].projectCode].type)) - }.backgroundImage($rawfile('judge/project_item.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('48%').height(90).margin({left:5,bottom:10}).justifyContent(FlexAlign.Center) - } - } - } - }); - } - }.backgroundImage($rawfile('judge/project_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).width('57%').height('100%').padding(30).margin({right:10}) - - }.margin({top:15}).height('80%').justifyContent(FlexAlign.SpaceBetween) - }.width('100%').height('100%').alignItems(HorizontalAlign.Start).margin({top:10}) - }.height('100%').alignItems(HorizontalAlign.Start) - }.width('75%').height('100%') - - Column(){ - Column(){ - Row(){ - Text('100').fontColor('#FFEECC').fontSize(35) - Text('分').fontColor('#FFEECC').fontSize(20).padding({top:5}) - }.width('90%').height(95).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center).border({width:3,color:'#4D4136',radius:15}) - - Row(){ - Image(this.kszp).width('85%').height('85%') - }.width('60%').height(200).backgroundImage($rawfile('judge/photo_bg.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).justifyContent(FlexAlign.Center).alignItems(VerticalAlign.Center).margin({top:20}) - } - Row(){ }.width('90%').height(85).backgroundImage($rawfile('judge/anniu_nor.png'),ImageRepeat.NoRepeat).backgroundImageSize({width:'100%',height:'100%'}).onClick(()=>{this.endPopupVisible = true}) - }.width('25%').height('100%').justifyContent(FlexAlign.SpaceBetween).alignItems(HorizontalAlign.Center).margin({bottom:20}) - }.height('90%').justifyContent(FlexAlign.Start).padding({top:40,left:30,bottom:10,right:30}) - - //结束考试弹窗 - if(this.endPopupVisible){ - EndPoPup({ - title:'确定结束考试吗?', - cancelFn:()=>{ - this.endPopupVisible = false; - }, - confirmFn:()=>{ - this.endPopupVisible = false; - - //调用考试结束,关闭定时器 - examJudgeEndExam(); - clearInterval(this.timer); - globalThis.windowClass.setWindowSystemBarEnable(['navigation']) - router.back(); - } - }) - } - - if(this.loadingPopupVisible){ - - LoadingPopup({ - title:'正在生成考试记录,请稍后......', - }) - } - - } - .height('100%').backgroundColor('#000').justifyContent(FlexAlign.Start) - } - - getProjectColor(type:string){ - switch (type){ - case '1': return '#E6DECF';break; - case '2': return '#FFAD33';break; - case '3': return '#00FFD5';break; - case '4': return '#FF7566';break; - default : return '#E6DECF';break; - } - } -}