瀏覽代碼

feat: 组件 更新支持

lanceJiang 1 年之前
父節點
當前提交
b8ad9ddbc3

+ 5 - 5
src/views/flow/create/components/ExtendSet.vue

@@ -8,13 +8,13 @@ defineProps({
 	}
 })
 const validate = () => {
-  // 根据后续的业务需求 调整 validate 的功能
-  return new Promise((resolve, reject) => {
-    resolve()
-  })
+	// 根据后续的业务需求 调整 validate 的功能
+	return new Promise((resolve, reject) => {
+		resolve()
+	})
 }
 defineExpose({
-  validate
+	validate
 })
 </script>
 

+ 8 - 3
src/views/flow/create/components/FlowDesign.vue

@@ -28,14 +28,18 @@ let form = ref({
 const saveDesign = json => {
 	modelContent.value = JSON.stringify(form.value.processConfig)
 }
-
-onMounted(() => {
+const updateCompInfo = () => {
 	if (modelContent.value) {
 		const _val = JSON.parse(modelContent.value)
 		form.value = Object.assign({ processConfig: _val }, {})
 	}
+}
+onMounted(() => {
+	updateCompInfo()
 })
 const validate = () => {
+	// 保存表单设计
+	saveDesign()
 	// 根据后续的业务需求 调整 validate 的功能
 	return new Promise((resolve, reject) => {
 		resolve()
@@ -44,7 +48,8 @@ const validate = () => {
 defineExpose({
 	formRef,
 	saveDesign,
-	validate
+	validate,
+	updateCompInfo
 })
 </script>
 

+ 13 - 9
src/views/flow/create/components/FormDesign.vue

@@ -22,29 +22,33 @@ const exportJson = async json => {
  * 2、如果不唯一,提示用户需要重新填写表单字段Id
  */
 const validate = () => {
-  // 根据后续的业务需求 调整 validate 的功能
-  exportJsonEv()
+	// 根据后续的业务需求 调整 validate 的功能
+	exportJsonEv()
 	return new Promise((resolve, reject) => {
 		const finallyFormData = JSON.parse(processForm.value)
 		const fields = finallyFormData.map(item => item.field)
 		const bool = fields.length === [...new Set(fields)].length
 		if (bool) {
-      resolve(true)
-    } else {
-      reject(false)
-    }
+			resolve(true)
+		} else {
+			reject(false)
+		}
 	})
 }
-// 初始化的时候,渲染当前组件的值
-onMounted(() => {
+const updateCompInfo = () => {
 	if (processForm.value) {
 		designer.value.initForm(processForm.value || [])
 	}
+}
+// 初始化的时候,渲染当前组件的值
+onMounted(() => {
+	updateCompInfo()
 })
 
 defineExpose({
 	exportJsonEv,
-	validate
+	validate,
+	updateCompInfo
 })
 </script>