Commit be5de7ac by qinjianhui

fix: 订单拦截功能接口联调

parent c7d581fe
......@@ -116,9 +116,9 @@ export function getFactoryOrderNewLogApi(id: number | string) {
}
export function getOperationOrderByIdApi(id: number | string) {
return axios.get<never, BaseRespData<operateOrderListData[]>>(
'factory/podOrder/getOperationOrderById',
'factory/podOrderOperation/getByPodOrderId',
{
params: { id },
params: { podOrderId: id },
},
)
}
......@@ -632,18 +632,17 @@ export function exportFactoryOrderInfo(data: ExportParams) {
}
export function interceptUpdateApi(ids: (string | number)[]) {
return axios.post<never, BaseRespData<never>>(
'factory/podOrder/interceptUpdate',
return axios.post<never, BaseRespData<ResultInfoDataItem[]>>(
'factory/podOrder/factoryOrderUnblock',
ids,
)
}
export function interceptSuccessApi(data: {
ids: (string | number)[]
interceptType: number
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podOrder/interceptSuccess',
export function interceptSuccessApi(
data: { factoryOrderNumber: string; suspendSussessType: number }[],
) {
return axios.post<never, BaseRespData<ResultInfoDataItem[]>>(
'factory/podOrder/factoryOrderBlockSuccess',
data,
)
}
......@@ -50,8 +50,11 @@ export function useOrderBatchActions(options: UseOrderBatchActionsOptions) {
const res = await action.api(ids)
if (res.code !== 200) return
if (action.successText) ElMessage.success(action.successText)
if (action.onSuccess) await action.onSuccess(res)
await refreshCurrentView({ isRefreshTree: !!action.refreshTree })
if (action.onSuccess) {
await action.onSuccess(res)
} else {
await refreshCurrentView({ isRefreshTree: !!action.refreshTree })
}
if (action.onAfter) await action.onAfter()
} catch (e) {
console.error(e)
......
......@@ -597,12 +597,12 @@
>
</span>
<span class="item">
<ElButton type="success" @click="handleInterceptionSuccess"
<ElButton type="success" @click="() => handleInterceptionSuccess()"
>拦截成功</ElButton
>
</span>
<span class="item">
<ElButton type="danger" @click="handleInterceptionFail"
<ElButton type="danger" @click="() => handleInterceptionFail()"
>拦截失败</ElButton
>
</span>
......@@ -676,7 +676,7 @@
</div>
</div>
<div v-if="status === 'CANCELLED'" class="status-subtabs">
<!-- <div v-if="status === 'CANCELLED'" class="status-subtabs">
<div
v-for="tab in cancelledTabs"
:key="tab.value"
......@@ -686,7 +686,7 @@
>
{{ tab.label }}({{ tab.count || 0 }})
</div>
</div>
</div> -->
<div v-if="status === 'PENDING_RECEIVE'" class="status-subtabs">
<div
......@@ -805,6 +805,24 @@
>
取消挂起
</ElButton>
<ElButton
v-if="status === 'SUSPEND'"
type="primary"
link
size="small"
@click.stop="handleInterceptionSuccess(row)"
>
拦截成功
</ElButton>
<ElButton
v-if="status === 'SUSPEND'"
type="primary"
link
size="small"
@click.stop="handleInterceptionFail(row)"
>
拦截失败
</ElButton>
</div>
</template>
</TableView>
......@@ -1007,7 +1025,7 @@
<ElForm ref="interceptSuccessFormRef" :model="interceptSuccessForm">
<ElFormItem
label="拦截成功类型"
prop="interceptType"
prop="suspendSussessType"
:rules="[
{
required: true,
......@@ -1017,7 +1035,7 @@
]"
>
<ElSelect
v-model="interceptSuccessForm.interceptType"
v-model="interceptSuccessForm.suspendSussessType"
placeholder="请选择"
style="width: 100%"
clearable
......@@ -1177,9 +1195,10 @@ const interceptSuccessTypeOptions = [
{ label: '生产拦截成功', value: 1 },
{ label: '发货拦截成功', value: 2 },
]
const interceptSuccessForm = ref<{ interceptType: number | undefined }>({
interceptType: undefined,
const interceptSuccessForm = ref<{ suspendSussessType: number | undefined }>({
suspendSussessType: undefined,
})
const interceptSuccessRows = ref<FactoryOrderNewListData[]>([])
const {
userMarkList,
......@@ -1224,7 +1243,7 @@ const {
pendingAcceptCounts,
suspendedTabs,
suspendedSubTab,
cancelledTabs,
// cancelledTabs,
cancelledSubTab,
treeRef,
isCardLayout,
......@@ -1233,7 +1252,7 @@ const {
getListPageAcceptedSubStatus,
getPendingReceiveCounts,
getSuspendCounts,
getCancelledCounts,
// getCancelledCounts,
loadStatusTreeCounts,
handlePendingAcceptTabClick: handlePendingAcceptTabClickRaw,
toggleExpand,
......@@ -1400,9 +1419,9 @@ const refreshCurrentView = (options?: { isRefreshTree?: boolean }) => {
if (status.value === 'SUSPEND') {
void getSuspendCounts()
}
if (status.value === 'CANCELLED') {
void getCancelledCounts()
}
// if (status.value === 'CANCELLED') {
// void getCancelledCounts()
// }
refreshTableList()
}
refreshCurrentViewProxy.value = () => refreshCurrentView()
......@@ -1520,13 +1539,13 @@ const handleSuspendTabClick = (value: number) => {
statusCurrentPageRef.value = 1
refreshTableList()
}
const handleCancelledTabClick = (value: number) => {
if (cancelledSubTab.value === value) return
cancelledSubTab.value = value
currentPage.value = 1
statusCurrentPageRef.value = 1
refreshTableList()
}
// const handleCancelledTabClick = (value: number) => {
// if (cancelledSubTab.value === value) return
// cancelledSubTab.value = value
// currentPage.value = 1
// statusCurrentPageRef.value = 1
// refreshTableList()
// }
const mainColumns = computed(() => [
{
prop: 'factoryOrderNumber',
......@@ -1711,10 +1730,9 @@ function parseOperationOrderImageAry(
}
function getOperationOrderMarkLabel(row: operateOrderListData): string {
const raw = row['prodcutMark'] ?? row.productMark
const mark = typeof raw === 'string' ? raw : ''
if (mark === 'custom_normal') return 'CB'
if (mark === 'normal') return 'G'
const mark = row.customizedQuantity
if (mark === 1) return '单面'
if (mark === 2) return '双面'
return ''
}
......@@ -1732,7 +1750,7 @@ const operationOrderColumns = [
prop: 'imageAry',
label: '商品图片',
minWidth: 100,
align: 'center' as const,
align: 'center',
render: (row: operateOrderListData) => {
const list = parseOperationOrderImageAry(row.imageAry)
if (!list.length) {
......@@ -1760,7 +1778,7 @@ const operationOrderColumns = [
prop: 'productName',
label: '商品名称',
minWidth: 180,
align: 'left' as const,
align: 'left',
showOverflowTooltip: true,
},
{
......@@ -1768,7 +1786,7 @@ const operationOrderColumns = [
prop: 'variantSku',
label: '变体SKU',
minWidth: 140,
align: 'center' as const,
align: 'center',
showOverflowTooltip: true,
},
{
......@@ -1776,7 +1794,7 @@ const operationOrderColumns = [
prop: 'thirdSkuCode',
label: '库存SKU',
minWidth: 140,
align: 'center' as const,
align: 'center',
showOverflowTooltip: true,
},
{
......@@ -1784,11 +1802,11 @@ const operationOrderColumns = [
prop: 'productMark',
label: '类型',
width: 72,
align: 'center' as const,
align: 'center',
render: (row: operateOrderListData) => {
const label = getOperationOrderMarkLabel(row)
if (!label) return <span />
return <ElTag type="info">{label}</ElTag>
return <ElTag type="primary">{label}</ElTag>
},
},
{
......@@ -1796,7 +1814,7 @@ const operationOrderColumns = [
prop: 'statusName',
label: '挂起前状态',
minWidth: 120,
align: 'left' as const,
align: 'center',
showOverflowTooltip: true,
},
{
......@@ -1804,7 +1822,7 @@ const operationOrderColumns = [
prop: 'craftName',
label: '工艺',
minWidth: 100,
align: 'center' as const,
align: 'center',
showOverflowTooltip: true,
},
{
......@@ -1812,7 +1830,7 @@ const operationOrderColumns = [
prop: 'supplierProductNo',
label: '款号',
minWidth: 120,
align: 'center' as const,
align: 'center',
showOverflowTooltip: true,
},
{
......@@ -1820,7 +1838,7 @@ const operationOrderColumns = [
prop: 'batchArrangeNumber',
label: '批次号',
minWidth: 120,
align: 'center' as const,
align: 'center',
showOverflowTooltip: true,
},
]
......@@ -2724,19 +2742,11 @@ const handleProductionComplete = async () => {
getIds: getSelectedIds,
api: completeDeliveryApi,
confirmText: '确定生产完成吗?',
refreshTree: true,
onSuccess: (res) => {
const data = Array.isArray(res.data)
? (res.data as ResultInfoDataItem[])
: []
const hasFailed = data.some((item) => !item.status)
if (hasFailed) {
resultInfo.value = data.filter((item) => !item.status)
resultRefs.value?.showDialog()
} else {
ElMessage.success('操作成功')
refreshCurrentView({ isRefreshTree: true })
}
openResultInfoDialog(data)
},
})
}
......@@ -2876,9 +2886,14 @@ const getLogisticsWay = async () => {
logisticsWayList.value = data
}
const handleInterceptionSuccess = () => {
if (!ensureSelection()) return
interceptSuccessForm.value.interceptType = undefined
const handleInterceptionSuccess = (row?: FactoryOrderNewListData) => {
if (row) {
interceptSuccessRows.value = [row]
} else {
if (!ensureSelection()) return
interceptSuccessRows.value = [...selectedRows.value]
}
interceptSuccessForm.value.suspendSussessType = undefined
interceptSuccessDialogVisible.value = true
nextTick(() => interceptSuccessFormRef.value?.clearValidate())
}
......@@ -2891,23 +2906,29 @@ const submitInterceptSuccess = async () => {
} catch {
return
}
const interceptType = interceptSuccessForm.value.interceptType
if (interceptType === undefined) return
const suspendSussessType = interceptSuccessForm.value.suspendSussessType
if (suspendSussessType === undefined) return
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
const rows = interceptSuccessRows.value
const data = rows.map((item: FactoryOrderNewListData) => {
return {
factoryOrderNumber: item.factoryOrderNumber as string,
suspendSussessType,
}
}) as { factoryOrderNumber: string; suspendSussessType: number }[]
try {
const res = await interceptSuccessApi({
ids: getSelectedIds(),
interceptType,
})
const res = await interceptSuccessApi(data)
if (res.code !== 200) return
ElMessage.success('操作成功')
interceptSuccessDialogVisible.value = false
refreshCurrentView({ isRefreshTree: true })
const resultData = Array.isArray(res.data)
? (res.data as ResultInfoDataItem[])
: []
openResultInfoDialog(resultData)
} catch (e) {
console.error(e)
} finally {
......@@ -2915,12 +2936,23 @@ const submitInterceptSuccess = async () => {
}
}
const handleInterceptionFail = async () => {
const handleInterceptionFail = async (row?: FactoryOrderNewListData) => {
await executeBatchAction({
getIds: getSelectedIds,
api: (ids) => interceptUpdateApi(ids as number[]),
getIds: () =>
row
? [row.factoryOrderNumber as string]
: selectedRows.value.map(
(item: FactoryOrderNewListData) =>
item.factoryOrderNumber as string,
),
api: (ids) => interceptUpdateApi(ids as string[]),
confirmText: '拦截失败,订单会恢复到拦截前的状态,确认是否拒绝拦截申请?',
successText: '拦截失败成功',
onSuccess: (res) => {
const data = Array.isArray(res.data)
? (res.data as ResultInfoDataItem[])
: []
openResultInfoDialog(data)
},
})
}
onMounted(() => {
......
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