快乐的昕的电脑
2025-11-14 7159779fb191a9f56710ba34f922678af4c2dceb
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
<template>
    <view class="parameter-page">
        <!-- 获取参数按钮 -->
        <button class="fetch-btn" @click="dialogToggle">获取当前参数</button>
 
        <!-- 参数表格,分为两列 -->
        <view class="parameter-table">
            <!-- 左列参数 -->
            <view class="parameter-column">
                <view class="table-row header">
                    <text class="table-cell txt">参数名</text>
                    <text class="table-cell txt">参数值</text>
                </view>
                <view v-for="(param, index) in firstHalf" :key="index" class="table-row">
                    <view class="table-cell">
                        <input class="parameter-name" v-model="param.field" disabled="true" />
                    </view>
                    <view class="table-cell">
                        <input class="parameter-value" v-model="param.value" disabled="true" />
                    </view>
                </view>
            </view>
 
            <!-- 右列参数 -->
            <view class="parameter-column">
                <view class="table-row header">
                    <text class="table-cell txt">参数名</text>
                    <text class="table-cell txt">参数值</text>
                </view>
                <view v-for="(param, index) in secondHalf" :key="index" class="table-row">
                    <view class="table-cell">
                        <input class="parameter-name" v-model="param.field" disabled="true" />
                    </view>
                    <view class="table-cell">
                        <input class="parameter-value" v-model="param.value" disabled="true" />
                    </view>
                </view>
            </view>
 
            <view class="parameter-column">
                <view class="table-row header">
                    <text class="table-cell txt">参数名</text>
                    <text class="table-cell txt">参数值</text>
                </view>
                <view v-for="(param, index) in secondHalf1" :key="index" class="table-row">
                    <view class="table-cell">
                        <input class="parameter-name" v-model="param.field" disabled="true" />
                    </view>
                    <view class="table-cell">
                        <input class="parameter-value" v-model="param.value" disabled="true" />
                    </view>
                </view>
            </view>
 
            <view class="parameter-column">
                <view class="table-row header">
                    <text class="table-cell txt">参数名</text>
                    <text class="table-cell txt">参数值</text>
                </view>
                <view v-for="(param, index) in secondHalf2" :key="index" class="table-row">
                    <view class="table-cell">
                        <input class="parameter-name" v-model="param.field" disabled="true" />
                    </view>
                    <view class="table-cell">
                        <input class="parameter-value" v-model="param.value" disabled="true" />
                    </view>
                </view>
            </view>
        </view>
        
         
    </view>
    
    
</template>
 
<script>
    export default {
        props: {
            orderNo: String,
            orderId: Number,
            machineNo: String
        },
        data() {
            return {
                parameters: [], // 参数集合
                firstHalf: [], // 第一半部分参数
                secondHalf: [], // 第二半部分参数
                secondHalf1: [], // 第三半部分参数
                secondHalf2: [] // 第四半部分参数
            };
        },
        created() {
 
            // let machine = uni.getStorageSync('machine');
            // let orderId = uni.getStorageSync('orderId');
            // let orderNo = uni.getStorageSync('orderNo');
 
            // if (orderId) {
            //     this.orderId = orderId;
            // } else {
            //     if (!this.orderId) {
            //         this.orderId = uni.getStorageSync('id');
            //     }
 
            // }
 
            // if (orderNo) {
            //     this.orderNo = orderNo;
            // } else {
            //     if (!this.orderNo) {
            //         this.orderNo = uni.getStorageSync('daa001');
            //     }
            // }
 
            // if (machine) {
            //     this.machineNo = machine;
            // } else {
            //     if (!this.machineNo) {
            //         this.machineNo = uni.getStorageSync('machineNo');
            //     }
            // }
 
            if (!this.orderId && !this.orderNo) {
                return;
            }
 
            this.fetchParameters();
        },
        methods: {
 
            dialogToggle() {
                let thit = this;
                uni.showModal({
                        title: '提示',
                        content: '确认重新获取工艺参数吗?',
                        success: function(res) {
                        if (res.confirm) {
                            // 执行确认后的操作
                            thit.manualSynchronization();
                        } 
                        else {
                            // 执行取消后的操作
                        }
                    }
                })
                 
            },
 
            fetchParameters() {
                this.$post({
                    url: "/DeviceMetrics/GetListByOrderNo",
                    data: {
                        orderNo: this.orderNo,
                        orderId: this.orderId,
                    }
                }).then(res => {
                    this.parameters = res.data.tbBillList;
                    this.splitParameters(); // 分割参数
                }).catch(err => {
                    console.error("获取参数失败:", err);
                });
            },
            manualSynchronization() {
                console.log(111);
                this.$sendPostRequest({
                    url: "http://192.168.0.94:9095/Numerical/manualSynchronizationBycl",
                    data: {
                        orderId: this.orderId,
                        machineNo: this.machineNo
                    },
                    contentType: "application/json"
                }).then(res1 => {
                    if (res1.code == 200) {
                        this.fetchParameters();
                        this.$showMessage("更新成功");
                    } else {
                        this.$showMessage("同步失败");
                    }
                });
                
                
            },
            // 将参数分成两部分
            splitParameters() {
                // const chunkSize = Math.ceil(this.parameters.length / 4);
                // this.firstHalf = this.parameters.slice(0, chunkSize), // 第一列
                //     this.secondHalf = this.parameters.slice(chunkSize, chunkSize * 2), // 第二列
                //     this.secondHalf1 = this.parameters.slice(chunkSize * 2, chunkSize * 3), // 第三列
                //     this.secondHalf2 = this.parameters.slice(chunkSize * 3) // 第四列 
                let groupedData = this.groupByGroupSeq(this.parameters);
                this.firstHalf = groupedData.get(1); // Group with groupSeq 1
                this.secondHalf = groupedData.get(2); // Group with groupSeq 2
                this.secondHalf1 = groupedData.get(3); // Group with groupSeq 3
                this.secondHalf2 = groupedData.get(4); // Group with groupSeq 4
            },
            groupByGroupSeq(data) {
                const acc = new Map(); // Initialize Map to store groups
 
                // Loop through all items and assign them to the correct group
                for (let i = 0; i < data.length; i++) {
                    const item = data[i];
                    if (!acc.has(item.groupSeq)) {
                        acc.set(item.groupSeq, []); // Initialize array for new groupSeq
                    }
                    acc.get(item.groupSeq).push(item); // Push item into the corresponding group
                }
 
                return acc;
            }
        }
    };
</script>
 
<style scoped>
    .parameter-page {
        padding: 20px;
    }
 
    .fetch-btn {
        display: block;
        width: 100%;
        margin-bottom: 20px;
        background-color: #007bff;
        color: white;
        text-align: center;
        font-size: 32px !important;
        padding: 18px 0;
    }
 
    .parameter-table {
        display: flex;
        justify-content: space-between;
        font-size: 28px !important;
    }
 
    .parameter-column {
        flex: 1;
    }
 
    .table-row {
        display: flex;
        justify-content: space-between;
    }
 
    .header {
        background-color: #f0f0f0;
        font-weight: bold;
        font-size: 32px !important;
    }
 
    .table-cell {
        flex: 1;
        padding: 5px;
        border: 1px solid #ccc;
    }
 
    .txt {
        text-align: center;
        padding: 10px 0;
    }
 
    .parameter-name {
        text-align: center;
        background-color: transparent;
        border: none;
    }
 
    .parameter-value {
        text-align: center;
        border: none;
        padding: 5px;
        background-color: transparent;
    }
 
    .table-row,
    .table-cell,
    .parameter-name,
    .parameter-value,
    .txt {
        font-size: 28px !important;
    }
 
</style>