Commit f5bb4f4e by qinjianhui

fix: 时间添加排序

parent 663cd9c1
...@@ -38,6 +38,10 @@ export interface SearchForm { ...@@ -38,6 +38,10 @@ export interface SearchForm {
productMarkList?: string[] productMarkList?: string[]
podCustomizedQuantity?: string podCustomizedQuantity?: string
cpCustomizedQuantity?: string cpCustomizedQuantity?: string
/** list_page 排序字段,需与 order 同时传递 */
prop?: string
/** list_page 排序方向:asc 正序,desc 倒序 */
order?: 'asc' | 'desc'
} }
export interface FactoryOrderNewListData { export interface FactoryOrderNewListData {
......
...@@ -42,6 +42,10 @@ export interface SearchForm { ...@@ -42,6 +42,10 @@ export interface SearchForm {
/** list_page:一件定制局部印单面/多面,与 productMarkList 中 custom_part 联动 */ /** list_page:一件定制局部印单面/多面,与 productMarkList 中 custom_part 联动 */
cpCustomizedQuantity?: string cpCustomizedQuantity?: string
operationNo?: string operationNo?: string
/** list_page 排序字段,需与 order 同时传递 */
prop?: string
/** list_page 排序方向:asc 正序,desc 倒序 */
order?: 'asc' | 'desc'
} }
export interface FactoryOrderNewListData { export interface FactoryOrderNewListData {
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
getFactoryOrderNewLogApi, getFactoryOrderNewLogApi,
getSuspendListApi, getSuspendListApi,
} from '@/api/factoryOrderNew' } from '@/api/factoryOrderNew'
import type { SearchForm } from '@/types/api/factoryOrderNew'
import type { import type {
FactoryOrderNewListData, FactoryOrderNewListData,
LogListData, LogListData,
...@@ -43,6 +44,21 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) { ...@@ -43,6 +44,21 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
const selectedRows = ref<FactoryOrderNewListData[]>([]) const selectedRows = ref<FactoryOrderNewListData[]>([])
const cardSelectList = ref<operateOrderListData[]>([]) 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 { const {
loading, loading,
currentPage, currentPage,
...@@ -56,7 +72,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) { ...@@ -56,7 +72,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
query: (page, size) => { query: (page, size) => {
if (status.value === 'SUSPEND') { if (status.value === 'SUSPEND') {
return getSuspendListApi( return getSuspendListApi(
getQueryPayload(), buildListQueryBody(),
page, page,
size, size,
suspendedSubTab.value, suspendedSubTab.value,
...@@ -72,7 +88,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) { ...@@ -72,7 +88,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
}) })
} }
return getFactoryOrderNewListApi( return getFactoryOrderNewListApi(
getQueryPayload(), buildListQueryBody(),
page, page,
size, size,
status.value === 'ALL' ? undefined : status.value, status.value === 'ALL' ? undefined : status.value,
...@@ -100,6 +116,51 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) { ...@@ -100,6 +116,51 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
productList.value = [] productList.value = []
logList.value = [] logList.value = []
currentRow.value = null 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[]) => { const handleMainSelectionChange = (rows: FactoryOrderNewListData[]) => {
...@@ -197,5 +258,6 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) { ...@@ -197,5 +258,6 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
getOrderDetailsById, getOrderDetailsById,
handleRowClick, handleRowClick,
handleTabClick, handleTabClick,
handleMainTableSortChange,
} }
} }
...@@ -674,6 +674,7 @@ ...@@ -674,6 +674,7 @@
serial-numberable serial-numberable
selectionable selectionable
@selection-change="handleMainSelectionChange" @selection-change="handleMainSelectionChange"
@sort-change="handleMainTableSortChange"
@row-click="handleRowClick" @row-click="handleRowClick"
> >
<template #operation="{ row }"> <template #operation="{ row }">
...@@ -1046,6 +1047,7 @@ const { ...@@ -1046,6 +1047,7 @@ const {
getOrderDetailsById, getOrderDetailsById,
handleRowClick, handleRowClick,
handleTabClick, handleTabClick,
handleMainTableSortChange,
} = useOrderListAndDetail({ } = useOrderListAndDetail({
status, status,
isCardLayout, isCardLayout,
...@@ -1272,18 +1274,24 @@ const mainColumns = computed(() => [ ...@@ -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', prop: 'startStockingTime',
label: '接单时间', label: '接单时间',
sortable: true, sortable: 'custom',
minWidth: 180, minWidth: 180,
align: 'center', align: 'center',
}, },
{ {
prop: 'finishTime', prop: 'finishTime',
label: '完成时间', label: '完成时间',
sortable: true, sortable: 'custom',
minWidth: 180, 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