Houjie
4 天以前 30590221cd34912a61f4734ea474859a0df98be6
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<template>
    <view class="container">
        <cu-custom :bgColor="NavBarColor" :isBack="true" backRouterName="productionTask">
            <block slot="backText">返回</block>
            <block slot="content">安灯处理</block>
        </cu-custom>
 
        <uni-forms ref="form" :modelValue="formData" :rules="rules" validate-trigger="submit" err-show-type="undertext">
            <uni-group top="10">
                <uni-forms-item name="factoryId" label="产线:" :label-width="100" :required="true">
                    <uni-data-select :localdata="formData.msListCategory" popup-title="请选择" @change="changeLine"
                        :disabled="true" :clear="false" v-model="formData.factoryId">
                    </uni-data-select>
                </uni-forms-item>
 
                <uni-forms-item name="buttonId" label="安灯类型:" :label-width="100">
                    <uni-data-select :localdata="formData.handleList" popup-title="请选择" :disabled="true"
                        @change="changehnadle" :clear="false" v-model="formData.buttonId">
                    </uni-data-select>
                </uni-forms-item>
 
                <uni-forms-item name="andonTime" :label-width="100" label="安灯时间:">
                    <uni-datetime-picker type="datetime" :disabled="true" v-model="formData.andonTime" />
                </uni-forms-item>
 
                <uni-forms-item name="andonLevel" :label-width="100" label="安灯等级:">
                    <uni-data-select :localdata="formData.andonLevel" popup-title="请选择" @change="changeLevel"
                        :clear="false" :disabled="true" v-model="formData.andonLevelValue">
                    </uni-data-select>
                </uni-forms-item>
 
                <uni-forms-item name="orderStatus" :label-width="100" label="安灯状态:">
                    <uni-data-select :localdata="formData.andonStatus" popup-title="请选择" @change="changeStatus"
                        :disabled="true" :clear="false" v-model="formData.orderStatus">
                    </uni-data-select>
                </uni-forms-item>
                <uni-forms-item name="num" :label-width="100" label="安灯发起人:">
                    <uni-easyinput v-model="formData.operator" :disabled="true" />
                </uni-forms-item>
                <uni-forms-item name="num" :label-width="100" label="处理人:">
                    <uni-easyinput v-model="formData.realname" :disabled="true" />
                </uni-forms-item>
                <uni-forms-item name="num" :label-width="100" label="响应人:">
                    <uni-easyinput v-model="formData.realname" :disabled="true" />
                </uni-forms-item>
                <uni-forms-item name="problemDescreption" :label-width="100" label="问题描述:">
                    <uni-easyinput type="textarea" placeholder="请输入问题描述" v-model="formData.problemDescreption"
                        :maxlength="500" />
                </uni-forms-item>
 
                <uni-forms-item name="resolutionDescreption" :label-width="100" label="处理结果描述:">
                    <uni-easyinput type="textarea" placeholder="请输入处理结果描述" v-model="formData.resolutionDescreption"
                        :maxlength="500" />
                </uni-forms-item>
            </uni-group>
        </uni-forms>
 
        <button class="margin-bottom" type="primary" @click="submitForm">确定</button>
    </view>
</template>
 
<script>
    import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
 
    export default {
        mixins: [MescrollMixin],
        data() {
            return {
                NavBarColor: this.NavBarColor,
                url: {
                    add: "andonorder/andonOrder/AndonHandel",
                    andonLevel: "sys/dict/getDictItems/andon_level",
                    andonStatus: "sys/dict/getDictItems/order_status",
                    andonType: 'sys/dict/getDictItems/andon_button_config,button_name,id',
                    andonCategory: "base/factory/queryUserProductionLineList"
                },
 
                formData: {
                    operator:'',
                    orderIds: '',
                    handleList: [],
                    msListCategory: [],
                    andonLevel: [],
                    andonStatus: [],
                    problemDescreption: '',
                    resolutionDescreption: '',
                    andonTime: Date.now(),
                    factoryId: '',
                    buttonId: '',
                    andonLevelValue: '',
                    orderStatus: '',
                    realname: '',
                    userId: ''
                },
 
                receivedItem: {},
                currentLineId: '',
                // 表单验证规则
                rules: {
                    factoryId: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择产线'
                        }]
                    },
                    buttonId: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择安灯类型'
                        }]
                    },
                    andonTime: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择安灯时间'
                        }]
                    },
                    andonLevelValue: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择安灯等级'
                        }]
                    },
                    orderStatus: {
                        rules: [{
                            required: true,
                            errorMessage: '请选择安灯状态'
                        }]
                    }
                }
            }
        },
        onLoad(options) {
            // 接收 item 参数(需要解码并转换回对象)
            if (options.item) {
                // 先解码再转成对象
                this.receivedItem = JSON.parse(decodeURIComponent(options.item));
 
            }
            
            this.formData.orderIds = this.receivedItem.id;
            this.formData.factoryId = options.currentLineId;
            this.formData.orderStatus = this.receivedItem.orderStatus;
            this.formData.operator=this.receivedItem.operatorName;
            this.formData.andonLevelValue = this.receivedItem.andonLevel;
            this.formData.realname = this.receivedItem.responder;
            this.formData.buttonId = this.receivedItem.buttonId;
            console.log('接收的item参数:', this.receivedItem);
 
        },
        created() {
            this.loadData();
        },
 
        methods: {
            serialNumScan() {
                uni.navigateTo({
                    url: "/pages/selectUsers/selectUsers"
                })
            },
            // 加载所有下拉列表数据
            loadData() {
                // 并行加载多个接口,优化性能
                Promise.all([
                    this.andonCategory(),
                    this.andonType(),
                    this.andonLevel(),
                    this.andonStatus()
                ]).then(() => {
                    console.log('所有数据加载完成');
                }).catch(() => {
                    uni.showToast({
                        title: '数据加载失败',
                        icon: 'none'
                    });
                });
            },
 
 
            // 产线变更
            changeLine(e) {
                this.formData.factoryId = e;
            },
 
            // 安灯类型变更
            changehnadle(e) {
                this.formData.buttonId = e;
            },
 
            // 安灯等级变更
            changeLevel(e) {
                this.formData.andonLevelValue = e;
            },
 
            // 安灯状态变更
            changeStatus(e) {
                this.formData.orderStatus = e;
            },
 
            // 获取产线列表
            andonCategory() {
                return new Promise((resolve, reject) => {
                    this.$http.get(this.url.andonCategory).then(res => {
                        if (res.data.success) {
                            this.formData.msListCategory = res.data.result;
                            resolve();
                        } else {
                            reject();
                        }
                    }).catch(() => {
                        uni.showToast({
                            title: '产线数据加载失败',
                            icon: 'none'
                        });
                        reject();
                    });
                });
            },
 
            // 获取安灯类型列表
            andonType() {
                return new Promise((resolve, reject) => {
                    this.$http.get(this.url.andonType).then(res => {
                        if (res.data.success) {
                            this.formData.handleList = res.data.result;
                            resolve();
                        } else {
                            reject();
                        }
                    }).catch(() => {
                        uni.showToast({
                            title: '安灯类型加载失败',
                            icon: 'none'
                        });
                        reject();
                    });
                });
            },
 
            // 获取安灯等级列表
            andonLevel() {
                return new Promise((resolve, reject) => {
                    this.$http.get(this.url.andonLevel).then(res => {
                        if (res.data.success) {
                            this.formData.andonLevel = res.data.result;
                            resolve();
                        } else {
                            reject();
                        }
                    }).catch(() => {
                        uni.showToast({
                            title: '安灯等级加载失败',
                            icon: 'none'
                        });
                        reject();
                    });
                });
            },
 
            // 获取安灯状态列表
            andonStatus() {
                return new Promise((resolve, reject) => {
                    this.$http.get(this.url.andonStatus).then(res => {
                        if (res.data.success) {
                            this.formData.andonStatus = res.data.result;
                            resolve();
                        } else {
                            reject();
                        }
                    }).catch(() => {
                        uni.showToast({
                            title: '安灯状态加载失败',
                            icon: 'none'
                        });
                        reject();
                    });
                });
            },
 
            // 表单提交
            submitForm() {
                this.AddLoadMaterial();
 
            },
 
            // 提交安灯工单
            AddLoadMaterial() {
                /**
                 * 安灯人- 发起人
                 */
                // 显示加载中
                uni.showLoading({
                    title: '提交中...'
                });
                this.$http.post(this.url.add, {
                    andonLevel: this.formData.andonLevelValue,
                    buttonId: this.formData.buttonId,
                    factoryId: this.formData.factoryId,
                    id: this.formData.orderIds,
                    operateTime: this.formData.andonTime,
                    operator:this.formData.operator,
                    responder: this.formData.realname,
                    processor: this.formData.realname,
                    orderStatus: this.formData.orderStatus,
                    problemDescreption: this.formData.problemDescreption,
                    resolutionDescreption: this.formData.resolutionDescreption
                }).then(res => {
                    uni.hideLoading();
 
                    if (res.data.success) {
                        uni.showModal({
                            title: '成功',
                            content: res.data.message || '处理成功',
                            showCancel: false,
                            success: () => {
                                uni.reLaunch({
                                    url:'/pages/eam/andon/andonCall/andonCall'
                                })
                            }
                        });
                    } else {
                        uni.showModal({
                            title: '提示',
                            content: res.data.message || '提交失败,请重试',
                            showCancel: false
                        });
                    }
                }).catch(() => {
                    uni.hideLoading();
                    uni.showToast({
                        title: '网络异常,请稍后再试',
                        icon: 'none'
                    });
                });
            }
        }
    }
</script>
 
<style scoped>
    .container {
        background-color: #f5f5f5;
        min-height: 100vh;
    }
 
    .margin-bottom {
        margin: 30px 30px 50px;
        width: calc(100% - 60px);
    }
 
    uni-easyinput[type="textarea"] {
        min-height: 100px;
    }
 
    /* 优化表单项间距 */
    uni-forms-item {
        margin-bottom: 10px;
    }
</style>