|
@@ -15,49 +15,20 @@ export struct ModifyMaterialNumDialog {
|
|
|
workOrderCode :string = ''
|
|
|
operationId :string = ''
|
|
|
processId :string = ''
|
|
|
+ seqNo :string = ''
|
|
|
// 新增时扫码搜索到的物料
|
|
|
scanMaterial: ProcessMaterial = {}
|
|
|
// 新增或者修改采集物料(1:新增 2:修改)
|
|
|
addOrModifyCollect: number = 1
|
|
|
- @State collectMaterials: ProcessMaterial[] = [
|
|
|
- {
|
|
|
- batchNo:'dsfs',
|
|
|
- materialCode:'Y11P1210ZJ10',
|
|
|
- spec:'Y11P1210ZJ10',
|
|
|
- materialName:'控制连接器插座',
|
|
|
- needNum:6.0,
|
|
|
- operationId:'679',
|
|
|
- processId:'',
|
|
|
- num:1.0,
|
|
|
- unitDictValue: "只",
|
|
|
- workOrderCode:'10.25.0022'
|
|
|
- },{
|
|
|
- batchNo:'32r4regrfd',
|
|
|
- materialCode:'Y11P0804ZJ102',
|
|
|
- spec:'Y11P0804ZJ102',
|
|
|
- materialName:'电源连接器插座',
|
|
|
- needNum:5.0,
|
|
|
- operationId:'679',
|
|
|
- processId:'',
|
|
|
- num:0,
|
|
|
- workOrderCode:'10.25.0022'
|
|
|
- },
|
|
|
- {
|
|
|
- batchNo:'sdg',
|
|
|
- materialCode:'Y11P1210ZJ10',
|
|
|
- spec:'Y11P1210ZJ10',
|
|
|
- materialName:'控制连接器插座',
|
|
|
- needNum:6.0,
|
|
|
- operationId:'679',
|
|
|
- processId:'',
|
|
|
- num:1.0,
|
|
|
- workOrderCode:'10.25.0022'
|
|
|
- }
|
|
|
- ]
|
|
|
+ @State collectMaterials: ProcessMaterial[] = []
|
|
|
@State collectNumArray: number[] = []
|
|
|
+ // 当前工位ID
|
|
|
+ @Consume('currentStationId') currentStationId: string
|
|
|
+ // 批次高度
|
|
|
+ batchHeight: number = 93.6
|
|
|
|
|
|
controller: CustomDialogController
|
|
|
- onConfirm: () => void = () => {}
|
|
|
+ confirm: () => void = () => {}
|
|
|
|
|
|
async aboutToAppear() {
|
|
|
if (!this.scanMaterial) {
|
|
@@ -70,7 +41,7 @@ export struct ModifyMaterialNumDialog {
|
|
|
this.needNum = this.scanMaterial.totalNum!
|
|
|
// 修改物料采集,则先查询采集历史
|
|
|
if (this.addOrModifyCollect === 2) {
|
|
|
- let result: OperationItem[] = await ProcessRequest.post('/v1/process/itemRecord/itemInfo/list',{
|
|
|
+ let result: OperationItem[] = await ProcessRequest.post('/api/v1/process/itemRecord/itemInfo/list',{
|
|
|
itemCode: this.scanMaterial.materialCode!,
|
|
|
opId: this.operationId,
|
|
|
processId: this.processId
|
|
@@ -103,18 +74,17 @@ export struct ModifyMaterialNumDialog {
|
|
|
// for (const element of this.collectMaterials) {
|
|
|
// this.collectNumArray.push(element.num ? element.num : 0)
|
|
|
// }
|
|
|
- console.log('hhtest', JSON.stringify(this.collectNumArray))
|
|
|
}
|
|
|
|
|
|
build() {
|
|
|
Column() {
|
|
|
// 标题
|
|
|
Column(){
|
|
|
- Text("数量")
|
|
|
+ Text('数量')
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_30'))
|
|
|
}
|
|
|
- .height($r('app.float.virtualSize_112'))
|
|
|
+ .height($r('app.float.virtualSize_100'))
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
Column(){
|
|
|
Text(`物料名称:${this.materialName}`)
|
|
@@ -125,8 +95,12 @@ export struct ModifyMaterialNumDialog {
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_16'))
|
|
|
.fontWeight(FontWeight.Lighter)
|
|
|
+ Text(`需求数量::${this.scanMaterial?.totalNum!}`)
|
|
|
+ .fontColor($r('app.color.FFFFFF'))
|
|
|
+ .fontSize($r('app.float.fontSize_16'))
|
|
|
+ .fontWeight(FontWeight.Lighter)
|
|
|
}
|
|
|
- .height($r('app.float.virtualSize_62'))
|
|
|
+ .height($r('app.float.virtualSize_56'))
|
|
|
.width('70.4%')
|
|
|
.justifyContent(FlexAlign.Start)
|
|
|
.alignItems(HorizontalAlign.Start)
|
|
@@ -155,8 +129,8 @@ export struct ModifyMaterialNumDialog {
|
|
|
Text('还需采集:')
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_16'))
|
|
|
- .fontWeight(FontWeight.Regular)
|
|
|
- Text(`还需采集:${this.scanMaterial?.needNum!}`)
|
|
|
+ .fontWeight(FontWeight.Lighter)
|
|
|
+ Text(`${this.scanMaterial?.needNum!}`)
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_16'))
|
|
|
.fontWeight(FontWeight.Regular)
|
|
@@ -179,10 +153,18 @@ export struct ModifyMaterialNumDialog {
|
|
|
.borderRadius($r('app.float.virtualSize_16'))
|
|
|
.opacity(((this.addOrModifyCollect === 1 && this.collectNumArray[index] <= 1) || (this.addOrModifyCollect === 2 && this.collectNumArray[index] <= 0)) ? 0.3 : 1)
|
|
|
.onClick(() => {
|
|
|
- if (this.collectNumArray[index] > 0) {
|
|
|
- this.collectNumArray[index]--
|
|
|
+ if (this.addOrModifyCollect === 1) {
|
|
|
+ if (this.collectNumArray[index] > 1) {
|
|
|
+ this.collectNumArray[index]--
|
|
|
+ } else {
|
|
|
+ this.collectNumArray[index] = 0
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.collectNumArray[index] = 0
|
|
|
+ if (this.collectNumArray[index] > 0) {
|
|
|
+ this.collectNumArray[index]--
|
|
|
+ } else {
|
|
|
+ this.collectNumArray[index] = 0
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
}.width('22%')
|
|
@@ -195,6 +177,19 @@ export struct ModifyMaterialNumDialog {
|
|
|
.type(InputType.Number)
|
|
|
.onChange((value: string) => {
|
|
|
this.collectNumArray[index] = parseInt(value)
|
|
|
+ if (this.addOrModifyCollect === 1) {
|
|
|
+ if (this.collectNumArray[index] > this.scanMaterial?.needNum!) {
|
|
|
+ this.collectNumArray[index] = this.scanMaterial?.needNum!
|
|
|
+ } else if (this.collectNumArray[index] < 1) {
|
|
|
+ this.collectNumArray[index] = 1
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (this.collectNumArray[index] > this.needNum) {
|
|
|
+ this.collectNumArray[index] = this.needNum
|
|
|
+ } else if (this.collectNumArray[index] < 0) {
|
|
|
+ this.collectNumArray[index] = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
.width('56%')
|
|
@@ -244,7 +239,7 @@ export struct ModifyMaterialNumDialog {
|
|
|
.width('100%')
|
|
|
}
|
|
|
}
|
|
|
- .height($r('app.float.virtualSize_156'))
|
|
|
+ .height(this.batchHeight)
|
|
|
.alignItems(HorizontalAlign.Start)
|
|
|
})
|
|
|
}
|
|
@@ -253,8 +248,9 @@ export struct ModifyMaterialNumDialog {
|
|
|
.scrollable(ScrollDirection.Vertical) // 垂直滚动
|
|
|
.scrollBar(BarState.Auto)
|
|
|
.width('70.4%')
|
|
|
- .layoutWeight(1)
|
|
|
+ .height(this.collectMaterials.length * this.batchHeight)
|
|
|
.align(Alignment.Top)
|
|
|
+ .constraintSize({ maxHeight: '70%' })
|
|
|
|
|
|
Column(){
|
|
|
Divider()
|
|
@@ -281,8 +277,7 @@ export struct ModifyMaterialNumDialog {
|
|
|
}
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.width('50%')
|
|
|
- .onClick(() => {
|
|
|
- this.onConfirm();
|
|
|
+ .onClick(async () => {
|
|
|
if (this.addOrModifyCollect === 1) {
|
|
|
if (this.collectNumArray[0] > this.scanMaterial?.needNum!) {
|
|
|
promptAction.showToast({
|
|
@@ -290,8 +285,15 @@ export struct ModifyMaterialNumDialog {
|
|
|
duration: 1500,
|
|
|
bottom: 100
|
|
|
})
|
|
|
+ return
|
|
|
}
|
|
|
- // todo 调接口新增
|
|
|
+ // 调接口新增采集
|
|
|
+ this.scanMaterial.stationId = this.currentStationId
|
|
|
+ this.scanMaterial.num = this.collectNumArray[0]
|
|
|
+ this.scanMaterial.seqNo = this.seqNo
|
|
|
+ let params: ProcessMaterial[] = []
|
|
|
+ params.push(this.scanMaterial)
|
|
|
+ await ProcessRequest.post('/api/v1/process/itemRecord/add', params)
|
|
|
} else {
|
|
|
let total: number = 0
|
|
|
for (const element of this.collectNumArray) {
|
|
@@ -303,9 +305,18 @@ export struct ModifyMaterialNumDialog {
|
|
|
duration: 1500,
|
|
|
bottom: 100
|
|
|
})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 调批量修改的接口
|
|
|
+ let stillNeed: number = this.needNum
|
|
|
+ for (let i = 0; i < this.collectMaterials.length; i++) {
|
|
|
+ this.collectMaterials[i].num = this.collectNumArray[i]
|
|
|
+ stillNeed -= this.collectNumArray[i]
|
|
|
+ this.collectMaterials[i].needNum = stillNeed
|
|
|
}
|
|
|
- // todo 调修改接口
|
|
|
+ await ProcessRequest.post('/api/v1/process/itemRecord/batchUpdate', this.collectMaterials)
|
|
|
}
|
|
|
+ this.confirm();
|
|
|
this.controller.close();
|
|
|
})
|
|
|
}
|