ImportRecordsDialog.ets
4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { Row, QueryParams, RecordsList } from '../api/recordsType'
import { getRecordsList, importRecord } from '../api/originalRecords'
import { AxiosResponse } from '@ohos/axios'
import preferencesUtil from '../utils/preferences'
import { promptAction } from '@kit.ArkUI'
let companyId: number = preferencesUtil.get('XF_COMPANY_ID', 0) as number
@CustomDialog
export default struct ImportRecordsDialog{
controller: CustomDialogController = new CustomDialogController({builder: ''})
//回调函数
onChange: () => void = () => {}
@Prop applyCompanyName: string
@Prop reportId: number
@State recordsList: Row[] = []
@State searchValue: string = ''
async aboutToAppear() {
let params: QueryParams = {
pageNum: 1,
pageSize: 20,
applyCompanyName: this.applyCompanyName,
companyId: companyId
}
const result: AxiosResponse<RecordsList> = await getRecordsList(params)
this.recordsList = result.data.rows
}
build() {
Column(){
Row(){
Search({ value: $$this.searchValue, placeholder: '请输入【记录编号】' })
.searchButton('搜索', {
fontSize: 12
})
.width('95%')
.height(30)
.backgroundColor('#fff')
.placeholderColor(Color.Grey)
.placeholderFont({ size: 12, weight: 400 })
.textFont({ size: 12, weight: 400 })
.layoutWeight(1)
.onSubmit(async () => {
this.recordsList = []
let params: QueryParams = {
pageNum: 1,
pageSize: 10,
applyCompanyName: this.applyCompanyName,
companyId: companyId,
reportType: '1',
reportNo: this.searchValue
}
const result: AxiosResponse<RecordsList> = await getRecordsList(params)
this.recordsList = result.data.rows
})
}.padding({left: 5, right: 5}).borderRadius(10)
List({space: 10}){
ForEach(this.recordsList, (item: Row) => {
ListItem(){
Row({space: 10}){
Column({space: 10}){
Row(){
Image($r('app.media.project')).width(16).margin({right: 10})
Text(item.reportName).fontSize(12).fontColor('#333').maxLines(2)
.textOverflow({overflow: TextOverflow.Ellipsis})
}
Row(){
Image($r('app.media.company')).width(16).margin({right: 10})
Text(item.applyCompanyName).fontSize(12).fontColor('#999')
}
Row(){
Image($r('app.media.numberNo')).width(16).margin({right: 10})
Text(item.reportNo).fontSize(12).fontColor('#999')
}
Row(){
Image($r('app.media.dateTime')).width(16).margin({right: 10})
Text(`${item.maintenanceTime}~${item.maintenanceEndTime || ''}`).fontSize(12).fontColor('#999')
}
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Text('导入').fontSize(14).fontColor('#1890ff')
.onClick(() => {
AlertDialog.show({
title: '',
message: '导入手会替换掉原来填写的信息,是否导入?',
autoCancel: true,
alignment: DialogAlignment.Center,
gridCount: 4,
offset: { dx: 0, dy: -20 },
buttonDirection: DialogButtonDirection.HORIZONTAL,
buttons: [
{
value: '取消',
action: () => {
console.info('Callback when button1 is clicked')
}
},
{
value: '确认',
action: async () => {
await importRecord(item.reportId,this.reportId)
this.onChange()
this.controller.close()
promptAction.showToast({message: '更新成功'})
}
}
],
cancel: () => {
console.info('Closed callbacks')
}
})
})
}.borderRadius(10).padding(10).backgroundColor('#fff').width('100%')
}
})
}.padding({top: 10, bottom: 20, left: 10, right: 10})
}.constraintSize({maxHeight: '60%'}).backgroundColor('#f2f3f7')
}
}