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
| // pages/selfpatrol/components/patrol-item/index.js
| Component({
| /**
| * 组件的属性列表
| */
| properties: {
| item: {
| type: Object,
| observer(value) {
| this.parseItem(value);
| },
| },
| },
|
| /**
| * 组件的初始数据
| */
| data: {
| // progressColor: ['#E83F3F', '#FFAD5B', '#20AD5E'],
| progressColor: { from: '#000', to: '#000' },
| },
|
| /**
| * 组件的方法列表
| */
| methods: {
| parseItem(value) {
| const { finished, total, ledgerTypeName } = value;
| const progressValue = total == 0 ? 0 : (finished / total) * 100;
| let progressColor;
| if (progressValue >= (2 / 3) * 100) {
| progressColor = 'green';
| } else if (progressValue >= (1 / 3) * 100) {
| progressColor = 'orange';
| } else {
| progressColor = 'red';
| }
| const taskContent = ledgerTypeName.replaceAll(';', '、');
| this.setData({ progressColor, progressValue, taskContent });
| },
|
| navToPatrolDetail() {
| const { guid } = this.data.item;
| wx.navigateTo({
| url: `/pages/selfpatrol/patroldetail/index?taskId=${guid}`,
| });
| },
| },
| });
|
|