Skip to content

Commit 108167d

Browse files
fix: Execution record page issue
1 parent ae2f0ca commit 108167d

File tree

5 files changed

+86
-56
lines changed

5 files changed

+86
-56
lines changed

ui/src/views/knowledge-workflow/component/execution-record/ExecutionRecordDrawer.vue

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<app-table
4646
ref="multipleTableRef"
4747
class="mt-16 document-table"
48-
:data="data"
48+
:data="tableData"
4949
:maxTableHeight="200"
5050
:pagination-config="paginationConfig"
5151
@sizeChange="changeSize"
@@ -164,14 +164,8 @@ const query = ref<any>({
164164
const loading = ref(false)
165165
const filter_type = ref<string>('user_name')
166166
const active_knowledge_id = ref<string>('')
167-
const data = ref<Array<any>>([])
168-
const tableIndexMap = computed<Dict<number>>(() => {
169-
return data.value
170-
.map((row, index) => ({
171-
[row.id]: index,
172-
}))
173-
.reduce((pre, next) => ({ ...pre, ...next }), {})
174-
})
167+
const tableData = ref<Array<any>>([])
168+
175169
const ExecutionDetailDrawerRef = ref<any>()
176170
const currentId = ref<string>('')
177171
const currentContent = ref<string>('')
@@ -211,50 +205,64 @@ const getList = (isLoading?: boolean) => {
211205
)
212206
.then((ok: any) => {
213207
paginationConfig.total = ok.data?.total
214-
data.value = ok.data.records
208+
tableData.value = ok.data.records
215209
})
216210
}
217211
212+
218213
const pre_disable = computed(() => {
219-
const index = tableIndexMap.value[currentId.value] - 1
220-
return index < 0
214+
const index = tableData.value.findIndex((item) => item.id === currentId.value)
215+
return index === 0 && paginationConfig.current_page === 1
221216
})
222217
223218
const next_disable = computed(() => {
224-
const index = tableIndexMap.value[currentId.value] + 1
225-
return index >= data.value.length && index >= paginationConfig.total - 1
219+
const index = tableData.value.findIndex((item) => item.id === currentId.value) + 1
220+
return (
221+
index >= tableData.value.length &&
222+
index + (paginationConfig.current_page - 1) * paginationConfig.page_size >=
223+
paginationConfig.total - 1
224+
)
226225
})
227226
227+
228228
const interval = ref<any>()
229229
/**
230230
* 下一页
231231
*/
232232
const nextRecord = () => {
233-
const index = tableIndexMap.value[currentId.value] + 1
234-
if (index >= data.value.length) {
235-
if (index >= paginationConfig.total - 1) {
233+
const index = tableData.value.findIndex((item) => item.id === currentId.value) + 1
234+
if (index >= tableData.value.length) {
235+
if (paginationConfig.current_page * paginationConfig.page_size >= paginationConfig.total) {
236236
return
237237
}
238238
paginationConfig.current_page = paginationConfig.current_page + 1
239239
getList(true).then(() => {
240-
currentId.value = data.value[index].id
241-
currentContent.value = data.value[index]
240+
currentId.value = tableData.value[index].id
241+
currentContent.value = tableData.value[index]
242242
})
243+
return
243244
} else {
244-
currentId.value = data.value[index].id
245-
currentContent.value = data.value[index]
245+
currentId.value = tableData.value[index].id
246+
currentContent.value = tableData.value[index]
246247
}
247248
}
248249
/**
249250
* 上一页
250251
*/
251252
const preRecord = () => {
252-
const index = tableIndexMap.value[currentId.value] - 1
253-
console.log('index', index)
254-
255-
if (index >= 0) {
256-
currentId.value = data.value[index].id
257-
currentContent.value = data.value[index]
253+
const index = tableData.value.findIndex((item) => item.id === currentId.value) - 1
254+
if (index < 0 && 1) {
255+
if (paginationConfig.current_page === 1) {
256+
return
257+
}
258+
paginationConfig.current_page = paginationConfig.current_page - 1
259+
getList(true).then(() => {
260+
currentId.value = tableData.value[tableData.value.length - 1].id
261+
currentContent.value = tableData.value[tableData.value.length - 1]
262+
})
263+
} else {
264+
currentId.value = tableData.value[index].id
265+
currentContent.value = tableData.value[index]
258266
}
259267
}
260268
@@ -269,7 +277,7 @@ const open = (knowledge_id: string) => {
269277
const close = () => {
270278
paginationConfig.current_page = 1
271279
paginationConfig.total = 0
272-
data.value = []
280+
tableData.value = []
273281
drawer.value = false
274282
if (interval.value) {
275283
clearInterval(interval.value)

ui/src/views/paragraph/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function setPosition(val: string, index: number) {
256256
if (val === 'top') {
257257
return 0
258258
} else if (val === 'bottom') {
259-
return paragraphDetail.value.length - 1
259+
return paginationConfig.total - 1
260260
} else if (val === 'up') {
261261
return index - 1
262262
} else if (val === 'down') {

ui/src/views/tool/execution-record/TriggerRecordDrawer.vue

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,6 @@ const query = ref<any>({
211211
const loading = ref<boolean>(false)
212212
const current_trigger_id = ref<string>()
213213
214-
const tableIndexMap = computed<Dict<number>>(() => {
215-
return tableData.value
216-
.map((row, index) => ({
217-
[row.id]: index,
218-
}))
219-
.reduce((pre, next) => ({ ...pre, ...next }), {})
220-
})
221214
const ExecutionDetailDrawerRef = ref<any>()
222215
223216
const currentId = ref<string>('')
@@ -258,29 +251,34 @@ const getList = (isLoading?: boolean) => {
258251
}
259252
260253
const pre_disable = computed(() => {
261-
const index = tableIndexMap.value[currentId.value] - 1
262-
return index < 0
254+
const index = tableData.value.findIndex((item) => item.id === currentId.value)
255+
return index === 0 && paginationConfig.current_page === 1
263256
})
264257
265258
const next_disable = computed(() => {
266-
const index = tableIndexMap.value[currentId.value] + 1
267-
return index >= tableData.value.length && index >= paginationConfig.total - 1
259+
const index = tableData.value.findIndex((item) => item.id === currentId.value) + 1
260+
return (
261+
index >= tableData.value.length &&
262+
index + (paginationConfig.current_page - 1) * paginationConfig.page_size >=
263+
paginationConfig.total - 1
264+
)
268265
})
269266
270267
/**
271268
* 下一页
272269
*/
273270
const nextRecord = () => {
274-
const index = tableIndexMap.value[currentId.value] + 1
271+
const index = tableData.value.findIndex((item) => item.id === currentId.value) + 1
275272
if (index >= tableData.value.length) {
276-
if (index >= paginationConfig.total - 1) {
273+
if (paginationConfig.current_page * paginationConfig.page_size >= paginationConfig.total) {
277274
return
278275
}
279276
paginationConfig.current_page = paginationConfig.current_page + 1
280277
getList(true).then(() => {
281278
currentId.value = tableData.value[index].id
282279
currentContent.value = tableData.value[index]
283280
})
281+
return
284282
} else {
285283
currentId.value = tableData.value[index].id
286284
currentContent.value = tableData.value[index]
@@ -290,9 +288,17 @@ const nextRecord = () => {
290288
* 上一页
291289
*/
292290
const preRecord = () => {
293-
const index = tableIndexMap.value[currentId.value] - 1
294-
295-
if (index >= 0) {
291+
const index = tableData.value.findIndex((item) => item.id === currentId.value) - 1
292+
if (index < 0 && 1) {
293+
if (paginationConfig.current_page === 1) {
294+
return
295+
}
296+
paginationConfig.current_page = paginationConfig.current_page - 1
297+
getList(true).then(() => {
298+
currentId.value = tableData.value[tableData.value.length - 1].id
299+
currentContent.value = tableData.value[tableData.value.length - 1]
300+
})
301+
} else {
296302
currentId.value = tableData.value[index].id
297303
currentContent.value = tableData.value[index]
298304
}

ui/src/views/trigger/ResourceTriggerDrawer.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h4>{{ $t('views.trigger.title') }}</h4>
55
</template>
66
<div class="flex-between">
7-
<h4 class="title-decoration-1">
7+
<h4 class="title-decoration-1 mb-12">
88
{{ $t('views.trigger.title') }}
99
</h4>
1010
<el-button
@@ -26,7 +26,9 @@
2626
<span class="ellipsis-1" :title="item.name"> {{ item.name }}</span>
2727
</div>
2828
<div class="w-180">
29-
{{ getTriggerCycleLabel(item.trigger_setting) }}
29+
<span v-if="item.trigger_type === 'SCHEDULED'">
30+
{{ getTriggerCycleLabel(item.trigger_setting) }}</span
31+
>
3032
</div>
3133
<div>
3234
<span class="mr-4">

ui/src/views/trigger/execution-record/TriggerTaskRecordDrawer.vue

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,36 @@ const getList = (isLoading?: boolean) => {
222222
} else return Promise.resolve()
223223
}
224224
225+
225226
const pre_disable = computed(() => {
226-
const index = tableIndexMap.value[currentId.value] - 1
227-
return index < 0
227+
const index = tableData.value.findIndex((item) => item.id === currentId.value)
228+
return index === 0 && paginationConfig.current_page === 1
228229
})
229230
230231
const next_disable = computed(() => {
231-
const index = tableIndexMap.value[currentId.value] + 1
232-
return index >= tableData.value.length && index >= paginationConfig.total - 1
232+
const index = tableData.value.findIndex((item) => item.id === currentId.value) + 1
233+
return (
234+
index >= tableData.value.length &&
235+
index + (paginationConfig.current_page - 1) * paginationConfig.page_size >=
236+
paginationConfig.total - 1
237+
)
233238
})
234239
235240
/**
236241
* 下一页
237242
*/
238243
const nextRecord = () => {
239-
const index = tableIndexMap.value[currentId.value] + 1
244+
const index = tableData.value.findIndex((item) => item.id === currentId.value) + 1
240245
if (index >= tableData.value.length) {
241-
if (index >= paginationConfig.total - 1) {
246+
if (paginationConfig.current_page * paginationConfig.page_size >= paginationConfig.total) {
242247
return
243248
}
244249
paginationConfig.current_page = paginationConfig.current_page + 1
245250
getList(true).then(() => {
246251
currentId.value = tableData.value[index].id
247252
currentContent.value = tableData.value[index]
248253
})
254+
return
249255
} else {
250256
currentId.value = tableData.value[index].id
251257
currentContent.value = tableData.value[index]
@@ -255,9 +261,17 @@ const nextRecord = () => {
255261
* 上一页
256262
*/
257263
const preRecord = () => {
258-
const index = tableIndexMap.value[currentId.value] - 1
259-
260-
if (index >= 0) {
264+
const index = tableData.value.findIndex((item) => item.id === currentId.value) - 1
265+
if (index < 0 && 1) {
266+
if (paginationConfig.current_page === 1) {
267+
return
268+
}
269+
paginationConfig.current_page = paginationConfig.current_page - 1
270+
getList(true).then(() => {
271+
currentId.value = tableData.value[tableData.value.length - 1].id
272+
currentContent.value = tableData.value[tableData.value.length - 1]
273+
})
274+
} else {
261275
currentId.value = tableData.value[index].id
262276
currentContent.value = tableData.value[index]
263277
}

0 commit comments

Comments
 (0)