快乐的昕的电脑
2025-10-22 96a7514a08ef3ca978533510ccde309ef9f3bdd8
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
<template>
    <div class="page">
        <!-- 右上角刷新 -->
        <div class="top-right">
            <button class="refresh-btn" @click="refresh" :disabled="loading">刷新</button>
        </div>
 
        <!-- 状态区 -->
        <div class="middle-section">
            <div class="item notice">
                <h4>说明:先点击调机开始,再点击送检呼叫;成功后两个按钮隐藏。首次首检合格后系统自动写入开工/调机完成时间。</h4>
            </div>
 
            <!-- 调机开始 -->
            <div class="item" v-if="showStartBtn">
                <button class="btn-blue"
                        @click="onStartClick"
                        :disabled="loading">
                    点击调机开始
                </button>
                <input class="txt-inp"
                       v-model="maStartTime"
                       placeholder="点击后记录调机时间"
                       disabled />
                <div class="hint">说明:点击调机开始后,该按钮与送检按钮将根据后续操作隐藏。</div>
            </div>
 
            <!-- 已开始但按钮隐藏时仍显示时间 -->
            <div class="item" v-else>
                <button class="btn-hidden" disabled>调机开始(已记录)</button>
                <input class="txt-inp" v-model="maStartTime" disabled />
            </div>
 
            <!-- 送检呼叫 -->
            <div class="item" v-if="showShoutBtn">
                <button class="btn-blue"
                        @click="onShoutClick"
                        :disabled="loading || !maStartTime">
                    点击送检呼叫
                </button>
                <input class="txt-inp"
                       v-model="maShoutTime"
                       placeholder="点击按钮带出时间"
                       disabled />
                <div class="hint">说明:需先调机开始后才能送检。</div>
            </div>
 
            <!-- 已送检 -->
            <div class="item" v-else>
                <button class="btn-hidden" disabled>送检呼叫(已记录)</button>
                <input class="txt-inp" v-model="maShoutTime" disabled />
            </div>
 
            <!-- 调机完成(首检OK自动写入) -->
            <div class="item">
                <button class="btn-disabled" disabled>
                    首检OK=调机完成=开工
                </button>
                <input class="txt-inp"
                       v-model="maEndTime"
                       placeholder="首次首检确认OK后系统写入"
                       disabled />
                <div class="hint">
                    若首检通过,后端调用 QualifiedInspection 自动写入 MaEndTime 与 StartTime。
                </div>
            </div>
        </div>
 
        <!-- 底部操作 -->
        <div class="bottom-section">
            <button class="save-btn"
                    v-if="!maEndTime"
                    :disabled="loading || !statusForm.id"
                    @click="save">
                保存并生效
            </button>
            <button class="btn-disabled"
                    v-else
                    disabled>
                保存并生效
            </button>
 
            <button class="cancel-btn" :disabled="loading" @click="cancel">
                取消
            </button>
        </div>
 
        <div class="footer-info" v-if="error">
            <span class="error">{{ error }}</span>
        </div>
    </div>
</template>
 
<script>
    export default {
        name: 'AdjustInspect',
        props: {
            orderNo: { type: String, required: true },
            orderId: { type: Number, required: true },
            machineNo: { type: String, required: true }
        },
        data() {
            return {
                maShoutTime: '',
                maStartTime: '',
                maEndTime: '',
                statusForm: {},
                flag: -1,
                loading: false,
                error: '',
                showStartBtn: true,
                showShoutBtn: true
            }
        },
        created() {
            this.loadStatus();
        },
        methods: {
            formatNow() {
                // 使用项目已有的日期工具 (若必须用 this.$getDate 保留)
                return this.$getDate('yyyy-mm-dd hh24:mi:ss');
            },
            async loadStatus() {
                this.loading = true;
                this.error = '';
                try {
                    const res = await this.$post({
                        url: '/MesOrderSta/FindByOrderNo',
                        data: {
                            orderId: this.orderId,
                            orderNo: this.orderNo
                        }
                    });
                    const row = res.data.tbBillList || {};
                    this.statusForm = row;
                    this.maStartTime = row.maStartTime || '';
                    this.maShoutTime = row.maShoutTime || '';
                    this.maEndTime = row.maEndTime || '';
                    // 控制按钮显隐
                    this.showStartBtn = !this.maStartTime;
                    this.showShoutBtn = !this.maShoutTime;
                } catch (e) {
                    this.error = '加载工单状态失败:' + (e.message || e);
                } finally {
                    this.loading = false;
                }
            },
            refresh() {
                this.loadStatus();
            },
            onStartClick() {
                if (this.maStartTime) return;
                this.maStartTime = this.formatNow();
                this.showStartBtn = false;
                // flag 保持 -1,不触发自动首检逻辑
                this.flag = -1;
            },
            onShoutClick() {
                if (!this.maStartTime) {
                    this.$showMessage('请先点击调机开始');
                    return;
                }
                if (this.maShoutTime) return;
                this.maShoutTime = this.formatNow();
                this.showShoutBtn = false;
                this.flag = -1;
            },
            async save() {
                if (!this.statusForm.id) {
                    this.$showMessage('ID为空,不允许推送');
                    return;
                }
                this.loading = true;
                this.error = '';
                try {
                    const res = await this.$post({
                        url: '/MesOrderSta/ChangeMachineTime',
                        data: {
                            maStartTime: this.maStartTime,
                            maShoutTime: this.maShoutTime,
                            maEndTime: this.maEndTime, // 这里通常为空,后端首检通过后自动写入
                            id: this.statusForm.id,
                            orderId: this.orderId,
                            machineNo: this.machineNo,
                            flag: this.flag
                        }
                    });
                    if (res.data.tbBillList) {
                        this.$showMessage('保存成功');
                        await this.loadStatus();
                    } else {
                        this.$showMessage('保存失败');
                        this.cancel();
                    }
                } catch (e) {
                    this.error = '保存异常:' + (e.message || e);
                    this.$showMessage('保存异常');
                } finally {
                    this.loading = false;
                }
            },
            cancel() {
                // 回退到上次加载状态
                this.maStartTime = this.statusForm.maStartTime || '';
                this.maShoutTime = this.statusForm.maShoutTime || '';
                this.maEndTime = this.statusForm.maEndTime || '';
                this.showStartBtn = !this.maStartTime;
                this.showShoutBtn = !this.maShoutTime;
            }
        }
    }
</script>
 
<style scoped>
    .page {
        padding: 2vh;
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        height: 100%;
        position: relative;
    }
 
    .top-right {
        position: absolute;
        top: 10px;
        right: 50px;
        z-index: 10;
    }
 
    .refresh-btn {
        padding: 10px;
        background-color: #00A2E9;
        color: #fff;
        font-size: 1.2vw;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }
 
    .middle-section {
        display: flex;
        flex-direction: column;
        gap: 18px;
        margin-top: 60px;
    }
 
    .item {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 20px;
    }
 
        .item.notice {
            height: auto;
        }
 
    button {
        width: 28%;
        min-width: 200px;
        padding: 14px;
        font-size: 1.1vw;
        border: none;
        cursor: pointer;
        border-radius: 4px;
    }
 
    .btn-blue {
        background-color: #00A2E9;
        color: #fff;
    }
 
    .btn-disabled {
        background-color: #9d9d9d;
        color: #fff;
        cursor: not-allowed;
    }
 
    .btn-hidden {
        background-color: #d0d0d0;
        color: #666;
        cursor: not-allowed;
    }
 
    .txt-inp {
        flex: 1;
        height: 54px;
        padding: 10px;
        font-size: 1.0vw;
        border: 1px solid #ccc;
        border-radius: 4px;
        box-sizing: border-box;
    }
 
    .hint {
        flex: 0 0 240px;
        font-size: 0.9vw;
        color: #b40000;
        line-height: 1.4;
    }
 
    .bottom-section {
        display: flex;
        justify-content: space-between;
        margin-top: auto;
        gap: 20px;
        padding-top: 30px;
    }
 
    .save-btn,
    .cancel-btn {
        width: 48%;
        padding: 16px;
        background-color: #00A2E9;
        color: #fff;
        font-size: 1.2vw;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }
 
        .save-btn:disabled,
        .cancel-btn:disabled {
            background-color: #7fbfdc;
            cursor: not-allowed;
        }
 
    .footer-info {
        margin-top: 16px;
        font-size: 0.9vw;
    }
 
    .error {
        color: #d40000;
    }
</style>