Browse Source

发票上传添加初始化就排序一次

huangguoce 3 weeks ago
parent
commit
08bc51ef96
1 changed files with 10 additions and 1 deletions
  1. 10 1
      src/views/common/NewDigitalInvoiceUploadComponentTest.vue

+ 10 - 1
src/views/common/NewDigitalInvoiceUploadComponentTest.vue

@@ -427,7 +427,14 @@ export default {
 				})
 			}
 		},
-		setNodeSort(oldIndex, newIndex) {
+		setNodeSort(oldIndex, newIndex, type) {
+			if (type == 'init') {
+				// 初始化给sort
+				this.dataListNew.forEach((item, index) => {
+					item.sort = index + 1
+				});
+				return
+			}
 			// 使用arr复制一份表格数组数据
 			const arr = this.dataListNew;
 			const currentRow = arr.splice(oldIndex, 1)[0]
@@ -736,6 +743,8 @@ export default {
 						},
 					})
 				}
+				// 👇 初始化时主动触发一次
+				this.setNodeSort(null, null, 'init');
 				// 在 changes 完成后,手动调用 handleUploadSuccess
 				await this.handleUploadSuccess(null, fileData, this.fileList);  // 传入空参数或实际参数
 			} catch (error) {