Commit fe21f5fc by qinjianhui

Merge branch 'dev' into 'master'

Dev

See merge request !20
parents 18b22a43 4d24ae1e
...@@ -193,6 +193,12 @@ export function deleteAddressByIds(params: { ids: string }) { ...@@ -193,6 +193,12 @@ export function deleteAddressByIds(params: { ids: string }) {
}, },
) )
} }
//获取国家名称及代码
export function getAllCountryApi() {
return axios.get<never, BaseRespData<never>>(
'/logisticsAddress/getAllCountry',
)
}
/** /**
* @description 物流报价 * @description 物流报价
......
...@@ -273,9 +273,9 @@ export function cancelLogisticsOrderApi(orderIds: (string | number)[]) { ...@@ -273,9 +273,9 @@ export function cancelLogisticsOrderApi(orderIds: (string | number)[]) {
} }
// 更改物流 // 更改物流
export function changeLogisticsApi(params: { export function changeLogisticsApi(params: {
UpdateByIdParam: { updateByIdParam: {
id: string | number id: string | number
dataVersion: string dataVersion: number
} }
logisticsTrialCalculation: LogisticsData logisticsTrialCalculation: LogisticsData
}) { }) {
...@@ -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,
)
}
...@@ -58,6 +58,7 @@ export interface PodUsOrderListData { ...@@ -58,6 +58,7 @@ export interface PodUsOrderListData {
productList?: ProductList[] productList?: ProductList[]
orderNumber?: string orderNumber?: string
logisticsWayId?: number | null logisticsWayId?: number | null
logisticsWayName?: string
} }
export interface ProductList { export interface ProductList {
id: number id: number
......
...@@ -43,36 +43,11 @@ ...@@ -43,36 +43,11 @@
</el-tag> </el-tag>
</div> </div>
<p <p
:title=" style="white-space: pre"
[ :title="getJosn(item)"
item.countryName,
// item.countryCode,
item.stateProvince,
// item.stateProvinceAbbr,
item.district,
// item.districtCode,
item.city,
// item.cityCode,
]
.filter((el) => el != null && el !== '')
.join(' ')
"
class="address" class="address"
> >
{{ {{ getJosn(item) }}
[
item.countryName,
// item.countryCode,
item.stateProvince,
// item.stateProvinceAbbr,
item.district,
// item.districtCode,
item.city,
// item.cityCode,
]
.filter((el) => el != null && el !== '')
.join(' ')
}}
</p> </p>
<p <p
:title=" :title="
...@@ -187,6 +162,7 @@ import { ...@@ -187,6 +162,7 @@ import {
updateAddress, updateAddress,
getLogisticsLog, getLogisticsLog,
deleteAddressByIds, deleteAddressByIds,
getAllCountryApi,
} from '@/api/logistics' } from '@/api/logistics'
import { IFormConfig } from '@/components/CustomizeForm.tsx' import { IFormConfig } from '@/components/CustomizeForm.tsx'
...@@ -196,7 +172,7 @@ import CustomizeForm from '@/components/CustomizeForm.tsx' ...@@ -196,7 +172,7 @@ import CustomizeForm from '@/components/CustomizeForm.tsx'
import { Edit, Delete, List } from '@element-plus/icons-vue' import { Edit, Delete, List } from '@element-plus/icons-vue'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import { ShippingAddressObj } from './types/shippingAddress.ts' import { ShippingAddressObj, ICountryObj } from './types/shippingAddress.ts'
import usePageList from '@/utils/hooks/usePageList' import usePageList from '@/utils/hooks/usePageList'
import { useValue } from './hooks/useValue' import { useValue } from './hooks/useValue'
import { showConfirm } from '@/utils/ui' import { showConfirm } from '@/utils/ui'
...@@ -226,8 +202,9 @@ const { ...@@ -226,8 +202,9 @@ const {
const dialogVisible = ref(false) const dialogVisible = ref(false)
const logDialogVisible = ref(false) const logDialogVisible = ref(false)
const editFormRef = ref<InstanceType<typeof CustomizeForm> | null>(null) const editFormRef = ref<InstanceType<typeof CustomizeForm> | null>(null)
const countryList = ref([])
const formConfig = ref<IFormConfig[]>([ const formConfig = computed<IFormConfig[]>(() => [
{ {
prop: 'shipperName', prop: 'shipperName',
type: 'input', type: 'input',
...@@ -266,88 +243,101 @@ const formConfig = ref<IFormConfig[]>([ ...@@ -266,88 +243,101 @@ const formConfig = ref<IFormConfig[]>([
}, },
}, },
{ {
prop: 'city', prop: 'countryCode',
type: 'input', type: 'select',
label: '城市', label: '国家代码',
attrs: { attrs: {
// options: [], options: countryList.value,
placeholder: '请输入城市', label: 'countryCode',
value: 'countryCode',
placeholder: '请选择国家代码',
onChange: (val: ICountryObj) => {
editForm.value.countryName = val.nameCn
},
}, },
rules: [{ required: true, message: '请输入城市' }], rules: [{ required: true, message: '请选择国家代码' }],
}, },
{ {
prop: 'cityCode', prop: 'countryName',
type: 'input', type: 'select',
label: '城市编码', label: '国家名称',
attrs: { attrs: {
// options: [], options: countryList.value,
placeholder: '请输入城市编码', label: 'nameCn',
value: 'nameCn',
placeholder: '请选择国家名称',
onChange: (val: ICountryObj) => {
editForm.value.countryCode = val.countryCode
},
}, },
rules: [{ required: true, message: '请选择国家名称' }],
}, },
{ {
prop: 'district', prop: 'stateProvince',
type: 'input', type: 'input',
label: '', label: '州/省',
attrs: { attrs: {
// options: [], // options: [],
placeholder: '请选择区', placeholder: '请输入州/省',
}, },
}, },
{ {
prop: 'districtCode', prop: 'stateProvinceAbbr',
type: 'input', type: 'input',
label: '区编码', label: '州/省简称',
attrs: { attrs: {
// options: [], // options: [],
placeholder: '请选择区', placeholder: '请输入州/省简称',
}, },
}, },
{ {
prop: 'postalCode', prop: 'cityCode',
type: 'input', type: 'input',
label: '邮编', label: '城市编码',
attrs: { attrs: {
placeholder: '请输入邮编', // options: [],
placeholder: '请输入城市编码',
}, },
}, },
{ {
prop: 'stateProvince', prop: 'city',
type: 'input', type: 'input',
label: '州/省', label: '城市',
attrs: { attrs: {
// options: [], // options: [],
placeholder: '请输入州/省', placeholder: '请输入城市',
}, },
rules: [{ required: true, message: '请输入城市' }],
}, },
{ {
prop: 'stateProvinceAbbr', prop: 'districtCode',
type: 'input', type: 'input',
label: '州/省简称', label: '区编码',
attrs: { attrs: {
// options: [], // options: [],
placeholder: '请输入州/省简称', placeholder: '请选择区',
}, },
}, },
{ {
prop: 'countryName', prop: 'district',
type: 'input', type: 'input',
label: '国家名称', label: '',
attrs: { attrs: {
// options: [], // options: [],
placeholder: '请输入国家名称', placeholder: '请选择区',
}, },
rules: [{ required: true, message: '请输入国家名称' }],
}, },
{ {
prop: 'countryCode', prop: 'postalCode',
type: 'input', type: 'input',
label: '国家代码', label: '邮编',
attrs: { attrs: {
// options: [], placeholder: '请输入邮编',
placeholder: '请输入国家代码',
}, },
rules: [{ required: true, message: '请输入邮编' }],
}, },
{ {
prop: 'phoneNumber', prop: 'phoneNumber',
...@@ -365,7 +355,36 @@ const formConfig = ref<IFormConfig[]>([ ...@@ -365,7 +355,36 @@ const formConfig = ref<IFormConfig[]>([
}, },
]) ])
// const loading = ref(false) async function getCountryList() {
try {
const { data } = await getAllCountryApi()
countryList.value = data
console.log(372, countryList.value)
} catch (error) {
console.log(error)
}
}
function getJosn(item: ShippingAddressObj) {
return [
[item.countryName, item.countryCode],
[item.stateProvince, item.stateProvinceAbbr],
[item.district, item.districtCode],
[item.city, item.cityCode],
]
.map(([value, code]) => {
if (value && code) return `${value} (${code})`
if (value) return value
if (code) return code // 当 value 不存在但 code 存在时,不使用括号
return null
})
.filter(Boolean)
.join(` `) // 使用三个空格作为分隔符增大间距
}
onMounted(() => {
getCountryList()
})
/** /**
* @description: 取消按钮 * @description: 取消按钮
......
...@@ -22,3 +22,13 @@ export interface ShippingAddressObj { ...@@ -22,3 +22,13 @@ export interface ShippingAddressObj {
updateTime?: string updateTime?: string
checked?: boolean checked?: boolean
} }
export interface ICountryObj {
aeCountryCode: string
continentCode: string
countryCode: string
id: number
nameCn: string
nameEn: string
needProviceAbbr: number
}
...@@ -516,6 +516,8 @@ const userStore = useUserStore() ...@@ -516,6 +516,8 @@ const userStore = useUserStore()
const getPackingData = async (code: string) => { const getPackingData = async (code: string) => {
const loading = ElLoading.service({ const loading = ElLoading.service({
fullscreen: true, fullscreen: true,
text: '加载中...',
background: 'rgba(0, 0, 0, 0.3)',
}) })
currentCode = code currentCode = code
try { try {
...@@ -592,6 +594,8 @@ const initOrderDetailBox = async () => { ...@@ -592,6 +594,8 @@ const initOrderDetailBox = async () => {
} }
const loading = ElLoading.service({ const loading = ElLoading.service({
fullscreen: true, fullscreen: true,
text: '加载中...',
background: 'rgba(0, 0, 0, 0.3)',
}) })
try { try {
const res = await getPodBoxListApi(factoryNo, warehouseId.value) const res = await getPodBoxListApi(factoryNo, warehouseId.value)
......
...@@ -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,15 +904,17 @@ ...@@ -901,15 +904,17 @@
<el-dialog <el-dialog
v-model="isChangeWay" v-model="isChangeWay"
:close-on-click-modal="false" :close-on-click-modal="false"
title="更换物流" :title="wayDialogTitle"
> >
<el-table <el-table
v-loading="isChangeWayLoading"
ref="changeWayRef"
height="400px" height="400px"
class="production-client-table" class="production-client-table"
: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="序号"
...@@ -947,8 +952,16 @@ ...@@ -947,8 +952,16 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<template #footer> <template #footer>
<el-button @click="isChangeWay = false">取消</el-button> <el-button :disabled="isChangeWayLoading" @click="cancelWayDialog">
<el-button type="primary" @click="changeWaySubmit">确定</el-button> 取消
</el-button>
<el-button
:loading="isChangeWayLoading"
type="primary"
@click="changeWaySubmit(wayDialogTitle)"
>
确定
</el-button>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
...@@ -981,8 +994,11 @@ import { ...@@ -981,8 +994,11 @@ import {
getTrackingNumberApi, getTrackingNumberApi,
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 {
LogListData, LogListData,
...@@ -1653,52 +1669,62 @@ const printPodOrder = async () => { ...@@ -1653,52 +1669,62 @@ 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: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
}) })
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
...@@ -1710,43 +1736,92 @@ const getOrderByIdApi = async (type: string) => { ...@@ -1710,43 +1736,92 @@ 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
} }
} }
//展示返回结果
const resultInfo = ref([])
const resultConfim = () => {
search()
}
/**
* @description: 更改物流方式
*/
const changeWayRow = ref<LogisticsData>({} as LogisticsData) const changeWayRow = ref<LogisticsData>({} as LogisticsData)
const currentChangeWay = (row: LogisticsData) => { const isChangeWayLoading = ref(false)
changeWayRow.value = row const changeWayRef = ref()
const wayDialogTitle = ref('')
const rowClick = (row: LogisticsData, title: string) => {
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)
}
} }
const changeWaySubmit = () => {
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
try {
const params = {
updateByIdParam: {
id: selection.value[0]?.id,
dataVersion: selection.value[0]?.version as number,
},
logisticsTrialCalculation: { ...changeWayRow.value },
}
// const params = { await Fn(params)
// UpdateByIdParam: { isChangeWay.value = false
// id: selection.value[0]?.id,
// dataVersion: selection.value[0]?.version,
// },
// logisticsTrialCalculation: { ...changeWayRow.value },
// }
isChangeWay.value = false isChangeWayLoading.value = false
// changeLogisticsApi(params) ElMessage.success('操作成功')
} search()
const resultInfo = ref([]) loadTabData()
const resultConfim = () => { } catch (error) {
search() console.log(error)
} finally {
isChangeWayLoading.value = false
}
} }
// 添加补货成功行的状态 // 添加补货成功行的状态
...@@ -1760,7 +1835,7 @@ const stockOutCheck = async () => { ...@@ -1760,7 +1835,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