Commit 5004f367 by zhuzhequan

Merge remote-tracking branch 'origin/dev' into dev

parents 67591999 4d24ae1e
......@@ -193,6 +193,12 @@ export function deleteAddressByIds(params: { ids: string }) {
},
)
}
//获取国家名称及代码
export function getAllCountryApi() {
return axios.get<never, BaseRespData<never>>(
'/logisticsAddress/getAllCountry',
)
}
/**
* @description 物流报价
......
......@@ -16,6 +16,7 @@ export interface LogisticsData {
status: boolean
logisticsWayCode: string // 物流编码
partition: string // 所在分区
logisticsWayId?: number | null
}
export function getOrderTabData() {
return axios.get<never, BaseRespData<Tab[]>>(
......@@ -270,3 +271,29 @@ export function cancelLogisticsOrderApi(orderIds: (string | number)[]) {
orderIds,
)
}
// 更改物流
export function changeLogisticsApi(params: {
updateByIdParam: {
id: string | number
dataVersion: number
}
logisticsTrialCalculation: LogisticsData
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podJomallOrderUs/changeLogistics',
params,
)
}
// 创建物流
export function createLogisticsOrderApi(params: {
updateByIdParam: {
id: string | number
dataVersion: number
}
logisticsTrialCalculation: LogisticsData
}) {
return axios.post<never, BaseRespData<never>>(
'factory/podJomallOrderUs/createLogisticsOrder',
params,
)
}
......@@ -57,6 +57,8 @@ export interface PodUsOrderListData {
version?: number
productList?: ProductList[]
orderNumber?: string
logisticsWayId?: number | null
logisticsWayName?: string
}
export interface ProductList {
id: number
......
......@@ -43,36 +43,11 @@
</el-tag>
</div>
<p
:title="
[
item.countryName,
// item.countryCode,
item.stateProvince,
// item.stateProvinceAbbr,
item.district,
// item.districtCode,
item.city,
// item.cityCode,
]
.filter((el) => el != null && el !== '')
.join(' ')
"
style="white-space: pre"
:title="getJosn(item)"
class="address"
>
{{
[
item.countryName,
// item.countryCode,
item.stateProvince,
// item.stateProvinceAbbr,
item.district,
// item.districtCode,
item.city,
// item.cityCode,
]
.filter((el) => el != null && el !== '')
.join(' ')
}}
{{ getJosn(item) }}
</p>
<p
:title="
......@@ -187,6 +162,7 @@ import {
updateAddress,
getLogisticsLog,
deleteAddressByIds,
getAllCountryApi,
} from '@/api/logistics'
import { IFormConfig } from '@/components/CustomizeForm.tsx'
......@@ -196,7 +172,7 @@ import CustomizeForm from '@/components/CustomizeForm.tsx'
import { Edit, Delete, List } from '@element-plus/icons-vue'
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 { useValue } from './hooks/useValue'
import { showConfirm } from '@/utils/ui'
......@@ -226,8 +202,9 @@ const {
const dialogVisible = ref(false)
const logDialogVisible = ref(false)
const editFormRef = ref<InstanceType<typeof CustomizeForm> | null>(null)
const countryList = ref([])
const formConfig = ref<IFormConfig[]>([
const formConfig = computed<IFormConfig[]>(() => [
{
prop: 'shipperName',
type: 'input',
......@@ -266,88 +243,101 @@ const formConfig = ref<IFormConfig[]>([
},
},
{
prop: 'city',
type: 'input',
label: '城市',
prop: 'countryCode',
type: 'select',
label: '国家代码',
attrs: {
// options: [],
placeholder: '请输入城市',
options: countryList.value,
label: 'countryCode',
value: 'countryCode',
placeholder: '请选择国家代码',
onChange: (val: ICountryObj) => {
editForm.value.countryName = val.nameCn
},
rules: [{ required: true, message: '请输入城市' }],
},
rules: [{ required: true, message: '请选择国家代码' }],
},
{
prop: 'cityCode',
type: 'input',
label: '城市编码',
prop: 'countryName',
type: 'select',
label: '国家名称',
attrs: {
// options: [],
placeholder: '请输入城市编码',
options: countryList.value,
label: 'nameCn',
value: 'nameCn',
placeholder: '请选择国家名称',
onChange: (val: ICountryObj) => {
editForm.value.countryCode = val.countryCode
},
},
rules: [{ required: true, message: '请选择国家名称' }],
},
{
prop: 'district',
prop: 'stateProvince',
type: 'input',
label: '',
label: '州/省',
attrs: {
// options: [],
placeholder: '请选择区',
placeholder: '请输入州/省',
},
},
{
prop: 'districtCode',
prop: 'stateProvinceAbbr',
type: 'input',
label: '区编码',
label: '州/省简称',
attrs: {
// options: [],
placeholder: '请选择区',
placeholder: '请输入州/省简称',
},
},
{
prop: 'postalCode',
prop: 'cityCode',
type: 'input',
label: '邮编',
label: '城市编码',
attrs: {
placeholder: '请输入邮编',
// options: [],
placeholder: '请输入城市编码',
},
},
{
prop: 'stateProvince',
prop: 'city',
type: 'input',
label: '州/省',
label: '城市',
attrs: {
// options: [],
placeholder: '请输入州/省',
placeholder: '请输入城市',
},
rules: [{ required: true, message: '请输入城市' }],
},
{
prop: 'stateProvinceAbbr',
prop: 'districtCode',
type: 'input',
label: '州/省简称',
label: '区编码',
attrs: {
// options: [],
placeholder: '请输入州/省简称',
placeholder: '请选择区',
},
},
{
prop: 'countryName',
prop: 'district',
type: 'input',
label: '国家名称',
label: '',
attrs: {
// options: [],
placeholder: '请输入国家名称',
placeholder: '请选择区',
},
rules: [{ required: true, message: '请输入国家名称' }],
},
{
prop: 'countryCode',
prop: 'postalCode',
type: 'input',
label: '国家代码',
label: '邮编',
attrs: {
// options: [],
placeholder: '请输入国家代码',
placeholder: '请输入邮编',
},
rules: [{ required: true, message: '请输入邮编' }],
},
{
prop: 'phoneNumber',
......@@ -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: 取消按钮
......
......@@ -22,3 +22,13 @@ export interface ShippingAddressObj {
updateTime?: string
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()
const getPackingData = async (code: string) => {
const loading = ElLoading.service({
fullscreen: true,
text: '加载中...',
background: 'rgba(0, 0, 0, 0.3)',
})
currentCode = code
try {
......@@ -592,6 +594,8 @@ const initOrderDetailBox = async () => {
}
const loading = ElLoading.service({
fullscreen: true,
text: '加载中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await getPodBoxListApi(factoryNo, warehouseId.value)
......@@ -800,7 +804,10 @@ const handlePrinterChange = (value: string) => {
const print = (data: OrderData, forcePrint = false, callback?: () => void) => {
const _boxIndex = boxIndex.value
if (!forcePrint && data.printResult) return
if (!forcePrint && data.printResult) {
callback && callback()
return
}
props.printOrder(data, (status: boolean) => {
callback && callback()
......
......@@ -178,6 +178,9 @@
</el-button>
<template #dropdown>
<ElDropdownMenu>
<ElDropdownItem @click="getOrderByIdApi('createLogisticsOrder')"
>创建物流</ElDropdownItem
>
<ElDropdownItem @click="getOrderByIdApi('getTrackingNumber')"
>获取跟踪号</ElDropdownItem
>
......@@ -187,6 +190,9 @@
<ElDropdownItem @click="getOrderByIdApi('cancelLogisticsOrder')"
>取消物流订单</ElDropdownItem
>
<ElDropdownItem @click="getOrderByIdApi('batchChangeLogistics')"
>更换物流</ElDropdownItem
>
</ElDropdownMenu>
</template>
</ElDropdown>
......@@ -894,6 +900,70 @@
:list="resultInfo"
@confirm="resultConfim"
></ResultInfo>
<el-dialog
v-model="isChangeWay"
:close-on-click-modal="false"
:title="wayDialogTitle"
>
<el-table
v-loading="isChangeWayLoading"
ref="changeWayRef"
height="400px"
class="production-client-table"
:data="logisticsWayData"
border
highlight-current-row
@row-click="(v:LogisticsData) =>rowClick(v, wayDialogTitle)"
>
<el-table-column
label="序号"
width="60"
align="center"
type="index"
></el-table-column>
<el-table-column
label="物流名称"
align="center"
prop="logisticsWayName"
></el-table-column>
<el-table-column
label="发货仓库"
align="center"
prop="warehouseName"
></el-table-column>
<el-table-column
label="物流编码"
align="center"
prop="logisticsWayCode"
></el-table-column>
<el-table-column
label="所在分区"
align="center"
prop="partition"
></el-table-column>
<el-table-column label="状态" align="center">
<template #default="{ row }">
<b v-if="row.status" style="color: green">成功</b>
<b v-else-if="!row.status" style="color: red">失败</b>
</template>
</el-table-column>
<el-table-column label="预计运费($)" align="center" prop="payFreight">
</el-table-column>
</el-table>
<template #footer>
<el-button :disabled="isChangeWayLoading" @click="cancelWayDialog">
取消
</el-button>
<el-button
:loading="isChangeWayLoading"
type="primary"
@click="changeWaySubmit(wayDialogTitle)"
>
确定
</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { getUserMarkList } from '@/api/common'
......@@ -924,7 +994,11 @@ import {
getTrackingNumberApi,
getfaceSimplexFileApi,
cancelLogisticsOrderApi,
changeLogisticsApi,
createLogisticsOrderApi,
} from '@/api/podUsOrder'
import { BaseRespData } from '@/types/api'
import TableView from '@/components/TableView.vue'
import {
LogListData,
......@@ -968,7 +1042,9 @@ declare global {
const tabsNav = ref<Tab[]>()
const resultRefs = ref<InstanceType<typeof ResultInfo> | null>(null)
const confirmDialogShow = ref(false)
const isChangeWay = ref(false)
const confirmData = ref([])
const logisticsWayData = ref([])
const confirmSelectionData = ref<LogisticsData[]>([])
const confirmRowData = ref<ProductList | null>(null)
const status = ref('TO_BE_CONFIRMED')
......@@ -1261,6 +1337,7 @@ const handleUpdateRemark = async (item: ProductList) => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await updateRemarkApi(item.id, value)
......@@ -1298,6 +1375,7 @@ const submitConfirm = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await confirmOrderApi(
......@@ -1333,6 +1411,7 @@ const updateOrder = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await updateExceptionOrderApi(ids)
......@@ -1354,6 +1433,7 @@ const printProductionOrder = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await printProductionOrderApi(orderIds)
......@@ -1374,6 +1454,7 @@ const printPickingOrder = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await printPrintOrderApi(orderIds)
......@@ -1403,6 +1484,7 @@ const pickingComplete = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await printPickingOrderApi(orderIds)
......@@ -1431,6 +1513,7 @@ const changeExceptionOrder = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await changeExceptionOrderApi(orderIds, value)
......@@ -1459,6 +1542,7 @@ const cancelOrder = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await cancelOrderApi(orderIds, value)
......@@ -1541,6 +1625,7 @@ const downloadMaterial = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await downloadMaterialApi(selectedIds)
......@@ -1584,43 +1669,62 @@ const printPodOrder = async () => {
}
/**
* @description: 获取跟踪号、获取打印面单、取消物流订单
* @description: 创建物流、获取跟踪号、获取打印面单、更改物流、取消物流订单
*/
const resultInfo = ref([])
const getOrderByIdApi = async (type: string) => {
if (selection.value.length === 0) {
return ElMessage.warning('请选择数据')
}
let message = ''
let Fn
if (type == 'getTrackingNumber') {
message = '获取跟踪号'
Fn = getTrackingNumberApi
} else if (type == 'getPrintOrder') {
message = '获取打印面单'
Fn = getfaceSimplexFileApi
} else if (type === 'cancelLogisticsOrder') {
message = '取消物流订单'
Fn = cancelLogisticsOrderApi
const operationMap: {
[key: string]: {
message: string
Fn: (orderIds: (string | number)[]) => Promise<BaseRespData<never>>
}
} = {
getTrackingNumber: { message: '获取跟踪号', Fn: getTrackingNumberApi },
getPrintOrder: { message: '获取打印面单', Fn: getfaceSimplexFileApi },
cancelLogisticsOrder: {
message: '取消物流订单',
Fn: cancelLogisticsOrderApi,
},
}
if (['batchChangeLogistics', 'createLogisticsOrder'].includes(type)) {
if (selection.value.length !== 1) {
return ElMessage.warning('请选择单条数据')
}
wayDialogTitle.value =
type === 'batchChangeLogistics'
? `切换物流(当前物流方式:${selection.value[0]?.logisticsWayName})`
: '创建物流'
isChangeWay.value = true
const { data } = await getLogisticsCalculation(selection.value[0]?.id)
logisticsWayData.value = data
return
}
const operation = operationMap[type]
if (operation) {
try {
await showConfirm(`确定对该订单 ${message}?`, {
await showConfirm(`确定对该订单 ${operation.message}?`, {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
})
const ids = selection.value.map((el) => el.id)
// console.log(Fn)
if (Fn) {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
const res = await Fn(ids)
const res = await operation.Fn(ids)
if (res.code === 200) {
if (isArray(res.data)) {
resultInfo.value = res.data
......@@ -1632,15 +1736,94 @@ const getOrderByIdApi = async (type: string) => {
ElMessage.error(res.message)
}
loading.close()
} catch (e) {
console.error(e)
}
} catch {
return
} else {
ElMessage.warning('未知操作类型')
}
}
//展示返回结果
const resultInfo = ref([])
const resultConfim = () => {
search()
}
/**
* @description: 更改物流方式
*/
const changeWayRow = ref<LogisticsData>({} as LogisticsData)
const isChangeWayLoading = ref(false)
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 cancelWayDialog = () => {
changeWayRow.value = {} as LogisticsData
changeWayRef.value?.setCurrentRow()
isChangeWay.value = false
}
//确认物流
const changeWaySubmit = async (title: string) => {
if (!changeWayRow.value?.logisticsWayId) {
return ElMessage.warning('请选择一条物流方式')
}
if (!changeWayRow.value.status) {
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 },
}
await Fn(params)
isChangeWay.value = false
isChangeWayLoading.value = false
ElMessage.success('操作成功')
search()
loadTabData()
} catch (error) {
console.log(error)
} finally {
isChangeWayLoading.value = false
}
}
// 添加补货成功行的状态
const stockOutSuccessIds = ref<number[]>([])
......@@ -1651,6 +1834,7 @@ const stockOutCheck = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const selectedIds = selection.value.map((item) => item.id)
......@@ -1714,6 +1898,7 @@ const toBePicking = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '操作中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await toBePickingApi(selection.value.map((item) => item.id))
......@@ -1751,8 +1936,7 @@ const printOrder = async (
return
}
if (data.filePath) {
// const strURL = filePath + data.filePath
const strURL = 'https://factory.jomalls.com/upload/factory' + data.filePath
const strURL = filePath + data.filePath
console.log('strURL', strURL, data)
lodop.ADD_PRINT_PDF(
0,
......@@ -1897,6 +2081,7 @@ const openDetail = async (id: number) => {
const loading = ElLoading.service({
fullscreen: true,
text: '加载中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await getOrderDetailById(id)
......@@ -1947,6 +2132,7 @@ const refreshMaterial = async () => {
const loading = ElLoading.service({
fullscreen: true,
text: '刷新中...',
background: 'rgba(0, 0, 0, 0.3)',
})
try {
const res = await refreshMaterialApi(
......@@ -2086,6 +2272,16 @@ onMounted(() => {
gap: 10px;
font-size: 12px;
margin-top: 10px;
.grid-item {
display: flex;
overflow: hidden;
.grid-item-value {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
.factory-sub-order-number {
......
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