|
|
@@ -266,6 +266,25 @@ export default {
|
|
266
|
266
|
this.orderDetail.itemBrand,
|
|
267
|
267
|
this.currentReceipt.clueId
|
|
268
|
268
|
)
|
|
|
269
|
+
|
|
|
270
|
+ // 按照 fileIds 排序
|
|
|
271
|
+ if (this.currentReceipt.fileIds && list && list.length > 0) {
|
|
|
272
|
+ const sortedIds = this.currentReceipt.fileIds.split(',')
|
|
|
273
|
+ list.sort((a, b) => {
|
|
|
274
|
+ const indexA = sortedIds.indexOf(a.id)
|
|
|
275
|
+ const indexB = sortedIds.indexOf(b.id)
|
|
|
276
|
+
|
|
|
277
|
+ // 如果都不在列表中,保持原顺序
|
|
|
278
|
+ if (indexA === -1 && indexB === -1) return 0
|
|
|
279
|
+ // 如果 a 不在列表中,放到后面
|
|
|
280
|
+ if (indexA === -1) return 1
|
|
|
281
|
+ // 如果 b 不在列表中,放到后面
|
|
|
282
|
+ if (indexB === -1) return -1
|
|
|
283
|
+ // 都在列表中,按 index 排序
|
|
|
284
|
+ return indexA - indexB
|
|
|
285
|
+ })
|
|
|
286
|
+ }
|
|
|
287
|
+
|
|
269
|
288
|
this.detailImages = list || []
|
|
270
|
289
|
} catch (error) {
|
|
271
|
290
|
console.error('加载细节图失败:', error)
|
|
|
@@ -382,10 +401,12 @@ export default {
|
|
382
|
401
|
this.resetDragState()
|
|
383
|
402
|
|
|
384
|
403
|
//每次拖拽结束后把新的顺序传送给接口
|
|
|
404
|
+ const fileIds = this.detailImages.map(item => item.id).join(',')
|
|
385
|
405
|
await uni.$u.api.updateReceiptForm({
|
|
386
|
406
|
id: this.currentReceipt.id,
|
|
387
|
|
- fileIds: this.detailImages.map(item => item.id).join(',')
|
|
|
407
|
+ fileIds: fileIds
|
|
388
|
408
|
})
|
|
|
409
|
+ this.$emit('update-file-ids', fileIds)
|
|
389
|
410
|
},
|
|
390
|
411
|
|
|
391
|
412
|
/**
|
|
|
@@ -433,13 +454,15 @@ export default {
|
|
433
|
454
|
'3',
|
|
434
|
455
|
uploadResults
|
|
435
|
456
|
)
|
|
436
|
|
- this.loadDetailImages()
|
|
|
457
|
+ await this.loadDetailImages()
|
|
437
|
458
|
|
|
438
|
459
|
//上传新图片完成之后也要把新数据给接口
|
|
|
460
|
+ const fileIds = this.detailImages.map(item => item.id).join(',')
|
|
439
|
461
|
await uni.$u.api.updateReceiptForm({
|
|
440
|
462
|
id: this.currentReceipt.id,
|
|
441
|
|
- fileIds: this.detailImages.map(item => item.id).join(',')
|
|
|
463
|
+ fileIds: fileIds
|
|
442
|
464
|
})
|
|
|
465
|
+ this.$emit('update-file-ids', fileIds)
|
|
443
|
466
|
|
|
444
|
467
|
} catch (error) {
|
|
445
|
468
|
console.error('上传失败:', error)
|
|
|
@@ -449,11 +472,23 @@ export default {
|
|
449
|
472
|
/**
|
|
450
|
473
|
* 隐藏图片
|
|
451
|
474
|
*/
|
|
452
|
|
- handleHideImage(item, index) {
|
|
|
475
|
+ async handleHideImage(item, index) {
|
|
453
|
476
|
const itemIndex = this.detailImages.findIndex(img => img.id === item.id || img.fileUrl === item.fileUrl)
|
|
454
|
477
|
if (itemIndex !== -1) {
|
|
455
|
478
|
this.detailImages.splice(itemIndex, 1)
|
|
456
|
|
- uni.$u.toast('图片已隐藏')
|
|
|
479
|
+
|
|
|
480
|
+ // 更新 fileIds
|
|
|
481
|
+ const fileIds = this.detailImages.map(item => item.id).join(',')
|
|
|
482
|
+ try {
|
|
|
483
|
+ await uni.$u.api.updateReceiptForm({
|
|
|
484
|
+ id: this.currentReceipt.id,
|
|
|
485
|
+ fileIds: fileIds
|
|
|
486
|
+ })
|
|
|
487
|
+ this.$emit('update-file-ids', fileIds)
|
|
|
488
|
+ uni.$u.toast('图片已隐藏')
|
|
|
489
|
+ } catch (error) {
|
|
|
490
|
+ console.error('更新失败:', error)
|
|
|
491
|
+ }
|
|
457
|
492
|
}
|
|
458
|
493
|
},
|
|
459
|
494
|
|