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
Component({
mixins: [],
data: {
lableTree: [],
locationName: '全部区域',//区域name
locationId: '',// 区域id
},
props: {
locationName: '',//区域name
locationId: '',// 区域id
areTreeList: []
},
didMount() {
const addKey = data => data.map(item => ({
...item,
status: true,
children: addKey(item.children)
}))
const lableTree = addKey(this.props.areTreeList)
this.setData({
lableTree: lableTree,
locationId: this.props.locationId,
locationName: this.props.locationName,
})
},
didUpdate() {},
didUnmount() {},
methods: {
onChangeStatus(e) {
let index = e.target.dataset.index
let cycleTimes = e.target.dataset.cycle
if (cycleTimes == 1) {
let listStr = `lableTree[${index[0]}].status`
this.setData({
[listStr]: this.data.lableTree[index[0]].status ? false : true
})
} else if (cycleTimes == 2) {
let listStr = `lableTree[${index[0]}].children[${index[1]}].status`
this.setData({
[listStr]: this.data.lableTree[index[0]].children[index[1]].status ? false : true
})
}
// else if (cycleTimes == 3) {
// let listStr = `lableTree[${index[0]}].children[${index[1]}].children[${index[2]}].status`
// this.setData({
// [listStr]: this.data.lableTree[index[0]].children[index[1]].children[index[2]].status ? false : true
// })
// }
},
onChangeAreId(e){
this.setData({
locationId: this.data.locationId === e.target.dataset.id ? '' : e.target.dataset.id,
locationName: this.data.locationId === e.target.dataset.id ? '全部区域' : e.target.dataset.name
})
},
cancelSelectAre() {
let data = {
type: 'cancel'
}
this.props.onPropsCS(data)
},
sureSelectAre() {
let data = {
type: 'sure',
id: this.data.locationId,
name: this.data.locationName
}
this.props.onPropsCS(data)
}
},
});