Xxxu
2020-07-07 4f953ffc89fc95f83b152e914c5e65938b440f17
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
  <div class="chargeListCss">
    <el-row>
      <el-col :span="24">
        <div style="height:50px">
          <h2 style="margin-left:25px">充电桩列表</h2>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="1">
        &nbsp;
      </el-col>
      <el-col :span="13">
        <el-input @keyup.enter.native="getKeyList()" @change="getKeyList()" v-model="key" placeholder="输入充电桩名称"></el-input>
      </el-col>
      <el-col :span="1">
        &nbsp;
      </el-col>
      <el-col :span="6">
        <el-button class="searchBtn" size="mini" @click="getKeyList()">搜索</el-button>
      </el-col>
    </el-row>
    <el-table
      highlight-current-row
      v-loading="dataLoading"
      :data="dataList"
      @row-click="openInfo"
      ref="chargeList"
      :height="documentClientHeight - 330"
      element-loading-text="加载充电桩中"
      element-loading-color='black'
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(0, 0, 0, 0)"
      style="width: 100%;background-color:rgba(0,0,0,0)"
      >
      <el-table-column
        prop="c2ChargingName"
        align="left">
      </el-table-column>
      <el-table-column
        prop="c2ChargingAddTime"
        align="left">
      </el-table-column>
    </el-table>
  </div>
</template>
 
<script>
export default {
  data () {
    return {
      key: '',
      row: 1,
      tableHeight: window.innerHeight - 180,
      dataList: [],
      dataLoading: false,
      pageIndex: 1,
      pageSize: 20,
      totalPage: 0
    }
  },
  mounted () {
    // 绑定滚动监听事件
    const selectWrap = this.$refs.chargeList.bodyWrapper
    selectWrap.addEventListener(
      'scroll',
      () => {
        let sign = 100
        const scrollDistance =
          selectWrap.scrollHeight -
          selectWrap.scrollTop -
          selectWrap.clientHeight
        if (scrollDistance <= sign && !this.dataListLoading) {
          this.getDataList()
        }
      },
      true
    )
  },
  computed: {
    documentClientHeight: {
      get () { return this.$store.state.common.documentClientHeight }
    }
  },
  watch: {
    dataList: function () {
      this.$nextTick(() => {
        this.$refs.chargeList.setCurrentRow(this.dataList[0])
      })
    }
  },
  activated () {
    this.getDataList()
  },
  methods: {
    getDataList () {
      this.dataLoading = true
      this.$http({
        url: this.$http.adornUrl('/pole/polec2charging/list'),
        method: 'get',
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize
        })
      }).then(({ data }) => {
        data.page.list.forEach(item => {
          this.dataList.push(item)
        })
        if (
          this.$store.state.charge.streetlightIdOfChargeControl == null ||
          this.$store.state.charge.streetlightIdOfChargeControl === 0
        ) {
          this.$store.commit(
            'updateStreetlightIdOfChargeControl',
            this.dataList[0] ? this.dataList[0].streetlightId : 0
          )
        }
        this.pageIndex++
        this.totalPage = data.page.total
        this.dataLoading = false
      })
    },
    openInfo (row, event, column) {
      this.$store.commit('updateStreetlightIdOfChargeControl', row.streetlightId)
      this.$notify({
        message: '选择充电桩:' + row.c2ChargingName + '(' + row.streetlightId + ')',
        type: 'success'
      })
    }
  }
}
</script>
<style scoped>
.el-table >>> thead {
  color: white;
}
.el-table >>> th {
  color: white;
  background: rgba(0, 0, 0, 0);
}
.el-table >>> tr {
  color: white;
  background: rgba(0, 0, 0, 0);
}
.el-table >>> td,
.el-table >>> th.is-leaf {
  border: 0px;
}
</style>
<style scoped>
.searchBtn {
  color:white;
  border:1px solid white;
  border-radius:15px;
  margin-left:5px;
  background-color: #3FA9FC
}
.searchBtn:hover{
  color: white;
  border: 1px solid white;
  background-color: #3FA9FC
}
.searchBtn:focus{
  color: white;
  border: 1px solid white;
  background-color: #3FA9FC
}
</style>
<style>
[placeholder~="输入充电桩名称"] {
  border: 1px solid white;
  color: white;
  background-color: rgba(0, 0, 0, 0);
  border-radius: 25px;
}
[placeholder~="输入充电桩名称"]:focus {
  border: 1px solid white;
  color: white;
  background-color: rgba(0, 0, 0, 0);
  border-radius: 25px;
}
</style>