Skip to content

Commit

Permalink
fix: 修复工作流接口传参历史数据兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 committed Oct 22, 2024
1 parent fc337cf commit 83f332a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 51 deletions.
4 changes: 2 additions & 2 deletions ui/src/components/dynamics-form/constructor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<el-input v-model="form_data.tooltip" placeholder="请输入参数提示说明" />
</el-form-item>
<el-form-item label="是否必填" :required="true" prop="required" :rules="rules.required">
<el-switch v-model="form_data.required" />
<el-switch v-model="form_data.required" :active-value="true" :inactive-value="false" />
</el-form-item>
<el-form-item label="组件类型" :required="true" prop="input_type" :rules="rules.input_type">
<el-select v-model="form_data.input_type" placeholder="请选择组件类型">
Expand Down Expand Up @@ -106,7 +106,7 @@ onMounted(() => {
}
})
const rander = (data: any) => {
form_data.value.required = data.required
form_data.value.required = data.required ? data.required : false
form_data.value.field = data.field
form_data.value.input_type = data.input_type + 'Constructor'
if (data.label && data.label.input_type === 'TooltipLabel') {
Expand Down
101 changes: 63 additions & 38 deletions ui/src/workflow/nodes/base-node/component/UserFieldFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
append-to-body
>
<DynamicsFormConstructor
v-model="currentItem"
v-model="currentRow"
label-position="top"
require-asterisk-position="right"
:input_type_list="inputTypeList"
Expand All @@ -25,80 +25,106 @@
</el-dialog>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ref, computed } from 'vue'
import { cloneDeep } from 'lodash'
import DynamicsFormConstructor from '@/components/dynamics-form/constructor/index.vue'
import type { FormField } from '@/components/dynamics-form/type'
import _ from 'lodash'
const emit = defineEmits(['refresh'])
const DynamicsFormConstructorRef = ref()
const loading = ref<boolean>(false)
const isEdit = ref(false)
const currentItem = ref<FormField>()
const currentIndex = ref(null)
const inputTypeList = ref([
{ label: '文本框', value: 'TextInputConstructor' },
{ label: '单选框', value: 'SingleSelectConstructor' },
{ label: '日期', value: 'DatePickerConstructor' }
])
const dialogVisible = ref<boolean>(false)
const open = (row: any, index: any) => {
dialogVisible.value = true
if (row) {
isEdit.value = true
currentItem.value = cloneDeep(row)
currentIndex.value = index
// 新版本已经上线
if (row.input_type) {
return
}
// 旧版本数据兼容
const currentItem = ref<FormField | any>()
const check_field = (field_list: Array<string>, obj: any) => {
return field_list.every((field) => _.get(obj, field, undefined) !== undefined)
}
const currentRow = computed(() => {
if (currentItem.value) {
const row = currentItem.value
switch (row.type) {
case 'input':
currentItem.value = {
if (check_field(['field', 'input_type', 'label', 'required'], currentItem.value)) {
return currentItem.value
}
return {
field: row.field || row.variable,
input_type: 'TextInput',
label: row.label || row.name,
default_value: row.default_value,
required: row.required || row.is_required
required: row.required != undefined ? row.required : row.is_required
}
break
case 'select':
currentItem.value = {
if (
check_field(
['field', 'input_type', 'label', 'required', 'option_list'],
currentItem.value
)
) {
return currentItem.value
}
return {
field: row.field || row.variable,
input_type: 'SingleSelect',
label: row.label || row.name,
default_value: row.default_value,
required: row.required || row.is_required,
required: row.required != undefined ? row.required : row.is_required,
option_list: row.optionList.map((o: any) => {
return { key: o, value: o }
})
}
break
case 'date':
currentItem.value = {
if (
check_field(
[
'field',
'input_type',
'label',
'required',
'attrs.format',
'attrs.value-format',
'attrs.type'
],
currentItem.value
)
) {
return currentItem.value
}
return {
field: row.field || row.variable,
input_type: 'DatePicker',
label: row.label || row.name,
default_value: row.default_value,
required: row.required || row.is_required,
required: row.required != undefined ? row.required : row.is_required,
attrs: {
format: 'YYYY-MM-DD HH:mm:ss',
'value-format': 'YYYY-MM-DD HH:mm:ss',
type: 'datetime'
}
}
break
default:
break
return currentItem.value
}
}
})
const currentIndex = ref(null)
const inputTypeList = ref([
{ label: '文本框', value: 'TextInputConstructor' },
{ label: '单选框', value: 'SingleSelectConstructor' },
{ label: '日期', value: 'DatePickerConstructor' }
])
const dialogVisible = ref<boolean>(false)
const open = (row: any, index: any) => {
dialogVisible.value = true
if (row) {
isEdit.value = true
currentItem.value = cloneDeep(row)
currentIndex.value = index
}
}
const close = () => {
Expand All @@ -119,7 +145,6 @@ const submit = async () => {
})
}
defineExpose({ open, close })
</script>
<style lang="scss" scoped></style>
19 changes: 8 additions & 11 deletions ui/src/workflow/nodes/base-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@submitDialog="submitDialog"
/>
</el-form-item>
<UserInputFieldTable ref="UserInputFieldTableFef" :node-model="nodeModel" />
<UserInputFieldTable ref="UserInputFieldTableFef" :node-model="nodeModel" />
<ApiInputFieldTable ref="ApiInputFieldTableFef" :node-model="nodeModel" />
<el-form-item>
<template #label>
Expand Down Expand Up @@ -90,7 +90,7 @@
></span>
<span>{{ item.name }}</span>
<el-tag v-if="item.permission_type === 'PUBLIC'" type="info" class="info-tag ml-8"
>公用
>公用
</el-tag>
</div>
<el-icon class="check-icon" v-if="item.id === form_data.stt_model_id">
Expand All @@ -113,8 +113,8 @@
></span>
<span>{{ item.name }}</span>
<span class="danger">{{
$t('views.application.applicationForm.form.aiModel.unavailable')
}}</span>
$t('views.application.applicationForm.form.aiModel.unavailable')
}}</span>
</div>
<el-icon class="check-icon" v-if="item.id === form_data.stt_model_id">
<Check />
Expand Down Expand Up @@ -174,7 +174,7 @@
></span>
<span>{{ item.name }}</span>
<el-tag v-if="item.permission_type === 'PUBLIC'" type="info" class="info-tag ml-8"
>公用
>公用
</el-tag>
</div>
<el-icon class="check-icon" v-if="item.id === form_data.tts_model_id">
Expand All @@ -197,8 +197,8 @@
></span>
<span>{{ item.name }}</span>
<span class="danger">{{
$t('views.application.applicationForm.form.aiModel.unavailable')
}}</span>
$t('views.application.applicationForm.form.aiModel.unavailable')
}}</span>
</div>
<el-icon class="check-icon" v-if="item.id === form_data.tts_model_id">
<Check />
Expand All @@ -208,9 +208,8 @@
</el-select>
</el-form-item>
</el-form>
<TTSModeParamSettingDialog ref="TTSModeParamSettingDialogRef" @refresh="refreshTTSForm" />
</NodeContainer>
<TTSModeParamSettingDialog ref="TTSModeParamSettingDialogRef" @refresh="refreshTTSForm" />
</template>
<script setup lang="ts">
import { app } from '@/main'
Expand Down Expand Up @@ -313,7 +312,6 @@ function getTTSModel() {
})
}
const openTTSParamSettingDialog = () => {
const model_id = form_data.value.tts_model_id
if (!model_id) {
Expand All @@ -327,7 +325,6 @@ const refreshTTSForm = (data: any) => {
form_data.value.tts_model_params_setting = data
}
onMounted(() => {
set(props.nodeModel, 'validate', validate)
if (!props.nodeModel.properties.node_data.tts_type) {
Expand Down

0 comments on commit 83f332a

Please sign in to comment.