floorOptionContent.vue
4.17 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
<template>
<div class="floor-option-content">
<span class="condition-item-text">{{$t('asisTab.floorT')}}</span>
<div class="condition-item-option" v-show="objectVal === 1">
<el-select v-model="floorVal" filterable :placeholder="$t('pholder.floorSelect')" class="floor-sel-box format-sel-box">
<el-option v-for="item in mutiFloorData" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</div>
<div class="condition-item-option" v-show="objectVal === 2">
<el-select v-model="mutiFloorVal" filterable :placeholder="$t('pholder.floorSelect')" class="floor-sel-box format-sel-box" multiple collapse-tags @change="floorChangeHandle">
<div :class="isFloorSelAll ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle('floor')">
<span class="custom-checkbox__input">
<span class="custom-checkbox__inner"></span>
</span>
<span style="padding-left: 5px;">{{$t('allPages.all')}}</span>
</div>
<el-option v-for="item in mutiFloorData" :key="item.id" :label="item.name" :value="item.id">
<span class="custom-checkbox__input">
<span class="custom-checkbox__inner"></span>
</span>
<span style="padding-left: 5px;">{{ item.name }}</span>
</el-option>
</el-select>
</div>
</div>
</template>
<script>
import Bus from '../../views/public/eventBus'
export default {
props: {
objectVal: Number,
asisLevel: String,
},
name: 'floor-option-content',
data() {
return {
floorVal: '',
mutiFloorVal: [],
mutiFloorData: [],
isFloorSelAll: false,
mallVal: '',
}
},
watch: {
asisLevel(level) {
if(level == 'floor') {
this.getFloorOpt(this.mallVal)
}
}
},
created() {
var _this = this;
Bus.$on('mallVal', function(val) {
_this.mallVal = val
if(_this.asisLevel == 'floor') {
_this.getFloorOpt(val)
}
})
},
mounted() {
},
methods: {
floorChangeHandle() {
this.isFloorSelAll = this.mutiFloorVal.length >= this.mutiFloorData.length ? true: false;
},
selAllHandle(selType) {
if(this.isFloorSelAll) {
this.isFloorSelAll = false;
if(this.mutiFloorVal.length == this.mutiFloorData.length) {
this.mutiFloorVal = [];
}
} else {
this.isFloorSelAll = true;
if(this.mutiFloorVal.length == this.mutiFloorData.length) {
this.mutiFloorVal = [];
} else {
this.mutiFloorVal = [];
this.mutiFloorData.forEach(item => {
this.mutiFloorVal.push(item.id);
})
}
}
},
getFloorOpt(mall_id) {
this.mutiFloorVal = [];
this.floorVal = '',
this.mutiFloorData = [];
this.isFloorSelAll = false;
this.$api.base.floor({
mallId: mall_id,
accountId: this.$cookie.get('accountId'),
status: 1,
})
.then(res => {
if (res.data.data.length > 0) {
let result = JSON.parse(JSON.stringify(res.data.data));
result.unshift({
name: this.$t('asisTab.all'),
id: ''
})
this.mutiFloorData = res.data.data;
this.mutiFloorVal = [res.data.data[0].id];
this.floorVal = res.data.data[0].id;
this.isFloorSelAll = this.mutiFloorVal.length == this.mutiFloorData.length ? true : false
}
})
.catch(err => {
this.catchErrorHandle(err)
})
}
}
}
</script>
<style>
</style>