fix: 修改了部分文件类型

This commit is contained in:
wangzhongjie 2025-02-12 11:47:54 +08:00
parent 4f34fc484c
commit daec42ee7d

View File

@ -1,175 +1,232 @@
import {MarkRule} from '../../judgeSDK/api/judgeSDK' import { MarkRule } from '../../judgeSDK/api/judgeSDK';
import EndPoPup from './EndPopup'; import EndPoPup from './EndPopup';
interface SEL{ interface SEL {
fontColor:string fontColor: string
bgColor:string bgColor: string
} }
@Component @Component
export default struct DeductedPopup { export default struct DeductedPopup {
@State fontSize: number = 30
@State unselected: SEL = { fontColor: '#000000', bgColor: '#CCC4B8' }
@State selected: SEL = { fontColor: '#FFAD33', bgColor: '#26231E' }
@State currentIndex: number = 0
@State currentPageIndex: number = 0
//通用评判扣分
@State currentUniversalPageIndex: number = 0;
@State universalMarkRules: MarkRule[] = []
@State manualMarkRules: MarkRule[] = []
@State lineBg: Array<string> = ['#4D4136', '#26231E']
@State selectedLine: number = undefined
@State endPopupVisible: boolean = false
@State selectedLineStyle: SEL = {
fontColor: '#FFF',
bgColor: '#B36E00'
}
@Prop defaultTabIndex: number = 0
@Prop @Watch('changeCurrentItems') currentItems: string[] = [];
@State preCurrentItemsLength: number = 0
private markRules: MarkRule[] = []
constructor() { constructor() {
super() super()
} }
@State fontSize:number = 30 aboutToAppear() {
@State unselected:SEL = {fontColor:'#000000', bgColor:'#CCC4B8'} this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno.toString()) ||
@State selected:SEL = {fontColor:'#FFAD33', bgColor:'#26231E'} this.currentItems.includes(item.itemno + '')));
@State currentIndex:number = 0
@State currentPageIndex:number = 0
//通用评判扣分
@State currentUniversalPageIndex:number = 0;
private markRules:MarkRule[] = []
@State universalMarkRules:MarkRule[] = []
@State manualMarkRules:MarkRule[] = []
@State lineBg:Array<string> = ['#4D4136','#26231E']
@State selectedLine:number = undefined
@State endPopupVisible:boolean = false
private closePopup:Function = ()=> {}
private confirmMark:Function = (itemno:number,serial:string) => {}
@State selectedLineStyle:SEL = {
fontColor:'#FFF',
bgColor:'#B36E00'
}
@Prop defaultTabIndex:number = 0
@Prop @Watch('changeCurrentItems') currentItems:string[] = [];
@State preCurrentItemsLength:number = 0
aboutToAppear(){
//@ts-ignore
this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno) || this.currentItems.includes(item.itemno + '')));
this.currentIndex = this.defaultTabIndex this.currentIndex = this.defaultTabIndex
if(this.currentIndex == 1){ if (this.currentIndex == 1) {
this.universalMarkRules = this.markRules.filter(item => item.itemno == 20 ) this.universalMarkRules = this.markRules.filter(item => item.itemno == 20)
} }
this.preCurrentItemsLength = this.currentItems.length this.preCurrentItemsLength = this.currentItems.length
} }
changeCurrentItems(){ changeCurrentItems() {
if(this.currentItems?.length && (this.currentItems?.length >= this.preCurrentItemsLength)){ if (this.currentItems?.length && (this.currentItems?.length >= this.preCurrentItemsLength)) {
//@ts-ignore this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno.toString()) ||
this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno) || this.currentItems.includes(item.itemno + ''))); this.currentItems.includes(item.itemno + '')));
this.currentIndex = this.defaultTabIndex this.currentIndex = this.defaultTabIndex
if(this.currentIndex == 1){ if (this.currentIndex == 1) {
this.universalMarkRules = this.markRules.filter(item => item.itemno == 20 ) this.universalMarkRules = this.markRules.filter(item => item.itemno == 20)
} }
this.preCurrentItemsLength = this.currentItems.length this.preCurrentItemsLength = this.currentItems.length
}else{ } else {
this.preCurrentItemsLength = 0 this.preCurrentItemsLength = 0
} }
} }
//上一页 下一页 //上一页 下一页
goPage(typeIndex){ goPage(typeIndex: number) {
const currentIndex = this.currentIndex const currentIndex = this.currentIndex
if(currentIndex){ if (currentIndex) {
//通用评判 //通用评判
typeIndex ? (this.currentUniversalPageIndex += 1) : (this.currentUniversalPageIndex -= 1) typeIndex ? (this.currentUniversalPageIndex += 1) : (this.currentUniversalPageIndex -= 1)
}else{ } else {
typeIndex ? (this.currentPageIndex += 1) : (this.currentPageIndex -= 1) typeIndex ? (this.currentPageIndex += 1) : (this.currentPageIndex -= 1)
} }
this.selectedLine = -1 this.selectedLine = -1
} }
//选中扣分项 //选中扣分项
getSelectedLine(index){ getSelectedLine(index: number) {
const {selectedLine,selectedLineStyle,lineBg} = this; // const { selectedLine, selectedLineStyle, lineBg } = this;
if(selectedLine === index){ if (this.selectedLine === index) {
return selectedLineStyle.bgColor return this.selectedLineStyle.bgColor
} }
if(index % 2 === 0){ if (index % 2 === 0) {
return lineBg[0] return this.lineBg[0]
}else{ } else {
return lineBg[1] return this.lineBg[1]
} }
} }
//获取当前页的数据 //获取当前页的数据
getCurrentMarkRuleList(){ getCurrentMarkRuleList() {
const {currentIndex,currentUniversalPageIndex,currentPageIndex,markRules,universalMarkRules} = this; // const { currentIndex, currentUniversalPageIndex, currentPageIndex, markRules, 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{ } else {
return universalMarkRules.slice(currentPageIndex*7,(currentPageIndex + 1)*7) return this.universalMarkRules.slice(this.currentPageIndex * 7, (this.currentPageIndex + 1) * 7)
} }
} }
build(){ build() {
Column(){ Column() {
Column(){ Column() {
Column(){ Column() {
Row(){ Row() {
Row(){ Row() {
ForEach(['人工评判','通用评判'],(text,index)=>{ ForEach(['人工评判', '通用评判'], (text: string, index) => {
Row(){ Row() {
Text(text).fontColor(index === this.currentIndex ? this.selected.fontColor : this.unselected.fontColor).fontSize(this.fontSize).fontWeight(500) Text(text)
.fontColor(index === this.currentIndex ? this.selected.fontColor : this.unselected.fontColor)
.fontSize(this.fontSize)
.fontWeight(500)
} }
.width(140).height(60) .width(140)
.backgroundColor(index === this.currentIndex ? this.selected.bgColor: this.unselected.bgColor ).justifyContent(FlexAlign.Center).justifyContent(FlexAlign.Center) .height(60)
.borderRadius({topLeft:20,topRight:20}).margin({right:10}) .backgroundColor(index === this.currentIndex ? this.selected.bgColor : this.unselected.bgColor)
.onClick(()=>{ .justifyContent(FlexAlign.Center)
.justifyContent(FlexAlign.Center)
.borderRadius({ topLeft: 20, topRight: 20 })
.margin({ right: 10 })
.onClick(() => {
this.currentIndex = index; this.currentIndex = index;
this.selectedLine = -1; this.selectedLine = -1;
if(index === 1) { if (index === 1) {
this.universalMarkRules = this.markRules.filter(item => item.itemno == 20 ) this.universalMarkRules = this.markRules.filter(item => item.itemno == 20)
}else{ } else {
//@ts-ignore this.universalMarkRules =
this.universalMarkRules = this.markRules.filter(item => (this.currentItems.includes(item.itemno) || this.currentItems.includes(item.itemno+''))) this.markRules.filter(item => (this.currentItems.includes(item.itemno.toString()) ||
this.currentItems.includes(item.itemno + '')))
} }
}) })
}) })
} }
Row(){
if( Row() {
(Math.ceil(this.universalMarkRules.length / 7 - 1)) >= (this.currentIndex ? this.currentUniversalPageIndex: this.currentPageIndex) && if (
(this.currentIndex ? this.currentUniversalPageIndex: this.currentPageIndex) > 0 (Math.ceil(this.universalMarkRules.length / 7 - 1)) >=
){ (this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) &&
Row(){ (this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex) > 0
Image($rawfile(`judge/km3/zuo_nor.png`)).height(15).margin({left:20,top:0}) ) {
Text('上一页'){}.fontColor('#FFF').fontSize(this.fontSize) Row() {
}.width(150).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}).margin({right:30}) Image($rawfile(`judge/km3/zuo_nor.png`)).height(15).margin({ left: 20, top: 0 })
.onClick(()=>{this.goPage(0)}) Text('上一页') {
}.fontColor('#FFF').fontSize(this.fontSize)
}
.width(150)
.height(60)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.backgroundImage($rawfile(`judge/km3/button_nor.png`))
.backgroundImageSize({ width: '100%', height: '100%' })
.margin({ right: 30 })
.onClick(() => {
this.goPage(0)
})
} }
if( if (
(Math.ceil(this.universalMarkRules.length / 7 - 1)) > (this.currentIndex ? this.currentUniversalPageIndex: this.currentPageIndex) (Math.ceil(this.universalMarkRules.length / 7 - 1)) >
){ (this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex)
Row(){ ) {
Text('下一页'){}.fontColor('#FFF').fontSize(this.fontSize).padding({left:30}) Row() {
Image($rawfile(`judge/km3/you_nor.png`)).height(15).margin({right:6,top:0}) Text('下一页') {
}.width(150).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}).margin({right:30}) }.fontColor('#FFF').fontSize(this.fontSize).padding({ left: 30 })
.onClick(()=>{this.goPage(1)})
Image($rawfile(`judge/km3/you_nor.png`)).height(15).margin({ right: 6, top: 0 })
}
.width(150)
.height(60)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.backgroundImage($rawfile(`judge/km3/button_nor.png`))
.backgroundImageSize({ width: '100%', height: '100%' })
.margin({ right: 30 })
.onClick(() => {
this.goPage(1)
})
} }
Row(){ Row() {
Text('扣 分'){}.fontColor('#FFF').fontSize(this.fontSize).padding({left:35}) Text('扣 分') {
}.width(140).height(60).justifyContent(FlexAlign.Start).alignItems(VerticalAlign.Center).backgroundImage($rawfile(`judge/km3/button_nor.png`)).backgroundImageSize({width:'100%',height:'100%'}) }.fontColor('#FFF').fontSize(this.fontSize).padding({ left: 35 })
.onClick(()=>{ }
.width(140)
.height(60)
.justifyContent(FlexAlign.Start)
.alignItems(VerticalAlign.Center)
.backgroundImage($rawfile(`judge/km3/button_nor.png`))
.backgroundImageSize({ width: '100%', height: '100%' })
.onClick(() => {
this.endPopupVisible = true this.endPopupVisible = true
}) })
} }
}.width('100%').justifyContent(FlexAlign.SpaceBetween) }.width('100%').justifyContent(FlexAlign.SpaceBetween)
Column(){
ForEach(this.getCurrentMarkRuleList(),(item,index) => { Column() {
Row(){ ForEach(this.getCurrentMarkRuleList(), (item: ESObject, index) => {
Row(){ Row() {
Text(`${item.markshow} (${item.markcatalog})`).fontColor('#FFF').fontSize(this.fontSize).fontWeight(600) Row() {
Text(`${item.markshow} (${item.markcatalog})`)
.fontColor('#FFF')
.fontSize(this.fontSize)
.fontWeight(600)
}.width(1000) }.width(1000)
Row(){
Row() {
Text(item.markreal + '').fontColor('#FFF').fontSize(this.fontSize).fontWeight(600) Text(item.markreal + '').fontColor('#FFF').fontSize(this.fontSize).fontWeight(600)
} }
} }
.width('100%').justifyContent(FlexAlign.SpaceBetween).alignItems(VerticalAlign.Center).constraintSize({minHeight:70}) .width('100%')
.padding({left:20,right:20}) .justifyContent(FlexAlign.SpaceBetween)
.alignItems(VerticalAlign.Center)
.constraintSize({ minHeight: 70 })
.padding({ left: 20, right: 20 })
.backgroundColor(this.getSelectedLine(index)) .backgroundColor(this.getSelectedLine(index))
.onClick(()=>{this.selectedLine = index}) .onClick(() => {
this.selectedLine = index
})
}) })
} }
} }
}.width(1200).height(620).position({x:30,y:315}).backgroundColor('#E6E3DF').padding({top:15,bottom:15,left:25,right:25}).borderRadius(20) }
.width(1200)
.height(620)
.position({ x: 30, y: 315 })
.backgroundColor('#E6E3DF')
.padding({
top: 15,
bottom: 15,
left: 25,
right: 25
})
.borderRadius(20)
// Row(){}.width(100).height(100).position({y:'85%',x:'50%'}).backgroundImage($rawfile('judge/km3/close_nor.png')).backgroundImageSize({width:'100%',height:'100%'}) // Row(){}.width(100).height(100).position({y:'85%',x:'50%'}).backgroundImage($rawfile('judge/km3/close_nor.png')).backgroundImageSize({width:'100%',height:'100%'})
//结束考试弹窗 //结束考试弹窗
if (this.endPopupVisible) { if (this.endPopupVisible) {
@ -179,12 +236,19 @@ export default struct DeductedPopup {
this.endPopupVisible = false; this.endPopupVisible = false;
}, },
confirmFn: async () => { confirmFn: async () => {
const index = this.currentIndex ? this.currentUniversalPageIndex: this.currentPageIndex; const index = this.currentIndex ? this.currentUniversalPageIndex : this.currentPageIndex;
const mark = this.universalMarkRules[index * 7 + this.selectedLine] const mark = this.universalMarkRules[index * 7 + this.selectedLine]
mark && this.confirmMark(mark.itemno,mark.markserial) mark && this.confirmMark(mark.itemno, mark.markserial)
} }
}) })
} }
}.width('100%').height('100%').position({y:0}).onClick(()=>{this.closePopup()}) }.width('100%').height('100%').position({ y: 0 }).onClick(() => {
this.closePopup()
})
}
private closePopup: Function = () => {
}
private confirmMark: Function = (itemno: number, serial: string) => {
} }
} }