yangys
2024-01-13 f466ae4fdc645c66c9f25e2e4598b9809e2b41af
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
<template>
  <div class="app-container">
    <div>
      <el-popover popper-class="mdc-popover"
        placement="bottom"
        trigger="click"
        v-model="isPopShowing">
        <ul class="mdc-list">
          <li class="mdc-list-item" v-for="workshop in workshopList" @click="onWorkshopChange(workshop)">{{ workshop.id }}</li>
        </ul>
        <el-button class="mdc-dropdown" slot="reference">
          <span>{{selectWorkshop.id}}</span><i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
      </el-popover>
 
      <el-table :data="list" v-loading.table="listLoading" element-loading-text="Loading" fit
                 :row-class-name="tableRowClassName" style="width: 100%;border: 1px solid #ebeef5;">
        <el-table-column align="center" label='机床名' prop="name"></el-table-column>
        <el-table-column label="采集时间" prop="time"></el-table-column>
<!--        <el-table-column label="机床状态" align="center" prop="state"></el-table-column>-->
<!--        <el-table-column label="主轴转速" align="center" prop="speed"></el-table-column>-->
<!--        <el-table-column label="主轴进给" align="center" prop="feed"></el-table-column>-->
<!--        <el-table-column label="主轴负载" align="center" prop="spindleLoad"></el-table-column>-->
<!--        <el-table-column label="主轴倍率" align="center" prop="rate"></el-table-column>-->
<!--        <el-table-column label="程序名" align="center" prop="progName"></el-table-column>-->
<!--        <el-table-column label="报警号" align="center" prop="alarmNo"></el-table-column>-->
<!--        <el-table-column label="报警信息" align="center" prop="alarmMsg"></el-table-column>-->
        <el-table-column label="采集内容" align="center" prop="monitortag"></el-table-column>
      </el-table>
    </div>
    <div style="padding-top: 10px;display: flex;justify-content: flex-end;align-items: center;">
      <el-button-group>
        <el-button type="primary" icon="el-icon-arrow-left" size="mini" round @click="prePage()" :disabled="canPaging[0]">上一页</el-button>
        <el-button disabled  size="mini" plain>{{currentPage}}/{{totalPage}}</el-button>
        <el-button type="primary" size="mini" round @click="nextPage()" :disabled="canPaging[1]">下一页<i class="el-icon-arrow-right el-icon--right"></i></el-button>
      </el-button-group>
    </div>
  </div>
</template>
 
<script>
  import { getHistoryData } from '@/api/MdcApi'
 
  export default {
    data() {
      return {
        list: null,
        listLoading: true,
        currentPage: 1,
        totalPage: 0,
        workshopList: [],
        selectWorkshop: {},
        isPopShowing: false
      }
    },
    created() {
      this.workshopList = this.$store.getters.workshopList
      this.selectWorkshop = this.workshopList[0]
      this.fetchData()
    },
    computed: {
      canPaging() {
        const tem = [false, false]
        tem[0] = (this.currentPage <= 1)
        tem[1] = (this.currentPage >= this.totalPage)
        return tem
      }
    },
    methods: {
      fetchData() {
        this.listLoading = true
        // console.log('-----------------------')
        // console.log(this.currentPage)
        // console.log(this.selectWorkshop.workshopId)
        getHistoryData(this.currentPage, this.selectWorkshop.workshopId).then((response = {}) => {
          // console.info(response)
          this.list = response.list || []
          this.totalPage = parseInt((response.totalPage || 0))
          this.listLoading = false
        })
      },
      /**
       * 按照车间查询
       * @param workshop
       */
      onWorkshopChange(workshop) {
        this.selectWorkshop = workshop
        this.isPopShowing = false
        this.fetchData()
      },
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex % 2 === 1) {
          return 'odd-row'
        } else {
          return 'even-row'
        }
      },
      // 前一页
      prePage() {
        if (this.currentPage > 1) {
          this.currentPage--
          this.fetchData()
        }
      },
      // 后一页
      nextPage() {
        if (this.currentPage < this.totalPage) {
          this.currentPage++
          this.fetchData()
        }
      }
    }
  }
</script>
<style scoped>
  .mdc-list{
    list-style: none;
    max-height: 300px;
    overflow-y: scroll;
    overflow-x:hidden;
  }
  .mdc-list-item{
    padding: 6px 16px;
    border-bottom: 1px solid #e5e5e5;
  }
  .el-table>>> .odd-row {
    background: transparent;
  }
  .el-table>>> .even-row {
    background: #f8f8f8;
  }
  .mdc-dropdown{
    -webkit-appearance: none;
    background-color: #fff;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #dcdfe6;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    color: #606266;
    font-size: 13px;
    /*line-height: 30px;*/
    display: inline-flex;
    align-items: center;
    padding: 7px 15px;
    -webkit-transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    margin-bottom: 10px;
  }
</style>