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
<template>
  <div class="led-list-list">
    <div class="title-text">LED列表</div>
    <div>
      <div style="padding: 10px 20px">
        <el-row>
          <el-col :span="13">
            <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
          </el-col>
          <el-col :span="1">
            &nbsp;
          </el-col>
          <el-col :span="6">
            <el-button @click="pageIndex = 1; dataList = []; getDataList()">搜索</el-button>
          </el-col>
        </el-row>
      </div>
      <el-table
        :data="dataList"
        :show-header="true"
        ref="table"
        v-loading="dataListLoading"
        @row-click="openDetails"
        highlight-current-row
        :height="documentClientHeight - 330"
        style="width: 100%">
        <el-table-column
          prop="lightemitName"
          header-align="center"
          align="center"
          label="">
        </el-table-column>
        <el-table-column
          prop="createTime"
          header-align="center"
          align="center"
          label="">
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
 
<script>
export default {
  data () {
    return {
      dataList: [],
      dataListLoading: false,
      pageIndex: 1,
      pageSize: 20,
      totalPage: 0,
      dataForm: {
        key: ''
      }
    }
  },
  watch: {
    dataList: function () {
      this.$nextTick(() => {
        this.$refs.table.setCurrentRow(this.dataList[0])
      })
    }
  },
  computed: {
    documentClientHeight: {
      get () { return this.$store.state.common.documentClientHeight }
    }
  },
  activated () {
    // this.init()
    this.getDataList()
  },
  mounted () {
    // 绑定滚动监听事件
    const selectWrap = this.$refs.table.bodyWrapper
    selectWrap.addEventListener('scroll', () => {
      let sign = 100
      const scrollDistance = selectWrap.scrollHeight - selectWrap.scrollTop - selectWrap.clientHeight
      if (scrollDistance <= sign && !this.dataListLoading) {
        this.getDataList()
      }
    }, true)
  },
  methods: {
    // 获取数据列表
    getDataList () {
      // 判断是否超出范围
      if (this.totalPage !== 0 && this.totalPage <= ((this.pageIndex - 1) * this.pageSize)) {
        return
      }
 
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/pole/polelightemit/list'),
        method: 'get',
        params: this.$http.adornParams({
          'page': this.pageIndex,
          'limit': this.pageSize,
          'key': this.dataForm.key,
          'group': ''
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          data.page.list.forEach(item => {
            this.dataList.push(item)
          })
          if (this.$store.state.led.lightemitId == null || this.$store.state.led.lightemitId === 0) {
            this.$store.commit('updateLightemitId', this.dataList[0] ? this.dataList[0].lightemitId : 0)
          }
          this.totalPage = data.page.totalCount
          this.pageIndex ++
        } else {
          this.totalPage = 0
        }
        this.dataListLoading = false
      })
    },
    openDetails (row) {
      this.$store.commit('updateLightemitId', row.lightemitId)
      this.$notify({
        message: '选择LED屏:' + row.lightemitName,
        type: 'success'
      })
    }
  }
}
</script>
 
<style lang="scss" scoped>
.led-list-list {
  // background-image: url(~@/assets/img/led/list.png);
  // background-size: 100% 100%;
  height: 100%;
  button {
    background-color:#3FA9FC;
    color:white;
    border-radius:15px;
  }
  /deep/ input {
    border-radius: 60px;
    background-color: transparent;
  }
  /deep/ .el-table{
    color: white;
    background-color: transparent;
    thead {
      color: white;
    }
    th {
      color: white;
      background: rgba(0, 0, 0, 0);
      border-bottom: 0px
    }
    tr {
      background-color: transparent;
      td {
        border-bottom: 0px
      }
    }
  }
}
</style>