ThemeStaticText.ets
3.6 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
let getInfoColor = (index: string | undefined) => {
let colorStr: string = ''
switch (index) {
case '1': colorStr = '#909399';break;
case '2': colorStr = '#1890ff';break;
case '4': colorStr = '#ffba00';break;
case '3': colorStr = '#13ce66';break;
default : colorStr = '#909399'
}
return colorStr
}
let getInfoBgColor = (index: string | undefined) => {
let colorStr: string = ''
switch (index) {
case '1': colorStr = '#f4f4f5';break;
case '2': colorStr = '#e8f4ff';break;
case '4': colorStr = '#fff8e6';break;
case '3': colorStr = '#e7faf0';break;
default : colorStr = '#f4f4f5'
}
return colorStr
}
let getInfoBorderColor = (index: string | undefined) => {
let colorStr: string = ''
switch (index) {
case '1': colorStr = '#e9e9eb';break;
case '2': colorStr = '#d1e9ff';break;
case '4': colorStr = '#fff1cc';break;
case '3': colorStr = '#d0f5e0';break;
default : colorStr = '#f4f4f5'
}
return colorStr
}
let getStateInfoColor = (index: string | undefined) => {
let colorStr: string = ''
switch (index) {
case '4': colorStr = '#909399';break;
case '0': colorStr = '#1890ff';break;
case '5': colorStr = '#ffba00';break;
case '2': colorStr = '#ff4949';break;
case '1': colorStr = '#13ce66';break;
default : colorStr = '#909399'
}
return colorStr
}
let getStateInfoBgColor = (index: string | undefined) => {
let colorStr: string = ''
switch (index) {
case '4': colorStr = '#f4f4f5';break;
case '0': colorStr = '#e8f4ff';break;
case '5': colorStr = '#fff8e6';break;
case '2': colorStr = '#ffeded';break;
case '1': colorStr = '#e7faf0';break;
default : colorStr = '#f4f4f5'
}
return colorStr
}
let getStateInfoBorderColor = (index: string | undefined) => {
let colorStr: string = ''
switch (index) {
case '4': colorStr = '#e9e9eb';break;
case '0': colorStr = '#d1e9ff';break;
case '5': colorStr = '#fff1cc';break;
case '2': colorStr = '#ffdbdb';break;
case '1': colorStr = '#d0f5e0';break;
default : colorStr = '#f4f4f5'
}
return colorStr
}
@Component
export default struct ThemeStaticTest {
@Prop textValue: string
@Prop type: string = '0'
// 获取维保记录类型
MaintenanceType = (index: string | undefined): string => {
let str: string = ''
switch (index) {
case '1': str = '月度';break;
case '2': str = '季度';break;
case '4': str = '半年度';break;
case '3': str = '年度';break;
default : str = ''
}
return str
}
// 获取维保记录状态
MaintenanceState = (index: string | undefined): string => {
let str: string = ''
switch (index) {
case '0': str = '编辑中';break;
case '1': str = '已签发';break;
case '2': str = '已删除';break;
case '3': str = '正常(除”删除“外)';break;
case '4': str = '待维保人员签字';break;
case '5': str = '待甲方签字';break;
default : str = ''
}
return str
}
build() {
if(this.type == '0') {
Text(this.MaintenanceType(this.textValue))
.padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).fontColor(getInfoColor(this.textValue))
.backgroundColor(getInfoBgColor(this.textValue)).borderColor(getInfoBorderColor(this.textValue))
} else if(this.type == '1'){
Text(this.MaintenanceState(this.textValue)).padding({left: 6, right: 6})
.borderWidth(1).fontSize(12).borderRadius(4).lineHeight(16).fontColor(getStateInfoColor(this.textValue))
.backgroundColor(getStateInfoBgColor(this.textValue)).borderColor(getStateInfoBorderColor(this.textValue))
}
}
}