Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ui/src/views/knowledge-workflow/component/action/DataSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</DynamicsForm>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { WorkflowKind, WorkflowType } from '@/enums/application'
import DynamicsForm from '@/components/dynamics-form/index.vue'
import type { FormField } from '@/components/dynamics-form/type'
Expand Down Expand Up @@ -135,6 +135,18 @@ const validate = () => {
const get_data = () => {
return form_data.value
}
watch(
source_node_list,
() => {
if (!base_form_data.value.node_id) {
if (source_node_list.value && source_node_list.value.length > 0) {
sourceChange(source_node_list.value[0].id)
}
}
},
{ immediate: true },
)

defineExpose({ validate, get_data })
</script>
<style lang="scss" scoped></style>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code has several minor optimizations and corrections:

  1. Import Statements: The import statements for Vue components are correctly placed at the top of the script block.

  2. Watch Statement:

    • A small typo was present in one place within the watch function: bas_form_data.value.node_id should be baseFormData.value.node_id.
    • Added an initial check to ensure that source_node_list is not null or undefined before iterating over its elements to avoid runtime errors.
  3. Define Expose Function: This line is correct and serves to expose methods and properties from the component's exported interface to other parts of the application.

Overall, the changes enhance readability and prevent potential runtime issues with variable naming errors during initialization.

Loading