import WmsRequest from '../../common/util/request/WmsRequest'
import RequestParamModel from '../../viewmodel/wms/RequestParamModel'
import WorkOrderInfo from '../../viewmodel/wms/WorkOrderInfo'

@Component
export struct ProcessMaterialKitOneStep {

  @Link workOrder: WorkOrderInfo

  @State workOrderArray: WorkOrderInfo[] = []

  @State selectWorkOrder: number = 0

  async aboutToAppear() {
    this.workOrderArray = await WmsRequest.post('/api/v1/plan/workOrder/list', {
      //查询未完成的工单
      queryComplete: 0,
    } as RequestParamModel) as WorkOrderInfo[]
    if (this.workOrderArray && this.workOrderArray.length > 0) {
      this.workOrder = this.workOrderArray[0]
      this.selectWorkOrder = 0
    }
  }

  build() {
    Row() {
      Column() {
        Row() {
          Text('选择工单')
            .fontSize($r('app.float.fontSize_12'))
            .fontColor($r('app.color.FFFFFF'))
            .fontWeight(FontWeight.Medium)
        }
        .height('10%')
        .width('29.6%')
        .justifyContent(FlexAlign.Center)

        List() {
          ForEach(this.workOrderArray, (item: WorkOrderInfo, index: number) => {
            ListItem() {
              Column() {

              }
              .height('15.4%')
              .backgroundColor(this.selectWorkOrder === index ? $r('app.color.2030D158') : $r('app.color.20FFFFFF'))
            }
          })
        }
        .width('100%')
        .height('90%')
      }

    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.SpaceBetween)
  }
}