Commit 3209488d by wuqian

feat:物流跟踪优化:#ID:1001056

parent f14854e6
...@@ -54,6 +54,7 @@ declare module 'vue' { ...@@ -54,6 +54,7 @@ declare module 'vue' {
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']
ElTimeline: typeof import('element-plus/es')['ElTimeline'] ElTimeline: typeof import('element-plus/es')['ElTimeline']
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree'] ElTree: typeof import('element-plus/es')['ElTree']
ElUpload: typeof import('element-plus/es')['ElUpload'] ElUpload: typeof import('element-plus/es')['ElUpload']
......
...@@ -63,6 +63,8 @@ export interface ILogisticsCompany { ...@@ -63,6 +63,8 @@ export interface ILogisticsCompany {
authCode: string | null // varchar(500) authCode: string | null // varchar(500)
redirectUri: string | null // varchar(256) redirectUri: string | null // varchar(256)
createTime: string | null // timestamp createTime: string | null // timestamp
orderStatus: string | null // varchar(60)
signTime: string | null // timestamp
vat: string | null // varchar(60) vat: string | null // varchar(60)
ioss: string | null // varchar(60) ioss: string | null // varchar(60)
basicType: number // int(11) basicType: number // int(11)
......
...@@ -27,6 +27,23 @@ ...@@ -27,6 +27,23 @@
<template #top> <template #top>
<el-card> <el-card>
<el-form inline :model="searchForm" ref="searchFormRef"> <el-form inline :model="searchForm" ref="searchFormRef">
<el-form-item label="创建时间">
<el-date-picker
v-model="tradingTime"
:shortcuts="pickerOptions.shortcuts"
:default-time="[
new Date(0, 0, 0, 0, 0, 0),
new Date(0, 0, 0, 23, 59, 59),
]"
type="datetimerange"
start-placeholder="开始时间"
end-placeholder="结束时间"
clearable
style="width: 260px"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item label="物流跟踪号"> <el-form-item label="物流跟踪号">
<el-input <el-input
v-model="searchForm.trackNumber" v-model="searchForm.trackNumber"
...@@ -87,6 +104,9 @@ ...@@ -87,6 +104,9 @@
<template #shipmentType="{ row }"> <template #shipmentType="{ row }">
{{ ['自有物流', '工厂物流'][row.shipmentType] }} {{ ['自有物流', '工厂物流'][row.shipmentType] }}
</template> </template>
<template #shippingAge="{ row }">
{{ getShippingAge(row) }}
</template>
</TableView> </TableView>
</div> </div>
<div class="pagination"> <div class="pagination">
...@@ -139,7 +159,124 @@ const searchForm = ref<SearchForm>({ ...@@ -139,7 +159,124 @@ const searchForm = ref<SearchForm>({
shopNumber: '', shopNumber: '',
trackNumber: '', trackNumber: '',
}) })
function getStartTime() {
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
return `${year}-${month}-${day} 00:00:00`
}
const tradingTime = ref<string[]>([])
const pickerOptions = {
shortcuts: [
{
text: '今日',
value: () => {
const start = new Date(new Date(getStartTime()).getTime())
const end = new Date()
return [start, end]
},
},
{
text: '昨天',
value: () => {
const start = new Date()
const end = new Date(new Date(getStartTime()).getTime() - 1)
start.setTime(end.getTime() - 3600 * 1000 * 24 * 1 + 1)
return [start, end]
},
},
{
text: '最近7天',
value: () => {
const end = new Date()
const start = new Date(getStartTime())
start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
return [start, end]
},
},
{
text: '最近14天',
value: () => {
const end = new Date()
const start = new Date(getStartTime())
start.setTime(start.getTime() - 3600 * 1000 * 24 * 13)
return [start, end]
},
},
{
text: '最近30天',
value: () => {
const end = new Date()
const start = new Date(getStartTime())
start.setTime(start.getTime() - 3600 * 1000 * 24 * 29)
return [start, end]
},
},
{
text: '本星期',
value: () => {
const end = new Date()
const start = new Date()
const nowDay = new Date().getDay() - 1
start.setTime(
new Date(getStartTime()).getTime() - 3600 * 1000 * 24 * nowDay,
)
return [start, end]
},
},
{
text: '上星期',
value: () => {
const end = new Date()
const start = new Date()
const nowDay = new Date().getDay() - 1
end.setTime(
new Date(getStartTime()).getTime() - 3600 * 1000 * 24 * nowDay - 1,
)
start.setTime(end.getTime() - 3600 * 1000 * 24 * 7 + 1)
return [start, end]
},
},
{
text: '这个月',
value: () => {
const end = new Date()
const start = new Date()
const nowDate = new Date().getDate() - 1
start.setTime(
new Date(getStartTime()).getTime() - 3600 * 1000 * 24 * nowDate,
)
return [start, end]
},
},
{
text: '上个月',
value: () => {
const date = new Date()
let year = date.getFullYear()
let month = date.getMonth()
const end = new Date(
new Date(`${year}-${month + 1}-1 00:00:00`).getTime() - 1,
)
if (month === 0) {
month = 12
year = year - 1
}
const start = new Date(
new Date(`${year}-${month}-1 00:00:00`).getTime(),
)
return [start, end]
},
},
{
text: '历史',
value: () => {
return ['', '']
},
},
],
}
const treeData = ref<LogisticsTrackingTree[]>() const treeData = ref<LogisticsTrackingTree[]>()
const treeRef = ref<InstanceType<typeof ElTree>>() const treeRef = ref<InstanceType<typeof ElTree>>()
const tableRef = ref<{ internalIsMore?: boolean }>() const tableRef = ref<{ internalIsMore?: boolean }>()
...@@ -183,6 +320,19 @@ const tableColumns = computed(() => { ...@@ -183,6 +320,19 @@ const tableColumns = computed(() => {
align: 'center', align: 'center',
}, },
{ {
label: '创建时间',
prop: 'createTime',
width: 200,
align: 'center',
},
{
label: '发货时效(天)',
prop: 'shippingAge',
slot: 'shippingAge',
width: 120,
align: 'center',
},
{
label: '订单状态', label: '订单状态',
prop: 'orderStatus', prop: 'orderStatus',
slot: 'orderStatus', slot: 'orderStatus',
...@@ -261,13 +411,38 @@ const getTree = async () => { ...@@ -261,13 +411,38 @@ const getTree = async () => {
console.error(e) console.error(e)
} }
} }
/** 计算发货时效(天)
* 已签收 → 停止计时
* <12h = 0天;≥12h & <24h = 1天;≥48h = 2天 ...
*/
function getShippingAge(row: ILogisticsCompany): number {
// 成功签收就固定: 已签收时间 - 创建时间
if (row.orderStatus === 'COMPLETE') {
const signTime = new Date(row.signTime ?? 0).getTime()
const createTime = new Date(row.createTime ?? 0).getTime()
return msToDays(signTime - createTime)
}
// 未签收:当前时间 - 创建时间
const now = Date.now()
const create = new Date(row.createTime ?? 0).getTime()
return msToDays(now - create)
}
/** 毫秒 → 天数(≥12h 向上取整) */
function msToDays(ms: number): number {
const hours = ms / (1000 * 60 * 60)
if (hours < 12) return 0
return Math.ceil(hours / 24)
}
// 列表查询 // 列表查询
async function getData() { async function getData() {
const res = await logisticsTrackingPage({ const res = await logisticsTrackingPage({
trackingStatus: nodeId.value, trackingStatus: nodeId.value,
shopNumber: searchForm.value.shopNumber, shopNumber: searchForm.value.shopNumber,
trackNumber: searchForm.value.trackNumber, trackNumber: searchForm.value.trackNumber,
startTime: tradingTime.value && tradingTime.value[0],
endTime: tradingTime.value && tradingTime.value[1],
queryDateType: tradingTime.value && 1,
}) })
leftData.value = res.data.records leftData.value = res.data.records
pagination.value.total = res.data.total pagination.value.total = res.data.total
......
...@@ -59,4 +59,7 @@ export interface LogisticsTrackingParams { ...@@ -59,4 +59,7 @@ export interface LogisticsTrackingParams {
trackNumber?: number | string trackNumber?: number | string
shopNumber?: string | number shopNumber?: string | number
trackingStatus?: number trackingStatus?: number
startTime?: string
endTime?: string
queryDateType?: number | string
} }
...@@ -307,7 +307,6 @@ import { debounce } from 'lodash-es' ...@@ -307,7 +307,6 @@ import { debounce } from 'lodash-es'
const editForm = ref<BaseForm>({ isAuto: false, status: 'ACTIVE' }) const editForm = ref<BaseForm>({ isAuto: false, status: 'ACTIVE' })
const tableData = ref([]) const tableData = ref([])
import userUserStore from '@/store/user' import userUserStore from '@/store/user'
import { tr } from 'element-plus/es/locales.mjs'
const userStore = userUserStore() const userStore = userUserStore()
const userInfo = userStore.user const userInfo = userStore.user
const loading = ref(false) const loading = ref(false)
......
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