Commit f14187fb by linjinhong

PODUS待发货状态添加创建物流按钮

parent 63e91d11
...@@ -284,3 +284,16 @@ export function changeLogisticsApi(params: { ...@@ -284,3 +284,16 @@ export function changeLogisticsApi(params: {
params, params,
) )
} }
// 创建物流
export function createLogisticsOrderApi(params: {
updateByIdParam: {
id: string | number
dataVersion: number
}
logisticsTrialCalculation: LogisticsData
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podJomallOrderUs/createLogisticsOrder',
params,
)
}
...@@ -178,6 +178,9 @@ ...@@ -178,6 +178,9 @@
</el-button> </el-button>
<template #dropdown> <template #dropdown>
<ElDropdownMenu> <ElDropdownMenu>
<ElDropdownItem @click="getOrderByIdApi('createLogisticsOrder')"
>创建物流</ElDropdownItem
>
<ElDropdownItem @click="getOrderByIdApi('getTrackingNumber')" <ElDropdownItem @click="getOrderByIdApi('getTrackingNumber')"
>获取跟踪号</ElDropdownItem >获取跟踪号</ElDropdownItem
> >
...@@ -901,7 +904,7 @@ ...@@ -901,7 +904,7 @@
<el-dialog <el-dialog
v-model="isChangeWay" v-model="isChangeWay"
:close-on-click-modal="false" :close-on-click-modal="false"
:title="`切换物流(当前物流方式:${selection[0]?.logisticsWayName})`" :title="wayDialogTitle"
> >
<el-table <el-table
v-loading="isChangeWayLoading" v-loading="isChangeWayLoading"
...@@ -911,7 +914,7 @@ ...@@ -911,7 +914,7 @@
:data="logisticsWayData" :data="logisticsWayData"
border border
highlight-current-row highlight-current-row
@current-change="currentChangeWay" @row-click="(v:LogisticsData) =>rowClick(v, wayDialogTitle)"
> >
<el-table-column <el-table-column
label="序号" label="序号"
...@@ -949,13 +952,13 @@ ...@@ -949,13 +952,13 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<template #footer> <template #footer>
<el-button :disabled="isChangeWayLoading" @click="isChangeWay = false"> <el-button :disabled="isChangeWayLoading" @click="cancelWayDialog">
取消 取消
</el-button> </el-button>
<el-button <el-button
:loading="isChangeWayLoading" :loading="isChangeWayLoading"
type="primary" type="primary"
@click="changeWaySubmit" @click="changeWaySubmit(wayDialogTitle)"
> >
确定 确定
</el-button> </el-button>
...@@ -992,7 +995,9 @@ import { ...@@ -992,7 +995,9 @@ import {
getfaceSimplexFileApi, getfaceSimplexFileApi,
cancelLogisticsOrderApi, cancelLogisticsOrderApi,
changeLogisticsApi, changeLogisticsApi,
createLogisticsOrderApi,
} from '@/api/podUsOrder' } from '@/api/podUsOrder'
import { BaseRespData } from '@/types/api'
import TableView from '@/components/TableView.vue' import TableView from '@/components/TableView.vue'
import { import {
...@@ -1664,52 +1669,61 @@ const printPodOrder = async () => { ...@@ -1664,52 +1669,61 @@ const printPodOrder = async () => {
} }
/** /**
* @description: 获取跟踪号、获取打印面单、取消物流订单 * @description: 创建物流、获取跟踪号、获取打印面单、更改物流、取消物流订单
*/ */
const getOrderByIdApi = async (type: string) => { const getOrderByIdApi = async (type: string) => {
if (selection.value.length === 0) { if (selection.value.length === 0) {
return ElMessage.warning('请选择数据') return ElMessage.warning('请选择数据')
} }
let message = ''
let Fn
if (type == 'getTrackingNumber') { const operationMap: {
message = '获取跟踪号' [key: string]: {
Fn = getTrackingNumberApi message: string
} else if (type == 'getPrintOrder') { Fn: (orderIds: (string | number)[]) => Promise<BaseRespData<never>>
message = '获取打印面单' }
Fn = getfaceSimplexFileApi } = {
} else if (type === 'cancelLogisticsOrder') { getTrackingNumber: { message: '获取跟踪号', Fn: getTrackingNumberApi },
message = '取消物流订单' getPrintOrder: { message: '获取打印面单', Fn: getfaceSimplexFileApi },
Fn = cancelLogisticsOrderApi cancelLogisticsOrder: {
} else if (type === 'batchChangeLogistics') { message: '取消物流订单',
Fn: cancelLogisticsOrderApi,
},
}
if (['batchChangeLogistics', 'createLogisticsOrder'].includes(type)) {
if (selection.value.length !== 1) { if (selection.value.length !== 1) {
return ElMessage.warning('请选择单条数据') return ElMessage.warning('请选择单条数据')
} }
wayDialogTitle.value =
type === 'batchChangeLogistics'
? `切换物流(当前物流方式:${selection.value[0]?.logisticsWayName})`
: '创建物流'
isChangeWay.value = true isChangeWay.value = true
const { data } = await getLogisticsCalculation(selection.value[0]?.id)
console.log(selection.value[0])
const { data } = await getLogisticsCalculation(selection.value[0]?.id)
logisticsWayData.value = data logisticsWayData.value = data
return return
} }
try {
await showConfirm(`确定对该订单 ${message}?`, {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
})
const ids = selection.value.map((el) => el.id)
// console.log(Fn)
if (Fn) { const operation = operationMap[type]
if (operation) {
try {
await showConfirm(`确定对该订单 ${operation.message}?`, {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
})
const ids = selection.value.map((el) => el.id)
const loading = ElLoading.service({ const loading = ElLoading.service({
fullscreen: true, fullscreen: true,
text: '操作中...', text: '操作中...',
}) })
const res = await Fn(ids)
console.log(res) const res = await operation.Fn(ids)
if (res.code === 200) { if (res.code === 200) {
if (isArray(res.data)) { if (isArray(res.data)) {
resultInfo.value = res.data resultInfo.value = res.data
...@@ -1721,10 +1735,11 @@ const getOrderByIdApi = async (type: string) => { ...@@ -1721,10 +1735,11 @@ const getOrderByIdApi = async (type: string) => {
ElMessage.error(res.message) ElMessage.error(res.message)
} }
loading.close() loading.close()
} catch (e) {
console.error(e)
} }
} catch (e) { } else {
console.error(e) ElMessage.warning('未知操作类型')
return
} }
} }
//展示返回结果 //展示返回结果
...@@ -1739,25 +1754,51 @@ const resultConfim = () => { ...@@ -1739,25 +1754,51 @@ const resultConfim = () => {
const changeWayRow = ref<LogisticsData>({} as LogisticsData) const changeWayRow = ref<LogisticsData>({} as LogisticsData)
const isChangeWayLoading = ref(false) const isChangeWayLoading = ref(false)
const changeWayRef = ref() const changeWayRef = ref()
const currentChangeWay = (row: LogisticsData) => { const wayDialogTitle = ref('')
if (row.logisticsWayId == selection.value[0]?.logisticsWayId) {
changeWayRow.value = {} as LogisticsData const rowClick = (row: LogisticsData, title: string) => {
return changeWayRef.value?.setCurrentRow() try {
if (title == '创建物流') {
changeWayRow.value = row
} else {
if (row.logisticsWayId === selection.value[0]?.logisticsWayId) {
changeWayRow.value = {} as LogisticsData
// nextTick(() => {
changeWayRef.value?.setCurrentRow()
// })
return
}
changeWayRow.value = row
}
} catch (error) {
console.log(error)
} }
changeWayRow.value = row
} }
const changeWaySubmit = async () => {
const cancelWayDialog = () => {
changeWayRow.value = {} as LogisticsData
changeWayRef.value?.setCurrentRow()
isChangeWay.value = false
}
//确认物流
const changeWaySubmit = async (title: string) => {
if (!changeWayRow.value?.logisticsWayId) { if (!changeWayRow.value?.logisticsWayId) {
return ElMessage.warning('请选择一条物流方式') return ElMessage.warning('请选择一条物流方式')
} }
if (
changeWayRow.value.logisticsWayId === selection.value[0]?.logisticsWayId
) {
return ElMessage.warning('更改的物流方式不能相同')
}
if (!changeWayRow.value.status) { if (!changeWayRow.value.status) {
return ElMessage.warning('请选择状态为成功的物流方式') return ElMessage.warning('请选择状态为成功的物流方式')
} }
let Fn
if (title !== '创建物流') {
if (
changeWayRow.value.logisticsWayId === selection.value[0]?.logisticsWayId
) {
return ElMessage.warning('更改的物流方式不能相同')
}
Fn = changeLogisticsApi
} else {
Fn = createLogisticsOrderApi
}
isChangeWayLoading.value = true isChangeWayLoading.value = true
try { try {
const params = { const params = {
...@@ -1768,11 +1809,11 @@ const changeWaySubmit = async () => { ...@@ -1768,11 +1809,11 @@ const changeWaySubmit = async () => {
logisticsTrialCalculation: { ...changeWayRow.value }, logisticsTrialCalculation: { ...changeWayRow.value },
} }
await changeLogisticsApi(params) await Fn(params)
isChangeWay.value = false isChangeWay.value = false
isChangeWayLoading.value = false isChangeWayLoading.value = false
ElMessage.success('操作成功')
search() search()
loadTabData() loadTabData()
} catch (error) { } catch (error) {
...@@ -1793,7 +1834,7 @@ const stockOutCheck = async () => { ...@@ -1793,7 +1834,7 @@ const stockOutCheck = async () => {
fullscreen: true, fullscreen: true,
text: '操作中...', text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)', background: 'rgba(0, 0, 0, 0.3)',
}) })
try { try {
const selectedIds = selection.value.map((item) => item.id) const selectedIds = selection.value.map((item) => item.id)
const res = await stockOutCheckApi(selectedIds) const res = await stockOutCheckApi(selectedIds)
......
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