cjb 1 giorno fa
parent
commit
71e3b6bffe

+ 77 - 0
entry/src/main/ets/pages/ProcessIndex.ets

@@ -19,6 +19,11 @@ import { WorkOrderPage } from '../viewmodel/WorkOrderPage';
 import { UserInfo } from '../viewmodel/UserInfo';
 import { CompleteReceiveDialog } from '../view/CompleteReceiveDialog';
 import { WorkInstructionsDialog } from '../view/WorkInstructionsDialog';
+import { ReportWorkNumDialog } from '../view/ReportWorkNumDialog';
+import { ProcessReportingDialog } from '../view/ProcessReportingDialog';
+import { JoinPersonNameDialog } from '../view/JoinPersonNameDialog';
+import ReportInfo from '../viewmodel/ReportInfo';
+import { BindTaskSeqVO } from '../viewmodel/BindTaskSeqVO';
 
 @Entry
 @Component
@@ -71,6 +76,11 @@ struct ProcessIndex {
   @Provide('currentStationId') @Watch('refreshWorkOrder') currentStationId: string = ''
   @Provide('currentUserName') currentUserName: string =''
   @Provide('currentUserId') currentUserId: number = 0
+  @Provide('bindTaskSeq')bindTaskSeq: BindTaskSeqVO[]=[]
+  @State reportList:ReportInfo[]=[]
+  @State currentReporterIndex:number =0
+  @State currentReportNumIndex:number =0
+  @State currentUnqualifiedIndex:number =0
 
   // 工位发生改变则可能需要重新选择工单
   async refreshWorkOrder() {
@@ -134,6 +144,73 @@ struct ProcessIndex {
     alignment:DialogAlignment.Center,
     maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
   })
+  ReportWorkNumController: CustomDialogController = new CustomDialogController({
+    builder: ReportWorkNumDialog({
+      userName: this.reportList[this.currentReporterIndex].userName,
+      onConfirm:(num:number)=>{
+        const index = this.currentReporterIndex;
+        if (this.reportList[index]) {
+          this.reportList[index].reportNum = String(num);
+          this.reportList = [...this.reportList];
+        }
+      }
+    }),
+    autoCancel: true,
+    customStyle: true,
+    alignment:DialogAlignment.Center,
+    maskColor: 'rgba(0,0,0,0.8)',
+  })
+  JoinPersonNameController: CustomDialogController = new CustomDialogController({
+    builder: JoinPersonNameDialog({
+      reportList:this.reportList,
+      onConfirm:(name:string)=>{
+        const nameExists = this.reportList.some(item =>
+        item.userName && name &&
+          item.userName.toString().toLowerCase() === name.toString().toLowerCase().trim()
+        );
+        if (nameExists) {
+          promptAction.showToast({
+            message: '该用户已添加,请添加其他用户!',
+            duration: 2000
+          });
+          return;
+        }
+        const index = this.currentReporterIndex;
+        if (this.reportList[index]) {
+          this.reportList[index].userName = name;
+          this.reportList = [...this.reportList];
+        }
+      }
+    }),
+    autoCancel: true,
+    customStyle: true,
+    alignment:DialogAlignment.Center,
+    maskColor: 'rgba(0,0,0,0.8)',
+  })
+  ProcessReportingController: CustomDialogController = new CustomDialogController({
+    builder: ProcessReportingDialog({
+      onSelectReporter:(index:number)=>{
+        this.currentReporterIndex = index; // 只记录当前索引
+        this.JoinPersonNameController.open();
+      },
+      onSelectReportNum:(index:number)=>{
+        if (!this.reportList[index]?.userName?.trim()) {
+          promptAction.showToast({
+            message: '请先添加用户',
+            duration: 2000
+          });
+          return;
+        }
+        this.currentReportNumIndex = index
+        this.ReportWorkNumController.open()
+      },
+      reportList:this.reportList
+    }),
+    autoCancel: true, // 点击遮罩关闭
+    customStyle: true,
+    alignment:DialogAlignment.Center,
+    maskColor: 'rgba(0,0,0,0.8)',  // 黑色遮罩
+  })
   // 切换产线弹窗控制器
   SwitchingProductLineController: CustomDialogController = new CustomDialogController({
     builder: SwitchingProductLineDialog({}),

+ 6 - 1
entry/src/main/ets/view/JoinPersonNameDialog.ets

@@ -2,18 +2,21 @@
 import { pinyin } from "pinyin-pro";
 import ProcessRequest from '../common/util/request/ProcessRequest';
 import PageInfo from '../viewmodel/PageInfo';
+import ReportInfo from '../viewmodel/ReportInfo';
 import RequestParamModel from '../viewmodel/RequestParamModel';
 import { UserInfo } from '../viewmodel/UserInfo';
 
 @CustomDialog
 export struct JoinPersonNameDialog{
   controller: CustomDialogController
-  onConfirm: () => void = () => {}
+
   scroller: Scroller = new Scroller()
   @State nameList:UserInfo[]=[]
   @State selectNameIndex:number=-1
   @State selectName:string = ''
   @State queryName:string = ''
+  @Link reportList: ReportInfo[]
+  onConfirm: (name: string) => void = () => {}
 
   private value: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G',
     'H', 'I', 'J', 'K', 'L', 'M', 'N',
@@ -32,6 +35,8 @@ export struct JoinPersonNameDialog{
   private onSelectName(index: number) {
     this.selectNameIndex = index
     this.selectName = this.nameList[index].userName??""
+    this.controller.close();
+    this.onConfirm(this.selectName);
   }
 
   loadPersonNameList = async ()=>{

+ 51 - 18
entry/src/main/ets/view/ProcessReportingDialog.ets

@@ -3,12 +3,13 @@ import ProcessRequest from '../common/util/request/ProcessRequest'
 import TaskSeqVO from '../viewmodel/process/TaskSeqInfo'
 import ReportInfo from '../viewmodel/ReportInfo'
 import RequestParamModel from '../viewmodel/RequestParamModel'
+import WorkOrderInfo from '../viewmodel/WorkOrderInfo'
 
 @CustomDialog
 export struct ProcessReportingDialog{
   private scrollerList: Scroller = new Scroller()
   //查询报工
-  @State reportList: ReportInfo[] = []
+  @Link reportList: ReportInfo[]
   //当前工单号
   @State currentWorkOrderCode:string = ''
   //当前工序号
@@ -17,18 +18,35 @@ export struct ProcessReportingDialog{
   @State currentStationId:string = ''
   //选择的按钮索引(默认加载全部)
   @State addReportingClick: number = 1
+  //从首页传来的工单
+  @Prop selectWorkOder: WorkOrderInfo = {}
+  @Prop selectProcessName:string = '正面三防'
+  //当前工序已报工数量
+  @State reportedNum:number = 0
+  //计划报工数量
+  @State planReportNum:number = 0
   //扫描的流水号/序列/铭牌号
   @State scanSeqValue: string = ''
   @State userName:string = '王德发'
+  @State currentReporterIndex: number = 0; // 记录当前点击的报工人索引
 
   controller: CustomDialogController
   onConfirm: () => void = () => {}
   //选择报工人
-  onSelectReporter: () => void = () => {}
+  onSelectReporter: (index:number) => void = () => {}
   //选择报工数量
-  onSelectReportNum: () => void = () => {}
+  onSelectReportNum: (index:number) => void = () => {}
   //选择不良品数量
-  onSelectUnqualified: () => void = () => {}
+  onSelectUnqualified: (index:number) => void = () => {}
+
+
+  updateReporterName(index: number, name: string) {
+    if (this.reportList[index]) {
+      this.reportList[index].userName = name;
+      // 强制刷新界面
+      this.reportList = [...this.reportList];
+    }
+  }
 
   //加载第一个报工人(无法删除)
   loadFirstReport=async ()=>{
@@ -37,6 +55,24 @@ export struct ProcessReportingDialog{
     this.reportList.push(firstReporter)
   }
 
+  onQueryTask = async (currentStateList: Array<number>): Promise<number> => {
+    let res = await ProcessRequest.post('/api/v1/plan/task/list', {
+      stationId: this.currentStationId,
+      workOrderCode: this.currentWorkOrderCode,
+      operationId: this.currentOperationId,
+      stateList: currentStateList
+    } as RequestParamModel) as TaskSeqVO[];
+    return res.length;
+  }
+
+  async handleAllClick(): Promise<void> {
+   this.planReportNum = await this.onQueryTask([]);
+  }
+
+  async handleReportedClick(): Promise<void> {
+    this.reportedNum = await this.onQueryTask([2]);
+  }
+
   aboutToAppear(): void {
     this.loadFirstReport()
   }
@@ -57,10 +93,10 @@ export struct ProcessReportingDialog{
       Column(){
           Row(){
             Column({space:3}){
-              Text("卫星通导模块")
+              Text(this.selectWorkOder.materialName)
                 .fontSize($r('app.float.fontSize_24'))
                 .fontColor($r('app.color.FFFFFF'))
-              Text("ASF-ASFA-ASD-FAS")
+              Text(this.selectWorkOder.materialCode)
                 .fontSize($r('app.float.fontSize_12'))
                 .fontColor($r('app.color.FFFFFF'))
                 .fontWeight(FontWeight.Lighter)
@@ -69,7 +105,7 @@ export struct ProcessReportingDialog{
                   .fontSize($r('app.float.fontSize_16'))
                   .fontColor($r('app.color.FFFFFF'))
                   .fontWeight(FontWeight.Lighter)
-                Text("123456789123456789")
+                Text(this.selectWorkOder.workOrderCode)
                   .fontSize($r('app.float.fontSize_16'))
                   .fontColor($r('app.color.FFFFFF'))
               }
@@ -83,7 +119,7 @@ export struct ProcessReportingDialog{
                 .fontSize($r('app.float.fontSize_16'))
                 .fontColor($r('app.color.FFFFFF'))
                 .fontWeight(FontWeight.Lighter)
-              Text('正面三防')
+              Text(this.selectProcessName)
                 .fontSize($r('app.float.fontSize_16'))
                 .fontColor($r('app.color.FFFFFF'))
             }
@@ -93,16 +129,12 @@ export struct ProcessReportingDialog{
             .alignItems(VerticalAlign.Bottom)
             Column(){
               Row(){
-                Text('10/')
+                Text(`${this.reportedNum}/`)
                   .fontSize($r('app.float.fontSize_38'))
                   .fontColor($r('app.color.FFFFFF'))
-                Text('100')
+                Text(`${this.planReportNum}`)
                   .fontSize($r('app.float.fontSize_38'))
                   .fontColor($r('app.color.60FFFFFF'))
-                Text('片')
-                  .fontSize($r('app.float.fontSize_16'))
-                  .fontColor($r('app.color.60FFFFFF'))
-                  .fontWeight(FontWeight.Lighter)
               }
               Text('当前工序已报工/计划')
                 .fontSize($r('app.float.fontSize_12'))
@@ -178,7 +210,8 @@ export struct ProcessReportingDialog{
                       .enabled(index!=0)
                       .backgroundColor($r('app.color.20FFFFFF'))
                       .onClick(()=>{
-                        this.onSelectReporter()
+                        this.onSelectReporter(index)
+                        this.currentReporterIndex = index;
                       })
                     }
                     .width('29%')
@@ -209,7 +242,7 @@ export struct ProcessReportingDialog{
                       .height('70%')
                       .backgroundColor($r('app.color.20FFFFFF'))
                       .onClick(()=>{
-                        this.onSelectReportNum()
+                        this.onSelectReportNum(index)
                       })
                     }
                     .width('29%')
@@ -241,7 +274,7 @@ export struct ProcessReportingDialog{
                       .backgroundColor($r('app.color.20FFFFFF'))
                       .height('70%')
                       .onClick(()=>{
-                        this.onSelectUnqualified()
+                        this.onSelectUnqualified(index)
                       })
                     }
                     .width('29%')
@@ -300,7 +333,7 @@ export struct ProcessReportingDialog{
             .strokeWidth(1)
             .color($r('app.color.15FFFFFF'))
           Row() {
-            Text('确')
+            Text('确认报工')
               .fontColor($r('app.color.007AFF'))
               .fontSize($r('app.float.fontSize_30'))
           }

+ 292 - 0
entry/src/main/ets/view/ReportWorkNumDialog.ets

@@ -0,0 +1,292 @@
+//报工数量
+import ProcessRequest from '../common/util/request/ProcessRequest';
+import { BindTaskSeqVO } from '../viewmodel/BindTaskSeqVO';
+import TaskSeqVO from '../viewmodel/process/TaskSeqInfo';
+import RequestParamModel from '../viewmodel/RequestParamModel';
+
+@CustomDialog
+export struct ReportWorkNumDialog{
+  controller: CustomDialogController
+  onConfirm: (num:number)=> void = () => {}
+  scroller: Scroller = new Scroller()
+
+  //是否全选
+  @State isAllSelected:boolean = false
+  //选择的数量
+  @State selectNum:number= 0
+  //当前工单
+  @State currentWorkOrderCode:string = ''
+  //当前工序号
+  @State currentOperationId:string = ''
+  //当前工位
+  @State currentStationId:string = ''
+  //总数量
+  @State totalNum:number= 0
+  //查询报工
+  @State queryTaskSeq: TaskSeqVO[] = []
+  @Consume ('bindTaskSeq') bindTaskSeq: BindTaskSeqVO[]
+  @Prop userName:string= ''
+  @State selectedIndexes:number[] =[]
+
+  onQueryTask=async ()=>{
+    this.queryTaskSeq = await ProcessRequest.post('/api/v1/plan/task/list', {
+      stationId:this.currentStationId,
+      workOrderCode:this.currentWorkOrderCode,
+      operationId:this.currentOperationId,
+      stateList:[-1,0,1]
+    } as RequestParamModel) as TaskSeqVO[];
+    this.totalNum = this.queryTaskSeq.length
+  }
+
+  private isSelectedByOthers(item: TaskSeqVO): boolean {
+    // 检查所有其他用户的选择记录
+    return this.bindTaskSeq.some(userSelection =>
+    userSelection.userName !== this.userName &&
+    userSelection.TaskSeq?.some(seq =>
+    seq.seqNo === item.seqNo &&
+      seq.operationId === item.operationId
+    )
+    );
+  }
+
+  // 获取选择当前项的用户名
+  private getSelectingUserName(item: TaskSeqVO): string | undefined {
+    const userSelection = this.bindTaskSeq.find(userSelection =>
+    userSelection.TaskSeq?.some(seq =>
+    seq.seqNo === item.seqNo &&
+      seq.operationId === item.operationId)
+    );
+    return userSelection?.userName;
+  }
+
+  //选择单个
+  private onSelectSeqNo(index: number) {
+    const item = this.queryTaskSeq[index];
+
+    if (this.isSelectedByOthers(item)) {
+      return; // 已被其他用户选择,不允许操作
+    }
+
+    if (this.selectedIndexes.includes(index)) {
+      this.selectedIndexes = this.selectedIndexes.filter(i => i !== index);
+    } else {
+      this.selectedIndexes = [index, ...this.selectedIndexes];
+    }
+
+    this.updateSelectState();
+  }
+
+  //全选
+  private handleSelectAll() {
+    this.isAllSelected = !this.isAllSelected;
+
+    if (this.isAllSelected) {
+      // 只选择未被其他用户选中的项
+      this.selectedIndexes = [];
+      this.queryTaskSeq.forEach((item: TaskSeqVO, index: number) => {
+        if (!this.isSelectedByOthers(item)) {
+          this.selectedIndexes.push(index);
+        }
+      });
+    } else {
+      this.selectedIndexes = [];
+    }
+
+    this.updateSelectState();
+  }
+
+  //更新选择状态
+  private updateSelectState() {
+    this.selectNum = this.selectedIndexes.length;
+    const availableItems = this.queryTaskSeq.filter(item => !this.isSelectedByOthers(item));
+    this.isAllSelected = availableItems.length > 0 &&
+      this.selectedIndexes.length === availableItems.length;
+  }
+
+  aboutToAppear(): void {
+    this.onQueryTask()
+  }
+
+  build() {
+    Column(){
+      Column() {
+        Text("报工数量")
+          .fontColor($r('app.color.FFFFFF'))
+          .fontSize($r('app.float.fontSize_30'))
+      }
+      .height('8%')
+      .width('100%')
+      .justifyContent(FlexAlign.Center)
+      Row() {
+        Row(){
+          Row(){}.width('5%')
+          Checkbox()
+            .select(this.isAllSelected)
+            .selectedColor($r('app.color.0A84FF'))
+            .unselectedColor($r('app.color.60FFFFFF'))
+            .width($r('app.float.virtualSize_24'))
+            .mark({
+              strokeColor:$r('app.color.000000'),
+              size: $r('app.float.virtualSize_20'),
+              strokeWidth: 1
+            })
+            .height($r('app.float.virtualSize_24'))
+            .onChange(async (value: boolean) => {
+            })
+            .onClick(()=>{
+              this.handleSelectAll()
+            })
+          Text("全选")
+            .fontColor($r('app.color.FFFFFF'))
+            .fontSize($r('app.float.fontSize_16'))
+        }
+        .width('20%')
+        .justifyContent(FlexAlign.Start)
+        .backgroundColor(this.isAllSelected?$r('app.color.200A84FF'):$r('app.color.20FFFFFF'))
+        .borderRadius($r('app.float.virtualSize_16'))
+        .onClick(()=>{
+          this.handleSelectAll()
+        })
+        Row(){
+          Text(`${this.selectNum}`)
+            .fontColor($r('app.color.30D158'))
+            .fontSize($r('app.float.fontSize_16'))
+            .fontWeight(FontWeight.Lighter)
+          Text(`/${this.totalNum}`)
+            .fontColor($r('app.color.FFFFFF'))
+            .fontSize($r('app.float.fontSize_16'))
+            .fontWeight(FontWeight.Lighter)
+        }
+        .margin({left:'49%'})
+        .width('30%')
+        .justifyContent(FlexAlign.End)
+      }
+      .borderRadius($r('app.float.virtualSize_16'))
+      .height('7%')
+      .width('96%')
+      .margin({left:'2%',right:'2%',bottom:'1.5%'})
+      Row() {
+        List({space:8,scroller:this.scroller}){
+          ForEach(this.queryTaskSeq, (item:TaskSeqVO,index) => {
+            ListItem() {
+              Row(){
+                Checkbox()
+                  .select(this.selectedIndexes.includes(index)||this.isSelectedByOthers(item))
+                  .selectedColor($r('app.color.30D158'))
+                  .unselectedColor($r('app.color.60FFFFFF'))
+                  .width($r('app.float.virtualSize_24'))
+                  .mark({
+                    strokeColor:$r('app.color.000000'),
+                    size: $r('app.float.virtualSize_20'),
+                    strokeWidth: 1
+                  })
+                  .height($r('app.float.virtualSize_24'))
+                  .onClick(()=>{
+                    this.onSelectSeqNo(index)
+                    this.selectNum = this.selectedIndexes.length;
+                  })
+                Text('S/N')
+                  .fontColor($r('app.color.FFFFFF'))
+                  .fontSize($r('app.float.fontSize_16'))
+                  .fontWeight(FontWeight.Lighter)
+                Text(item.seqNo)
+                  .fontColor($r('app.color.FFFFFF'))
+                  .fontSize($r('app.float.fontSize_16'))
+                  .fontWeight(FontWeight.Bold)
+                  .margin({left:'2%'})
+                Text(this.getSelectingUserName(item))
+                  .fontColor($r('app.color.FFFFFF'))
+                  .fontSize($r('app.float.fontSize_12'))
+                  .fontWeight(FontWeight.Lighter)
+                  .width('50%')
+                  .textAlign(TextAlign.End)
+              }
+              .borderRadius($r('app.float.virtualSize_16'))
+              .backgroundColor(
+                this.selectedIndexes.includes(index) ||this.isSelectedByOthers(item)?
+                $r('app.color.2030D158') :
+                $r('app.color.20FFFFFF')
+              )
+              .border({
+                width:  1 ,
+                color: this.selectedIndexes.includes(index)||this.isSelectedByOthers(item) ?
+                $r('app.color.30D158') :
+                $r('app.color.20FFFFFF')
+              })
+              .width('100%')
+              .opacity(this.isSelectedByOthers(item) ? 0.3 : 1)
+              .onClick(()=>{
+                this.onSelectSeqNo(index)
+                this.selectNum = this.selectedIndexes.length;
+              })
+            }
+            .width('96%')
+            .margin({left:'2%',right:'2%'})
+          })
+        }
+        .height('100%')
+        .width('100%')
+      }
+      .height('73%')
+      .width('100%')
+      .margin({bottom:'1.5%'})
+      Column() {
+        Divider()
+          .vertical(false)
+          .strokeWidth(1)
+          .color($r('app.color.15FFFFFF'))
+        Row() {
+          Row() {
+            Text('取消')
+              .fontColor($r('app.color.60FFFFFF'))
+              .fontSize($r('app.float.fontSize_30'))
+          }
+          .justifyContent(FlexAlign.Center)
+          .width('50%')
+          .onClick(() => this.controller.close())
+          Divider()
+            .vertical(true)
+            .strokeWidth(1)
+            .color($r('app.color.15FFFFFF'))
+          Row() {
+            Text('确定')
+              .fontColor($r('app.color.007AFF'))
+              .fontSize($r('app.float.fontSize_30'))
+          }
+          .justifyContent(FlexAlign.Center)
+          .width('50%')
+          .onClick(() => {
+            const currentUserSelection: BindTaskSeqVO = {
+              userName: this.userName,
+              TaskSeq: this.queryTaskSeq.filter((_, index) => this.selectedIndexes.includes(index))
+            };
+            const existingUserIndex = this.bindTaskSeq.findIndex(
+              item => item.userName === this.userName
+            );
+            if (existingUserIndex >= 0) {
+              this.bindTaskSeq[existingUserIndex] = currentUserSelection;
+            } else {
+              this.bindTaskSeq.push(currentUserSelection);
+            }
+            this.onConfirm(this.selectedIndexes.length);
+            this.controller.close()
+          })
+        }
+      }
+      .width('100%')
+      .height('8%')
+    }
+    .height('71%')
+    .width('30%')
+    .backgroundColor($r('app.color.2A2A2A'))
+    .justifyContent(FlexAlign.End)
+    .alignItems(HorizontalAlign.Start)
+    .borderColor($r('app.color.000000'))
+    .borderWidth(1)
+    .borderRadius($r('app.float.virtualSize_16'))
+  }
+}
+
+
+
+

+ 3 - 3
entry/src/main/ets/view/SwitchingProductDialog.ets

@@ -9,11 +9,11 @@ export struct SwitchingProductDialog{
   //查询报工
   @State queryTaskSeq: TaskSeqVO[] = []
   //当前工单号
-  @State currentWorkOrderCode:string = ''
+  @Prop currentWorkOrderCode:string = ''
   //当前工序号
-  @State currentOperationId:string = ''
+  @Prop currentOperationId:string = ''
   //当前工位
-  @State currentStationId:string = ''
+  @Prop currentStationId:string = ''
   //选择的按钮索引(默认加载全部)
   @State selectedButtonIndex: number = 0
   //扫描的流水号/序列/铭牌号

+ 7 - 0
entry/src/main/ets/viewmodel/BindTaskSeqVO.ets

@@ -0,0 +1,7 @@
+import TaskSeqVO from './process/TaskSeqInfo'
+
+export interface BindTaskSeqVO
+{
+  userName?:string,
+  TaskSeq?:TaskSeqVO[]
+}

+ 2 - 0
entry/src/main/ets/viewmodel/process/TaskSeqInfo.ets

@@ -7,4 +7,6 @@ export default class TaskSeqVO {
   currentTask?: string
   //报工时间
   updated?:string
+  //工序id
+  operationId?:string
 }