schangxiang@126.com
2024-08-11 0bbeeaf8cc151c2b31ca81c3989a6c6b1c6e4163
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
 
<template>
  <a-card :title="'设备刀具明细(' + equipmentID + ')'" :bordered="false" style="margin-top:10px">
    <a-spin :spinning="spinning">
      <a-table
        :columns="columns"
        :pagination="pages"
        :data-source="data"
        :rowKey="record => record.id"
      >
        <!-- 序号 -->
        <span slot="indexScopedSlots" slot-scope="text, record, index">{{ index + 1 }}</span>
        <!-- 操作 -->
        <span slot="actionScopedSlots" slot-scope="text, record, index">
          <a @click="$refs.toolOff.show(record)">下刀</a>
          <a-divider type="vertical"/>
          <a @click="$refs.toolOnline.show(record,'change')">换刀</a>
        </span>
      </a-table>
    </a-spin>
    <toolOff ref="toolOff" @reflesh="getData" />
    <toolOnline ref="toolOnline" @reflesh="getData"/>
  </a-card>
</template>
 
  <script>
  import { getKnifetoolequipmentinfo } from '@/api/modular/main/KnifeToolDataMonitorManage'
import toolOff from './toolOff.vue'
import toolOnline from './toolOnline.vue'
  export default {
    name: 'ToolDetail',
    components: { toolOff, toolOnline },
    data() {
      return {
        spinning: false,
        pages: {
          current: 1,
          pageSize: 5,
          total: 0,
          showTotal: (total, range) => `${range[0]}-${range[1]}共${total}条`,
          showSizeChanger: true,
          pageSizeOptions: ['5', '10', '20', '40', '50', '100', '200', '300'],
          onChange: this.getData,
          onShowSizeChange: this.showSizeChange
        },
        columns: [
          {
            title: '序',
            width: '50px',
            align: 'center',
            sorter: false,
            scopedSlots: { customRender: 'indexScopedSlots' }
          },
          {
            title: '刀具Id',
            ellipsis: true,
            dataIndex: 'knifeToolID'
          },
          {
            title: '工位',
            ellipsis: true,
            dataIndex: 'station'
          },
          {
            title: '上刀时间',
            ellipsis: true,
            dataIndex: 'changeStartTime'
          },
          {
            title: '计划寿命(件)',
            ellipsis: true,
            dataIndex: 'knifeToolLife'
          },
          {
            title: '当前寿命(件)',
            ellipsis: true,
            dataIndex: 'currentLife'
          },
          {
            title: '设备Id',
            ellipsis: true,
            dataIndex: 'equipmentID'
          },
          {
            title: '工序',
            ellipsis: true,
            dataIndex: 'workingProcedure'
          },
          {
            title: '操作',
            align: 'center',
            scopedSlots: { customRender: 'actionScopedSlots' }
          }
        ],
        data: [],
        equipmentID: '', // 设备ID
        selectedRowKeys: [],
        selectedData: []
      }
    },
    methods: {
      show(record) {
        this.clear()
        if (record !== null) {
          this.equipmentID = record.equipmentID
          this.getData()
        }
      },
      // 获取数据
      async getData(pageNo) {
        if (pageNo) this.pages.current = pageNo
        const { current, pageSize } = this.pages
        const { equipmentID } = this
        this.spinning = true
        try {
          const { data } = await getKnifetoolequipmentinfo({ equipmentID, pageNo: current, pageSize })
          this.data = data.rows
          this.pages.total = data.totalRows
        } catch (error) {
          console.log(error)
        }
        this.spinning = false
      },
        // 表格显示数据条数改变
        showSizeChange(current, size) {
        this.pages.pageSize = size
        this.getData(1)
      },
      // 清除
      clear() {
        this.data = []
        this.equipmentID = ''
        Object.assign(this.pages, {
          current: 1,
          pageSize: 5,
          total: 0
        })
      }
    }
  }
  </script>
 
  <style></style>