4747 @changePage =" changePage"
4848 :maxTableHeight =" 150"
4949 :paginationConfig =" paginationConfig"
50+ :row-class-name =" setRowClass"
5051 >
5152 <el-table-column prop =" user_name" :label =" $t('workflow.initiator')" >
5253 <template #default =" { row } " >
9495 </template >
9596 </el-table-column >
9697 </app-table-infinite-scroll >
97- <ExecutionDetailDrawer ref="ExecutionDetailDrawerRef" />
98+ <ExecutionDetailDrawer
99+ ref="ExecutionDetailDrawerRef"
100+ v-model :currentId =" currentId "
101+ v-model :currentContent =" currentContent "
102+ :next =" nextRecord "
103+ :pre =" preRecord "
104+ :pre_disable =" pre_disable "
105+ :next_disable =" next_disable "
106+ />
98107 </el-drawer >
99108</template >
100109<script setup lang="ts">
@@ -104,6 +113,7 @@ import ExecutionDetailDrawer from './ExecutionDetailDrawer.vue'
104113import { computed , ref , reactive } from ' vue'
105114import { useRoute , useRouter } from ' vue-router'
106115import { datetimeFormat } from ' @/utils/time'
116+ import type { Dict } from ' @/api/type/common'
107117const drawer = ref <boolean >(false )
108118const route = useRoute ()
109119
@@ -118,7 +128,7 @@ const apiType = computed(() => {
118128})
119129const paginationConfig = reactive ({
120130 current_page: 1 ,
121- page_size: 50 ,
131+ page_size: 10 ,
122132 total: 0 ,
123133})
124134const query = ref <any >({
@@ -129,10 +139,22 @@ const loading = ref(false)
129139const filter_type = ref <string >(' user_name' )
130140const active_knowledge_id = ref <string >(' ' )
131141const data = ref <Array <any >>([])
142+ const tableIndexMap = computed <Dict <number >>(() => {
143+ return data .value
144+ .map ((row , index ) => ({
145+ [row .id ]: index ,
146+ }))
147+ .reduce ((pre , next ) => ({ ... pre , ... next }), {})
148+ })
132149const ExecutionDetailDrawerRef = ref <any >()
150+ const currentId = ref <string >(' ' )
151+ const currentContent = ref <string >(' ' )
133152
134153const toDetails = (row : any ) => {
135- ExecutionDetailDrawerRef .value .open (row )
154+ currentContent .value = row
155+ currentId .value = row .id
156+
157+ ExecutionDetailDrawerRef .value ?.open ()
136158}
137159
138160const changeFilterHandle = () => {
@@ -144,13 +166,59 @@ const changePage = () => {
144166}
145167
146168const getList = () => {
147- loadSharedApi ({ type: ' knowledge' , systemType: apiType .value })
169+ return loadSharedApi ({ type: ' knowledge' , systemType: apiType .value })
148170 .getWorkflowActionPage (active_knowledge_id .value , paginationConfig , query .value , loading )
149171 .then ((ok : any ) => {
150172 paginationConfig .total = ok .data ?.total
151173 data .value = data .value .concat (ok .data .records )
152174 })
153175}
176+
177+ const setRowClass = ({ row }: any ) => {
178+ return currentId .value === row ?.id ? ' highlight' : ' '
179+ }
180+
181+ /**
182+ * 下一页
183+ */
184+ const nextRecord = () => {
185+ const index = tableIndexMap .value [currentId .value ] + 1
186+ if (index >= data .value .length ) {
187+ if (index >= paginationConfig .total - 1 ) {
188+ return
189+ }
190+ paginationConfig .current_page = paginationConfig .current_page + 1
191+ getList ().then (() => {
192+ currentId .value = data .value [index ].id
193+ currentContent .value = data .value [index ]
194+ })
195+ } else {
196+ currentId .value = data .value [index ].id
197+ currentContent .value = data .value [index ]
198+ }
199+ }
200+ const pre_disable = computed (() => {
201+ const index = tableIndexMap .value [currentId .value ] - 1
202+ return index < 0
203+ })
204+
205+ const next_disable = computed (() => {
206+ const index = tableIndexMap .value [currentId .value ] + 1
207+ return index >= data .value .length && index >= paginationConfig .total - 1
208+ })
209+ /**
210+ * 上一页
211+ */
212+ const preRecord = () => {
213+ const index = tableIndexMap .value [currentId .value ] - 1
214+ console .log (' index' , index )
215+
216+ if (index >= 0 ) {
217+ currentId .value = data .value [index ].id
218+ currentContent .value = data .value [index ]
219+ }
220+ }
221+
154222const open = (knowledge_id : string ) => {
155223 active_knowledge_id .value = knowledge_id
156224 getList ()
0 commit comments