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
| <template>
| <view class="content">
| <!-- 顶部标题 -->
| <view class="title">{{title}}</view>
| <view class="detail">
| <u-grid :col="3">
| <u-grid-item v-for="item in statisticsArr" :key="item.code" @click="goDetail(item.type)" style="margin-bottom: 10rpx;">
| <u-badge max="99" :value="item.count" :absolute="true" :offset="[0,40]" style="z-index: 10000;"></u-badge>
| <u-icon name="photo" :size="46"></u-icon>
| <view class="grid-text">{{item.title}}</view>
| </u-grid-item>
| </u-grid>
| </view>
| </view>
| </template>
|
| <script>
| //清洗液更换告警 刀具更换告警 切削液更换告警 设备告警
| const warns = ['isAlertDetergent','isAlertKnifeTool','isAlertCuttingFluid','isAlert'];
| const titleArr = ['清洗液更换告警','刀具更换告警','切削液更换告警','设备告警']
| const typeArr = [1,2,3,4];
| export default {
| props: {
| title: {type: String,required: true},
| warnArr: {type: Array, required: true}
| },
| data() {
| return {
| value: 10
| }
| },
| computed: {
| statisticsArr() {
| return this.warnArr.reduce((curr,item) => {
| for(let i=0;i<warns.length;i++) {
| if(item[warns[i]]) {
| const index = curr.findIndex(ele => ele.code == warns[i]);
| if(index == -1) {
| curr.push({
| code: warns[i],
| title: titleArr[i],
| count: 1,
| type: typeArr[i]
| })
| }else {
| curr[index].count ++;
| }
| }else {
| const index = curr.findIndex(ele => ele.code == warns[i]);
| if(index == -1) {
| curr.push({
| code: warns[i],
| title: titleArr[i],
| count: 0,
| type: typeArr[i]
| })
| }
|
| }
| }
| return curr;
| },[])
| }
| },
| methods: {
| goDetail(type) {
| uni.navigateTo({
| url: `/pages/home/detail?type=${type}&title=${titleArr[type-1]}`
| })
| }
| }
| }
| </script>
|
| <style scoped lang="scss">
| .content {
| width: 96%;
| margin: 18rpx auto;
| .title {
| border-left: 6rpx solid #F18202;
| padding-left: 10rpx;
| box-sizing: border-box;
| font-size: 36rpx;
| margin-bottom: 10rpx;
| }
| .detail {
| box-sizing: border-box;
| width: 100%;
| background: #fff;
| }
| }
| </style>
|
|