Commit f5bb4f4e by qinjianhui

fix: 时间添加排序

parent 663cd9c1
......@@ -38,6 +38,10 @@ export interface SearchForm {
productMarkList?: string[]
podCustomizedQuantity?: string
cpCustomizedQuantity?: string
/** list_page 排序字段,需与 order 同时传递 */
prop?: string
/** list_page 排序方向:asc 正序,desc 倒序 */
order?: 'asc' | 'desc'
}
export interface FactoryOrderNewListData {
......
......@@ -42,6 +42,10 @@ export interface SearchForm {
/** list_page:一件定制局部印单面/多面,与 productMarkList 中 custom_part 联动 */
cpCustomizedQuantity?: string
operationNo?: string
/** list_page 排序字段,需与 order 同时传递 */
prop?: string
/** list_page 排序方向:asc 正序,desc 倒序 */
order?: 'asc' | 'desc'
}
export interface FactoryOrderNewListData {
......
......@@ -7,6 +7,7 @@ import {
getFactoryOrderNewLogApi,
getSuspendListApi,
} from '@/api/factoryOrderNew'
import type { SearchForm } from '@/types/api/factoryOrderNew'
import type {
FactoryOrderNewListData,
LogListData,
......@@ -43,6 +44,21 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
const selectedRows = ref<FactoryOrderNewListData[]>([])
const cardSelectList = ref<operateOrderListData[]>([])
const listSortProp = ref<string | null>(null)
const listSortOrder = ref<'asc' | 'desc' | null>(null)
const buildListQueryBody = (): SearchForm => {
const base = { ...getQueryPayload() } as SearchForm
if (listSortProp.value && listSortOrder.value) {
return {
...base,
prop: listSortProp.value,
order: listSortOrder.value,
}
}
return base
}
const {
loading,
currentPage,
......@@ -56,7 +72,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
query: (page, size) => {
if (status.value === 'SUSPEND') {
return getSuspendListApi(
getQueryPayload(),
buildListQueryBody(),
page,
size,
suspendedSubTab.value,
......@@ -72,7 +88,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
})
}
return getFactoryOrderNewListApi(
getQueryPayload(),
buildListQueryBody(),
page,
size,
status.value === 'ALL' ? undefined : status.value,
......@@ -100,6 +116,51 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
productList.value = []
logList.value = []
currentRow.value = null
listSortProp.value = null
listSortOrder.value = null
}
const SORTABLE_COLUMN_PROPS = [
'createTime',
'startStockingTime',
'finishTime',
] as const
/** 表格列 prop → 后端 list_page 排序字段(如 MyBatis 列别名) */
const LIST_SORT_PROP_BY_COLUMN: Record<
(typeof SORTABLE_COLUMN_PROPS)[number],
string
> = {
createTime: 'po.create_time',
startStockingTime: 'po.start_stocking_time',
finishTime: 'po.finish_time',
}
const handleMainTableSortChange = (data: {
prop?: string
order: string | null
}) => {
const { prop, order } = data
if (
!prop ||
!SORTABLE_COLUMN_PROPS.includes(
prop as (typeof SORTABLE_COLUMN_PROPS)[number],
)
) {
return
}
const sortProp = LIST_SORT_PROP_BY_COLUMN[prop as keyof typeof LIST_SORT_PROP_BY_COLUMN]
if (order === 'ascending') {
listSortProp.value = sortProp
listSortOrder.value = 'asc'
} else if (order === 'descending') {
listSortProp.value = sortProp
listSortOrder.value = 'desc'
} else {
listSortProp.value = null
listSortOrder.value = null
}
refreshTableList()
}
const handleMainSelectionChange = (rows: FactoryOrderNewListData[]) => {
......@@ -197,5 +258,6 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
getOrderDetailsById,
handleRowClick,
handleTabClick,
handleMainTableSortChange,
}
}
......@@ -674,6 +674,7 @@
serial-numberable
selectionable
@selection-change="handleMainSelectionChange"
@sort-change="handleMainTableSortChange"
@row-click="handleRowClick"
>
<template #operation="{ row }">
......@@ -1046,6 +1047,7 @@ const {
getOrderDetailsById,
handleRowClick,
handleTabClick,
handleMainTableSortChange,
} = useOrderListAndDetail({
status,
isCardLayout,
......@@ -1272,18 +1274,24 @@ const mainColumns = computed(() => [
)
},
},
{ prop: 'createTime', label: '创建时间', minWidth: 180, align: 'center' },
{
prop: 'createTime',
label: '创建时间',
minWidth: 180,
align: 'center',
sortable: 'custom',
},
{
prop: 'startStockingTime',
label: '接单时间',
sortable: true,
sortable: 'custom',
minWidth: 180,
align: 'center',
},
{
prop: 'finishTime',
label: '完成时间',
sortable: true,
sortable: 'custom',
minWidth: 180,
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment