|
@@ -4,6 +4,10 @@ import { BindTaskSeqVO } from '../viewmodel/BindTaskSeqVO';
|
|
|
import TaskSeqVO from '../viewmodel/process/TaskSeqInfo';
|
|
|
import RequestParamModel from '../viewmodel/RequestParamModel';
|
|
|
import { Font } from '@ohos.arkui.UIContext';
|
|
|
+import DictValue from '../viewmodel/DictValue';
|
|
|
+import ProcessEscalationFault from '../viewmodel/process/ProcessEscalationFault';
|
|
|
+import ProcessBaseBug from '../viewmodel/process/ProcessBaseBug';
|
|
|
+import ProcessInfo from '../viewmodel/process/ProcessInfo';
|
|
|
|
|
|
@CustomDialog
|
|
|
export struct AddUnqualifiedRecordDialog{
|
|
@@ -13,30 +17,118 @@ export struct AddUnqualifiedRecordDialog{
|
|
|
scroller: Scroller = new Scroller()
|
|
|
|
|
|
//是否是编辑状态(需要传入的参数)
|
|
|
- @Prop isEdit:Boolean = false
|
|
|
+ @Prop isEdit: boolean = false
|
|
|
//选择不良类型索引(需要传入的参数)
|
|
|
- @Prop selectedTypeIndex:number= -1
|
|
|
+ @Prop selectDefectType: number = -1
|
|
|
//选择缺陷类型索引(需要传入的参数)
|
|
|
- @Prop selectedDefectTypeIndex:number= -1
|
|
|
-
|
|
|
+ @Prop selectedDefectBug: number= -1
|
|
|
+ // 不良类型(数据字典)
|
|
|
+ @Prop defectTypes: DictValue[] = []
|
|
|
+ // 不良类型对应的缺陷
|
|
|
+ defectBugs: ProcessBaseBug[] = []
|
|
|
+ // 不良类型对应的缺陷map(key为不良类型字典值,value为对应的缺陷)
|
|
|
+ defectBugMap: Map<string, ProcessBaseBug[]> = new Map<string, ProcessBaseBug[]>()
|
|
|
//不良类型
|
|
|
- @State unqualifiedType:Array<SelectOption> = [
|
|
|
- {value:"质量问题类型"},
|
|
|
- {value:"操作问题类型"},
|
|
|
- {value:"生产问题类型"},
|
|
|
- {value:"其它问题类型"},]
|
|
|
+ @State defectTypeOptions: Array<SelectOption> = []
|
|
|
//缺陷类型
|
|
|
- @State defectType:Array<SelectOption> = [
|
|
|
- {value:"PCBA缺陷"},
|
|
|
- {value:"结构缺陷"},
|
|
|
- {value:"外购材料缺陷"},
|
|
|
- {value:"外观缺陷"},]
|
|
|
+ @State defectBugOptions: Array<SelectOption> = []
|
|
|
+ // 如果是修改需要从自检页面传过来
|
|
|
+ @State defectRecord: ProcessEscalationFault = {}
|
|
|
+ // 不良类型记录列表
|
|
|
+ @Link defectRecords: ProcessEscalationFault[]
|
|
|
+ // 备注
|
|
|
+ @State defectRemark: string = ''
|
|
|
+
|
|
|
+ @Consume('currentUserName') currentUserName: string
|
|
|
+ seqNo: string = ''
|
|
|
+ selectOperationId: string = ''
|
|
|
+ process: ProcessInfo = {}
|
|
|
+
|
|
|
+ // 刷新不良类型对应的缺陷
|
|
|
+ async refreshDefectBugs() {
|
|
|
+ let defectTypeValue: string = this.defectTypes[this.selectDefectType]?.dictValue!
|
|
|
+ this.defectBugOptions = []
|
|
|
+ if (this.defectBugMap.has(defectTypeValue)) {
|
|
|
+ this.defectBugs = this.defectBugMap.get(defectTypeValue)!
|
|
|
+ } else {
|
|
|
+ this.defectBugs = await ProcessRequest.post('/api/v1/op/baseBug/list', {
|
|
|
+ bugType: defectTypeValue
|
|
|
+ } as RequestParamModel)
|
|
|
+ this.defectBugMap.set(defectTypeValue, this.defectBugs)
|
|
|
+ }
|
|
|
+ // 遍历封装缺陷下拉选择框
|
|
|
+ for (let i = 0; i < this.defectBugs.length; i++) {
|
|
|
+ this.defectBugOptions.push({value: this.defectBugs[i].bugName!})
|
|
|
+ }
|
|
|
+ this.selectedDefectBug = 0;
|
|
|
+ }
|
|
|
+ // 刷新不良类型记录列表
|
|
|
+ async refreshDefectRecords() {
|
|
|
+ this.defectRecords = []
|
|
|
+ this.defectRecords = await ProcessRequest.post('/api/v1/process/escalationFault/list', {
|
|
|
+ seqNo: this.seqNo
|
|
|
+ } as RequestParamModel)
|
|
|
+ if (this.defectRecords && this.defectTypes) {
|
|
|
+ for (const element of this.defectRecords) {
|
|
|
+ if (element.defectList) {
|
|
|
+ for (const dict of this.defectTypes) {
|
|
|
+ if (element.defectList[0].bugType === dict.dictValue) {
|
|
|
+ element.defectList[0].bugTypeLabel = dict.dictLabel
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ async aboutToAppear() {
|
|
|
+ for (let i = 0; i < this.defectTypes.length; i++) {
|
|
|
+ this.defectTypeOptions.push({value: this.defectTypes[i].dictLabel!})
|
|
|
+ }
|
|
|
+ // 新增时,默认选中第一个不良类型及其第一种缺陷
|
|
|
+ if (!this.isEdit && this.defectTypes) {
|
|
|
+ this.selectDefectType = 0
|
|
|
+ this.defectBugs = await ProcessRequest.post('/api/v1/op/baseBug/list', {
|
|
|
+ bugType: this.defectTypes[0].dictValue!
|
|
|
+ } as RequestParamModel)
|
|
|
+ this.defectBugMap.set(this.defectTypes[0].dictValue!, this.defectBugs)
|
|
|
+ for (let i = 0; i < this.defectBugs.length; i++) {
|
|
|
+ this.defectBugOptions.push({value: this.defectBugs[i].bugName!})
|
|
|
+ }
|
|
|
+ this.selectedDefectBug = 0;
|
|
|
+ } else if (this.isEdit && this.defectRecord && this.defectRecord.defectList) {
|
|
|
+ this.defectRemark = this.defectRecord.remark ? this.defectRecord.remark : ''
|
|
|
+ // 修改时,不良类型、缺陷名称直接选中
|
|
|
+ let defectTypeValue: string = this.defectRecord.defectList[0].bugType!
|
|
|
+ // 不良类型选中
|
|
|
+ for (let i = 0; i < this.defectTypes.length; i++) {
|
|
|
+ if (defectTypeValue === this.defectTypes[i].dictValue!) {
|
|
|
+ this.selectDefectType = i;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 查询不良类型下所有的缺陷
|
|
|
+ let defectBugCode: string = this.defectRecord.defectList[0].bugCode!
|
|
|
+ this.defectBugs = await ProcessRequest.post('/api/v1/op/baseBug/list', {
|
|
|
+ bugType: defectTypeValue
|
|
|
+ } as RequestParamModel)
|
|
|
+ this.defectBugMap.set(defectTypeValue, this.defectBugs)
|
|
|
+ // 缺陷名称选中
|
|
|
+ for (let i = 0; i < this.defectBugs.length; i++) {
|
|
|
+ this.defectBugOptions.push({value: this.defectBugs[i].bugName!})
|
|
|
+ if (defectBugCode === this.defectBugs[i].bugCode) {
|
|
|
+ this.selectedDefectBug = i;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
build() {
|
|
|
Column(){
|
|
|
Column() {
|
|
|
- Text(this.isEdit?'不良类型记录':'添加不良类型记录')
|
|
|
+ Text(this.isEdit ? '不良类型记录' : '添加不良类型记录')
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
.fontSize($r('app.float.fontSize_30'))
|
|
|
}
|
|
@@ -47,49 +139,51 @@ export struct AddUnqualifiedRecordDialog{
|
|
|
Text('不良类型')
|
|
|
.fontSize($r('app.float.fontSize_16'))
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
- Select(this.unqualifiedType)
|
|
|
+ Select(this.defectTypeOptions)
|
|
|
.height('16%')
|
|
|
.width('100%')
|
|
|
.borderRadius($r('app.float.virtualSize_16'))
|
|
|
- .selected(this.selectedTypeIndex === -1 ? 0 : this.selectedTypeIndex)
|
|
|
- .value(this.selectedTypeIndex === -1 ? '请选择' : String(this.unqualifiedType[this.selectedTypeIndex].value))
|
|
|
+ .selected(this.selectDefectType === -1 ? 0 : this.selectDefectType)
|
|
|
+ .value(this.selectDefectType === -1 ? '请选择' : String(this.defectTypeOptions[this.selectDefectType].value))
|
|
|
.backgroundColor($r('app.color.20FFFFFF'))
|
|
|
.selectedOptionBgColor($r('app.color.20FFFFFF'))
|
|
|
- .fontColor(this.selectedTypeIndex === -1?$r('app.color.30FFFFFF'):$r('app.color.FFFFFF'))
|
|
|
+ .fontColor(this.selectDefectType === -1 ? $r('app.color.30FFFFFF'):$r('app.color.FFFFFF'))
|
|
|
.font({size:$r('app.float.fontSize_24')})
|
|
|
.selectedOptionFont({
|
|
|
size:$r('app.float.fontSize_24')
|
|
|
})
|
|
|
.onSelect((index: number) => {
|
|
|
- this.selectedTypeIndex = index
|
|
|
-
|
|
|
+ if (this.selectDefectType === index) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.selectDefectType = index
|
|
|
+ this.refreshDefectBugs()
|
|
|
})
|
|
|
.margin({top:'3%',bottom:'3%'})
|
|
|
Text('缺陷名称')
|
|
|
.fontSize($r('app.float.fontSize_16'))
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
- Select(this.defectType)
|
|
|
+ Select(this.defectBugOptions)
|
|
|
.height('16%')
|
|
|
.width('100%')
|
|
|
.borderRadius($r('app.float.virtualSize_16'))
|
|
|
- .selected(this.selectedDefectTypeIndex === -1 ? 0 : this.selectedDefectTypeIndex)
|
|
|
- .value(this.selectedDefectTypeIndex === -1 ? '请选择' : String(this.defectType[this.selectedDefectTypeIndex].value))
|
|
|
+ .selected(this.selectedDefectBug === -1 ? 0 : this.selectedDefectBug)
|
|
|
+ .value(this.selectedDefectBug === -1 ? '请选择' : String(this.defectBugOptions[this.selectedDefectBug]?.value ? this.defectBugOptions[this.selectedDefectBug]?.value : ''))
|
|
|
.backgroundColor($r('app.color.20FFFFFF'))
|
|
|
.selectedOptionBgColor($r('app.color.20FFFFFF'))
|
|
|
- .fontColor(this.selectedDefectTypeIndex === -1?$r('app.color.30FFFFFF'):$r('app.color.FFFFFF'))
|
|
|
+ .fontColor(this.selectedDefectBug === -1 ? $r('app.color.30FFFFFF'):$r('app.color.FFFFFF'))
|
|
|
.font({size:$r('app.float.fontSize_24')})
|
|
|
.selectedOptionFont({
|
|
|
size:$r('app.float.fontSize_24')
|
|
|
})
|
|
|
.onSelect((index: number) => {
|
|
|
- this.selectedDefectTypeIndex = index
|
|
|
-
|
|
|
+ this.selectedDefectBug = index
|
|
|
})
|
|
|
.margin({top:'3%',bottom:'3%'})
|
|
|
Text('备注')
|
|
|
.fontSize($r('app.float.fontSize_16'))
|
|
|
.fontColor($r('app.color.FFFFFF'))
|
|
|
- TextArea({placeholder:'请录入不良详情'})
|
|
|
+ TextArea({placeholder:'请录入不良详情', text: this.defectRemark})
|
|
|
.backgroundColor($r('app.color.000000'))
|
|
|
.height('40%')
|
|
|
.width('100%')
|
|
@@ -101,7 +195,9 @@ export struct AddUnqualifiedRecordDialog{
|
|
|
.maxLength(200)
|
|
|
.margin({top:'3%',bottom:'3%'})
|
|
|
.borderRadius($r('app.float.virtualSize_16'))
|
|
|
-
|
|
|
+ .onChange((value: string) => {
|
|
|
+ this.defectRemark = value
|
|
|
+ })
|
|
|
}
|
|
|
.width('70%')
|
|
|
.height('80%')
|
|
@@ -147,7 +243,22 @@ export struct AddUnqualifiedRecordDialog{
|
|
|
}
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.width('33.3%')
|
|
|
- .onClick(() => {
|
|
|
+ .onClick(async () => {
|
|
|
+ this.defectRecord.remark = this.defectRemark
|
|
|
+ if (this.defectRecord.defectList) {
|
|
|
+ this.defectRecord.defectList[0].bugType = this.defectBugs[this.selectedDefectBug].bugType!
|
|
|
+ this.defectRecord.defectList[0].bugCode = this.defectBugs[this.selectedDefectBug].bugCode!
|
|
|
+ this.defectRecord.defectList[0].bugName = this.defectBugs[this.selectedDefectBug].bugName!
|
|
|
+ this.defectRecord.reasonList = [...this.defectRecord.defectList]
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('hhtest', JSON.stringify(this.defectRecord))
|
|
|
+ await ProcessRequest.post('/api/v1/process/escalationFault/updateRemarkAndDefect', this.defectRecord)
|
|
|
+ // 重新刷新不良类型记录列表
|
|
|
+ this.refreshDefectRecords()
|
|
|
+ if (this.controller) {
|
|
|
+ this.controller.close()
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -179,7 +290,19 @@ export struct AddUnqualifiedRecordDialog{
|
|
|
}
|
|
|
.justifyContent(FlexAlign.Center)
|
|
|
.width('50%')
|
|
|
- .onClick(() => {
|
|
|
+ .onClick(async () => {
|
|
|
+ this.defectRecord.processId = this.process.id!
|
|
|
+ this.defectRecord.seqNoList = [this.seqNo]
|
|
|
+ this.defectRecord.reasonList = [this.defectBugs[this.selectedDefectBug]]
|
|
|
+ this.defectRecord.processesList = [this.selectOperationId]
|
|
|
+ this.defectRecord.personResponsible = this.currentUserName
|
|
|
+ this.defectRecord.remark = this.defectRemark
|
|
|
+ await ProcessRequest.post('/api/v1/process/escalationFault/add', this.defectRecord)
|
|
|
+ // 重新刷新不良类型记录列表
|
|
|
+ this.refreshDefectRecords()
|
|
|
+ if (this.controller) {
|
|
|
+ this.controller.close()
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|