payne
2024-04-26 3946fe3c23ff022b7e1d27c2a29041496ef6d529
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<template>
  <div class="zz-inverting-storages-list-box">
    <div class="box-top">
      <div class="check-all-box">
        <a-checkbox :indeterminate="indeterminate" :checked="checkAll" @change="onAllChange">{{checkAll?'全部取消':'全部选择'}}</a-checkbox>
      </div>
      <div class="checked-des auto-wrap">已选择库位数:<a style="cursor:default;">{{checkedNum}}</a></div>
    </div>
    <div class="list-group">
      <div class="lsit-item" v-for="(item,index) in list" :key="'lsit-item-'+index">
        <a-checkbox :checked="item.checked" @change="onSingleChange(index,item,$event)" /><a class="space-link" @click.stop="openDetail(item)">{{item.placecode}}</a>
      </div>
    </div>
    
    <detail-drawer :visible.sync="detailVisible" :row="detailRow" />
  </div>
</template>
 
<script>
import DetailDrawer from './DetailDrawer.vue'
export default {
  name:'zzInvertingStorageListBox',
  components:{DetailDrawer},
  data(){
    return {
      checkAll:false,
      indeterminate:false,
      list:[],
      checkedNum:0,
      detailVisible:false,
      detailRow:{}
    }
  },
  methods:{
    setList(arr){
      this.list = [...arr]
      this.restCheckAll()
    },
    emptyChoosen(){
      this.restCheckAll()
      this.linkSetCheckList(false)
    },
    restCheckAll(){
      this.checkAll = false
      this.indeterminate = false
      this.checkedNum = 0
    },
    onSingleChange(index,obj,e){
      obj.checked = e.target.checked
      if (obj.checked) {
        this.checkedNum++;
      } else {
        this.checkedNum--;
      }
      this.linkSetCheckAll()
    },
    onAllChange(e){
      let _temp = e.target.checked
      if (_temp) {
        this.checkAll = true
        this.checkedNum = this.list.length
      } else {
        this.checkAll = false
        this.checkedNum = 0
      }
      this.indeterminate = false
      this.linkSetCheckList(_temp)
    },
    linkSetCheckAll(){
      let c = 0 , n = this.list.length;
      this.list.forEach((listitem)=>{
        if (listitem.checked) {
          c++
        }
      })
      if (c===0) {
        this.checkAll = false;
        this.indeterminate = false
      } else if (c===n) {
        this.checkAll = true;
        this.indeterminate = false
      } else {
        this.checkAll = false;
        this.indeterminate = true
      }
    },
    linkSetCheckList(__empty) {
      this.list.forEach((listitem)=>{
        listitem.checked = __empty
      })
    },
    openDetail(obj){
      this.detailRow = obj
      this.detailVisible = true;
    },
    getChoosen(){
      let arr = [];
      this.list.forEach((listitem)=>{
        if (listitem.checked) {
          arr.push(listitem)
        }
      })
      return arr
    }
  }
}
</script>
 
<style lang="less" scoped>
.zz-inverting-storages-list-box {
  height:100%;
  display: flex;
  flex-direction: column;
  background-color: #fff;
  .box-top {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #dcdcdc;
    .check-all-box{
      flex-shrink: 0;
      padding: 0 12px;
    }
    .checked-des{
      flex-grow: 1;
      width: 1px;
      padding: 6px 6px 6px 0;
    }
  }
  .list-group{
    height: 1px;
    flex-grow: 1;
    overflow: auto;
    .lsit-item{
      border-bottom: 1px dashed #dcdcdc;
      padding: 6px 12px;
      .space-link{
        margin-left: 8px;
      }
      &:last-child{
        border-bottom: 0;
      }
    }
  }
}
</style>