Commit be5de7ac by qinjianhui

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

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