-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: The switch node does not display default values #1957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,7 +53,11 @@ | |
| </div></template | ||
| > | ||
|
|
||
| <el-table class="border" v-if="form_data.form_field_list.length > 0" :data="form_data.form_field_list"> | ||
| <el-table | ||
| class="border" | ||
| v-if="form_data.form_field_list.length > 0" | ||
| :data="form_data.form_field_list" | ||
| > | ||
| <el-table-column prop="field" label="参数"> | ||
| <template #default="{ row }"> | ||
| <span :title="row.field" class="ellipsis-1">{{ row.field }}</span> | ||
|
|
@@ -84,7 +88,9 @@ | |
|
|
||
| <el-table-column prop="default_value" label="默认值"> | ||
| <template #default="{ row }"> | ||
| <span :title="row.default_value" class="ellipsis-1">{{ getDefaultValue(row) }}</span> | ||
| <span :title="row.default_value" class="ellipsis-1">{{ | ||
| getDefaultValue(row) | ||
| }}</span> | ||
| </template> | ||
| </el-table-column> | ||
| <el-table-column label="必填"> | ||
|
|
@@ -208,6 +214,9 @@ const getDefaultValue = (row: any) => { | |
| } | ||
| return row.default_value | ||
| } | ||
| if (row.default_value !== undefined) { | ||
| return row.default_value | ||
| } | ||
| } | ||
|
|
||
| const validate = () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no immediate irregularities, potential issues, or optimization opportunities identified in the provided Vue.js template with an El Table component.
Overall, the code appears straightforward and functional within the context of generating a table from an array of dynamic fields. Here’s a minor improvement for better clarity: const validate = () => {
return form_data.form_field_list.every(field => {
if ((field.hasOwnProperty('field') && field.field.trim() === '') ||
(!field.hasOwnProperty('default_value'))) {
errors.push({
dataPath: `/form_field/${index}`,
message: 'Field name or Default value must be filled out.'
});
}
});
}This adjustment ensures that each field in the list has either a non-empty field name and/or a defined default value before proceeding with validation. Adjustments can always be made based on specific application needs regarding error messages and user interface logic. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can review this code snippet for you. Here are some suggestions:
Changes and Suggestions:
default_valueis a string andoption_listis an object.return ''withnullwhen no match is found, which allows the caller to determine whether a valid value was returned or not.findinstead offilterwhere possible to find only matches without creating unnecessary arrays.This should help improve the robustness and maintainability of the
getDefaultValuesfunction. Let me know if you have any other questions!