zmc
2023-08-31 013ed9283200da41902835f9fd679df13299d436
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
<!-- 多选框显示店铺名称 
返回父组件已选择的店铺
 
-->
<script>
import axiosInstance from '../utils/request.js'
export default {
emits:['submitShops'],
  data() {
    return {
      checkAll: false,
      isIndeterminate: false,
      selectedShopName: [],
      shopNames: []
    };
  },
  mounted(){
    this.getAllShopNames()
  },
  methods: {
    getAllShopNames(){
            axiosInstance.get('/fume/shopnamepy').then(response =>{
                 response.data.data.forEach(item => {
                    this.shopNames.push(item.diName)
                 }
                 );
            })
        },
    handleCheckAllChange(val) {
      this.selectedShopName = val ? this.shopNames : [];
      this.isIndeterminate = false;
      this.$emit('submitShops',this.selectedShopName)
    },
    handleCheckedCitiesChange(value) {
      const checkedCount = value.length;
      this.checkAll = checkedCount === this.shopNames.length;
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.shopNames.length;
        this.$emit('submitShops',this.selectedShopName)
    }
  }
};
</script>
 
<template>
  <div>
    <el-checkbox
      v-model="checkAll"
      :indeterminate="isIndeterminate"
      @change="handleCheckAllChange"
      
      >全选</el-checkbox
    >
    <el-checkbox-group
      v-model="selectedShopName"
      @change="handleCheckedCitiesChange"
    >
      <el-checkbox v-for="shop in shopNames" :key="shop" :label="shop"
        >{{ shop }}
      </el-checkbox>
    </el-checkbox-group>
  </div>
</template>