Commit 4118f798 by wuqian

feat:工厂订单筛选操作单状态、订单列表展示延期时间#ID1011328

parent 54195e1d
......@@ -11,6 +11,7 @@ import type {
RestockData,
SearchForm,
StatusTreeNode,
StatusListNode,
} from '@/types/api/factoryOrderNew'
import { ResultInfoDataItem } from '@/types/api/order/common'
import { ExportParams } from '@/types/api/order/factoryOrderNew'
......@@ -37,6 +38,11 @@ export function getPodOrderStateGroupListApi() {
'factory/podOrder/findStateGroupList',
)
}
export function getStatusPushApi() {
return axios.get<never, BaseRespData<StatusListNode[]>>(
'factory/podOrderOperation/get-operation-order-status',
)
}
export function getFactoryOrderNewListApi(
data: SearchForm,
......
......@@ -5,7 +5,10 @@ export interface StatusTreeNode {
quantity: number
children: StatusTreeNode[] | null
}
export interface StatusListNode {
status: string
statusName: string
}
export interface SearchForm {
status?: string
pauseReason?: number
......
......@@ -7,6 +7,7 @@ export interface StatusTreeNode {
export interface SearchForm {
status?: string
operationStatus?: string | string[]
pauseReason?: number
platform?: string
craftCode?: string | string[]
......@@ -103,6 +104,7 @@ export interface FactoryOrderNewListData {
totalCustomsValue?: number
pauseStatus?: number
statusName?: string
finishTime?:string
thirdOrderNumber?: string
customTagList?: { id: string; name: string }[]
}
......
......@@ -62,7 +62,7 @@
class="search-form"
:model="searchForm"
:inline="true"
label-width="70px"
label-width="110px"
>
<ElFormItem v-if="status === 'ALL'" label="订单状态">
<ElTreeSelect
......@@ -178,7 +178,24 @@
width="140px"
/>
</ElFormItem>
<ElFormItem v-if="status === 'PICKING'" label="操作单状态">
<ElSelect
v-model="searchFormOperationStatusSelect"
placeholder="请选择"
clearable
multiple
collapse-tags
filterable
style="width: 170px"
>
<ElOption
v-for="(item, index) in statusList"
:key="index"
:value="item.status"
:label="item.statusName"
></ElOption>
</ElSelect>
</ElFormItem>
<ElFormItem label="数量">
<el-radio-group v-model="searchForm.multi">
<el-radio-button :value="false" @click="toggleMulti(false)"
......@@ -1241,6 +1258,7 @@
</template>
<script setup lang="tsx">
import dayjs from 'dayjs'
import {
ArrowDown,
ArrowUp,
......@@ -1298,6 +1316,7 @@ import {
interceptUpdateApi,
interceptSuccessApi,
deliveryCompleteApi,
getStatusPushApi,
} from '@/api/factoryOrderNew'
import { getConfigApi } from '@/api/order'
import { getLogisticsWayApi } from '@/api/podUsOrder'
......@@ -1329,6 +1348,7 @@ import ChangeWayDialog from '@/views/order/podCN/components/ChangeWayDialog.vue'
import { ResultInfoDataItem } from '@/types/api/order/common'
import type { FactoryOrderSearchQueryVisibilityContext } from '@/types/api/factoryOrderNew/searchQueryVisibility'
import type { StatusTreeNode } from '@/types/api/order/factoryOrderNew'
import type { StatusListNode } from '@/types/api/factoryOrderNew'
import { useOrderDictionaries } from './hooks/useOrderDictionaries'
import { useOrderSearchForm } from './hooks/useOrderSearchForm'
import { useOrderStatusTree } from './hooks/useOrderStatusTree'
......@@ -1456,7 +1476,17 @@ const searchFormStatusSelect = computed({
searchForm.value.status = arr.length ? arr.join(',') : undefined
},
})
const searchFormOperationStatusSelect = computed({
get() {
const val = searchForm.value.operationStatus
if (!val) return []
return String(val).split(',').filter(Boolean)
},
set(val: string | string[] | undefined) {
const arr = Array.isArray(val) ? val : val ? [val] : []
searchForm.value.operationStatus = arr.length ? arr.join(',') : undefined
},
})
getFactoryOrderSearchVisibilityContext = () => ({
status: searchForm.value.status ?? status.value,
isCardLayout: isCardLayout.value,
......@@ -1699,11 +1729,28 @@ const handleStatusNodeClick = (node: { status: string }) => {
if (node.status !== 'CANCELLED') {
cancelledSubTab.value = 1
}
if (node.status === 'PICKING') {
getOrderStatus()
}
clearTableState()
if (!isSpecialLayout.value) {
refreshCurrentView()
}
}
const statusList = ref<StatusListNode[]>([])
const getOrderStatus = async () => {
try {
const res = await getStatusPushApi()
if (res.code === 200) {
statusList.value = res.data
} else {
ElMessage.error(res.message)
}
} catch (error) {
console.error(error)
ElMessage.error('订单状态刷新失败')
}
}
const handlePendingAcceptTabClick = (
tab: 'PENDING_RECEIVE' | 'ACCEPT_FAIL_OUT_OF_STOCK',
) => handlePendingAcceptTabClickRaw(tab, refreshTableList)
......@@ -1896,6 +1943,28 @@ const mainColumns = computed(() => [
width: 140,
align: 'center',
},
// 订单状态为已取消时隐藏延期时间列
...(status.value === 'CANCELLED'
? []
: [
{
prop: 'createTime',
label: '延期时间',
width: 140,
align: 'center',
render: (row: FactoryOrderNewListData) => {
const delayText = getOrderDelayText(
row.createTime ?? '',
row.finishTime ?? '',
)
return (
<div style={{ color: 'red', fontWeight: 'bolder' }}>
{delayText}
</div>
)
},
},
]),
{
prop: 'logisticsWayName',
label: '物流类型',
......@@ -2588,6 +2657,35 @@ const handleUpdateCustomsInfo = async () => {
await nextTick()
updateCustomsDialogRef.value?.resetForm()
}
// 值为空:待接单
const PENDING_RECEIVE_STATUSES = ['PENDING_RECEIVE']
// 终态订单:已完成/已归档
const TERMINAL_ORDER_STATUSES = ['COMPLETED', 'ARCHIVE']
const getOrderDelayText = (
createTime?: string | null,
finishTime?: string | null,
) => {
if (!createTime) return ''
if (TERMINAL_ORDER_STATUSES.includes(status.value) && !finishTime) return ''
const createAt = dayjs(createTime)
if (!createAt.isValid()) return ''
// 终态订单用 finishTime - createTime 的差值
// 其他状态用 当前时间 - createTime 的差值
const endTime =
TERMINAL_ORDER_STATUSES.includes(status.value) && finishTime
? dayjs(finishTime)
: dayjs()
const diffMinutes = Math.max(0, endTime.diff(createAt, 'minute'))
const baseHours = Math.floor(diffMinutes / 60)
const remainMinutes = diffMinutes % 60
const hours = baseHours + (remainMinutes > 30 ? 1 : 0)
// 待接单状态不显示时间,其余显示小时数
const result = !PENDING_RECEIVE_STATUSES.includes(status?.value)
? `${hours}h`
: ''
return result
}
const handleTransferToArrange = async () => {
if (!ensureSelection('请选择订单')) return
......
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