2764b83e
刘淇
分配养护员
|
1
2
3
4
5
6
7
|
<template>
<view class="page-container">
<view class="work-order-form-content commonPageLRpadding">
<up-form
label-position="left"
:model="workOrderForm"
ref="workOrderFormRef"
|
5059c4dd
刘淇
养护员提交养护工单
|
8
|
labelWidth="170rpx"
|
2764b83e
刘淇
分配养护员
|
9
|
>
|
dacff5e3
刘淇
养护员退回
|
10
|
<!-- 1. 工单编号(只读展示,从缓存获取) -->
|
2764b83e
刘淇
分配养护员
|
11
12
13
14
15
16
17
18
19
20
21
22
|
<up-form-item
label="工单编号"
border-bottom
>
<up-input
v-model="workOrderForm.orderNo"
border="none"
readonly
placeholder="暂无工单编号"
></up-input>
</up-form-item>
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<!-- 2. 作业类型(决定加载哪套动态字段配置:数据中心/业务类型字段配置 配置归属=工单) -->
<up-form-item
label="作业类型"
prop="workTypeName"
required
border-bottom
@click="openWorkTypeSheet(); hideKeyboard()"
>
<up-input
v-model="workOrderForm.workTypeName"
disabled
disabled-color="#ffffff"
placeholder="请选择作业类型"
border="none"
></up-input>
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-form-item>
<!-- 3. 共同处理人(支持多选) -->
|
2764b83e
刘淇
分配养护员
|
44
45
46
47
48
49
50
|
<up-form-item
label="共同处理人"
prop="coProcessorName"
border-bottom
@click="handleActionSheetOpen('coProcessor'); hideKeyboard()"
>
<up-input
|
371cf0eb
刘淇
流程节点
|
51
|
v-model="workOrderForm.coProcessorNameStr"
|
2764b83e
刘淇
分配养护员
|
52
53
|
disabled
disabled-color="#ffffff"
|
5059c4dd
刘淇
养护员提交养护工单
|
54
|
placeholder="请选择共同处理人"
|
2764b83e
刘淇
分配养护员
|
55
56
57
58
59
60
61
|
border="none"
></up-input>
<template #right>
<up-icon name="arrow-right" size="16"></up-icon>
</template>
</up-form-item>
|
fa775c6b
刘淇
养护计划调整
|
62
|
<!-- 3. 处理建议(处理情况描述,必填) -->
|
2764b83e
刘淇
分配养护员
|
63
|
<up-form-item
|
5059c4dd
刘淇
养护员提交养护工单
|
64
|
label="处理情况"
|
2764b83e
刘淇
分配养护员
|
65
66
67
68
|
prop="reason"
required
>
<up-textarea
|
fa775c6b
刘淇
养护计划调整
|
69
|
placeholder="请输入处理情况描述(必填,最多200字)"
|
2764b83e
刘淇
分配养护员
|
70
71
72
|
v-model.trim="workOrderForm.reason"
count
maxlength="200"
|
5059c4dd
刘淇
养护员提交养护工单
|
73
|
rows="5"
|
2764b83e
刘淇
分配养护员
|
74
75
76
77
|
@blur="() => workOrderFormRef.validateField('reason')"
></up-textarea>
</up-form-item>
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<!-- 4. 动态字段:按「业务类型(busiLine) + 作业类型」加载数据中心配置的工单填报项 -->
<view class="dynamic-field-block" v-if="workOrderForm.workTypeId">
<view class="dynamic-field-title">作业填报</view>
<work-field-form
ref="workFieldFormRef"
:business-type="workOrderForm.businessType"
:biz-type="1"
:work-type-id="workOrderForm.workTypeId"
@loaded="onDynamicFieldsLoaded"
></work-field-form>
<view class="dynamic-field-empty" v-if="dynamicFieldCount === 0">
<text>该作业类型暂无需填报项</text>
</view>
</view>
|
5059c4dd
刘淇
养护员提交养护工单
|
93
94
95
96
97
98
99
100
101
|
<!-- Tabs标签栏(图片切换:开始、进行中、结束、人员、材料)- 改造后 -->
<view class="tabs-wrap " style="margin-top: 30rpx;">
<up-tabs
v-model="activeTab"
:list="tabList"
line-width="40rpx"
active-color="#1989fa"
inactive-color="#666666"
@change = "imgTabChange"
|
e6a04285
刘淇
单图情况 宽高70*70
|
102
|
|
5059c4dd
刘淇
养护员提交养护工单
|
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
>
<!-- 使用content插槽自定义每个tab的内容,添加红色*号 -->
<template #content="{ item, index }">
<view class="tab-item-content">
<!-- 给索引0(开始)和索引2(结束)添加红色*号 -->
<text v-if="index === 0 || index === 2" class="required-star">*</text>
<text class="tab-text">{{ item.name }}</text>
</view>
</template>
</up-tabs>
<view class="tab-content" style="padding-top: 20rpx; background: #fff; padding-bottom: 20rpx;">
<!-- 开始阶段图片上传 -->
<view v-if="activeTab == 0">
<up-form-item prop="startImgs">
<up-upload
|
6c3b6516
刘淇
快速工单 加上业务线
|
118
|
:file-list="startImgs.rawImgList.value|| []"
|
5059c4dd
刘淇
养护员提交养护工单
|
119
120
121
122
123
124
125
126
127
128
129
130
131
|
@after-read="startImgs.uploadImgs"
@delete="startImgs.deleteImg"
multiple
:max-count="startImgs.uploadConfig.maxCount"
:upload-text="startImgs.uploadConfig.uploadText"
:size-type="startImgs.uploadConfig.sizeType"
></up-upload>
</up-form-item>
</view>
<!-- 进行中阶段图片上传 -->
<view v-if="activeTab == 1">
<up-form-item prop="processingImgs">
<up-upload
|
6c3b6516
刘淇
快速工单 加上业务线
|
132
|
:file-list="processingImgs.rawImgList.value|| []"
|
5059c4dd
刘淇
养护员提交养护工单
|
133
134
135
136
137
138
139
140
141
142
143
144
145
|
@after-read="processingImgs.uploadImgs"
@delete="processingImgs.deleteImg"
multiple
:max-count="processingImgs.uploadConfig.maxCount"
:upload-text="processingImgs.uploadConfig.uploadText"
:size-type="processingImgs.uploadConfig.sizeType"
></up-upload>
</up-form-item>
</view>
<!-- 结束阶段图片上传 -->
<view v-if="activeTab == 2">
<up-form-item prop="endImgs">
<up-upload
|
6c3b6516
刘淇
快速工单 加上业务线
|
146
|
:file-list="endImgs.rawImgList.value|| []"
|
5059c4dd
刘淇
养护员提交养护工单
|
147
148
149
150
151
152
153
154
155
156
157
158
159
|
@after-read="endImgs.uploadImgs"
@delete="endImgs.deleteImg"
multiple
:max-count="endImgs.uploadConfig.maxCount"
:upload-text="endImgs.uploadConfig.uploadText"
:size-type="endImgs.uploadConfig.sizeType"
></up-upload>
</up-form-item>
</view>
<!-- 人员配置图片上传 -->
<view v-if="activeTab == 3">
<up-form-item prop="personImgs">
<up-upload
|
6c3b6516
刘淇
快速工单 加上业务线
|
160
|
:file-list="personImgs.rawImgList.value|| []"
|
5059c4dd
刘淇
养护员提交养护工单
|
161
162
163
164
165
166
167
168
169
170
171
172
173
|
@after-read="personImgs.uploadImgs"
@delete="personImgs.deleteImg"
multiple
:max-count="personImgs.uploadConfig.maxCount"
:upload-text="personImgs.uploadConfig.uploadText"
:size-type="personImgs.uploadConfig.sizeType"
></up-upload>
</up-form-item>
</view>
<!-- 材料使用图片上传 -->
<view v-if="activeTab == 4">
<up-form-item prop="materialImgs">
<up-upload
|
6c3b6516
刘淇
快速工单 加上业务线
|
174
|
:file-list="materialImgs.rawImgList.value|| []"
|
5059c4dd
刘淇
养护员提交养护工单
|
175
176
177
178
179
180
181
182
183
|
@after-read="materialImgs.uploadImgs"
@delete="materialImgs.deleteImg"
multiple
:max-count="materialImgs.uploadConfig.maxCount"
:upload-text="materialImgs.uploadConfig.uploadText"
:size-type="materialImgs.uploadConfig.sizeType"
></up-upload>
</up-form-item>
</view>
|
fa775c6b
刘淇
养护计划调整
|
184
|
</view>
|
2764b83e
刘淇
分配养护员
|
185
|
</view>
|
fa775c6b
刘淇
养护计划调整
|
186
|
</up-form>
|
2764b83e
刘淇
分配养护员
|
187
188
|
</view>
|
fa775c6b
刘淇
养护计划调整
|
189
|
<!-- 底部提交按钮(保留,按需可移除) -->
|
2764b83e
刘淇
分配养护员
|
190
191
192
193
194
195
196
197
|
<view class="fixed-bottom-btn-wrap">
<up-button
type="primary"
text="提交工单"
@click="submitWorkOrder"
></up-button>
</view>
|
fa775c6b
刘淇
养护计划调整
|
198
|
<!-- 通用下拉弹窗(仅用于共同处理人多选) -->
|
2764b83e
刘淇
分配养护员
|
199
200
201
202
203
204
205
|
<up-action-sheet
:show="showActionSheet"
:actions="currentActionSheetData.list"
:title="currentActionSheetData.title"
@close="handleActionSheetClose"
@select="handleActionSheetSelect"
></up-action-sheet>
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
206
207
208
209
210
211
212
213
214
215
|
<!-- 作业类型选择弹窗(字典 maintain_type) -->
<up-action-sheet
:show="showWorkTypeSheet"
:actions="workTypeOptions"
title="请选择作业类型"
cancel-text="取消"
@close="showWorkTypeSheet = false"
@select="onWorkTypeSelect"
></up-action-sheet>
|
2764b83e
刘淇
分配养护员
|
216
217
218
219
|
</view>
</template>
<script setup>
|
fa775c6b
刘淇
养护计划调整
|
220
221
|
import { ref, reactive, watch } from 'vue'
import { onLoad, onReady, onShow } from '@dcloudio/uni-app';
|
2764b83e
刘淇
分配养护员
|
222
|
import { useUploadImgs } from '@/common/utils/useUploadImgs'
|
5059c4dd
刘淇
养护员提交养护工单
|
223
|
import { getYlWorkersPage, universalApproval } from '@/api/work-order-manage/work-order-manage'
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
224
|
import { workRecordSubmit } from '@/api/common'
|
5059c4dd
刘淇
养护员提交养护工单
|
225
|
import { nextStepMap } from '@/common/utils/common'
|
fa775c6b
刘淇
养护计划调整
|
226
|
import { useUserStore } from '@/pinia/user';
|
fa775c6b
刘淇
养护计划调整
|
227
|
const userStore = useUserStore();
|
2764b83e
刘淇
分配养护员
|
228
|
|
fa775c6b
刘淇
养护计划调整
|
229
230
|
// 表单Ref
const workOrderFormRef = ref(null)
|
2764b83e
刘淇
分配养护员
|
231
|
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
// 作业填报动态表单Ref(components/work-field-form)
const workFieldFormRef = ref(null)
// 作业类型选择弹窗
const showWorkTypeSheet = ref(false)
// 作业类型选项:字典 maintain_type(打开弹窗时取,避免字典异步加载导致首次为空)
const workTypeOptions = ref([])
// 当前作业类型下的动态字段数量(0 时给「无需填报」提示)
const dynamicFieldCount = ref(0)
// 动态字段提交幂等流水号:同一页面生命周期内保持不变,网络重试只落一条记录
let workRecordClientSeq = ''
|
fa775c6b
刘淇
养护计划调整
|
246
|
// 页面状态
|
2764b83e
刘淇
分配养护员
|
247
248
249
250
|
const showActionSheet = ref(false)
const currentActionSheetData = reactive({
type: '',
list: [],
|
fa775c6b
刘淇
养护计划调整
|
251
|
title: '',
|
2764b83e
刘淇
分配养护员
|
252
|
})
|
2764b83e
刘淇
分配养护员
|
253
|
|
fa775c6b
刘淇
养护计划调整
|
254
255
|
// Tabs配置(图片切换用)
const activeTab = ref(0)
|
2764b83e
刘淇
分配养护员
|
256
257
258
259
260
261
262
263
|
const tabList = ref([
{ name: '开始' },
{ name: '进行中' },
{ name: '结束' },
{ name: '人员' },
{ name: '材料' }
])
|
fa775c6b
刘淇
养护计划调整
|
264
265
|
// 共同处理人列表
const coProcessorList = ref([])
|
2764b83e
刘淇
分配养护员
|
266
|
|
371cf0eb
刘淇
流程节点
|
267
|
// 工单表单数据(修改:新增coProcessorName数组,coProcessorNameStr用于页面展示)
|
2764b83e
刘淇
分配养护员
|
268
|
const workOrderForm = reactive({
|
6c3b6516
刘淇
快速工单 加上业务线
|
269
|
busiLine:'',
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
270
271
272
|
businessType:'', // 业务类型(由 busiLine 首段得出,用于加载动态字段配置)
workTypeId:'', // 作业类型ID(字典 maintain_type,用于加载动态字段配置)
workTypeName:'', // 作业类型名称(页面展示)
|
5059c4dd
刘淇
养护员提交养护工单
|
273
274
|
workerDataId:'',
taskId:'', // 任务id
|
fa775c6b
刘淇
养护计划调整
|
275
|
orderNo: '', // 工单编号
|
371cf0eb
刘淇
流程节点
|
276
277
278
|
coProcessorId: [], // 共同处理人ID数组(多选,改为数组格式)
coProcessorName: [], // 共同处理人名称数组(多选,数组格式,用于提交)
coProcessorNameStr: '', // 共同处理人名称字符串(用于页面输入框展示)
|
fa775c6b
刘淇
养护计划调整
|
279
280
281
282
283
284
285
|
reason: '', // 处理情况描述
})
// ========== 图片上传配置(5个Tab分别配置,均限制3张,与参考示例一致) ==========
// 开始阶段图片
const startImgs = useUploadImgs({
maxCount: 3,
|
5059c4dd
刘淇
养护员提交养护工单
|
286
|
uploadText: '选择开始照片',
|
fa775c6b
刘淇
养护计划调整
|
287
288
289
290
291
292
293
|
sizeType: ['compressed'],
formRef: workOrderFormRef,
fieldName: 'startImgs'
})
// 进行中阶段图片
const processingImgs = useUploadImgs({
maxCount: 3,
|
5059c4dd
刘淇
养护员提交养护工单
|
294
|
uploadText: '选择进行中照片',
|
fa775c6b
刘淇
养护计划调整
|
295
296
297
298
299
300
301
|
sizeType: ['compressed'],
formRef: workOrderFormRef,
fieldName: 'processingImgs'
})
// 结束阶段图片
const endImgs = useUploadImgs({
maxCount: 3,
|
5059c4dd
刘淇
养护员提交养护工单
|
302
|
uploadText: '选择结束照片',
|
fa775c6b
刘淇
养护计划调整
|
303
304
305
|
sizeType: ['compressed'],
formRef: workOrderFormRef,
fieldName: 'endImgs'
|
2764b83e
刘淇
分配养护员
|
306
|
})
|
fa775c6b
刘淇
养护计划调整
|
307
308
309
|
// 人员配置图片
const personImgs = useUploadImgs({
maxCount: 3,
|
5059c4dd
刘淇
养护员提交养护工单
|
310
|
uploadText: '选择人员照片',
|
fa775c6b
刘淇
养护计划调整
|
311
312
313
314
315
316
317
|
sizeType: ['compressed'],
formRef: workOrderFormRef,
fieldName: 'personImgs'
})
// 材料使用图片
const materialImgs = useUploadImgs({
maxCount: 3,
|
5059c4dd
刘淇
养护员提交养护工单
|
318
|
uploadText: '选择材料照片',
|
fa775c6b
刘淇
养护计划调整
|
319
320
321
322
323
|
sizeType: ['compressed'],
formRef: workOrderFormRef,
fieldName: 'materialImgs'
})
|
6c3b6516
刘淇
快速工单 加上业务线
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
// // ========== 核心修复:监听每个上传实例的响应式数组变化,解决u-upload不刷新问题 ==========
// watch(() => startImgs.rawImgList.value, (newVal) => {
// startImgs.imgList = newVal
// }, { deep: true })
//
// watch(() => processingImgs.rawImgList.value, (newVal) => {
// processingImgs.imgList = newVal
// }, { deep: true })
//
// watch(() => endImgs.rawImgList.value, (newVal) => {
// endImgs.imgList = newVal
// }, { deep: true })
//
// watch(() => personImgs.rawImgList.value, (newVal) => {
// personImgs.imgList = newVal
// }, { deep: true })
//
// watch(() => materialImgs.rawImgList.value, (newVal) => {
// materialImgs.imgList = newVal
// }, { deep: true })
|
2764b83e
刘淇
分配养护员
|
344
|
|
fa775c6b
刘淇
养护计划调整
|
345
|
// 表单校验规则(新增5个图片字段校验,复用上传校验规则)
|
2764b83e
刘淇
分配养护员
|
346
|
const workOrderFormRules = reactive({
|
fa775c6b
刘淇
养护计划调整
|
347
|
orderNo: [
|
2764b83e
刘淇
分配养护员
|
348
349
|
{ type: 'string', trigger: ['change'] }
],
|
fa775c6b
刘淇
养护计划调整
|
350
351
352
353
|
reason: [
{ type: 'string', required: true, message: '请输入处理情况描述', trigger: ['change', 'blur'] },
{ type: 'string', max: 200, message: '处理情况描述最多200字', trigger: ['change', 'blur'] }
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
354
355
356
|
],
workTypeName: [
{ type: 'string', required: true, message: '请选择作业类型', trigger: ['change'] }
|
dacff5e3
刘淇
养护员退回
|
357
|
]
|
2764b83e
刘淇
分配养护员
|
358
359
|
})
|
dacff5e3
刘淇
养护员退回
|
360
|
// 生命周期 - 从本地缓存获取完整工单数据
|
2764b83e
刘淇
分配养护员
|
361
|
onLoad((options) => {
|
dacff5e3
刘淇
养护员退回
|
362
363
364
365
366
367
368
369
370
371
372
|
try {
// 1. 校验tempKey是否缺失
if (!options || !options.tempKey) {
uni.showToast({
title: '缺失工单缓存Key,无法加载数据',
icon: 'none',
duration: 3000
});
console.error('onLoad异常:options或tempKey缺失');
return;
}
|
5059c4dd
刘淇
养护员提交养护工单
|
373
|
|
dacff5e3
刘淇
养护员退回
|
374
375
376
377
378
379
380
381
382
383
384
|
const { tempKey } = options;
let orderItem = {};
// 2. 读取缓存并校验缓存数据是否有效
orderItem = uni.getStorageSync(tempKey) || {};
if (JSON.stringify(orderItem) === '{}') {
uni.showToast({
title: '工单缓存数据为空,请重新进入',
icon: 'none',
duration: 3000
});
console.error('onLoad异常:工单缓存数据为空');
|
dacff5e3
刘淇
养护员退回
|
385
386
|
return;
}
|
5059c4dd
刘淇
养护员提交养护工单
|
387
|
|
dacff5e3
刘淇
养护员退回
|
388
389
|
// 可选:读取后移除缓存,避免冗余数据
uni.removeStorageSync(tempKey);
|
5059c4dd
刘淇
养护员提交养护工单
|
390
|
|
dacff5e3
刘淇
养护员退回
|
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
// 3. 填充基础表单数据(存在则赋值,不存在则提示)
if (!orderItem.id) {
uni.showToast({
title: '缺失工单ID,数据异常',
icon: 'none',
duration: 2000
});
console.warn('工单数据缺失:id');
}
if (!orderItem.taskId) {
uni.showToast({
title: '缺失任务ID,提交可能失败',
icon: 'none',
duration: 2000
});
console.warn('工单数据缺失:taskId');
}
if (!orderItem.orderNo) {
uni.showToast({
title: '缺失工单编号,数据异常',
icon: 'none',
duration: 2000
});
console.warn('工单数据缺失:orderNo');
}
workOrderForm.workerDataId = orderItem.id || '';
workOrderForm.taskId = orderItem.taskId || '';
workOrderForm.orderNo = orderItem.orderNo || '';
workOrderForm.reason = orderItem.handleResult || ''; // 处理情况回显
|
6c3b6516
刘淇
快速工单 加上业务线
|
421
|
workOrderForm.busiLine = orderItem.busiLine
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
422
423
424
425
426
427
428
|
// 业务线可能是逗号分隔多值(如 "yl,hj"),字段配置按单值定位,取首段
workOrderForm.businessType = String(orderItem.busiLine || '').split(',')[0].trim()
// 来源数据若已带作业类型则回显(工单主表当前无该字段,通常为空,由用户手选)
if (orderItem.workTypeId) {
workOrderForm.workTypeId = orderItem.workTypeId
workOrderForm.workTypeName = uni.$dict.getDictLabel('maintain_type', orderItem.workTypeId) || ''
}
|
371cf0eb
刘淇
流程节点
|
429
|
// 共同处理人(如有数据则回显,转换为数组格式)
|
dacff5e3
刘淇
养护员退回
|
430
|
if (orderItem.coHandlers && orderItem.coHandlersName) {
|
371cf0eb
刘淇
流程节点
|
431
432
433
434
435
436
437
438
439
440
|
// 处理ID:如果是字符串(逗号分隔),转为数组;本身是数组则直接赋值
workOrderForm.coProcessorId = Array.isArray(orderItem.coHandlers)
? orderItem.coHandlers
: (orderItem.coHandlers.split(',').filter(Boolean) || []);
// 处理名称:同理,转为数组格式(用于提交),并拼接为字符串(用于展示)
workOrderForm.coProcessorName = Array.isArray(orderItem.coHandlersName)
? orderItem.coHandlersName
: (orderItem.coHandlersName.split(',').filter(Boolean) || []);
// 拼接名称为字符串,用于输入框展示
workOrderForm.coProcessorNameStr = workOrderForm.coProcessorName.join(',');
|
dacff5e3
刘淇
养护员退回
|
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
} else {
console.warn('工单数据提示:无共同处理人信息');
}
// 4. 回显各类图片:使用 useUploadImgs 内置 setImgList 方法(自动添加 status: 'success')
// 校验图片字段是否存在,不存在则赋值空数组,避免报错
const startImgsArr = orderItem.startImgs || [];
const processingImgsArr = orderItem.processingImgs || [];
const endImgsArr = orderItem.endImgs || [];
const personImgsArr = orderItem.personImgs || [];
const materialImgsArr = orderItem.materialImgs || [];
// 图片回显前校验数组有效性
if (!Array.isArray(startImgsArr)) {
uni.showToast({
title: '开始图片数据格式异常',
icon: 'none',
duration: 2000
});
console.error('开始图片异常:非数组格式');
}
if (!Array.isArray(endImgsArr)) {
uni.showToast({
title: '结束图片数据格式异常',
icon: 'none',
duration: 2000
});
console.error('结束图片异常:非数组格式');
}
startImgs.setImgList(startImgsArr);
processingImgs.setImgList(processingImgsArr);
endImgs.setImgList(endImgsArr);
personImgs.setImgList(personImgsArr);
materialImgs.setImgList(materialImgsArr);
// 5. 校验必填图片(开始/结束)是否为空,提前提示
if (startImgsArr.length === 0) {
uni.showToast({
title: '开始图片为空,请补充上传',
icon: 'none',
duration: 2000
});
console.warn('工单提示:开始图片数组为空');
}
if (endImgsArr.length === 0) {
uni.showToast({
title: '结束图片为空,请补充上传',
icon: 'none',
duration: 2000
});
console.warn('工单提示:结束图片数组为空');
}
console.log('工单数据初始化完成:', workOrderForm);
} catch (error) {
uni.showToast({
title: '工单数据加载失败,请重试',
icon: 'none',
duration: 3000
});
console.error('获取工单缓存数据失败:', error);
|
dacff5e3
刘淇
养护员退回
|
503
|
}
|
2764b83e
刘淇
分配养护员
|
504
505
|
})
|
fa775c6b
刘淇
养护计划调整
|
506
|
// 生命周期 - 初始化表单规则
|
2764b83e
刘淇
分配养护员
|
507
|
onReady(() => {
|
dacff5e3
刘淇
养护员退回
|
508
509
510
511
512
513
514
515
516
|
// 校验表单实例是否存在
if (!workOrderFormRef.value) {
uni.showToast({
title: '表单实例初始化失败',
icon: 'none',
duration: 2000
});
console.error('onReady异常:workOrderFormRef.value 为空');
return;
|
2764b83e
刘淇
分配养护员
|
517
|
}
|
dacff5e3
刘淇
养护员退回
|
518
|
workOrderFormRef.value.setRules(workOrderFormRules)
|
2764b83e
刘淇
分配养护员
|
519
520
|
})
|
fa775c6b
刘淇
养护计划调整
|
521
|
// 生命周期 - 加载共同处理人列表
|
2764b83e
刘淇
分配养护员
|
522
|
onShow(async () => {
|
2764b83e
刘淇
分配养护员
|
523
524
525
|
await loadCoProcessorList()
})
|
fa775c6b
刘淇
养护计划调整
|
526
|
// 加载共同处理人列表
|
2764b83e
刘淇
分配养护员
|
527
528
529
|
const loadCoProcessorList = async () => {
try {
uni.showLoading({ title: '获取处理人列表中...' })
|
2764b83e
刘淇
分配养护员
|
530
|
const queryData = {
|
6c3b6516
刘淇
快速工单 加上业务线
|
531
532
|
// roleCode: 'yl_worker',
busiLine: workOrderForm.busiLine,
|
2764b83e
刘淇
分配养护员
|
533
534
535
536
|
pageNo: 1,
pageSize: 100
}
const res = await getYlWorkersPage(queryData)
|
dacff5e3
刘淇
养护员退回
|
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
// 校验接口返回数据是否有效
if (!res || !res.list) {
uni.showToast({
title: '获取处理人列表失败(无数据)',
icon: 'none',
duration: 2000
});
console.error('loadCoProcessorList异常:接口返回无有效数据');
coProcessorList.value = [];
uni.hideLoading();
return;
}
|
2764b83e
刘淇
分配养护员
|
551
552
|
uni.hideLoading()
|
fa775c6b
刘淇
养护计划调整
|
553
|
if (res.list && res.list.length > 0) {
|
dacff5e3
刘淇
养护员退回
|
554
555
556
557
558
559
560
561
562
563
564
565
|
coProcessorList.value = res.list.map(item => {
// 校验列表项是否含必填字段
if (!item.id || !item.nickname) {
console.warn('处理人列表项异常:缺失id或nickname', item);
return null;
}
return {
name: item.nickname,
value: item.id,
id: item.id
}
}).filter(Boolean); // 过滤null项
|
2764b83e
刘淇
分配养护员
|
566
567
|
} else {
coProcessorList.value = []
|
8ddc6f6e
刘淇
登录 修改样式
|
568
569
570
571
572
|
// uni.showToast({
// title: '暂无共同处理人数据',
// icon: 'none',
// duration: 1000
// });
|
dacff5e3
刘淇
养护员退回
|
573
|
console.warn('loadCoProcessorList提示:处理人列表为空');
|
2764b83e
刘淇
分配养护员
|
574
575
576
|
}
} catch (err) {
uni.hideLoading()
|
dacff5e3
刘淇
养护员退回
|
577
578
579
580
581
|
uni.showToast({
title: '获取处理人列表失败,请重试',
icon: 'none',
duration: 3000
});
|
2764b83e
刘淇
分配养护员
|
582
|
console.error('获取共同处理人列表失败:', err)
|
2764b83e
刘淇
分配养护员
|
583
584
585
586
|
coProcessorList.value = []
}
}
|
fa775c6b
刘淇
养护计划调整
|
587
|
// 打开通用下拉弹窗(仅共同处理人)
|
2764b83e
刘淇
分配养护员
|
588
|
const handleActionSheetOpen = (type) => {
|
dacff5e3
刘淇
养护员退回
|
589
590
591
592
593
594
595
596
597
598
599
600
|
// 校验弹窗类型是否为支持的类型
if (type !== 'coProcessor') {
uni.showToast({
title: '不支持该弹窗类型',
icon: 'none',
duration: 2000
});
console.error('handleActionSheetOpen异常:不支持的弹窗类型', type);
return;
}
// 共同处理人列表为空时,提示并返回
|
2764b83e
刘淇
分配养护员
|
601
|
if (type === 'coProcessor' && coProcessorList.value.length === 0) {
|
dacff5e3
刘淇
养护员退回
|
602
603
604
605
606
607
|
uni.showToast({
title: '暂无共同处理人可选',
icon: 'none',
duration: 2000
});
console.warn('handleActionSheetOpen提示:共同处理人列表为空');
|
2764b83e
刘淇
分配养护员
|
608
609
610
|
return
}
|
fa775c6b
刘淇
养护计划调整
|
611
|
// 弹窗配置映射(仅保留共同处理人)
|
2764b83e
刘淇
分配养护员
|
612
613
614
|
const configMap = {
coProcessor: {
title: '请选择共同处理人',
|
fa775c6b
刘淇
养护计划调整
|
615
|
list: coProcessorList.value,
|
2764b83e
刘淇
分配养护员
|
616
617
618
619
620
621
622
623
624
|
}
}
currentActionSheetData.type = type
currentActionSheetData.title = configMap[type].title
currentActionSheetData.list = configMap[type].list
showActionSheet.value = true
}
|
fa775c6b
刘淇
养护计划调整
|
625
|
// 关闭通用下拉弹窗
|
2764b83e
刘淇
分配养护员
|
626
627
|
const handleActionSheetClose = () => {
showActionSheet.value = false
|
dacff5e3
刘淇
养护员退回
|
628
|
// 重置弹窗数据,避免残留
|
2764b83e
刘淇
分配养护员
|
629
630
631
632
633
|
currentActionSheetData.type = ''
currentActionSheetData.list = []
currentActionSheetData.title = ''
}
|
371cf0eb
刘淇
流程节点
|
634
|
// 下拉弹窗选择事件(修改:支持多选,存储名称和ID为数组)
|
2764b83e
刘淇
分配养护员
|
635
|
const handleActionSheetSelect = (e) => {
|
dacff5e3
刘淇
养护员退回
|
636
637
638
639
640
641
642
643
644
645
646
647
|
// 校验事件参数是否有效
if (!e || !e.name || !e.id) {
uni.showToast({
title: '选择处理人失败(参数异常)',
icon: 'none',
duration: 2000
});
console.error('handleActionSheetSelect异常:e参数缺失name或id', e);
showActionSheet.value = false;
return;
}
|
2764b83e
刘淇
分配养护员
|
648
|
const { type } = currentActionSheetData
|
371cf0eb
刘淇
流程节点
|
649
|
// 多选场景(仅共同处理人,存储数组格式)
|
fa775c6b
刘淇
养护计划调整
|
650
|
if (type === 'coProcessor') {
|
371cf0eb
刘淇
流程节点
|
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
|
// 若已选中该处理人,移除(实现切换选择);未选中则添加
const idIndex = workOrderForm.coProcessorId.findIndex(id => id === e.id);
if (idIndex > -1) {
// 移除已选中的ID和名称
workOrderForm.coProcessorId.splice(idIndex, 1);
workOrderForm.coProcessorName.splice(idIndex, 1);
} else {
// 添加新选中的ID和名称(数组格式)
workOrderForm.coProcessorId.push(e.id);
workOrderForm.coProcessorName.push(e.name);
}
// 拼接名称数组为字符串,用于输入框展示
workOrderForm.coProcessorNameStr = workOrderForm.coProcessorName.join(',');
|
dacff5e3
刘淇
养护员退回
|
666
667
668
669
670
671
|
// 校验表单实例是否存在,再执行字段校验
if (workOrderFormRef.value) {
workOrderFormRef.value?.validateField('coProcessorName')
} else {
console.warn('handleActionSheetSelect提示:表单实例不存在,跳过字段校验');
}
|
2764b83e
刘淇
分配养护员
|
672
673
674
675
|
}
showActionSheet.value = false
}
|
fa775c6b
刘淇
养护计划调整
|
676
677
|
// 图片切换选择
const imgTabChange = (item)=> {
|
dacff5e3
刘淇
养护员退回
|
678
679
680
681
682
683
684
685
686
687
|
// 校验切换参数是否有效
if (!item || item.index === undefined || item.index === null) {
uni.showToast({
title: '图片标签切换失败(参数异常)',
icon: 'none',
duration: 2000
});
console.error('imgTabChange异常:item参数缺失index', item);
return;
}
|
fa775c6b
刘淇
养护计划调整
|
688
|
activeTab.value = item.index
|
2764b83e
刘淇
分配养护员
|
689
690
|
}
|
fa775c6b
刘淇
养护计划调整
|
691
|
// 隐藏键盘
|
2764b83e
刘淇
分配养护员
|
692
693
694
695
|
const hideKeyboard = () => {
uni.hideKeyboard()
}
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
|
// 打开作业类型选择弹窗
const openWorkTypeSheet = () => {
// up-action-sheet 用 name 展示,value 作为回传值
workTypeOptions.value = uni.$dict.getDictSimpleList('maintain_type')
.map(item => ({ name: item.label, value: item.value }))
if (workTypeOptions.value.length === 0) {
uni.showToast({
title: '暂无作业类型字典数据',
icon: 'none',
duration: 2000
})
return
}
showWorkTypeSheet.value = true
}
// 选择作业类型:驱动动态字段按「业务类型 + 作业类型」重新加载
const onWorkTypeSelect = (e) => {
showWorkTypeSheet.value = false
if (!e || e.value === undefined || e.value === null || e.value === '') {
return
}
workOrderForm.workTypeId = e.value
workOrderForm.workTypeName = e.name
dynamicFieldCount.value = 0
if (workOrderFormRef.value) {
workOrderFormRef.value.validateField('workTypeName')
}
}
// 动态字段加载完成(count=0 时页面提示「暂无需填报项」)
const onDynamicFieldsLoaded = (count) => {
dynamicFieldCount.value = count || 0
}
// 动态字段提交幂等流水号(后端按 userId+clientSeq 去重)
const genClientSeq = () => `${Date.now()}-${Math.random().toString(16).slice(2, 10)}`
|
371cf0eb
刘淇
流程节点
|
734
|
// 提交工单(修改:将coProcessorName数组一并传入提交参数)
|
2764b83e
刘淇
分配养护员
|
735
736
|
const submitWorkOrder = async () => {
try {
|
dacff5e3
刘淇
养护员退回
|
737
738
739
740
741
742
743
744
745
746
747
748
|
// ========== 前置校验:表单实例是否存在 ==========
if (!workOrderFormRef.value) {
uni.showToast({
title: '表单实例异常,无法提交',
icon: 'none',
duration: 2000
});
console.error('submitWorkOrder异常:workOrderFormRef.value 为空');
return;
}
// ========== 开始/结束图片必填校验 ==========
|
5059c4dd
刘淇
养护员提交养护工单
|
749
750
751
|
const startImgUrls = startImgs.getSuccessImgUrls(); // 开始阶段图片URL数组
const endImgUrls = endImgs.getSuccessImgUrls(); // 结束阶段图片URL数组
|
dacff5e3
刘淇
养护员退回
|
752
753
754
755
|
// 打印日志验证(可选,用于排查)
console.log('开始图片有效URL:', startImgUrls);
console.log('结束图片有效URL:', endImgUrls);
|
5059c4dd
刘淇
养护员提交养护工单
|
756
|
// 判断开始图片是否为空
|
dacff5e3
刘淇
养护员退回
|
757
|
if (!Array.isArray(startImgUrls) || startImgUrls.length === 0) {
|
5059c4dd
刘淇
养护员提交养护工单
|
758
759
760
761
762
|
uni.showToast({
title: '请至少上传1张开始阶段图片',
icon: 'none',
duration: 2000
});
|
dacff5e3
刘淇
养护员退回
|
763
|
console.warn('submitWorkOrder校验失败:开始图片为空');
|
5059c4dd
刘淇
养护员提交养护工单
|
764
765
766
767
|
return; // 终止提交流程
}
// 判断结束图片是否为空
|
dacff5e3
刘淇
养护员退回
|
768
|
if (!Array.isArray(endImgUrls) || endImgUrls.length === 0) {
|
5059c4dd
刘淇
养护员提交养护工单
|
769
770
771
772
773
|
uni.showToast({
title: '请至少上传1张结束阶段图片',
icon: 'none',
duration: 2000
});
|
dacff5e3
刘淇
养护员退回
|
774
|
console.warn('submitWorkOrder校验失败:结束图片为空');
|
5059c4dd
刘淇
养护员提交养护工单
|
775
776
|
return; // 终止提交流程
}
|
5059c4dd
刘淇
养护员提交养护工单
|
777
|
|
dacff5e3
刘淇
养护员退回
|
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
|
// ========== 处理情况必填校验(兜底,防止表单校验失效) ==========
if (!workOrderForm.reason || workOrderForm.reason.trim().length === 0) {
uni.showToast({
title: '请输入处理情况描述',
icon: 'none',
duration: 2000
});
console.warn('submitWorkOrder校验失败:处理情况为空');
return;
}
if (workOrderForm.reason.trim().length > 200) {
uni.showToast({
title: '处理情况描述不能超过200字',
icon: 'none',
duration: 2000
});
console.warn('submitWorkOrder校验失败:处理情况超过200字');
return;
}
// ========== 原有表单校验 ==========
|
2764b83e
刘淇
分配养护员
|
799
800
|
await workOrderFormRef.value.validate()
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
|
// ========== 作业类型 + 动态字段校验 ==========
if (!workOrderForm.workTypeId) {
uni.showToast({
title: '请选择作业类型',
icon: 'none',
duration: 2000
});
console.warn('submitWorkOrder校验失败:作业类型为空');
return;
}
let dynamicValues = []
if (workFieldFormRef.value) {
// 校验失败时 reject 字段数组(uview-plus 已提示),交给外层 catch 忽略
await workFieldFormRef.value.validate()
dynamicValues = workFieldFormRef.value.getValues()
}
|
dacff5e3
刘淇
养护员退回
|
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
|
// ========== 校验核心提交参数 ==========
if (!workOrderForm.taskId) {
uni.showToast({
title: '缺失任务ID,无法提交',
icon: 'none',
duration: 2000
});
console.error('submitWorkOrder异常:taskId 为空');
return;
}
if (!workOrderForm.workerDataId) {
uni.showToast({
title: '缺失工单ID,无法提交',
icon: 'none',
duration: 2000
});
console.error('submitWorkOrder异常:workerDataId 为空');
return;
}
|
5059c4dd
刘淇
养护员提交养护工单
|
838
|
// 构造所有图片URL(原有代码不变)
|
fa775c6b
刘淇
养护计划调整
|
839
|
const allImgs = {
|
dacff5e3
刘淇
养护员退回
|
840
841
842
843
844
|
startImgs: startImgUrls,
processingImgs: processingImgs.getSuccessImgUrls() || [],
endImgs: endImgUrls,
personImgs: personImgs.getSuccessImgUrls() || [],
materialImgs: materialImgs.getSuccessImgUrls() || []
|
fa775c6b
刘淇
养护计划调整
|
845
846
|
}
|
371cf0eb
刘淇
流程节点
|
847
|
// 构造提交参数(修改:添加coProcessorName数组一并提交)
|
2764b83e
刘淇
分配养护员
|
848
|
const submitData = {
|
5059c4dd
刘淇
养护员提交养护工单
|
849
850
|
taskId: workOrderForm.taskId,
taskKey:'ylWorker',
|
dacff5e3
刘淇
养护员退回
|
851
852
|
operateType: nextStepMap['ylWorker']?.operateTypePass || '', // 兜底:防止nextStepMap缺失属性
workerDataId: Number(workOrderForm.workerDataId) || '',
|
5059c4dd
刘淇
养护员提交养护工单
|
853
|
handleResult: workOrderForm.reason.trim(),
|
371cf0eb
刘淇
流程节点
|
854
855
|
coHandlers: workOrderForm.coProcessorId || [], // ID数组
coHandlersName: workOrderForm.coProcessorName || [], // 名称数组(一并提交)
|
fa775c6b
刘淇
养护计划调整
|
856
857
858
859
860
|
startImgs: allImgs.startImgs,
processingImgs: allImgs.processingImgs,
endImgs: allImgs.endImgs,
personImgs: allImgs.personImgs,
materialImgs: allImgs.materialImgs,
|
5059c4dd
刘淇
养护员提交养护工单
|
861
|
problemsImgs:[]
|
2764b83e
刘淇
分配养护员
|
862
|
}
|
dacff5e3
刘淇
养护员退回
|
863
|
|
371cf0eb
刘淇
流程节点
|
864
865
866
|
// 打印提交参数,验证coProcessorName是否为数组
console.log('提交参数(含名称数组):', submitData);
|
dacff5e3
刘淇
养护员退回
|
867
868
869
870
871
872
873
874
875
876
|
// 校验operateType是否有效
if (!submitData.operateType) {
uni.showToast({
title: '提交类型异常,无法提交',
icon: 'none',
duration: 2000
});
console.error('submitWorkOrder异常:operateType 为空');
return;
}
|
2764b83e
刘淇
分配养护员
|
877
|
|
2764b83e
刘淇
分配养护员
|
878
|
uni.showLoading({ title: '提交中...' })
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
|
// ========== 先落作业填报(动态字段),再走审批流转 ==========
// 值按「业务类型 + 作业类型」的字段配置落库;同一工单重复实施时后端按 (bizType,bizId) 覆盖原记录并红冲旧物料
if (dynamicValues.length > 0) {
if (!workRecordClientSeq) {
workRecordClientSeq = genClientSeq()
}
await workRecordSubmit({
businessType: workOrderForm.businessType,
bizType: 1,
bizId: Number(workOrderForm.workerDataId),
workTypeId: Number(workOrderForm.workTypeId),
clientSeq: workRecordClientSeq,
remark: workOrderForm.reason.trim(),
fields: dynamicValues
})
}
|
5059c4dd
刘淇
养护员提交养护工单
|
897
|
const res = await universalApproval(submitData)
|
dacff5e3
刘淇
养护员退回
|
898
899
900
901
902
903
904
905
906
907
908
909
910
|
// 校验接口返回结果
if (!res) {
uni.hideLoading();
uni.showToast({
title: '工单提交失败(接口无返回)',
icon: 'none',
duration: 3000
});
console.error('submitWorkOrder异常:universalApproval接口无有效返回');
return;
}
|
2764b83e
刘淇
分配养护员
|
911
|
uni.hideLoading()
|
fa775c6b
刘淇
养护计划调整
|
912
|
|
2764b83e
刘淇
分配养护员
|
913
914
915
916
917
918
919
920
|
uni.showToast({
title: '工单提交成功',
icon: 'success',
duration: 1000
})
// 延迟跳转
setTimeout(() => {
|
4fa8cf12
刘淇
巡查员结束工单
|
921
|
uni.reLaunch({
|
2764b83e
刘淇
分配养护员
|
922
923
924
925
926
927
|
url: '/pages-sub/problem/work-order-manage/index'
})
}, 1000)
} catch (error) {
uni.hideLoading()
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
928
929
930
|
// 本次提交失败后重置流水号:下次重试允许按最新填报值覆盖原记录(后端按 bizType+bizId 覆盖,不会重复建单)
workRecordClientSeq = ''
|
dacff5e3
刘淇
养护员退回
|
931
|
// 区分校验失败和接口失败,仅接口失败时提示(校验失败已有内置提示)
|
2764b83e
刘淇
分配养护员
|
932
|
if (!Array.isArray(error)) {
|
2764b83e
刘淇
分配养护员
|
933
934
935
936
|
uni.showToast({
title: '提交失败,请重试',
icon: 'none',
duration: 2000
|
dacff5e3
刘淇
养护员退回
|
937
938
939
940
|
});
console.error('工单提交失败:', error)
} else {
console.warn('工单提交校验失败:', error);
|
2764b83e
刘淇
分配养护员
|
941
942
943
944
945
946
|
}
}
}
</script>
<style lang="scss" scoped>
|
fa775c6b
刘淇
养护计划调整
|
947
|
// 页面容器样式
|
2764b83e
刘淇
分配养护员
|
948
949
|
.page-container {
min-height: 100vh;
|
dacff5e3
刘淇
养护员退回
|
950
|
padding-bottom: 100rpx; // 给底部按钮留空间
|
2764b83e
刘淇
分配养护员
|
951
952
|
}
|
fa775c6b
刘淇
养护计划调整
|
953
|
// 表单内容容器
|
2764b83e
刘淇
分配养护员
|
954
955
956
957
958
959
960
961
962
963
|
.work-order-form-content {
background: #fff;
padding-bottom: 30rpx;
}
// Tabs容器样式
.tabs-wrap {
background: #fff;
}
|
dacff5e3
刘淇
养护员退回
|
964
|
// Tab自定义内容样式(红色*号)
|
5059c4dd
刘淇
养护员提交养护工单
|
965
966
967
968
969
970
971
972
973
974
975
|
.tab-item-content {
display: flex;
align-items: center;
}
.required-star {
color: #f53f3f; // 红色必填标识
margin-right: 4rpx; // 与文字保持小间距
font-weight: bold;
}
|
dd60ac14
王彪总
业务线 小程序不用写死,从后端接口获取
|
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
|
// 作业填报(动态字段)区块
.dynamic-field-block {
margin-top: 10rpx;
.dynamic-field-title {
padding: 20rpx 0 10rpx;
font-size: 30rpx;
font-weight: 600;
color: #303133;
border-bottom: 1rpx solid #f0f0f0;
}
.dynamic-field-empty {
padding: 30rpx 0;
text-align: center;
font-size: 26rpx;
color: #999;
}
}
|
e6a04285
刘淇
单图情况 宽高70*70
|
996
|
|
2764b83e
刘淇
分配养护员
|
997
|
</style>
|