Quellcode durchsuchen

支持导出 导入失败的数据

kagg886 vor 2 Monaten
Ursprung
Commit
f297829854
1 geänderte Dateien mit 16 neuen und 7 gelöschten Zeilen
  1. 16 7
      src/views/flow/flowForm/list/index.vue

+ 16 - 7
src/views/flow/flowForm/list/index.vue

@@ -316,27 +316,36 @@ export default defineComponent({
 			})
 
 			const x = JSON.parse(json)
-			const result = await Promise.all<boolean>(
+			const result = await Promise.all<{ success: boolean; result?: FlowFormInfoData }>(
 				x.map(async (it: FlowFormInfoData) => {
 					return await addFlowForm(it)
-						.then(() => true)
-						.catch(() => false)
+						.then(() => {
+							return { success: true }
+						})
+						.catch(() => {
+							return { success: false, result: it }
+						})
 				})
 			)
 
-			const error = result.filter((it) => !it).length
-			if (error == 0) {
+			const failed = result.filter((it) => !it)
+			if (failed.length == 0) {
 				ElMessage.success('导入成功')
 				flowFormList()
 				reset()
 				return
 			}
 
-			await ElMessageBox.alert(`导入失败: 有 ${error} 个数据导入失败。`, '提示', {
-				confirmButtonText: '确认',
+			const showErrorDialog = await ElMessageBox.alert(`导入失败: 有 ${failed.length} 个数据导入失败。`, '提示', {
+				confirmButtonText: '查看失败的数据',
+				cancelButtonText: '确认',
 				type: 'warning',
 			})
 
+			if (showErrorDialog) {
+				download(JSON.stringify(failed.map((it) => it.result)), 'failed.json')
+			}
+
 			reset()
 		})