Commit 3a03af12 by qinjianhui

feat: 挂起状态功能开发

parent 893492ca
......@@ -241,11 +241,23 @@ export function getSuspendListApi(
data: SearchForm,
currentPage: number,
pageSize: number,
statusCode?: string,
pauseReason?: number,
) {
return axios.post<never, BasePaginationData<FactoryOrderNewListData>>(
'factory/podOrderPauseControl/list_page',
{ ...data, currentPage, pageSize, statusCode },
{ ...data, currentPage, pageSize, pauseReason },
)
}
export function getSuspendStatisticsApi(
data: SearchForm,
currentPage: number,
pageSize: number,
pauseReason?: number,
) {
return axios.post<never, BaseRespData<Record<string, number>>>(
'factory/podOrderPauseControl/suspendStatistics',
{ ...data, currentPage, pageSize, pauseReason },
)
}
......
......@@ -5,9 +5,7 @@ import {
getFactoryOrderNewDetailApi,
getFactoryOrderNewListApi,
getFactoryOrderNewLogApi,
getSuspendDetailApi,
getSuspendListApi,
getSuspendLogApi,
} from '@/api/factoryOrderNew'
import type {
FactoryOrderNewListData,
......@@ -22,6 +20,7 @@ interface UseOrderListAndDetailOptions {
isTableLayout: Ref<boolean>
getQueryPayload: () => Record<string, unknown>
getListPageAcceptedSubStatus: () => number | undefined
suspendedSubTab: Ref<number>
}
export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
......@@ -31,6 +30,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
isTableLayout,
getQueryPayload,
getListPageAcceptedSubStatus,
suspendedSubTab,
} = options
const subLoading = ref(false)
......@@ -59,9 +59,11 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
getQueryPayload(),
page,
size,
status.value,
suspendedSubTab.value,
).then(async (res) => {
const records = Array.isArray(res.data?.records) ? res.data.records : []
const records = Array.isArray(res.data?.records)
? res.data.records
: []
await nextTick(() => {
tableRef.value.setCurrentRow(records[0])
currentRow.value = records[0] as never
......@@ -76,7 +78,7 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
status.value === 'ALL' ? undefined : status.value,
getListPageAcceptedSubStatus(),
).then(async (res) => {
const records = res.data.records
const records = res.data.records || []
await nextTick(() => {
tableRef.value.setCurrentRow(records[0])
currentRow.value = (records[0] as never) || null
......@@ -116,21 +118,27 @@ export function useOrderListAndDetail(options: UseOrderListAndDetailOptions) {
return
}
const id = currentRow.value.id
const isSuspend = status.value === 'SUSPEND'
// const isSuspend = status.value === 'SUSPEND'
const effectiveTab = tabName ?? activeTab.value
subLoading.value = true
try {
if (effectiveTab === 'product') {
productList.value = []
const productRes = isSuspend
? await getSuspendDetailApi(id)
: await getFactoryOrderNewDetailApi(id)
productList.value = Array.isArray(productRes.data) ? productRes.data : []
// const productRes = isSuspend
// ? await getSuspendDetailApi(id)
// : await getFactoryOrderNewDetailApi(id)
const productRes = await getFactoryOrderNewDetailApi(id)
if (productRes.code !== 200) return
productList.value = Array.isArray(productRes.data)
? productRes.data
: []
} else {
logList.value = []
const logRes = isSuspend
? await getSuspendLogApi(id)
: await getFactoryOrderNewLogApi(id)
// const logRes = isSuspend
// ? await getSuspendLogApi(id)
// : await getFactoryOrderNewLogApi(id)
const logRes = await getFactoryOrderNewLogApi(id)
if (logRes.code !== 200) return
logList.value = Array.isArray(logRes.data) ? logRes.data : []
}
} catch (e) {
......
import { computed, ref, nextTick } from 'vue'
import { getPodOrderAcceptedStatisticsApi, getPodOrderStateGroupListApi } from '@/api/factoryOrderNew'
import {
getPodOrderAcceptedStatisticsApi,
getPodOrderStateGroupListApi,
getSuspendStatisticsApi,
} from '@/api/factoryOrderNew'
import type { StatusTreeNode } from '@/types/api/order/factoryOrderNew'
interface UseOrderStatusTreeOptions {
......@@ -11,8 +15,13 @@ interface UseOrderStatusTreeOptions {
}
export function useOrderStatusTree(options: UseOrderStatusTreeOptions) {
const { getQueryPayload, currentPage, pageSize, onClearTableState, onRefreshCurrentView } =
options
const {
getQueryPayload,
currentPage,
pageSize,
onClearTableState,
onRefreshCurrentView,
} = options
const cardLayoutStatuses = [
'PENDING_SCHEDULE',
......@@ -25,9 +34,9 @@ export function useOrderStatusTree(options: UseOrderStatusTreeOptions) {
const statusTree = ref<StatusTreeNode[]>()
const status = ref<string>('PENDING_RECEIVE')
const pendingAcceptSubTab = ref<'PENDING_RECEIVE' | 'ACCEPT_FAIL_OUT_OF_STOCK'>(
'PENDING_RECEIVE',
)
const pendingAcceptSubTab = ref<
'PENDING_RECEIVE' | 'ACCEPT_FAIL_OUT_OF_STOCK'
>('PENDING_RECEIVE')
const pendingAcceptCounts = ref<{
acceptedOutOfStockCount?: number
pendingCount?: number
......@@ -36,16 +45,18 @@ export function useOrderStatusTree(options: UseOrderStatusTreeOptions) {
pendingCount: 0,
acceptedOutOfStockCount: 0,
})
const suspendedTabs = [
{ label: '客户拦截', value: 'CUSTOMER_INTERCEPT', count: 0 },
{ label: '地址异常', value: 'ADDRESS_EXCEPTION', count: 0 },
{ label: '其他', value: 'OTHER', count: 0 },
]
const suspendedSubTab = ref('CUSTOMER_INTERCEPT')
const suspendedTabs = ref([
{ label: '客户拦截', key: 'customerInterceptCount', value: 1, count: 0 },
{ label: '地址异常', key: 'addressExceptionCount', value: 2, count: 0 },
{ label: '其他', key: 'otherReasonCount', value: 4, count: 0 },
])
const suspendedSubTab = ref(1)
const treeRef = ref()
const isCardLayout = computed(() => cardLayoutStatuses.includes(status.value))
const isSpecialLayout = computed(() => specialLayoutStatuses.includes(status.value))
const isSpecialLayout = computed(() =>
specialLayoutStatuses.includes(status.value),
)
const isTableLayout = computed(
() => !isCardLayout.value && !isSpecialLayout.value,
)
......@@ -76,6 +87,25 @@ export function useOrderStatusTree(options: UseOrderStatusTreeOptions) {
}
}
const getSuspendCounts = async () => {
try {
const res = await getSuspendStatisticsApi(
getQueryPayload(),
currentPage.value,
pageSize.value,
suspendedSubTab.value,
)
if (res.code !== 200 || !res.data) return
const data = res.data || {}
suspendedTabs.value = suspendedTabs.value.map((tab) => ({
...tab,
count: data[String(tab.key)] ?? 0,
}))
} catch (e) {
console.error(e)
}
}
const loadStatusTreeCounts = async () => {
try {
const res = await getPodOrderStateGroupListApi()
......@@ -96,12 +126,15 @@ export function useOrderStatusTree(options: UseOrderStatusTreeOptions) {
pendingAcceptSubTab.value = 'PENDING_RECEIVE'
}
if (node.status !== 'SUSPEND') {
suspendedSubTab.value = 'CUSTOMER_INTERCEPT'
suspendedSubTab.value = 1
}
onClearTableState()
if (!isSpecialLayout.value) {
onRefreshCurrentView()
}
if (node.status === 'SUSPEND') {
void getSuspendCounts()
}
}
const handlePendingAcceptTabClick = (
......@@ -132,6 +165,7 @@ export function useOrderStatusTree(options: UseOrderStatusTreeOptions) {
isTableLayout,
getListPageAcceptedSubStatus,
getPendingReceiveCounts,
getSuspendCounts,
loadStatusTreeCounts,
handleStatusNodeClick,
handlePendingAcceptTabClick,
......
......@@ -574,14 +574,9 @@
>
</span>
<!-- 待发货 -->
<template v-if="status === 'PENDING_DELIVERY'">
<span class="item">
<ElButton type="primary" @click="handleWeightSort"
>称重分拣</ElButton
>
</span>
</template>
<span v-if="status === 'PENDING_DELIVERY'" class="item">
<ElButton type="primary" @click="handleWeightSort">称重分拣</ElButton>
</span>
<!-- 已完成 -->
<template v-if="status === 'COMPLETED'">
<span class="item">
......@@ -666,7 +661,7 @@
:key="tab.value"
class="status-subtab"
:class="{ active: suspendedSubTab === tab.value }"
@click="suspendedSubTab = tab.value"
@click="handleSuspendTabClick(tab.value)"
>
{{ tab.label }}({{ tab.count || 0 }})
</div>
......@@ -1005,6 +1000,7 @@ const {
isTableLayout,
getListPageAcceptedSubStatus,
getPendingReceiveCounts,
getSuspendCounts,
loadStatusTreeCounts,
handlePendingAcceptTabClick: handlePendingAcceptTabClickRaw,
toggleExpand,
......@@ -1045,6 +1041,7 @@ const {
isTableLayout,
getQueryPayload,
getListPageAcceptedSubStatus,
suspendedSubTab,
})
statusCurrentPageRef.value = currentPage.value
statusPageSizeRef.value = pageSize.value
......@@ -1066,6 +1063,9 @@ const refreshCurrentView = (options?: { isRefreshTree?: boolean }) => {
statusPageSizeRef.value = pageSize.value
void getPendingReceiveCounts()
}
if (status.value === 'SUSPEND') {
void getSuspendCounts()
}
refreshTableList()
}
refreshCurrentViewProxy.value = () => refreshCurrentView()
......@@ -1076,7 +1076,7 @@ const handleStatusNodeClick = (node: { status: string }) => {
pendingAcceptSubTab.value = 'PENDING_RECEIVE'
}
if (node.status !== 'SUSPEND') {
suspendedSubTab.value = 'CUSTOMER_INTERCEPT'
suspendedSubTab.value = 1
}
clearTableState()
if (!isSpecialLayout.value) {
......@@ -1086,6 +1086,14 @@ const handleStatusNodeClick = (node: { status: string }) => {
const handlePendingAcceptTabClick = (
tab: 'PENDING_RECEIVE' | 'ACCEPT_FAIL_OUT_OF_STOCK',
) => handlePendingAcceptTabClickRaw(tab, refreshTableList)
const handleSuspendTabClick = (value: number) => {
if (suspendedSubTab.value === value) return
suspendedSubTab.value = value
currentPage.value = 1
statusCurrentPageRef.value = 1
refreshTableList()
}
const mainColumns = [
{
prop: 'factoryOrderNumber',
......
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