Selaa lähdekoodia

feat: JSON格式化二次弹窗

luoyali 1 vuosi sitten
vanhempi
sitoutus
0dee635681
1 muutettua tiedostoa jossa 14 lisäystä ja 11 poistoa
  1. 14 11
      src/views/flow/create/components/FlowDesign.vue

+ 14 - 11
src/views/flow/create/components/FlowDesign.vue

@@ -1,6 +1,7 @@
 <script setup name="FlowDesign">
-import { onMounted, ref, watch } from 'vue'
+import { onMounted, ref } from 'vue'
 import CodeMirrorEditor from '@/components/CodeMirrorEditor/index.vue'
+import { ElMessageBox } from 'element-plus'
 
 import ScWorkflow from '@/components/scWorkflow'
 import useFlowStore from '@/store/modules/flow'
@@ -61,17 +62,23 @@ const validate = () => {
 		resolve()
 	})
 }
+const sureImportJson = () => {
+	ElMessageBox.confirm('确定应用JSON模型吗?', '提示', {
+		callback: async action => {
+			if (action === 'confirm') {
+				form.value.processConfig = JSON.parse(jsonFormat.value || {})
+				drawer.value = !drawer.value
+			} else {
+			}
+		}
+	}).catch(() => {})
+}
 
 const openDrawerEv = () => {
 	jsonFormat.value = JSON.stringify(form.value.processConfig, null, '  ')
 	drawer.value = !drawer.value
 }
 
-const sureImportJson = () => {
-	form.value.processConfig = JSON.parse(jsonFormat.value || {})
-	drawer.value = !drawer.value
-}
-
 onMounted(() => {
 	updateCompInfo()
 })
@@ -96,11 +103,7 @@ defineExpose({
 			<code-mirror-editor v-model="jsonFormat"></code-mirror-editor>
 			<template #footer>
 				<el-button type="primary" @click="copyJson">复制 JSON</el-button>
-				<el-popconfirm title="确定应用JSON模型吗?" @confirm="sureImportJson">
-					<template #reference>
-						<el-button>导入JSON</el-button>
-					</template>
-				</el-popconfirm>
+				<el-button @click="sureImportJson">导入JSON</el-button>
 			</template>
 		</el-dialog>
 	</div>