123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341 |
- /*
- * 工步页面
- * */
- import { BottomOperateComp } from '../../common/component/BottomOperateComp'
- import router from '@ohos.router';
- import ProcessData from '../../viewmodel/ProcessData';
- import CommonConstants from '../../common/constants/CommonConstants';
- import ProcessStep from '../../viewmodel/ProcessStep'
- import MaterialInfo from '../../model/MaterialInfo';
- import { MaterialCollectView } from '../../view/processview/MaterialCollectView';
- import { RecordItemView } from '../../view/processview/RecordItemView';
- import { MultimediaCollectView } from '../../view/processview/MultimediaCollectView';
- import { EsopView } from '../../view/processview/EsopView';
- import { SpotCheckView } from '../../view/processview/SpotCheckView';
- import { EquipRecordView } from '../../view/processview/EquipRecordView';
- import { DebugPairView } from '../../view/processview/DebugPairView';
- import { FixtureView } from '../../view/processview/FixtureView';
- import { NameplateBindView } from '../../view/processview/NameplateBindView';
- import { pinyin } from 'pinyin-pro';
- import HashMap from '@ohos.util.HashMap';
- import { ProcessTitleComp } from '../../common/component/ProcessTitleComp';
- import JGRequest from '../../common/util/request/Request';
- import StartWorkInfo from '../../viewmodel/StartWorkInfo';
- const params = router.getParams(); // 获取传递过来的参数对象
- const startWorkInfo = params['startWorkInfo']; // 获取开工信息
- const processInfo = params['processInfo']; // 获取当前工序信息
- @Entry
- @Component
- struct ProcessStepPage {
- startWorkInfo: StartWorkInfo = startWorkInfo
- @State process: ProcessData = processInfo
- @State processSteps: ProcessStep[] = []
- private stepImages: Resource[] = CommonConstants.STEP_IMAGES
- private stepSelectImages: Resource[] = CommonConstants.STEP_SELECT_IMAGES
- // 选中的工步索引
- @State selectStep: number = -1
- // 报故弹窗
- reportFaultController: CustomDialogController = new CustomDialogController({
- builder: ReportFaultDialog({
- }),
- autoCancel: true,
- alignment: DialogAlignment.TopEnd,
- // gridCount: 3,
- customStyle: true,
- })
- // 报工弹窗
- reportWorkController: CustomDialogController = new CustomDialogController({
- builder: ReportWorkDialog({
- }),
- autoCancel: true,
- alignment: DialogAlignment.Center,
- // gridCount: 3,
- customStyle: true,
- })
- async aboutToAppear() {
- let res: ProcessStep[] = await JGRequest.get("/api/v1/process/opCompent/get/" + 129, {})
- if (res && res.length > 0) {
- this.processSteps = res
- this.selectStep = 0
- }
- }
- build() {
- Column() {
- ProcessTitleComp()
- Row() {
- // 左侧信息和操作栏
- Column() {
- // 信息栏(产品、工序、主料)
- Column() {
- Column() {
- Text(this.startWorkInfo.materialName)
- .fontSize($r('app.float.card_title_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- .maxLines(1)
- Text(this.startWorkInfo.materialCode)
- .fontSize($r('app.float.card_info_font_size'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Regular)
- .opacity($r('app.float.card_font_default_opacity'))
- .maxLines(1)
- }
- .height('27%')
- .width('90%')
- .alignItems(HorizontalAlign.Start)
- Column() {
- Text('序列号')
- .fontSize($r('app.float.card_info_font_size'))
- .fontWeight(FontWeight.Regular)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.card_font_default_opacity'))
- Text(this.startWorkInfo.seqNo)
- .fontSize($r('app.float.card_info_font_size'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Medium)
- .opacity($r('app.float.general_font_opacity'))
- .maxLines(1)
- }
- .height('27%')
- .width('90%')
- .alignItems(HorizontalAlign.Start)
- Column() {
- Text('当前工序')
- .fontSize($r('app.float.card_info_font_size'))
- .fontWeight(FontWeight.Regular)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.card_font_default_opacity'))
- Row() {
- Text(this.process.operationName)
- .fontSize($r('app.float.card_info_font_size'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Medium)
- .opacity($r('app.float.general_font_opacity'))
- Image($r('app.media.subscript'))
- .height($r('app.float.card_subscript_size'))
- .width($r('app.float.card_subscript_size'))
- }
- .alignItems(VerticalAlign.Center)
- .justifyContent(FlexAlign.SpaceBetween)
- .width('90%')
- }
- .height('27%')
- .width('90%')
- .alignItems(HorizontalAlign.Start)
- }
- .height('29%')
- .width('100%')
- .justifyContent(FlexAlign.SpaceEvenly)
- .backgroundColor($r('app.color.general_card_background_color'))
- .borderRadius($r('app.float.general_border_radius'))
- // 操作卡片
- OperateCard({operateName: '叫料', operateImage:$r('app.media.call_material'), clickEvent: ()=>{
- router.pushUrl({
- url: 'pages/process/CallMaterialPage',
- // params: {}
- })
- }})
- OperateCard({operateName: '工位上料', operateImage:$r('app.media.station_loading'), clickEvent: ()=>{
- router.pushUrl({
- url: 'pages/process/StationLoadingPage'
- })
- }})
- OperateCard({operateName: '物料流转', operateImage:$r("app.media.material_circulation"), clickEvent: ()=>{
- router.pushUrl({
- url: 'pages/process/MaterialCirculationPage',
- // params: {}
- })
- }})
- OperateCard({operateName: '图纸', operateImage:$r('app.media.drawing'), clickEvent: ()=>{
- router.pushUrl({
- url: 'pages/process/ProcessDrawingPage',
- params: {
- mainMaterial: this.startWorkInfo.materialCode
- }
- })
- }})
- OperateCard({operateName: '报故', operateImage:$r('app.media.report_fault'), clickEvent: ()=>{
- this.reportFaultController.open()
- }})
- OperateCard({operateName: '报工', operateImage:$r('app.media.report_work'), bgColor: $r('app.color.process_card_green_color'), clickEvent: ()=>{
- this.reportWorkController.open()
- }})
- }
- .height('83%')
- .width('15%')
- .justifyContent(FlexAlign.SpaceBetween)
- .alignItems(HorizontalAlign.Center)
- // 工步和当前工步的操作
- Column() {
- // 当前工序的工步列表
- List({space: 6}) {
- ForEach(this.processSteps, (item: ProcessStep, index: number)=> {
- ListItem() {
- Column() {
- Image(this.selectStep === index ? this.stepSelectImages[item.compentType - 1] : this.stepImages[item.compentType - 1])
- .width($r('app.float.card_image_size'))
- .height($r('app.float.card_image_size'))
- Text(item.compentName)
- .fontSize($r('app.float.card_info_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor(this.selectStep === index ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
- .opacity(this.selectStep === index ? 1 : $r('app.float.general_font_opacity'))
- }
- .height('100%')
- .width('9.5%')
- .justifyContent(FlexAlign.Center)
- .borderRadius($r('app.float.general_border_radius'))
- .backgroundColor(this.selectStep === index ? $r('app.color.process_card_blue_color') : $r('app.color.page_general_background'))
- .onClick(()=>{
- this.selectStep = index
- })
- }
- })
- }
- .height('9%')
- .width('100%')
- .listDirection(Axis.Horizontal)
- .margin({left: '2%'})
- Column() {
- if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '1') {
- MaterialCollectView({
- startWorkInfo: this.startWorkInfo,
- })
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '2') {
- RecordItemView({
- operationId: this.process.operationId,
- processId: this.startWorkInfo.id
- })
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '3') {
- MultimediaCollectView({
- operationId: this.process.operationId,
- processId: this.startWorkInfo.id,
- })
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '4') {
- EsopView({operationId: this.process.operationId,})
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '5') {
- SpotCheckView({
- operationId: this.process.operationId,
- processId: this.startWorkInfo.id
- })
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '6') {
- EquipRecordView({
- operationId: this.process.operationId,
- processId: this.startWorkInfo.id
- })
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '7') {
- FixtureView()
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '8') {
- DebugPairView()
- } else if (this.processSteps && this.processSteps.length > 0 && this.processSteps[this.selectStep].compentType.toString() === '9') {
- NameplateBindView({mainMaterial: this.startWorkInfo.materialCode})
- }
- }
- .width('100%')
- .height('91%')
- }
- .height('100%')
- .width('85%')
- }
- .width('100%')
- .height('84%')
- .alignItems(VerticalAlign.Top)
- .margin({left: '1.25%'})
- BottomOperateComp()
- }
- .width('100%')
- .height('100%')
- .backgroundColor($r('app.color.page_general_background'))
- }
- }
- @Component
- struct OperateCard {
- operateName: string
- operateImage: Resource
- bgColor?: Resource = $r('app.color.general_card_background_color')
- clickEvent?: Function
- build() {
- Row() {
- Row() {
- Text(this.operateName)
- .fontSize($r('app.float.card_title_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- Image(this.operateImage)
- .width($r('app.float.general_icon_size'))
- .height($r('app.float.general_icon_size'))
- }
- .width('90%')
- .justifyContent(FlexAlign.SpaceBetween)
- }
- .height('11.5%')
- .width('100%')
- .backgroundColor(this.bgColor)
- .borderRadius($r('app.float.general_border_radius'))
- .justifyContent(FlexAlign.Center)
- .onClick(()=>{
- if (this.clickEvent) {
- this.clickEvent()
- }
- })
- }
- }
- @CustomDialog
- struct ReportFaultDialog {
- @State historyArray: MaterialInfo[] = CommonConstants.MATERIAL_ARRAY
- // 所有的缺陷类型
- @State faultTypes: FaultType[] = [
- {id: 1, faultName: '外观缺陷'}, {id: 2, faultName: '尺寸和形状缺陷'}, {id: 3, faultName: '功能性缺陷'}, {id: 4, faultName: '电气连接缺陷'}, {id: 5, faultName: '密闭性缺陷'},
- ]
- // 所有的缺陷类型
- @State faultLevels: FaultLevel[] = [
- {id: 1, levelName: '1级缺陷'}, {id: 2, levelName: '2级缺陷'}, {id: 3, levelName: '3级缺陷'}, {id: 4, levelName: '4级缺陷'},
- ]
- @State selectTypes: number[] = []
- @State selectLevel: number = -1
- @State faultImage: Resource[] = [$r('app.media.return'), $r('app.media.pcb_demo'), $r('app.media.pcb_demo'), $r('app.media.pcb_demo')]
- // 故障缺陷选择弹窗
- faultTypeController: CustomDialogController = new CustomDialogController({
- builder: FaultTypeDialog({
- faultTypes: this.faultTypes,
- selectTypes: $selectTypes,
- }),
- autoCancel: true,
- alignment: DialogAlignment.Center,
- // gridCount: 3,
- customStyle: true,
- })
- // 故障等级选择弹窗
- faultLevelController: CustomDialogController = new CustomDialogController({
- builder: FaultLevelDialog({
- faultLevels: this.faultLevels,
- selectLevel: $selectLevel,
- }),
- autoCancel: true,
- alignment: DialogAlignment.Center,
- // gridCount: 3,
- customStyle: true,
- })
- controller?: CustomDialogController
- cancel: () => void = () => {}
- confirm: () => void = () => {}
- aboutToAppear(){
- // todo 查询故障类型 故障等级
- }
- build() {
- Column() {
- Row() {
- Text('报故')
- .fontSize($r('app.float.process_card_large_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('7.5%')
- .alignItems(VerticalAlign.Bottom)
- Column() {
- Row() {
- Text('故障缺陷')
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .width('96%')
- .height('6%')
- Scroll() {
- Flex({ wrap: FlexWrap.Wrap}) {
- ForEach(this.selectTypes, (item: number, index: number) => {
- Row().width('2%')
- Row() {
- Text(this.faultTypes[item].faultName)
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .backgroundColor($r('app.color.general_card_background_color'))
- .width('47%')
- .height('10%')
- .borderRadius($r('app.float.general_border_radius'))
- .padding({left: 15})
- .margin({bottom: 5})
- })
- Row() {
- Row().width('2%')
- Image($r('app.media.fault_add'))
- .objectFit(ImageFit.Contain)
- .onClick(()=>{
- this.faultTypeController.open()
- })
- }
- .width('100%')
- .height('10%')
- Row() {
- Row().width('2%')
- Text('故障等级')
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .width('100%')
- .height('6%')
- Row() {
- Row().width('2%')
- Row() {
- Text(this.faultLevels && this.faultLevels[this.selectLevel] ? this.faultLevels[this.selectLevel].levelName : '请选择')
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.material_collect_font_opacity'))
- Blank()
- Row() {
- Image($r('app.media.subscript_space'))
- .height($r('app.float.card_subscript_new_size'))
- .width($r('app.float.card_subscript_new_size'))
- }
- .alignItems(VerticalAlign.Bottom)
- .justifyContent(FlexAlign.End)
- .width('20%')
- .height('100%')
- }
- .backgroundColor($r('app.color.general_card_background_color'))
- .width('47%')
- .height('10%')
- .borderRadius($r('app.float.general_border_radius'))
- .padding({left: 15})
- .onClick(()=>{
- this.faultLevelController.open()
- })
- }
- .width('100%')
- Row() {
- Row().width('2%')
- Text('故障图片')
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .width('100%')
- .height('6%')
- ForEach(this.faultImage, (item: Resource, index: number) => {
- Row().width('2%')
- if (index === 0) {
- Row() {
- Image($r('app.media.process_camera'))
- .width('30%')
- Image($r('app.media.local_upload'))
- .width('30%')
- }
- .width('30.67%')
- .height('33%')
- .layoutWeight(1)
- .justifyContent(FlexAlign.SpaceAround)
- .borderRadius($r('app.float.general_border_radius'))
- .borderStyle(BorderStyle.Dashed)
- .borderColor($r('app.color.material_collect_border_color'))
- .borderWidth(1)
- .margin({bottom: 5})
- } else {
- Row() {
- Image(item)
- .objectFit(ImageFit.Fill)
- .borderRadius($r('app.float.general_border_radius'))
- }
- .width('30.67%')
- .height('33%')
- .margin({bottom: 5})
- .onClick(()=> {
- // todo
- })
- }
- })
- Row().width('100%').height('10%')
- }
- }
- .scrollBar(BarState.Off)
- }
- .width('100%')
- .layoutWeight(1)
- .justifyContent(FlexAlign.Start)
- Row() {
- Button('取消')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.robot_set_card_blue'))
- .width('45%')
- .height('66.5%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .onClick(() => {
- // todo
- })
- Button('报故')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_white_color'))
- .width('45%')
- .height('66.5%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_card_blue'))
- .onClick(() => {
- // todo
- })
- }
- .justifyContent(FlexAlign.SpaceEvenly)
- .alignItems(VerticalAlign.Center)
- .height('11%')
- .width('100%')
- }
- .width('50.6%')
- .height('100%')
- .backgroundColor($r('app.color.page_general_background'))
- .justifyContent(FlexAlign.Start)
- .borderRadius({topLeft: $r('app.float.general_border_radius'), bottomLeft: $r('app.float.general_border_radius'),})
- }
- }
- @CustomDialog
- struct ReportWorkDialog {
- @State reportSwitch: number = 1
- // 上报的工人
- @State reportWorkers: UserInfo[] = [
- {userName: '王德发', workHoursRatio: 100}
- ]
- // 工时总比率(max:100) todo 提交需要校验是否等于 100
- @State radioTotal: number = 100
- // 弹窗可用比率 = radioTotal - 当前用户的workHoursRatio
- @State availableRatio: number = 0
- workerRatio: number = 0
- // 修改的人员索引
- workerIndex: number = -1
- @State addWorker: UserInfo = null
- // 报工人员选择弹窗
- workerAddController: CustomDialogController = new CustomDialogController({
- builder: WorkerAddDialog({
- reportWorkers: $reportWorkers,
- addWorker: $addWorker,
- confirm: ()=> {
- this.reportWorkers.splice(this.reportWorkers.length - 1, 0, this.addWorker)
- this.addWorker = null
- }
- }),
- autoCancel: true,
- alignment: DialogAlignment.TopEnd,
- // gridCount: 3,
- customStyle: true,
- })
- workHoursRatioController: CustomDialogController = new CustomDialogController({
- builder: WorkHoursRatioDialog({
- availableRatio: $availableRatio,
- workerRatio: this.workerRatio,
- confirm: ()=> {
- console.log('testTag', '----'+this.availableRatio)
- this.reportWorkers[this.workerIndex] = {
- userName: this.reportWorkers[this.workerIndex].userName,
- workHoursRatio: this.availableRatio
- }
- this.radioTotal = 0
- for (const worker of this.reportWorkers) {
- this.radioTotal += worker.workHoursRatio
- }
- }
- }),
- autoCancel: true,
- alignment: DialogAlignment.TopEnd,
- // gridCount: 3,
- customStyle: true,
- })
- controller?: CustomDialogController
- cancel: () => void = () => {}
- confirm: () => void = () => {}
- aboutToAppear() {
- this.reportWorkers.push({userName: 'admin', workHoursRatio: 0})
- }
- build(){
- Column() {
- Row() {
- Text('报工')
- .fontSize($r('app.float.title_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('12.6%')
- .alignItems(VerticalAlign.Bottom)
- .padding({ bottom : 10})
- // 报工切换按钮
- Row() {
- Row() {
- Stack() {
- if (this.reportSwitch === 1) {
- Text()
- .backgroundColor($r('app.color.general_card_background_color'))
- .width('100%')
- .height('100%')
- .borderRadius($r('app.float.general_border_radius'))
- }
- Text('单人报工')
- .fontSize($r('app.float.set_card_font_size'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Medium)
- .opacity(this.reportSwitch === 1 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
- }
- .width('100%')
- .height('100%')
- }
- .onClick(() => {
- this.reportSwitch = 1
- })
- .width('50%')
- Row() {
- Stack() {
- if (this.reportSwitch === 2) {
- Text()
- .backgroundColor($r('app.color.general_card_background_color'))
- .width('100%')
- .height('100%')
- .borderRadius($r('app.float.general_border_radius'))
- }
- Text('多人报工')
- .fontSize($r('app.float.set_card_font_size'))
- .fontColor($r('app.color.general_font_color'))
- .fontWeight(FontWeight.Medium)
- .opacity(this.reportSwitch === 2 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
- }
- .width('100%')
- .height('100%')
- }
- .width('50%')
- .onClick(() => {
- this.reportSwitch = 2
- })
- }
- .width('66%')
- .height('10%')
- .borderRadius($r('app.float.general_border_radius'))
- .backgroundColor($r('app.color.robot_toward_set_card_background'))
- .margin({bottom: 22})
- // 报工人员
- Row() {
- if (this.reportSwitch === 1) {
- Column() {
- Row(){}.height('16.5%')
- Row(){
- Image($r('app.media.user'))
- .height('100%')
- .objectFit(ImageFit.Fill)
- }
- .height('28.5%')
- .width('100%')
- .justifyContent(FlexAlign.Center)
- Row(){
- Text(this.reportWorkers[0].userName)
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.card_font_select_opacity'))
- }
- .height('14.6%')
- Column() {
- Text('100%')
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.process_card_blue_color'))
- Text('用时占比')
- .fontSize($r('app.float.process_card_small_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.process_step_font_opacity'))
- }
- .height('27.5%')
- .width('75%')
- .justifyContent(FlexAlign.Center)
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .borderRadius($r('app.float.general_border_radius'))
- }
- .width('48%')
- .height('63%')
- .backgroundColor($r('app.color.general_card_background_color'))
- .borderRadius($r('app.float.general_border_radius'))
- } else {
- Scroll() {
- Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween}) {
- ForEach(this.reportWorkers, (item: UserInfo, index: number)=>{
- if (index === this.reportWorkers.length - 1) {
- Column() {
- Row() {
- Image($r('app.media.user_add'))
- .height('100%')
- .objectFit(ImageFit.Fill)
- }
- .height('39%')
- }
- .width('48%')
- .height('63%')
- .borderRadius($r('app.float.general_border_radius'))
- .justifyContent(FlexAlign.Center)
- .borderStyle(BorderStyle.Dashed)
- .borderColor($r('app.color.material_collect_border_color'))
- .borderWidth(1)
- .onClick(()=>{
- this.workerAddController.open()
- })
- } else {
- Column() {
- Row(){}.height('16.5%')
- Row(){
- Image($r('app.media.user'))
- .height('100%')
- .objectFit(ImageFit.Fill)
- }
- .height('28.5%')
- .width('100%')
- .justifyContent(FlexAlign.Center)
- Row(){
- Text(item.userName)
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.card_font_select_opacity'))
- }
- .height('14.6%')
- Column() {
- Text(item.workHoursRatio + '%')
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.process_card_blue_color'))
- Text('用时占比')
- .fontSize($r('app.float.process_card_small_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.process_step_font_opacity'))
- }
- .height('27.5%')
- .width('75%')
- .justifyContent(FlexAlign.Center)
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .borderRadius($r('app.float.general_border_radius'))
- Row() {
- Image($r('app.media.subscript_space'))
- .height($r('app.float.card_subscript_new_size'))
- .width($r('app.float.card_subscript_new_size'))
- }
- .alignItems(VerticalAlign.Bottom)
- .justifyContent(FlexAlign.End)
- .width('100%')
- .layoutWeight(1)
- }
- .width('48%')
- .height('63%')
- .backgroundColor($r('app.color.general_card_background_color'))
- .borderRadius($r('app.float.general_border_radius'))
- .onClick(()=>{
- this.workerIndex = index
- this.workerRatio = this.reportWorkers[index].workHoursRatio
- this.availableRatio = (100 - this.radioTotal) + this.reportWorkers[index].workHoursRatio
- console.log('testTag', '========='+ this.availableRatio)
- this.workHoursRatioController.open()
- })
- }
- })
- }
- }
- }
- }
- .width('66%')
- .justifyContent(FlexAlign.Start)
- .alignItems(VerticalAlign.Top)
- .layoutWeight(1)
- // 确认/取消按钮
- Row() {
- Button('取消')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.robot_set_card_blue'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .onClick(() => {
- this.controller.close()
- this.cancel()
- })
- Row()
- .width('2.5%')
- Button('确认报工')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_white_color'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_card_blue'))
- .onClick(() => {
- if (this.controller != undefined) {
- this.controller.close()
- }
- })
- }
- .justifyContent(FlexAlign.Center)
- .alignItems(VerticalAlign.Center)
- .height('20%')
- .width('100%')
- }
- .width('48%')
- .height('74%')
- .backgroundColor($r('app.color.page_general_background'))
- .borderRadius($r('app.float.general_border_radius'))
- }
- }
- @CustomDialog
- struct FaultTypeDialog {
- faultTypes: FaultType[]
- @Link selectTypes: number[]
- selectTemps: number[] = []
- aboutToAppear() {
- if (this.selectTypes && this.selectTypes.length > 0) {
- for (const select of this.selectTypes) {
- this.selectTemps.push(select)
- }
- }
- }
- controller?: CustomDialogController
- cancel: () => void = () => {}
- confirm: () => void = () => {}
- build(){
- Column() {
- Row() {
- Text('选择缺陷')
- .fontSize($r('app.float.title_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('15%')
- .alignItems(VerticalAlign.Center)
- List({ space: 10}) {
- ForEach(this.faultTypes, (item: FaultType, index: number)=>{
- ListItem() {
- Row() {
- Text(item.faultName)
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- Checkbox()
- .select(this.selectTemps.includes(index) ? true : false)
- .onChange((value: boolean)=>{
- if (value) {
- this.selectTemps.push(index)
- } else {
- this.selectTemps = this.selectTemps.filter(function(item) {
- return item !== index
- });
- }
- })
- }
- .backgroundColor($r('app.color.general_card_background_color'))
- .width('71%')
- .height('14%')
- .borderRadius($r('app.float.general_border_radius'))
- .justifyContent(FlexAlign.SpaceBetween)
- .padding({left: 15, right: 15})
- }
- })
- }
- .width('100%')
- .layoutWeight(1)
- .alignListItem(ListItemAlign.Center)
- Row() {
- Button('取消')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.robot_set_card_blue'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .onClick(() => {
- this.controller.close()
- this.cancel()
- })
- Row()
- .width('2.5%')
- Button('确认')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_white_color'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_card_blue'))
- .onClick(() => {
- if (this.controller != undefined) {
- this.controller.close()
- this.selectTypes = this.selectTemps
- this.selectTypes.sort(function(a, b){
- return a as number - (b as number);
- })
- }
- })
- }
- .justifyContent(FlexAlign.Center)
- .alignItems(VerticalAlign.Center)
- .height('15%')
- .width('100%')
- }
- .width('48%')
- .height('74%')
- .backgroundColor($r('app.color.page_general_background'))
- .borderRadius($r('app.float.general_border_radius'))
- }
- }
- @CustomDialog
- struct FaultLevelDialog {
- faultLevels: FaultLevel[]
- @Link selectLevel: number
- @State selectTemp: number = -1
- aboutToAppear() {
- this.selectTemp = this.selectLevel
- }
- controller?: CustomDialogController
- cancel: () => void = () => {}
- confirm: () => void = () => {}
- build(){
- Column() {
- Row() {
- Text('选择故障等级')
- .fontSize($r('app.float.title_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('15%')
- .alignItems(VerticalAlign.Center)
- List({ space: 10 }) {
- ForEach(this.faultLevels, (item: FaultLevel, index: number)=>{
- ListItem() {
- Row() {
- Text(item.levelName)
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor(this.selectTemp === index ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
- .opacity(this.selectTemp === index ? 1 : $r('app.float.general_font_opacity'))
- }
- .backgroundColor(this.selectTemp === index ? $r('app.color.process_card_blue_color') : $r('app.color.general_card_background_color'))
- .width('71%')
- .height('20%')
- .borderRadius($r('app.float.general_border_radius'))
- .justifyContent(FlexAlign.Center)
- .padding({left: 15, right: 15})
- .onClick(()=>{
- this.selectTemp = index
- })
- }
- })
- }
- .width('100%')
- .layoutWeight(1)
- .alignListItem(ListItemAlign.Center)
- Row() {
- Button('取消')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.robot_set_card_blue'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .onClick(() => {
- this.controller.close()
- this.cancel()
- })
- Row()
- .width('2.5%')
- Button('确认')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_white_color'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_card_blue'))
- .onClick(() => {
- if (this.controller != undefined) {
- this.controller.close()
- this.selectLevel = this.selectTemp
- }
- })
- }
- .justifyContent(FlexAlign.Center)
- .alignItems(VerticalAlign.Center)
- .height('15%')
- .width('100%')
- }
- .width('48%')
- .height('54%')
- .backgroundColor($r('app.color.page_general_background'))
- .borderRadius($r('app.float.general_border_radius'))
- }
- }
- @CustomDialog
- struct WorkerAddDialog {
- @Link reportWorkers: UserInfo[]
- @Link addWorker: UserInfo
- // 所有工人
- @State workerArray: UserInfo[] = [
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- {userName: '王德发'}, {userName: '阿强'}, {userName: '包天'}, {userName: '毕想'}, {userName: '安海兵'},
- ]
- // 字母对应的索引
- @State alphabetMap: HashMap<string, number> = new HashMap();
- @State alphabetArray: string[] = []
- scroller: Scroller = new Scroller()
- controller?: CustomDialogController
- cancel: () => void = () => {}
- confirm: () => void = () => {}
- aboutToAppear() {
- // todo 查询所有工人(过滤掉已选择的)
- for (const worker of this.workerArray) {
- let str = pinyin(worker.userName, { mode: 'surname', toneType: 'none', pattern: 'first'})
- worker.pinyinInitial = str.charAt(0).toUpperCase()
- }
- // 将工人按照姓名字母排序
- this.workerArray = this.workerSort(this.workerArray)
- // 把第一个工人姓名的字母保存到对应的数组中
- this.workerArray.unshift({userName: 'A', pinyinInitial: 'A'})
- this.alphabetMap.set(this.workerArray[0].pinyinInitial, 0)
- this.alphabetArray.push(this.workerArray[0].pinyinInitial)
- let lastInitial: string = this.workerArray[0].pinyinInitial
- for (let index = 0; index < this.workerArray.length; index++) {
- if (this.workerArray[index].pinyinInitial !== lastInitial) {
- lastInitial = this.workerArray[index].pinyinInitial
- // 工人姓名字母发生变化,则在数组中插入 字母 保证渲染
- this.workerArray.splice(index, 0, {userName: lastInitial, pinyinInitial: lastInitial});
- this.alphabetMap.set(lastInitial, index)
- this.alphabetArray.push(lastInitial)
- } else {
- if (index === 0) {
- continue
- }
- this.workerArray[index].pinyinInitial = '@'
- }
- }
- }
- workerSort (arr: UserInfo[]) {
- if (arr.length <= 1) {
- return arr;
- }
- var medianIndex = Math.floor(arr.length / 2); // 找分界值索引
- var medianValue: UserInfo[] = arr.splice(medianIndex, 1); // 把分界值从原数组中取出并删除
- var left: UserInfo[] = []; // 比分界值小的,放左边
- var right: UserInfo[] = []; // 比分界值大的,放右边
- for (let i = 0; i < arr.length; i++) {
- if (arr[i].pinyinInitial < medianValue[0].pinyinInitial) {
- left.push(arr[i])
- } else {
- right.push(arr[i])
- }
- }
- return this.workerSort(left).concat(medianValue, this.workerSort(right)); // 最后进行拼接
- };
- build() {
- Column() {
- Row() {
- Text('参与人员')
- .fontSize($r('app.float.process_card_large_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('7.5%')
- .alignItems(VerticalAlign.Bottom)
- Row() {
- Row() {
- Row() {
- Image($r('app.media.user'))
- .height('31%')
- }
- .width('8%')
- .justifyContent(FlexAlign.End)
- TextInput({ placeholder: '员工名单搜索' })
- .placeholderColor($r('app.color.text_input_placeholder_font_color'))
- .placeholderFont({size: $r('app.float.robot_set_font_size'), weight: FontWeight.Medium})
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .textAlign(TextAlign.Start)
- .height('100%')
- .layoutWeight(1)
- .maxLength(100)
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.general_font_white_color'))
- .onChange((value: string) => {
- })
- .onSubmit(() => {
- })
- }
- .height('66.5%')
- .width('92%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.general_font_white_color'))
- }
- .height('11%')
- Row() {
- List({space:14, scroller: this.scroller}) {
- ForEach(this.workerArray, (item: UserInfo, index: number) => {
- ListItem() {
- if (this.alphabetMap.hasKey(item.pinyinInitial)) {
- Column() {
- Text(item.pinyinInitial)
- .fontSize($r('app.float.process_worker_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_white_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('9%')
- .width('26.5%')
- .justifyContent(FlexAlign.Center)
- .backgroundColor($r('app.color.process_card_blue_color'))
- } else {
- Column() {
- Text(item.userName)
- .fontSize($r('app.float.process_card_middle_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .textAlign(TextAlign.Center)
- }
- .height('9%')
- .onClick(()=>{
- this.addWorker = {
- userName: item.userName,
- workHoursRatio: 0
- }
- this.controller.close()
- this.confirm()
- })
- }
- }
- })
- }
- .width('50%')
- AlphabetIndexer({ arrayValue: this.alphabetArray, selected: 0 })
- .color($r('app.color.process_worker_font_color'))
- .selectedColor($r('app.color.process_worker_font_color')) // 选中项文本颜色
- .selectedBackgroundColor($r('app.color.general_font_white_color')) // 选中项背景颜色
- .usingPopup(false) // 是否显示弹出框
- .onSelect((index: number) => {
- if (this.alphabetMap.hasKey(this.alphabetArray[index])) {
- this.scroller.scrollToIndex(this.alphabetMap.get(this.alphabetArray[index]))
- }
- })
- }
- .width('92%')
- .justifyContent(FlexAlign.SpaceBetween)
- .layoutWeight(1)
- }
- .width('48%')
- .height('100%')
- .backgroundColor($r('app.color.page_general_background'))
- .borderRadius($r('app.float.general_border_radius'))
- }
- }
- @CustomDialog
- struct WorkHoursRatioDialog {
- @Link availableRatio: number
- workerRatio: number
- // 选择项(10%为一个间隔)
- selectItems: string[] = []
- private select: number = 1
- controller?: CustomDialogController
- cancel: () => void = () => {}
- confirm: () => void = () => {}
- aboutToAppear() {
- console.log('testTag', JSON.stringify(this.availableRatio))
- let radio = 10
- while (radio <= this.availableRatio) {
- this.selectItems.push(radio + '%')
- if (this.workerRatio && this.workerRatio === radio) {
- this.select = this.selectItems.length - 1
- }
- radio += 10
- }
- console.log('testTag', JSON.stringify(this.workerRatio))
- }
- build() {
- Column() {
- Row() {
- Text('用时占比')
- .fontSize($r('app.float.process_card_large_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_color'))
- .opacity($r('app.float.general_font_opacity'))
- }
- .height('16%')
- Row() {
- TextPicker({ range: this.selectItems, selected: this.select})
- .onChange((value: string, index: number) => {
- this.availableRatio = Number.parseInt(value)
- })
- .width('40%')
- .height('100%')
- .backgroundColor($r('app.color.bottom_bar_background'))
- .borderImage({source:$r('app.media.text_picker_frame'), fill: true})
- }
- .width('100%')
- .layoutWeight(1)
- .justifyContent(FlexAlign.Center)
- Row() {
- Button('取消')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.robot_set_card_blue'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_coord_card_grey'))
- .onClick(() => {
- this.controller.close()
- this.cancel()
- })
- Row()
- .width('2.5%')
- Button('确认')
- .fontSize($r('app.float.robot_set_font_size'))
- .fontWeight(FontWeight.Medium)
- .fontColor($r('app.color.general_font_white_color'))
- .width('32%')
- .height('50%')
- .borderRadius($r('app.float.robot_set_radius'))
- .backgroundColor($r('app.color.robot_set_card_blue'))
- .onClick(() => {
- if (this.controller != undefined) {
- this.controller.close()
- this.confirm()
- }
- })
- }
- .justifyContent(FlexAlign.Center)
- .height('24%')
- .width('100%')
- }
- .width('48%')
- .height('62%')
- .backgroundColor($r('app.color.page_general_background'))
- .borderRadius($r('app.float.general_border_radius'))
- }
- }
- class FaultType {
- id?: number
- faultName?: string
- }
- class FaultLevel {
- id?: number
- levelName?: string
- }
- class UserInfo {
- id?: number
- userName?: string
- // 工时占比
- workHoursRatio?: number
- // 姓氏的拼音首字母
- pinyinInitial?: string
- }
|