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
16 changes: 3 additions & 13 deletions ui/src/views/document/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@
:storeKey="storeKey"
>
<el-table-column type="selection" width="55" :reserve-selection="true" />
<el-table-column
prop="name"
:label="$t('views.document.table.name')"
min-width="280"
sortable
>
<el-table-column prop="name" :label="$t('views.document.table.name')" min-width="280">
<template #default="{ row }">
<ReadWrite
@change="editName($event, row.id)"
Expand Down Expand Up @@ -250,12 +245,7 @@
{{ $t(hitHandlingMethod[row.hit_handling_method as keyof typeof hitHandlingMethod]) }}
</template>
</el-table-column>
<el-table-column
prop="create_time"
:label="$t('common.createTime')"
width="175"
sortable
>
<el-table-column prop="create_time" :label="$t('common.createTime')" width="175" sortable>
<template #default="{ row }">
{{ datetimeFormat(row.create_time) }}
</template>
Expand Down Expand Up @@ -829,7 +819,7 @@ function getList(bool?: boolean) {
const param = {
...(filterText.value && { name: filterText.value }),
...filterMethod.value,
order_by: orderBy.value,
order_by: orderBy.value
}
documentApi
.getDocument(id as string, paginationConfig.value, param, bool ? undefined : loading)
Copy link
Copy Markdown
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 looks generally correct for an El Table component setup. Here's a concise review with some minor suggestions:

Potential Issues

  1. Duplicate Code: The "Create Time" column has both sortable set to false and no filters property defined in the template slot (#default). This might be unintentional.

  2. Parameter Merge Logic in getList Function:

    • Line 829 is almost identical to line 826 but uses arrow functions instead of traditional callbacks. Ensure this behavior aligns with your design preferences.
  3. TypeScript Typing: There are type annotations like (hitHandlingMethod[row.hit_handling_method as keyof typeof hitHandlingMethod]) which should ensure that the lookup using row.hit_handling_method returns a valid index into the dictionary hitHandlingMethod. If it could return null/undefined, additional error handling might be necessary.

Optimization Suggestions

  1. Simplified Filter Handling: Consider consolidating duplicate logic around filters by creating a reusable utility function or merging conditional checks within a single method call where applicable (e.g., checking if filterText.value exists before adding its key-value pair).

  2. Consistent Arrow Functions Usage: While not mandatory here, consistent use of either traditional callback methods or arrow functions can improve readability and consistency.

  3. Error Handling in Type Annotations: For better developer experience, consider more descriptive type definitions. For example, replace "views.document.table.name" and "common.createTime" with their respective imported keys from $t.

Overall, the overall structure seems functional given the context, but these points might aid optimization and maintainability.

Expand Down