baotian
2024-06-04 b959135a1139fb66646523d92e5bd20c5910f283
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
<template>
  <div>
    <x-card :bordered="false" v-if="hasPerm('WorkPieceProcess:page')">
      <div slot="content" class="table-page-search-wrapper">
        <a-form :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="gutter">
            <a-col :md="colMd" :sm="colSm">
              <a-form-item label="工件号">
                <a-input v-model="queryParam.workPieceID" allow-clear placeholder="请输入工件号" />
              </a-form-item>
            </a-col>
 
            <a-col :md="colMd" :sm="colSm">
              <a-form-item label="设备名称">
                <a-select
                  show-search
                  option-filter-prop="children"
                  :filter-option="filterOption"
                  :allowClear="true"
                  style="width: 100%"
                  v-model="queryParam.EquipmentID"
                  placeholder="请选择设备名称"
                >
                  <a-select-option v-for="item in equitypeData" :key="item.id" :value="item.equipmentId">{{
                    item.equipmentName
                  }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <!-- <a-col :md="colMd" :sm="colSm">
              <a-form-item label="日期范围">
                <a-range-picker
                  :placeholder="['开始日期', '结束日期']"
                  format="YYYY-MM"
                  :mode="mode"
                  :value="value"
                  @panelChange="handlePanelChange"></a-range-picker>
              </a-form-item>
            </a-col> -->
            <template v-if="advanced">
              <a-col :md="colMd" :sm="colSm">
                <a-form-item label="刀沿数">
                  <a-input-number
                    v-model="queryParam.knifeEdgeNumber"
                    style="width: 100%"
                    allow-clear
                    placeholder="请输入刀沿数"
                  />
                </a-form-item>
              </a-col>
            </template>
            <a-col :md="colMd" :sm="colSm">
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="getData">查询</a-button>
                <a-button style="margin-left: 8px" @click="resetHandle">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px" v-if="flag">
                  {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'" />
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </x-card>
    <!-- 图表部分1 -->
    <a-card :bordered="false" :bodyStyle="tstyle">
      <Echarts title="刀具使用分析图" :data="knifeToolLoad"></Echarts>
    </a-card>
    <!-- 图标部分2 -->
    <a-card>
      <a-table
        ref="table"
        :columns="columns"
        :dataSource="knifeToolList"
        :pagination="false"
        :rowKey="(record) => record.id"
      >
      </a-table>
    </a-card>
  </div>
</template>
<script>
import Echarts from './modules/Echarts.vue'
import { XCard } from '@/components'
import moment from 'moment'
// 获取设备下拉框数据
import { getEquipmentName } from '@/api/modular/main/EquipmentBaseInfoManage'
import { GetKnifeToolAnalysisInfo } from '@/api/modular/main/YieldAnalysisManage'
export default {
  name: 'KnifeToolUsageAnalysis',
  components: { Echarts, XCard },
  data() {
    return {
      gutter: 36,
      colMd: 6,
      colSm: 18,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      advanced: false, // 高级搜索 展开/关闭
      flag: false, // 显示隐藏展开按钮
      // 查询数据
      queryParam: {},
      // 设备下拉框数据
      equitypeData: [],
      knifeToolLoad: [],
      knifeToolList: [],
      columns: [
        {
          title: '序号',
          dataIndex: 'index',
          key: 'index',
          align: 'center',
          customRender: (text, record, index) => `${index + 1}`
        },
        {
          title: '设备编号',
          align: 'center',
          sorter: true,
          dataIndex: 'equipmentID',
          scopedSlots: { customRender: 'equipmentIDSlots' }
        },
        {
          title: '设备名称',
          align: 'center',
          sorter: true,
          dataIndex: 'equipmentName'
        },
        {
          title: '所属工序',
          align: 'center',
          sorter: true,
          dataIndex: 'workingProcedure'
        },
        {
          title: '刀具Id',
          ellipsis: true,
          dataIndex: 'knifeToolID'
        },
        {
          title: '工位',
          ellipsis: true,
          dataIndex: 'station'
        },
        {
          title: '上刀时间',
          ellipsis: true,
          dataIndex: 'changeStartTime'
        },
        {
          title: '换下时间',
          ellipsis: true,
          dataIndex: 'changeEndTime'
 
        },
        {
          title: '计划寿命(件)',
          ellipsis: true,
          dataIndex: 'knifeToolLife'
        },
        {
          title: '当前寿命(件)',
          ellipsis: true,
          dataIndex: 'currentLife'
        }
      ],
      tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' }
    }
  },
  mounted() {
    // this.loadData(this.queryParam)
    this.getEquipmentName()
    // this.getData()
  },
  methods: {
    /**
     * 查询参数组装
     */
    switchingDate() {
      const obj = JSON.parse(JSON.stringify(this.queryParam))
      return obj
    },
    toggleAdvanced() {
      this.advanced = !this.advanced
    },
    // 发起请求获取数据
    async getData() {
      try {
        const { data } = await GetKnifeToolAnalysisInfo(this.queryParam)
        this.knifeToolLoad = data.knifeToolLoad || []
        this.knifeToolList = data.knifeToolList || []
      } catch (error) {
        console.log(error)
      }
    },
    // 获取设备名称
    getEquipmentName() {
      getEquipmentName({ type: 'knifeTool' }).then((res) => {
        this.equitypeData = res.data
      })
    },
    // 重置按钮
    resetHandle() {
      this.queryParam = {}
      this.getData()
    },
    // 设备查询框筛选
    filterOption(input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    }
  }
}
</script>
<style lang="less">
.table-operator {
  margin-bottom: 18px;
}
 
button {
  margin-right: 8px;
}
 
.table {
  padding: 10px 20px;
  height: 140px;
  font-weight: 700;
  font-size: 16px;
  color: #000;
 
  .time,
  .num {
    // height: 38px;
    // line-height: 35px;
    display: flex;
    justify-content: space-around;
    background-color: #f8f8f9;
    margin-bottom: 2px;
 
    div {
      width: 60px;
    }
  }
 
  .num {
    div {
      height: 38px;
      line-height: 35px;
    }
  }
}
</style>