1
lzhe
2024-12-01 2ec3250c83921ba91836ef8af129a74fef9d3c6a
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
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-04-26 09:36:18
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-11-27 15:44:14
 * @FilePath: /smart-web/src/views/mdc/status-record.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <el-main style="height: 100%;" class="timeAnalysis">
        <el-card shadow="never" style="height: 100%;" body-style="height: 100%;padding: 0;">
            <el-container style="height: 100%;">
                <el-aside width="300px" style="height: 100%;">
                    <el-main style="border-bottom: 1px solid #ccc;">
                        <el-form ref="form" :model="searchInfo" label-width="80px">
                          <el-form-item label="零件号">
                            <el-input v-model="searchInfo.partNo"></el-input>
                          </el-form-item>
                          <el-form-item label="工位编号">
                            <el-input v-model="searchInfo.workstationName"></el-input>
                          </el-form-item>
                          <el-form-item label="开始时间">
                            <el-date-picker v-model="searchInfo.startDate" format="YYYY-MM-DD" value-format="YYYY-MM-DD" type="date" placeholder="选择日期"></el-date-picker>
                          </el-form-item>
                          <el-form-item label="结束时间">
                            <el-date-picker v-model="searchInfo.endDate" format="YYYY-MM-DD" value-format="YYYY-MM-DD" type="date" placeholder="选择日期"></el-date-picker>
                          </el-form-item>
                        </el-form>
                        <div style="text-align: center;"><el-button type="primary" @click="searchBtn">查询</el-button></div>
                    </el-main>
                    <el-main>
                        <el-radio-group v-model="tabPosition" style="margin-bottom: 12px;">
                            <el-radio-button label="设备结构树"></el-radio-button>
                            <el-radio-button label="零件结构树"></el-radio-button>
                        </el-radio-group>
                        <MYTree v-model="treeChecked" show-checkbox class="MYTree-content"></MYTree>
                    </el-main>
                </el-aside>
                <el-container>
                    <el-main>
                        <el-table :data="tableData" border @selection-change="handleSelectionChange">
                            <el-table-column type="selection" width="55"></el-table-column>
                            <el-table-column prop="index" label="序号" width="60"></el-table-column>
                            <el-table-column prop="partNo" label="零件号" width="80"></el-table-column>
                            <el-table-column prop="processNo" label="工序号" width="80"></el-table-column>
                            <el-table-column prop="version" label="版次" width="60"></el-table-column>
                            <el-table-column prop="workstationName" label="机床" width="100"></el-table-column>
                            <el-table-column prop="startTime" label="开机时间" width="145"></el-table-column>
                            <el-table-column prop="endTime" label="结束时间" width="145"></el-table-column>
                            <el-table-column prop="occupancySecs" label="占机时间" width="100">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.occupancySecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="clampingSecs" label="装夹调试时间" width="100">
                                 <template #default="scope">
                                    {{ convertSeconds(scope.row.clampingSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="firstWorkingSecs" label="首件切削时间" width="100">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.firstWorkingSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="firstMeasureSecs" label="首件计量时间" width="100">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.firstMeasureSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="lastRemoveSecs" label="末件拆卸时间" width="100">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.lastRemoveSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="processingSecs" label="加工时间" width="80">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.processingSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="prepareSecs" label="准备时间" width="80">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.prepareSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="singleProcessSecs" label="单件工时" width="80">
                                <template #default="scope">
                                    {{ convertSeconds(scope.row.singleProcessSecs || 0) }}
                                </template>
                            </el-table-column>
                            <el-table-column prop="amount" label="数量" width="60"></el-table-column>
                        </el-table>
                        <el-pagination background layout="total, prev, pager, next" :total="total" style="margin-top: 12px;" @current-change="handleCurrentChange"></el-pagination>
                    </el-main>
                    <el-footer>
                        <el-button type="primary" @click="goFirstWorkDetail">详情</el-button>
                        <el-button type="primary">输出</el-button>
                    </el-footer>
                </el-container>
            </el-container>
        </el-card>
    </el-main>
</template>
 
<script>
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
let icons = []
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    icons.push(key)
}
import * as echarts from 'echarts';
import MYTree from './MYTree.vue';
export default {
    components: {
        ...ElementPlusIconsVue,MYTree
    },
    data() {
        return {
            searchInfo: {
              "endDate": "",
              "partNo": "",
              "startDate": "",
              "workstationName": ""
            },
            tabPosition: "设备结构树",
            tableData: [],
            treeChecked: [],
            ids: [],
            total: 0,
            current: 1,
            size: 20
        }
    },
    created() {
        // var obj = {test:1}
        // for(var i=0;i<10;i++) {
        //     this.tableData.push(obj);
        // }
    },
    mounted() {
        var date = new Date();
        var threeDaysInMilliseconds = 3 * 24 * 60 * 60 * 1000;
        var threeDaysAgo = new Date(date.getTime() - threeDaysInMilliseconds);
        this.searchInfo.startDate = threeDaysAgo.toLocaleDateString().replace(/\//g,"-");
        this.searchInfo.endDate = date.toLocaleDateString().replace(/\//g,"-");
        this.getTableData();
    },
    methods: {
        handleCurrentChange(val) {
            this.current = val;
            this.getTableData();
        },
        convertSeconds(seconds) {  //转换时间
            // 定义时间单位转换关系
            const daysInSeconds = 24 * 60 * 60;
            const hoursInSeconds = 60 * 60;
            const minutesInSeconds = 60;
 
            // 计算天数
            let days = Math.floor(seconds / daysInSeconds);
            seconds %= daysInSeconds;
 
            // 计算小时数
            let hours = Math.floor(seconds / hoursInSeconds);
            seconds %= hoursInSeconds;
 
            // 计算分钟数
            let minutes = Math.floor(seconds / minutesInSeconds);
            seconds %= minutesInSeconds;
 
            // 准备结果数组
            let result = [];
 
            // 根据需要添加天数到结果数组
            if (days > 0) {
                result.push(`${days}天`);
            }
 
            // 根据需要添加小时数到结果数组
            if (hours > 0) {
                result.push(`${hours}小时`);
            }
 
            // 根据需要添加分钟数到结果数组
            if (minutes > 0) {
                result.push(`${minutes}分钟`);
            }
 
            // 始终添加秒数到结果数组(因为秒数总是有意义的)
            result.push(`${seconds}秒`);
 
            // 返回格式化后的字符串
            return result.join(' ');
        },
        changeStartDate(val) {
        },
        searchBtn() {
            if(!this.searchInfo.startDate || !this.searchInfo.endDate) {
                this.$message.error('选择开始、结束时间查询');
                return;
            }
            this.getTableData();
        },
        getTableData() {
            this.$HTTP.post(`/api/workinghour/page?current=${this.current}&size=${this.size}`, this.searchInfo).then(res => {
                if (res.code === 200) {
                    res.data.records.forEach((item,index)=> {
                        item.index = index + 1;
                    })
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                }
            })
        },
        goFirstWorkDetail() {
            if(this.ids.length == 0) {
                this.$message.error("请先选择数据");
                return;
            }
            this.$router.push({path: `/mdc/first-workpiece-detail`,query: {ids: this.ids.join(',')}})
        },
        handleSelectionChange(val) {
            this.ids = [];
            val.forEach(item=> {
                this.ids.push(item.id);
            })
        },
        query() {
            
        }
    }
}
</script>
 
<style scoped>
    /* .timeAnalysis >>> .el-dialog__body {
        padding-bottom: 0px;
        padding-top: 0px;
    } */
</style>