-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: Workflow Knowledge Base Execution Record Search Result Exception #4460
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 |
|---|---|---|
|
|
@@ -19,8 +19,8 @@ | |
| </el-select> | ||
| <el-select | ||
| v-if="filter_type === 'state'" | ||
| v-model="query.status" | ||
| @change="getList" | ||
| v-model="query.state" | ||
| @change="getList(true)" | ||
| style="width: 220px" | ||
| clearable | ||
| > | ||
|
|
@@ -31,7 +31,7 @@ | |
| <el-input | ||
| v-else | ||
| v-model="query.user_name" | ||
| @change="getList" | ||
| @change="getList(true)" | ||
| :placeholder="$t('common.search')" | ||
| prefix-icon="Search" | ||
| style="width: 220px" | ||
|
|
@@ -133,7 +133,7 @@ const paginationConfig = reactive({ | |
| }) | ||
| const query = ref<any>({ | ||
| user_name: '', | ||
| status: '', | ||
| state: '', | ||
| }) | ||
| const loading = ref(false) | ||
| const filter_type = ref<string>('user_name') | ||
|
|
@@ -165,38 +165,22 @@ const changePage = () => { | |
| getList() | ||
| } | ||
|
|
||
| const getList = () => { | ||
| const getList = (clear?: boolean) => { | ||
| if (clear) { | ||
| paginationConfig.current_page = 1 | ||
| } | ||
| return loadSharedApi({ type: 'knowledge', systemType: apiType.value }) | ||
| .getWorkflowActionPage(active_knowledge_id.value, paginationConfig, query.value, loading) | ||
| .then((ok: any) => { | ||
| paginationConfig.total = ok.data?.total | ||
| data.value = data.value.concat(ok.data.records) | ||
| if (clear) { | ||
| data.value = ok.data.records | ||
| } else { | ||
| data.value = data.value.concat(ok.data.records) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| const setRowClass = ({ row }: any) => { | ||
| return currentId.value === row?.id ? 'highlight' : '' | ||
| } | ||
|
|
||
| /** | ||
| * 下一页 | ||
| */ | ||
| const nextRecord = () => { | ||
| const index = tableIndexMap.value[currentId.value] + 1 | ||
| if (index >= data.value.length) { | ||
| if (index >= paginationConfig.total - 1) { | ||
| return | ||
| } | ||
| paginationConfig.current_page = paginationConfig.current_page + 1 | ||
| getList().then(() => { | ||
| currentId.value = data.value[index].id | ||
| currentContent.value = data.value[index] | ||
| }) | ||
| } else { | ||
| currentId.value = data.value[index].id | ||
| currentContent.value = data.value[index] | ||
| } | ||
| } | ||
| const pre_disable = computed(() => { | ||
| const index = tableIndexMap.value[currentId.value] - 1 | ||
| return index < 0 | ||
|
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. The provided code has a few issues:
Here are some optimizations and corrections: a. Consistently Use Either const getList = (clear?: boolean) => {
if (clear) {
paginationConfig.current_page = 1;
}
const params = { ...query.value };
if (!Object.keys(params).length) params[user_filter_key.value] = ''; // Assuming this key exists
return loadSharedApi({ type: 'knowledge', systemType: apiType.value })
.getWorkflowActionPage(active_knowledge_id.value, paginationConfig, params, loading)
.then((ok: any) => {
paginationConfig.total = ok.data?.total;
if (clear) {
data.value = ok.data.records;
} else {
data.value = data.value.concat(ok.data.records);
}
});
};b. Ensure Consistent Use of Variable Names: type RowState = 'highlight';
let selectedRowHighlightID: string | null = null;
// Check functions can now refer accurately
setRowClass(row): string {
if (selectedRowHighlightID === row.id) {
return 'highlight';
}
// Default behavior for un-highlighted rows
}
onNextClick(): void {
let currentIndex = tableData.findIndex(r => r.id === currRowID);
if (currentIndex < 0 || currentIndex >= tableData.length - 1) return;
selectedRowHighlightID = tableData[currentIndex + 1].id;
}
onPrevClick(): void {
let currentIndex = tableData.findIndex(r => r.id === currRowID);
if (currentIndex <= 0 ) return;
selectedRowHighlightID = tableData[currentIndex - 1].id;
}This approach ensures that there isn't unnecessary duplication or misinterpretation of context. |
||
|
|
||
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.
The provided code has some potential issues and can be optimized:
Potential Error with
query_params: The method.page()is supposed to accept pagination parameters likecurrent_pageandpage_size. If these should come fromrequest.data, it suggests that there might be an issue with how the data is being accessed or passed.Security Consideration: The use of
TokenAuthfor authentication in theOperateview does not provide any additional protection beyond what is necessary for API calls that don't involve sensitive operations. Ensure that other security measures (like Django's UserAuthentication) are in place if required for more secure access controls.Code Documentation: While not strictly a coding mistake, adding proper documentation comments to your methods would help clarify their purpose and usage.
Here’s a revised version of the code with some improvements:
In this updated version:
pagination.ModuleName.pagination.PageNumberPaginationandserializers.module_name.KnowledgeWorkflowActionSerializerare correctly defined in your project.Always ensure that any custom logic related to
get_queryset()within the serializer is properly implemented and handles permissions and security appropriately.