perf: [BPM 工作流] 更多设置,监听流程表单数据优化
parent
2b48d60735
commit
e1151738f5
|
|
@ -232,34 +232,6 @@ import { ProcessVariableEnum } from '@/components/SimpleProcessDesignerV2/src/co
|
||||||
import HttpRequestSetting from '@/components/SimpleProcessDesignerV2/src/nodes-config/components/HttpRequestSetting.vue'
|
import HttpRequestSetting from '@/components/SimpleProcessDesignerV2/src/nodes-config/components/HttpRequestSetting.vue'
|
||||||
|
|
||||||
const modelData = defineModel<any>()
|
const modelData = defineModel<any>()
|
||||||
const formFields = ref<string[]>([])
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
// 流程表单 ID
|
|
||||||
modelFormId: {
|
|
||||||
type: Number,
|
|
||||||
required: false,
|
|
||||||
default: undefined,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// 监听 modelFormId 变化
|
|
||||||
watch(
|
|
||||||
() => props.modelFormId,
|
|
||||||
async (newVal) => {
|
|
||||||
if (newVal) {
|
|
||||||
const form = await FormApi.getForm(newVal);
|
|
||||||
formFields.value = form?.fields;
|
|
||||||
} else {
|
|
||||||
// 如果 modelFormId 为空,清空表单字段
|
|
||||||
formFields.value = [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true },
|
|
||||||
);
|
|
||||||
// 暴露给子组件使用
|
|
||||||
provide('formFields', formFields)
|
|
||||||
|
|
||||||
/** 自定义 ID 流程编码 */
|
/** 自定义 ID 流程编码 */
|
||||||
const timeOptions = ref([
|
const timeOptions = ref([
|
||||||
|
|
@ -374,10 +346,10 @@ const handleTaskAfterTriggerEnableChange = (val: boolean | string | number) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 表单选项 */
|
/** 已解析表单字段 */
|
||||||
const formField = ref<Array<{ field: string; title: string }>>([])
|
const formFields = ref<Array<{ field: string; title: string }>>([])
|
||||||
const formFieldOptions4Title = computed(() => {
|
const formFieldOptions4Title = computed(() => {
|
||||||
let cloneFormField = formField.value.map((item) => {
|
let cloneFormField = formFields.value.map((item) => {
|
||||||
return {
|
return {
|
||||||
label: item.title,
|
label: item.title,
|
||||||
value: item.field
|
value: item.field
|
||||||
|
|
@ -399,7 +371,7 @@ const formFieldOptions4Title = computed(() => {
|
||||||
return cloneFormField
|
return cloneFormField
|
||||||
})
|
})
|
||||||
const formFieldOptions4Summary = computed(() => {
|
const formFieldOptions4Summary = computed(() => {
|
||||||
return formField.value.map((item) => {
|
return formFields.value.map((item) => {
|
||||||
return {
|
return {
|
||||||
label: item.title,
|
label: item.title,
|
||||||
value: item.field
|
value: item.field
|
||||||
|
|
@ -407,6 +379,11 @@ const formFieldOptions4Summary = computed(() => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 未解析的表单字段 */
|
||||||
|
const unParsedFormFields = ref<string[]>([])
|
||||||
|
/** 暴露给子组件 HttpRequestSetting 使用 */
|
||||||
|
provide('formFields', unParsedFormFields)
|
||||||
|
|
||||||
/** 兼容以前未配置更多设置的流程 */
|
/** 兼容以前未配置更多设置的流程 */
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
if (!modelData.value.processIdRule) {
|
if (!modelData.value.processIdRule) {
|
||||||
|
|
@ -456,13 +433,15 @@ watch(
|
||||||
const data = await FormApi.getForm(newFormId)
|
const data = await FormApi.getForm(newFormId)
|
||||||
const result: Array<{ field: string; title: string }> = []
|
const result: Array<{ field: string; title: string }> = []
|
||||||
if (data.fields) {
|
if (data.fields) {
|
||||||
|
unParsedFormFields.value = data.fields
|
||||||
data.fields.forEach((fieldStr: string) => {
|
data.fields.forEach((fieldStr: string) => {
|
||||||
parseFormFields(JSON.parse(fieldStr), result)
|
parseFormFields(JSON.parse(fieldStr), result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
formField.value = result
|
formFields.value = result
|
||||||
} else {
|
} else {
|
||||||
formField.value = []
|
formFields.value = []
|
||||||
|
unParsedFormFields.value = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,7 @@
|
||||||
|
|
||||||
<!-- 第四步:更多设置 -->
|
<!-- 第四步:更多设置 -->
|
||||||
<div v-show="currentStep === 3" class="mx-auto w-700px">
|
<div v-show="currentStep === 3" class="mx-auto w-700px">
|
||||||
<ExtraSettings
|
<ExtraSettings ref="extraSettingsRef" v-model="formData" />
|
||||||
ref="extraSettingsRef"
|
|
||||||
v-model="formData"
|
|
||||||
:model-form-id="formData.formId"/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue