|
@@ -1,42 +1,37 @@
|
|
|
-import CommonConstants from '../../common/constants/CommonConstants'
|
|
|
-import MaterialInfo from '../../model/MaterialInfo'
|
|
|
-import HashMap from '@ohos.util.HashMap'
|
|
|
-import ProcessData from '../../viewmodel/ProcessData'
|
|
|
+import { AddAndSubtractComp } from '../../common/component/AddAndSubtractComp'
|
|
|
+import JGRequest from '../../common/util/request/Request'
|
|
|
+import StartWorkInfo from '../../viewmodel/StartWorkInfo'
|
|
|
|
|
|
@Component
|
|
|
+@Entry
|
|
|
export struct MaterialCollectView {
|
|
|
- mainMaterial: string
|
|
|
- @Link process: ProcessData
|
|
|
- // 查询到工序需要的物料
|
|
|
- @State materialArray: MaterialInfo[] = CommonConstants.MATERIAL_ARRAY
|
|
|
- // 采集到的物料
|
|
|
- @State collectMaterials: MaterialInfo[] = []
|
|
|
+ startWorkInfo: StartWorkInfo
|
|
|
+ // 查询到工序需要的物料(实际数量大于1则为为采集到的物料数量)
|
|
|
+ @State materialArray: MaterialCollectInfo[] = []
|
|
|
+ // 本次采集到的物料(取消/确认后置为空)
|
|
|
+ @State collectArray: MaterialCollectInfo[] = []
|
|
|
+ // 扫描到的编码
|
|
|
@State collectCode: string = ''
|
|
|
- // 方便查询已采集的物料信息
|
|
|
- private collectMap:HashMap<string, MaterialInfo> = new HashMap()
|
|
|
|
|
|
scroller: Scroller = new Scroller()
|
|
|
+ // 扫描弹窗控制器
|
|
|
+ scanCodeController: CustomDialogController = new CustomDialogController({
|
|
|
+ builder: ScanCodeDialog({
|
|
|
+ collectCode: $collectCode,
|
|
|
+ materialArray: this.materialArray,
|
|
|
+ collectArray: $collectArray,
|
|
|
+ }),
|
|
|
+ autoCancel: true,
|
|
|
+ alignment: DialogAlignment.TopEnd,
|
|
|
+ // gridCount: 3,
|
|
|
+ customStyle: true,
|
|
|
+ })
|
|
|
|
|
|
- aboutToAppear() {
|
|
|
- // todo 查询需要的物料信息
|
|
|
- //遍历已采集的物料
|
|
|
- for (const material of this.materialArray) {
|
|
|
- if (material.materialNo && material.materialNo.length > 0) {
|
|
|
- if (this.collectMap.hasKey(material.materialNo)) {
|
|
|
- this.collectMap.get(material.materialNo).collectNum++
|
|
|
- } else {
|
|
|
- material.collectNum = 0
|
|
|
- this.collectMap.set(material.materialNo, material)
|
|
|
- }
|
|
|
- } else if (material.batchCode && material.batchCode.length > 0) {
|
|
|
- if (this.collectMap.hasKey(material.batchCode)) {
|
|
|
- this.collectMap.get(material.batchCode).collectNum++
|
|
|
- } else {
|
|
|
- material.collectNum = 0
|
|
|
- this.collectMap.set(material.batchCode, material)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ async aboutToAppear() {
|
|
|
+ // 查询需要的物料信息
|
|
|
+ this.materialArray = await JGRequest.post('/api/v1/process/itemRecord/list',{
|
|
|
+ "processId": this.startWorkInfo.id
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
build() {
|
|
@@ -50,52 +45,21 @@ export struct MaterialCollectView {
|
|
|
}
|
|
|
.width('8%')
|
|
|
.justifyContent(FlexAlign.End)
|
|
|
+ .onClick(()=>{
|
|
|
+ // todo 对接硬件后删除
|
|
|
+ this.scanCodeController.open()
|
|
|
+ })
|
|
|
|
|
|
- TextInput({ placeholder: '请扫描物料编码', text: this.collectCode })
|
|
|
- .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'))
|
|
|
+ Text(this.collectCode)
|
|
|
+ .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'))
|
|
|
.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) => {
|
|
|
- this.collectCode = value
|
|
|
- })
|
|
|
- .onSubmit(() => {
|
|
|
- // 遍历需要的物料
|
|
|
- for (const needMaterial of this.materialArray) {
|
|
|
- if (needMaterial.materialNo && needMaterial.materialNo.length > 0 && this.collectCode === needMaterial.materialNo) {
|
|
|
- if (this.collectMap.hasKey(needMaterial.materialNo)) {
|
|
|
- this.collectMap.get(needMaterial.materialNo).collectNum++
|
|
|
- } else {
|
|
|
- needMaterial.collectNum = 1
|
|
|
- let collect: MaterialInfo = new MaterialInfo()
|
|
|
- Object.assign(collect, needMaterial)
|
|
|
- this.collectMap.set(needMaterial.materialNo, collect)
|
|
|
- this.collectMaterials.push(collect)
|
|
|
- console.log('testTag', '---collect-------' +JSON.stringify(collect))
|
|
|
- }
|
|
|
- break
|
|
|
- } else if (needMaterial.batchCode && needMaterial.batchCode.length > 0 && this.collectCode === needMaterial.batchCode) {
|
|
|
- if (this.collectMap.hasKey(needMaterial.batchCode)) {
|
|
|
- this.collectMap.get(needMaterial.batchCode).collectNum++
|
|
|
- } else {
|
|
|
- needMaterial.collectNum = 1
|
|
|
- let collect: MaterialInfo = new MaterialInfo()
|
|
|
- Object.assign(collect, needMaterial)
|
|
|
- this.collectMap.set(needMaterial.batchCode, collect)
|
|
|
- this.collectMaterials.push(collect)
|
|
|
- }
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- this.collectCode = ''
|
|
|
- })
|
|
|
}
|
|
|
.borderRadius($r('app.float.robot_set_radius'))
|
|
|
.backgroundColor($r('app.color.general_font_white_color'))
|
|
@@ -106,20 +70,19 @@ export struct MaterialCollectView {
|
|
|
.height('13%')
|
|
|
.justifyContent(FlexAlign.Start)
|
|
|
|
|
|
- if (this.collectMaterials && this.collectMaterials.length > 0) {
|
|
|
+ if (this.materialArray && this.materialArray.length > 0) {
|
|
|
Grid() {
|
|
|
- ForEach(this.collectMaterials, (material: MaterialInfo) => {
|
|
|
+ ForEach(this.materialArray, (material: MaterialCollectInfo) => {
|
|
|
GridItem() {
|
|
|
Row() {
|
|
|
Column() {
|
|
|
- Text(material.materialName)
|
|
|
+ Text(material.itemName)
|
|
|
.fontSize($r('app.float.process_card_middle_font_size'))
|
|
|
.fontColor($r('app.color.general_font_color'))
|
|
|
.opacity($r('app.float.general_font_opacity'))
|
|
|
.fontWeight(FontWeight.Medium)
|
|
|
|
|
|
- // todo 不知道是啥
|
|
|
- Text('100*200')
|
|
|
+ Text(material.itemModel)
|
|
|
.fontSize($r('app.float.process_card_small_font_size'))
|
|
|
.fontColor($r('app.color.general_font_color'))
|
|
|
.opacity($r('app.float.process_step_font_opacity'))
|
|
@@ -136,9 +99,9 @@ export struct MaterialCollectView {
|
|
|
.height('100%')
|
|
|
.padding({left: '4%'})
|
|
|
Column() {
|
|
|
- if (material.needNum - material.collectNum > 0) {
|
|
|
+ if (material.needNum - (material.realNum ? material.realNum : 0) > 0) {
|
|
|
Column() {
|
|
|
- Text((material.needNum - material.collectNum).toString())
|
|
|
+ Text((material.needNum - material.realNum).toString())
|
|
|
.fontSize($r('app.float.process_card_large_font_size'))
|
|
|
.fontColor($r('app.color.general_font_color'))
|
|
|
.opacity($r('app.float.general_font_opacity'))
|
|
@@ -215,4 +178,251 @@ export struct MaterialCollectView {
|
|
|
.height('100%')
|
|
|
.margin({left: '2%'})
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+//扫码弹窗
|
|
|
+@CustomDialog
|
|
|
+struct ScanCodeDialog {
|
|
|
+
|
|
|
+ // 扫描到的物料编码
|
|
|
+ @Link collectCode: string
|
|
|
+ materialArray: MaterialCollectInfo[]
|
|
|
+ @Link collectArray: MaterialCollectInfo[]
|
|
|
+
|
|
|
+ // 若尝试在CustomDialog中传入多个其他的Controller,以实现在CustomDialog中打开另一个或另一些CustomDialog,那么此处需要将指向自己的controller放在最后
|
|
|
+ controller?: CustomDialogController
|
|
|
+ cancel: () => void
|
|
|
+ confirm: () => void
|
|
|
+
|
|
|
+ aboutToAppear() {
|
|
|
+ if (this.collectCode && this.collectCode.length > 0) {
|
|
|
+ // 判断扫描到的物料编码是否在需要的物料中
|
|
|
+ let isValid: boolean = false
|
|
|
+ let collectMaterial: MaterialCollectInfo = {}
|
|
|
+ for (const material of this.materialArray) {
|
|
|
+ if (material.itemSeq && material.itemSeq.length > 0 && material.itemSeq === this.collectCode) {
|
|
|
+ isValid = true
|
|
|
+ Object.assign(collectMaterial, material)
|
|
|
+ collectMaterial.realNum = 1
|
|
|
+ } else if (material.batchNo && material.batchNo.length > 0 && material.batchNo === this.collectCode) {
|
|
|
+ isValid = true
|
|
|
+ Object.assign(collectMaterial, material)
|
|
|
+ collectMaterial.realNum = 0
|
|
|
+ }
|
|
|
+ if (isValid) {
|
|
|
+ this.collectArray.push(collectMaterial)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ build() {
|
|
|
+ Column(){
|
|
|
+ Text('物料采集'+'['+ this.collectArray.length + ']')
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .width('100%')
|
|
|
+ .height('10%')
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.title_font_size'))
|
|
|
+ .fontColor($r('app.color.general_font_color'))
|
|
|
+ .opacity($r('app.float.general_border_radius'))
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ Row() {
|
|
|
+ Row() {
|
|
|
+ Image($r('app.media.qr_code'))
|
|
|
+ .height('31%')
|
|
|
+ }
|
|
|
+ .width('8%')
|
|
|
+ .justifyContent(FlexAlign.End)
|
|
|
+
|
|
|
+ Text(this.collectCode)
|
|
|
+ .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'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .height('100%')
|
|
|
+ .layoutWeight(1)
|
|
|
+ .borderRadius($r('app.float.robot_set_radius'))
|
|
|
+ .backgroundColor($r('app.color.general_font_white_color'))
|
|
|
+ }
|
|
|
+ .borderRadius($r('app.float.robot_set_radius'))
|
|
|
+ .backgroundColor($r('app.color.general_font_white_color'))
|
|
|
+ .width('100%')
|
|
|
+ .height('77%')
|
|
|
+ }
|
|
|
+ .width('66%')
|
|
|
+ .height('10%')
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .alignItems(VerticalAlign.Top)
|
|
|
+
|
|
|
+ List({ space : 10}) {
|
|
|
+ if (this.collectArray && this.collectArray.length > 0) {
|
|
|
+ ForEach(this.collectArray, (item: MaterialCollectInfo, index: number) => {
|
|
|
+ ListItem() {
|
|
|
+ Row(){
|
|
|
+ Column({space:5}){
|
|
|
+ Text(item.itemName)
|
|
|
+ .fontColor($r('app.color.general_font_color'))
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontSize($r('app.float.card_title_font_size'))
|
|
|
+ .opacity($r('app.float.general_font_opacity'))
|
|
|
+ .width('100%')
|
|
|
+ Text(item.itemModel)
|
|
|
+ .fontColor($r('app.color.general_font_color'))
|
|
|
+ .fontWeight(FontWeight.Regular)
|
|
|
+ .fontSize($r('app.float.card_info_font_size'))
|
|
|
+ .opacity($r('app.float.card_font_default_opacity'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ Text(item.itemSeq && item.itemSeq.length > 0 ? '序列号:' + item.itemSeq: '批次号:' + item.batchNo)
|
|
|
+ .fontColor($r('app.color.general_font_color'))
|
|
|
+ .fontWeight(FontWeight.Regular)
|
|
|
+ .fontSize($r('app.float.card_info_font_size'))
|
|
|
+ .opacity($r('app.float.card_font_default_opacity'))
|
|
|
+ .textAlign(TextAlign.Start)
|
|
|
+ .width('100%')
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .width('50%')
|
|
|
+ .height('100%')
|
|
|
+ .padding({left: 15})
|
|
|
+
|
|
|
+ Column() {
|
|
|
+ Row() {
|
|
|
+ Text('录入数量')
|
|
|
+ .fontColor($r('app.color.general_font_color'))
|
|
|
+ .fontWeight(FontWeight.Regular)
|
|
|
+ .fontSize($r('app.float.card_info_font_size'))
|
|
|
+ .opacity($r('app.float.card_font_default_opacity'))
|
|
|
+ }
|
|
|
+ .height('49%')
|
|
|
+ .width('81.8%')
|
|
|
+ .alignItems(VerticalAlign.Bottom)
|
|
|
+ if (item.itemSeq && item.itemSeq.length > 0) {
|
|
|
+ Text(item.realNum.toString())
|
|
|
+ .fontWeight(FontWeight.Bold)
|
|
|
+ .fontColor('#303030')
|
|
|
+ .fontSize('51px')
|
|
|
+ } else {
|
|
|
+ Row() {
|
|
|
+ AddAndSubtractComp({
|
|
|
+ inputNum: item.realNum,
|
|
|
+ obj: item,
|
|
|
+ editPropertyName: 'realNum',
|
|
|
+ upperLimit: item.needNum,
|
|
|
+ lowerLimit: 0,
|
|
|
+ addFunction: ()=>{
|
|
|
+ item.realNum++
|
|
|
+ },
|
|
|
+ subFunction: ()=>{
|
|
|
+ item.realNum--
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('81.8%')
|
|
|
+ .height('32%')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .width('50%')
|
|
|
+ .height('100%')
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ }
|
|
|
+ .borderRadius($r('app.float.general_border_radius'))
|
|
|
+ .height('35%')
|
|
|
+ .width('83%')
|
|
|
+ .backgroundColor($r('app.color.robot_set_card_white'))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('70%')
|
|
|
+ .alignListItem(ListItemAlign.Center)
|
|
|
+
|
|
|
+ Row({space:10}){
|
|
|
+ Text('取消')
|
|
|
+ .width('35%')
|
|
|
+ .height('70%')
|
|
|
+ .borderRadius(40)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontColor('#0A59F7')
|
|
|
+ .backgroundColor('#0f000000')
|
|
|
+ .onClick(()=>{
|
|
|
+ this.controller.close()
|
|
|
+ })
|
|
|
+ Text('确认')
|
|
|
+ .width('35%')
|
|
|
+ .height('70%')
|
|
|
+ .borderRadius(40)
|
|
|
+ .textAlign(TextAlign.Center)
|
|
|
+ .fontColor('#FFFFFF')
|
|
|
+ .backgroundColor('#0A59F7')
|
|
|
+ .onClick(()=>{
|
|
|
+ this.controller.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('10%')
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ Blank()
|
|
|
+ }
|
|
|
+ .width('50%')
|
|
|
+ .height('100%')
|
|
|
+ .backgroundColor($r('app.color.page_general_background'))
|
|
|
+ .borderRadius({ topLeft: $r('app.float.general_border_width'), bottomLeft: $r('app.float.general_border_width') })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class MaterialCollectInfo {
|
|
|
+ // 创建时间
|
|
|
+ created?: string
|
|
|
+ // 创建人
|
|
|
+ creator?: string
|
|
|
+ // 删除标识
|
|
|
+ deleted?: number
|
|
|
+ // 部门ID
|
|
|
+ deptId?: string
|
|
|
+ // 主键id
|
|
|
+ id?: number
|
|
|
+ // 修改时间
|
|
|
+ updated?: string
|
|
|
+ // 上次修改人
|
|
|
+ updator?: string
|
|
|
+ // 批次号
|
|
|
+ batchNo?: string
|
|
|
+ // 物料编码
|
|
|
+ itemCode?: string
|
|
|
+ // 物料型号
|
|
|
+ itemModel?: string
|
|
|
+ // 物料名称
|
|
|
+ itemName?: string
|
|
|
+ // 物料序列号
|
|
|
+ itemSeq?: string
|
|
|
+ // 需要数量
|
|
|
+ needNum?: number
|
|
|
+ // 旧序列号
|
|
|
+ oldSeq?: string
|
|
|
+ // 工序名称
|
|
|
+ operationName?: string
|
|
|
+ // 组织ID
|
|
|
+ orgId?: string
|
|
|
+ // 生产过程id
|
|
|
+ processId?: string
|
|
|
+ // 实际数量
|
|
|
+ realNum?: number
|
|
|
+ // 排序号
|
|
|
+ sortNum?: number
|
|
|
+ // 工作台名称
|
|
|
+ stationName?: string
|
|
|
+ // 步骤id
|
|
|
+ stepInstanceId?: string
|
|
|
+ // 采集人
|
|
|
+ trackBy?: string
|
|
|
+ // 追溯类型
|
|
|
+ trackType?: string
|
|
|
+ // 采集时间
|
|
|
+ trackWhen?: string
|
|
|
}
|