checkItem.vue
3.26 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
<template>
<view class="margin-top">
<u-grid col="2">
<u-grid-item v-for="(item,index) in checkList" :key="index" @click="clickItem(item,index)">
<view class="cardItemCss">
<view class="">
{{item.title}}
</view>
<view class="flex">
<u-icon color="#EE2F24" :name="calcSfhg(item)"></u-icon>
<!-- close-circle-fill -->
<u-icon name="arrow-right"></u-icon>
</view>
</view>
</u-grid-item>
</u-grid>
</view>
</template>
<script>
import ajJson from '@/static/aj.json'
export default {
name: "checkItem",
components: {},
props: {
rhaj: {
type: Object,
default: () => {}
},
},
data() {
return {
checkList: ajJson,
// rhaj:{
// lq:{},
// syhj:{},
// syxw:{},
// rsqsnaz:{},
// pgzf:{},
// rqpxlbjzz:{}
// }
}
},
watch: {},
computed: {
},
mounted() {
// console.log('打印ajJson',JSON.parse(JSON.stringify(ajJson)));
},
methods: {
calcSfhg(item) {
let key = item.key;
let sflq = key === 'lq'; //是否漏气
let sfbjOrRsq = key === 'rsqsnaz' || key === 'rqpxlbjzz' //是否报警或热水器
// 如果为漏气选择是为不合格
if (sflq && this.rhaj[key][0].jcjg === '是') {
return '/static/images/home/fengxiang.png'
}
// 如果非漏气第一个选择为否为不合格
if (!sflq && this.rhaj[key][0].jcjg === '否') {
// console.log("不合格2");
return '/static/images/home/fengxiang.png';
}
// 如果是漏气选择是为合格,如果非漏气且(非报警和热水器)第一个选择为是为合格
if ((sflq && this.rhaj[key][0].jcjg === '否') || (!sflq && !sfbjOrRsq && this.rhaj[key][0].jcjg === '是')) {
// console.log("合格3");
return '/static/images/home/hege.png';
}
// 如果是(非报警和热水器),第一个选择和第二个选择都为是为合格
if (sfbjOrRsq && this.rhaj[key][0].jcjg === '是' && this.rhaj[key][1]?.jcjg === '是') {
return '/static/images/home/hege.png';
}
// 否则返回不合格
return '/static/images/home/fengxiang.png';
},
clickItem(item, index) {
// console.log("当前item",item);
for (let i in this.rhaj) {
if (item.key === i) {
// console.log("1、安检项目", this.rhaj[i]);
if (i === "rqpxlbjzz" || i === 'rsqsnaz') {
this.rhaj[i].map((aj, aix) => {
if (aix === 0) {
item.radioOne = this.rhaj[i][aix].jcjg;
} else if (aix === 1) {
item.radioTwo = this.rhaj[i][aix].jcjg;
} else {
item.checkboxValue.push(this.rhaj[i][aix].bt);
}
})
} else {
this.rhaj[i].map((aj, aix) => {
if (aix === 0) {
item.radioOne = this.rhaj[i][aix].jcjg;
} else {
item.checkboxValue.push(this.rhaj[i][aix].bt)
}
})
}
}
}
item.ifhx = true;
console.log('item', JSON.parse(JSON.stringify(item)));
uni.$emit('chekItemData', item);
}
}
}
</script>
<style lang="scss" scoped>
.cardItemCss {
display: flex;
padding: 0 6px 0 6px;
justify-content: space-between;
align-items: center;
background: #fff;
border-radius: 10px;
margin: 5px 0;
width: calc(100% - 5px);
height: 44px;
border: 1px solid #f6f6f6 !important;
}
</style>