HomePage.ets
7.7 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import { router } from '@kit.ArkUI'
import { AxiosResponse } from '@ohos/axios'
import { getNoticeList, noticeTest, noticeParams, noticeRow } from '../api/notice'
import { getCompanyPersonList } from '../api/originalRecords'
import { companyPersonTest, companyPersonRow } from '../api/recordsType'
import preferencesUtils from '../utils/preferences'
import baseUrl from '../utils/baseUrl'
@Component
export default struct HomePage {
@State searchValue: string = ''
@State params: noticeParams = {
pageNum: 1,
pageSize: 10
}
@State noticeList: noticeRow[] = []
@State noticeTitleList: string[] = []
@State personList: companyPersonRow[] = []
roleName = preferencesUtils.get('XF_ROLE_NAME', '')
async aboutToAppear() {
getNoticeList(this.params).then((res: AxiosResponse<noticeTest>) => {
this.noticeList = res.data.rows
this.noticeTitleList = res.data.rows.map((item: noticeRow) => item.noticeTitle)
})
if(this.roleName == 'company') {
let companyId = preferencesUtils.get('XF_COMPANY_ID', '')
const personRes: AxiosResponse<companyPersonTest> = await getCompanyPersonList({pageNum: 1, pageSize: 10, companyId: Number(companyId), state: '2' })
this.personList = personRes.data.rows
}
}
build() {
Scroll(){
Column(){
Search({value: $$this.searchValue, placeholder: '请输入原始记录名称'}).backgroundColor('#fff')
.searchButton('搜索')
.onSubmit((value) => {
router.pushUrl({
url: 'pages/MaintenanceRecords',
params: {
reportName: value
}
})
})
Column(){
Text('维保原始记录').fontSize(18).lineHeight(24).fontColor('#fff').fontWeight(600)
Text('查看所有维保记录').fontSize(10).lineHeight(13).fontColor('#CACBFD').margin({bottom: 18, top: 2})
Row(){
Text('立即查看').fontSize(12).fontColor('#36278D').lineHeight(16)
Image($r('app.media.right_1')).width(16).margin({left: 5})
}.width(80).height(20).backgroundColor(Color.White).borderRadius(10).justifyContent(FlexAlign.Center)
}.width('100%').height(100).backgroundImage($r('app.media.bg_1'))
.backgroundImageSize({width: '100%', height: 100}).margin({top: 15}).alignItems(HorizontalAlign.Start)
.padding({top: 10, left: 20}).onClick(() => {
router.pushUrl({
url: 'pages/MaintenanceRecords'
})
})
Column(){
Text('操作手册').fontSize(18).lineHeight(24).fontColor('#fff').fontWeight(600)
Text('查看APP操作手册').fontSize(10).lineHeight(13).fontColor('#B5E9E6').margin({bottom: 18, top: 2})
Row(){
Text('立即查看').fontSize(12).fontColor('#1D8F90').lineHeight(16)
Image($r('app.media.right_2')).width(16).margin({left: 5})
}.width(80).height(20).backgroundColor(Color.White).borderRadius(10).justifyContent(FlexAlign.Center)
}.width('100%').height(100).backgroundImage($r('app.media.bg_2'))
.backgroundImageSize({width: '100%', height: 100}).margin({top: 15}).alignItems(HorizontalAlign.Start)
.padding({top: 10, left: 20}).onClick(() => {
router.pushUrl({
url: 'pages/OperationManual'
})
})
// 通知栏
Row(){
Row(){
Image($r('app.media.notice')).width(16).margin({right: 5})
Text('公告').fontSize(13).fontColor('3d3d3d')
}.width(75).backgroundColor('#F0FAFF').height(30).borderRadius(15).justifyContent(FlexAlign.Center)
Text(this.noticeTitleList.join(' '))
.fontColor('#3d3d3d').fontSize(12).layoutWeight(1).textOverflow({overflow: TextOverflow.MARQUEE})
}.width('100%').height(30).backgroundColor('#fff').borderRadius(15).margin({top: 15})
// 企业人员
Column(){
Row(){
Row(){
Text().width(4).height(20).backgroundColor('#6D9DFF').margin({right: 10})
Text('企业人员').fontSize(16).lineHeight(21).fontColor('#3d3d3d').fontWeight(600)
}
Row(){
Text('更多').fontSize(12).fontColor('#999').margin({right: 3})
Image($r('app.media.two_right')).width('12')
}.onClick(() => {
router.pushUrl({
url: 'pages/PersonList'
})
})
}.justifyContent(FlexAlign.SpaceBetween).width('100%')
Column(){
ForEach(this.personList, (item: companyPersonRow, index: number) => {
Row(){
Row({space: 10}){
Image(baseUrl + item.personalImg).width(60).height(60).borderRadius(10)
Column(){
Text(item.personName).fontSize(14).fontWeight(600).lineHeight(19).margin({bottom: 5})
.fontColor('#3d3d3d').textOverflow({overflow: TextOverflow.Ellipsis}).maxLines(1)
Text(item.createTime).fontColor('#999').fontSize(12).lineHeight(16)
}.alignItems(HorizontalAlign.Start)
}.layoutWeight(1)
Image($r('app.media.right_3')).width(12)
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: this.personList.length == index + 1 ? 0 : 1}, color: '#eee'}).padding({top: 15, bottom: 15})
.onClick(() => {
router.pushUrl({
url: 'pages/PersonDetail',
params: {
personId: item.personId
}
})
})
})
}.margin({top: 15})
}.width('100%').padding(15).borderRadius(10).backgroundColor('#fff').margin({top: 15})
.visibility(this.roleName == 'company' ? Visibility.Visible : Visibility.None)
// 通知公告
Column(){
Row(){
Row(){
Text().width(4).height(20).backgroundColor('#6D9DFF').margin({right: 10})
Text('通知公告').fontSize(16).lineHeight(21).fontColor('#3d3d3d').fontWeight(600)
}
Row(){
Text('更多').fontSize(12).fontColor('#999').margin({right: 3})
Image($r('app.media.two_right')).width('12')
}.onClick(() => {
router.pushUrl({
url: 'pages/NoticeList'
})
})
}.justifyContent(FlexAlign.SpaceBetween).width('100%')
Column(){
ForEach(this.noticeList, (item: noticeRow, index: number) => {
Row(){
Column(){
Text(item.noticeTitle).fontSize(14).fontWeight(600).lineHeight(19).margin({bottom: 5})
.fontColor('#3d3d3d').textOverflow({overflow: TextOverflow.Ellipsis}).maxLines(1)
Text(item.createTime).fontColor('#999').fontSize(12).lineHeight(16)
}.alignItems(HorizontalAlign.Start).layoutWeight(1)
Image($r('app.media.right_3')).width(12)
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: this.noticeList.length == index + 1 ? 0 : 1}, color: '#eee'}).padding({top: 15, bottom: 15})
.onClick(() => {
router.pushUrl({
url: 'pages/NoticeDetail',
params: {
id: item.noticeId
}
})
})
})
}.margin({top: 15})
}.width('100%').padding(15).borderRadius(10).backgroundColor('#fff').margin({top: 15})
}.width('100%')
.padding({left: 15, right: 15, bottom: 30})
}.height('100%').scrollBar(BarState.Off).linearGradient({colors: [['#E1EEFF', 0], ['#F2F3F7', 0.3]]})
}
}