|
58 | 58 | @creatQuick="creatQuickHandle" |
59 | 59 | @row-click="rowClickHandle" |
60 | 60 | @selection-change="handleSelectionChange" |
| 61 | + @sort-change="handleSortChange" |
61 | 62 | v-loading="loading" |
62 | 63 | :row-key="(row: any) => row.id" |
63 | 64 | :storeKey="storeKey" |
64 | 65 | > |
65 | 66 | <el-table-column type="selection" width="55" :reserve-selection="true" /> |
66 | | - <el-table-column prop="name" :label="$t('views.document.table.name')" min-width="280"> |
| 67 | + <el-table-column |
| 68 | + prop="name" |
| 69 | + :label="$t('views.document.table.name')" |
| 70 | + min-width="280" |
| 71 | + sortable |
| 72 | + > |
67 | 73 | <template #default="{ row }"> |
68 | 74 | <ReadWrite |
69 | 75 | @change="editName($event, row.id)" |
|
77 | 83 | :label="$t('views.document.table.char_length')" |
78 | 84 | align="right" |
79 | 85 | min-width="90" |
| 86 | + sortable |
80 | 87 | > |
81 | 88 | <template #default="{ row }"> |
82 | 89 | {{ numberFormat(row.char_length) }} |
|
87 | 94 | :label="$t('views.document.table.paragraph')" |
88 | 95 | align="right" |
89 | 96 | min-width="90" |
| 97 | + sortable |
90 | 98 | /> |
91 | 99 | <el-table-column prop="status" :label="$t('views.document.fileStatus.label')" width="130"> |
92 | 100 | <template #header> |
|
242 | 250 | {{ $t(hitHandlingMethod[row.hit_handling_method as keyof typeof hitHandlingMethod]) }} |
243 | 251 | </template> |
244 | 252 | </el-table-column> |
245 | | - <el-table-column prop="create_time" :label="$t('common.createTime')" width="175"> |
| 253 | + <el-table-column |
| 254 | + prop="create_time" |
| 255 | + :label="$t('common.createTime')" |
| 256 | + width="175" |
| 257 | + sortable |
| 258 | + > |
246 | 259 | <template #default="{ row }"> |
247 | 260 | {{ datetimeFormat(row.create_time) }} |
248 | 261 | </template> |
|
251 | 264 | prop="update_time" |
252 | 265 | :label="$t('views.document.table.updateTime')" |
253 | 266 | width="175" |
| 267 | + sortable |
254 | 268 | > |
255 | 269 | <template #default="{ row }"> |
256 | 270 | {{ datetimeFormat(row.update_time) }} |
@@ -509,6 +523,7 @@ const loading = ref(false) |
509 | 523 | let interval: any |
510 | 524 | const filterText = ref('') |
511 | 525 | const filterMethod = ref<any>({}) |
| 526 | +const orderBy = ref<string>('') |
512 | 527 | const documentData = ref<any[]>([]) |
513 | 528 | const currentMouseId = ref(null) |
514 | 529 | const datasetDetail = ref<any>({}) |
@@ -805,10 +820,16 @@ function handleSizeChange() { |
805 | 820 | getList() |
806 | 821 | } |
807 | 822 |
|
| 823 | +function handleSortChange({ prop, order }: { prop: string; order: string }) { |
| 824 | + orderBy.value = order === 'ascending' ? prop : `-${prop}` |
| 825 | + getList() |
| 826 | +} |
| 827 | +
|
808 | 828 | function getList(bool?: boolean) { |
809 | 829 | const param = { |
810 | 830 | ...(filterText.value && { name: filterText.value }), |
811 | | - ...filterMethod.value |
| 831 | + ...filterMethod.value, |
| 832 | + order_by: orderBy.value, |
812 | 833 | } |
813 | 834 | documentApi |
814 | 835 | .getDocument(id as string, paginationConfig.value, param, bool ? undefined : loading) |
|
0 commit comments