zhaowei
12 小时以前 d7d5760fba228083cec7bc3323266f298ef4b4dc
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<template>
  <div class="device_list">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="loadData">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="设备编号">
              <a-input placeholder="请输入设备编号" v-model="queryParam.equipmentId"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="日期">
              <a-range-picker value-format="YYYY-MM-DD" v-model="dates" @change="dateParamChange"
                              :allow-clear="false" :disabled-date="disabledDate"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-space>
              <a-button type="primary" @click="loadData" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
              <a-button type="primary" icon="download" @click="handleExportXls('倍率报表')">导出</a-button>
            </a-space>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
 
    <!-- 操作按钮区域 -->
    <!--<div class="table-operator">-->
    <!--<a-button type="primary" icon="download" @click="handleExportXls('倍率报表')">导出</a-button>-->
    <!--</div>-->
 
    <!-- table区域-begin -->
    <a-spin :spinning="spinning">
      <div id="Efficiency" class="container" style="margin-top: 20px;">
        <div class="table2">
          <table class="dataContent table" border="1" cellspacing="0" cellpadding="0" style="white-space: nowrap"
                 v-if="dataList.length>0">
            <thead>
            <tr class="thead fixed equipname">
              <th class="thgu dong1 name" rowspan="2"
                  style="min-width: 50px; max-width: 50px;width: 50px;height: 66px">公司
              </th>
              <th class="thgu dong2 name" rowspan="2" style="min-width: 50px; max-width: 50px;width: 50px;">车间</th>
              <th class="thgu dong3 name" rowspan="2" style="min-width: 50px; max-width: 50px;width: 50px;">工段</th>
              <th class="thgu dong4 name" rowspan="2" style="min-width: 150px; max-width: 150px;width: 150px;">设备编号
              </th>
              <th class="thgu dong5 name" rowspan="2" style="min-width: 162px; max-width: 162px;width: 162px;">设备名称
              </th>
              <th class="thgu dong6 name" rowspan="2" style="min-width: 150px; max-width: 150px;width: 150px;">设备类型
              </th>
              <template v-for="tableHead in tableHeads">
                <th class="timeth" colspan="2">{{tableHead}}</th>
              </template>
            </tr>
            <tr class="thead notfixed gudingth">
              <template v-for="tableHead in tableHeads">
                <th>主轴倍率平均值</th>
                <th>进给倍率平均值</th>
              </template>
            </tr>
            </thead>
            <tbody>
 
            <tr class="mathData" v-for="(item, index) in dataList">
              <template v-if="item.level1!=='合计'&&item.level1!=='平均值'">
                <td class="tdgu kaitou" :rowspan="item.level1span"
                    :class="{hidden: item.level1dis,noExl:item.level1dis}" v-show="!item.level1dis">
                  <div class="wenzi">
                    {{item.level1}}
                  </div>
                </td>
                <td class="tdgu1 kaitou" :rowspan="item.level2span"
                    :class="{hidden: item.level2dis,noExl:item.level2dis}" v-show="!item.level2dis">
                  <div class="wenzi">
                    {{item.level2}}
                  </div>
                </td>
                <td class="tdgu2 kaitou wenzi" :rowspan="item.level3span"
                    :class="{hidden: item.level3dis,noExl:item.level3dis}" v-show="!item.level3dis">
                  <div class="wenzi">
                    {{item.level3}}
                  </div>
                </td>
                <td class="tdgu3  kaitou">{{item.equipmentId}}</td>
                <td class="tdgu4 kaitou" style="min-width: 162px; max-width: 162px;width: 162px;">
                  {{item.equipmentName}}
                </td>
                <td class="tdgu5 kaitou">{{item.equipmentType}}</td>
              </template>
 
              <!--合计与平均值区域-->
              <template v-else>
                <td colspan="6" class="tdgu kaitou">{{item.level1}}</td>
              </template>
 
              <template v-for="(tableHead, index) in item.mdcBeilvVoList">
                <td>{{tableHead.spindlebeilv | numFilter}}</td>
                <td>{{tableHead.feedbeilv | numFilter}}</td>
              </template>
            </tr>
            </tbody>
          </table>
        </div>
      </div>
    </a-spin>
  </div>
</template>
 
<script>
  import moment from 'moment'
  import $ from 'jquery'
  import '@/components/table2excel/table2excel'
  import { putAction, getAction } from '@/api/manage'
 
  export default {
    name: 'MagnificationReportList',
    components: {},
    props: { nodeTree: '', Type: '', nodePeople: '' },
    data() {
      return {
        tableHeads: [],
        dataList: [],
        spinning: false,
        /* 分页参数 */
        queryParam: {},
        dates: [moment().subtract(7, 'day').startOf('day'), moment().subtract(1, 'day').endOf('day')],
        // 表头
        url: {
          list: '/mdc/magnification/beilvList'
        }
      }
    },
    filters: {
      numFilter(value) {
        if (value) {
          return parseFloat((value * 100).toFixed(2))
        } else {
          return '0'
        }
      }
    },
    watch: {
      Type(valmath) {
        this.dataList = []
        this.queryParam.typeTree = valmath
      },
      nodeTree(val) { //监听currSelected 变化,将变化后的数值传递给 getCurrSelected 事件
        if (JSON.stringify(val) != '{}') {
          if (val.equipmentId) {
            this.queryParam.parentId = ''
            this.queryParam.equipmentId = val.equipmentId
          } else {
            this.queryParam.parentId = val.key
            this.queryParam.equipmentId = ''
          }
          this.loadData()
        }
      },
      nodePeople(val) {
        if (JSON.stringify(val) != '{}') {
          if (val.equipmentId) {
            this.queryParam.parentId = ''
            this.queryParam.equipmentId = val.equipmentId
          } else {
            this.queryParam.parentId = val.key
            this.queryParam.equipmentId = ''
          }
          this.loadData()
        }
      }
    },
    created() {
      this.queryParam.startTime = moment(this.dates[0]).format('YYYY-MM-DD')
      this.queryParam.endTime = moment(this.dates[1]).format('YYYY-MM-DD')
      this.loadData()
    },
    mounted() {
      window.addEventListener('resize', this.handleWindowResize)
      this.handleWindowResize()
    },
    beforeDestroy() {
      window.removeEventListener('resize', this.handleWindowResize)
    },
    methods: {
      loadData() {
        this.tableHeads = []
        this.dataList = []
        this.spinning = true
        getAction(this.url.list, this.queryParam).then(res => {
          if (res.success) {
            this.tableHeads = res.result.dates
            this.dataList = res.result.mdcMagnificationVos
            if (res.result.mdcMagnificationVos && !res.result.mdcMagnificationVos.length) {
              this.$notification.info({
                message: '消息',
                description: '暂无该类型数据'
              })
            }
            this.checkSameData(this.dataList)
            this.checkSameData1(this.dataList)
            this.checkSameData2(this.dataList)
            this.combineCell()
          }
        }).finally(() => {
          this.spinning = false
        })
      },
 
      checkSameData(dataList) {
        let cache = {}  //存储的是键是kclx 的值,值是kclx 在indeces中数组的下标
        let indices = []  //数组中每一个值是一个数组,数组中的每一个元素是原数组中相同kclx的下标
        dataList.map((item, index) => {
          let level1 = item.level1
          let _index = cache[level1]
          if (_index !== undefined) {
            indices[_index].push(index)
          } else {
            cache[level1] = indices.length
            indices.push([index])
          }
        })
        let result = []
        indices.map((item) => {
          item.map((index) => {
            result.push(dataList[index])
          })
        })
        this.dataList = result
      },
 
      checkSameData1(dataList) {
        let cache = {}  //存储的是键是kclx 的值,值是kclx 在indeces中数组的下标
        let indices = []  //数组中每一个值是一个数组,数组中的每一个元素是原数组中相同kclx的下标
        dataList.map((item, index) => {
          let level2 = item.level2
          let _index = cache[level2]
          if (_index !== undefined) {
            indices[_index].push(index)
          } else {
            cache[level2] = indices.length
            indices.push([index])
          }
        })
        let result = []
        indices.map((item) => {
          item.map((index) => {
            result.push(dataList[index])
          })
        })
        this.dataList = result
      },
 
      checkSameData2(dataList) {
        let cache = {}  //存储的是键是kclx 的值,值是kclx 在indeces中数组的下标
        let indices = []  //数组中每一个值是一个数组,数组中的每一个元素是原数组中相同kclx的下标
        dataList.map((item, index) => {
          let level3 = item.level3
          let _index = cache[level3]
          if (_index !== undefined) {
            indices[_index].push(index)
          } else {
            cache[level3] = indices.length
            indices.push([index])
          }
        })
        let result = []
        indices.map((item) => {
          item.map((index) => {
            result.push(dataList[index])
          })
        })
        this.dataList = result
      },
 
      // 合并
      combineCell() {
        console.log(this.dataList)
        let list = this.dataList
        for (let field in list[0]) {
          var k = 0
          while (k < list.length) {
            list[k][field + 'span'] = 1
            list[k][field + 'dis'] = false
            for (var i = k + 1; i <= list.length - 1; i++) {
              if (list[k][field] === list[i][field] && list[k][field] !== '') {
                list[k][field + 'span']++
                list[k][field + 'dis'] = false
                list[i][field + 'span'] = 1
                list[i][field + 'dis'] = true
              } else {
                break
              }
            }
            k = i
          }
        }
        return list
      },
 
      handleExportXls() {
        $('#Efficiency').table2excel({
          exclude: '.noExl',
          name: 'Excel Document Name',
          filename: '倍率报表',
          exclude_img: true,
          fileext: '.xls',
          exclude_links: true,
          exclude_inputs: false
        })
      },
 
      dateParamChange(dateArray) {
        this.queryParam.startTime = dateArray[0]
        this.queryParam.endTime = dateArray[1]
      },
 
      disabledDate(current) {
        // Can not select days before today and today
        return current > moment().subtract(1, 'day').endOf('day')
      },
 
      searchReset() {
        this.dates = [moment().subtract(7, 'day').startOf('day'), moment().subtract(1, 'day').endOf('day')]
        this.queryParam = {
          startTime: moment(this.dates[0]).format('YYYY-MM-DD'),
          endTime: moment(this.dates[1]).format('YYYY-MM-DD')
        }
        this.loadData()
      },
 
      /**
       * 当浏览器可视窗口尺寸发生改变时触发
       */
      handleWindowResize() {
        const tableContainer = document.getElementById('Efficiency') // 表格容器
        const clientHeight = document.documentElement.clientHeight || document.body.clientHeight // 浏览器可视区域高度
        const containerTopToClientTopHeight = tableContainer.getBoundingClientRect().top // 表格容器顶部到浏览器可视区域顶部的间距
        tableContainer.style.height = (clientHeight - containerTopToClientTopHeight - 32) + 'px'
      }
    }
  }
</script>
<style scoped>
  .table2 {
    width: 100%;
    height: 100%;
    overflow: auto;
  }
 
  .table2 thead tr th:first-child,
  .table tbody tr .tdgu {
    position: sticky;
    left: 0;
    z-index: 1;
  }
 
  .table tbody tr .wenzi {
    transform: rotate(360deg);
    writing-mode: vertical-lr;
    letter-spacing: 2px;
  }
 
  .table tbody tr .kaitou {
    z-index: 1;
    background-color: white;
  }
 
  .table tbody tr .tdgu1 {
    position: sticky;
    left: 50px;
    z-index: 2;
  }
 
  .table tbody tr .tdgu2 {
    position: sticky;
    left: 100px;
    z-index: 2;
  }
 
  .table tbody tr .tdgu3 {
    position: sticky;
    left: 150px;
    z-index: 2;
  }
 
  .table tbody tr .tdgu4 {
    position: sticky;
    left: 300px;
    z-index: 2;
  }
 
  .table tbody tr .tdgu5 {
    position: sticky;
    left: 462px;
    z-index: 2;
  }
 
  .table2 thead tr .timeth,
  .table2 thead tr .thgu {
    position: sticky;
    top: 0;
    z-index: 3;
  }
 
  .table2 thead .gudingth th {
    position: sticky;
    top: 32px;
    z-index: 2;
  }
 
  .table2 thead .equipname .name {
    z-index: 3;
  }
 
  .table2 thead .equipname .dong1 {
    z-index: 4;
    left: 0;
  }
 
  .table2 thead .equipname .dong2 {
    z-index: 5;
    left: 50px;
  }
 
  .table2 thead .equipname .dong3 {
    z-index: 5;
    left: 100px;
  }
 
  .table2 thead .equipname .dong4 {
    z-index: 5;
    left: 150px;
  }
 
  .table2 thead .equipname .dong5 {
    z-index: 5;
    left: 300px;
  }
 
  .table2 thead .equipname .dong6 {
    z-index: 5;
    left: 462px;
  }
 
  #Efficiency {
    overflow: hidden;
  }
 
  .dataContent {
    white-space: nowrap;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #ccc;
    width: 100%;
    text-align: center;
  }
 
  .dataContent .thead th {
    background-color: #fafafa;
    text-align: center;
    height: 30px;
    padding: 5px;
  }
 
  .dataContent .mathData td {
    padding: 10px;
  }
 
  td {
    vertical-align: middle;
  }
</style>