提交
This commit is contained in:
1 parent
88da74d72a
commit
9fcb9270e6
53 files changed
+612846
-3438
No files matched your search
@@ -292,6 +292,7 @@ export const transportAddressApi = {
|
||||
list: (params?: TransportAddressQuery) =>
|
||||
request.get<PlListResponse<TransportAddress>>('/transport/address', { params }),
|
||||
listAll: (params?: { q?: string }) =>
|
||||
/** 选择器:仅按地址名称、详细地址模糊检索(不含联系人/电话) */
|
||||
request.get<PlListResponse<TransportAddress>>('/transport/address/all', { params }),
|
||||
get: (id: string) => request.get<TransportAddress>(`/transport/address/${id}`),
|
||||
create: (data: TransportAddressPayload) =>
|
||||
@@ -708,6 +709,8 @@ export const planApi = {
|
||||
waitNotice: (id: string) => request.post<Plan>(`/transport/plan/${id}/wait-notice`),
|
||||
cancelWaitNotice: (id: string) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/cancel-wait-notice`),
|
||||
forceFollowStatus: (id: string, followStatus: string) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/force-follow-status`, { followStatus }),
|
||||
getArrangeInfo: (id: string) => request.get<PlanArrangeInfo>(`/transport/plan/${id}/arrange-info`),
|
||||
archive: (id: string, data?: PlanArchiveBody) =>
|
||||
request.post<Plan>(`/transport/plan/${id}/archive`, data),
|
||||
|
||||
@@ -55,10 +55,54 @@ export interface PublicIoOrderPage {
|
||||
items: PublicIoOrderItem[]
|
||||
}
|
||||
|
||||
export interface PublicIoOrderHistoryRecord {
|
||||
kind: 'inbound' | 'outbound' | string
|
||||
orderId: string
|
||||
orderNo: string
|
||||
planId?: string | null
|
||||
planNo?: string | null
|
||||
planDate?: string | null
|
||||
partnerCompany?: string | null
|
||||
supplierName?: string | null
|
||||
customerName?: string | null
|
||||
vehicleNo?: string | null
|
||||
siteAccessToken?: string | null
|
||||
siteUrl?: string | null
|
||||
status?: string | null
|
||||
orderVoided?: boolean
|
||||
planArchived?: boolean
|
||||
statusLabel?: string
|
||||
}
|
||||
|
||||
export interface PublicIoOrderHistoryPage {
|
||||
date: string
|
||||
keyword?: string | null
|
||||
page: number
|
||||
pageSize: number
|
||||
total: number
|
||||
records: PublicIoOrderHistoryRecord[]
|
||||
}
|
||||
|
||||
export function createPublicIoOrderApi(kind: 'inbound' | 'outbound') {
|
||||
const base = `/public/pl/${kind}`
|
||||
return {
|
||||
getPage: (token: string) => publicPlGet<PublicIoOrderPage>(`${base}/${token}`),
|
||||
getHistory: (
|
||||
token: string,
|
||||
date: string,
|
||||
q?: string,
|
||||
page = 1,
|
||||
pageSize = 20
|
||||
) => {
|
||||
const params = new URLSearchParams({
|
||||
date,
|
||||
page: String(page),
|
||||
pageSize: String(pageSize)
|
||||
})
|
||||
const keyword = (q || '').trim()
|
||||
if (keyword) params.set('q', keyword)
|
||||
return publicPlGet<PublicIoOrderHistoryPage>(`${base}/${token}/history?${params.toString()}`)
|
||||
},
|
||||
saveFeedback: (
|
||||
token: string,
|
||||
data: {
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
<template>
|
||||
<div class="pl-address-with-library">
|
||||
<div class="pl-address-with-library__row">
|
||||
<AmapAddressPicker
|
||||
v-model="innerAddress"
|
||||
v-model:lng="innerLng"
|
||||
v-model:lat="innerLat"
|
||||
<el-select
|
||||
v-model="selectedId"
|
||||
class="pl-address-with-library__picker"
|
||||
popper-class="pl-address-select-dropdown"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
/>
|
||||
filterable
|
||||
remote
|
||||
clearable
|
||||
:remote-method="searchAddresses"
|
||||
:loading="loading"
|
||||
:reserve-keyword="false"
|
||||
@focus="handleFocus"
|
||||
@clear="handleClear"
|
||||
@change="handleSelectChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in displayOptions"
|
||||
:key="item.id"
|
||||
:label="optionLabel(item)"
|
||||
:value="item.id"
|
||||
>
|
||||
<div class="pl-address-option">
|
||||
<span class="pl-address-option__name">{{ item.addressName || '—' }}</span>
|
||||
<span class="pl-address-option__full">{{ item.fullAddress || '—' }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button
|
||||
class="pl-address-with-library__library-btn btn-ghost"
|
||||
:disabled="disabled"
|
||||
@@ -23,18 +43,23 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { FolderOpened } from '@element-plus/icons-vue'
|
||||
import AmapAddressPicker from '@/components/business/amap-address-picker/index.vue'
|
||||
import PlTransportAddressSelectDialog from '@/components/business/pl-transport-address-select-dialog/index.vue'
|
||||
import type { TransportAddress } from '@/api/pl/index'
|
||||
import { transportAddressApi, type TransportAddress } from '@/api/pl/index'
|
||||
import { pickBxList } from '@/utils/http/bx'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
contact?: string
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
}>()
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
lng?: number | null
|
||||
lat?: number | null
|
||||
contact?: string
|
||||
placeholder?: string
|
||||
disabled?: boolean
|
||||
}>(),
|
||||
{
|
||||
placeholder: '请选择地址(可按地址名称、详细地址检索)'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
@@ -43,22 +68,31 @@ const emit = defineEmits<{
|
||||
'update:contact': [value: string]
|
||||
}>()
|
||||
|
||||
/** 下拉默认最多展示条数 */
|
||||
const DROPDOWN_PAGE_SIZE = 10
|
||||
|
||||
const libraryVisible = ref(false)
|
||||
const loading = ref(false)
|
||||
const options = ref<TransportAddress[]>([])
|
||||
const selectedId = ref('')
|
||||
/** 编辑态/历史地址:当前值不在地址库时的回显项 */
|
||||
const legacyOption = ref<TransportAddress | null>(null)
|
||||
|
||||
const innerAddress = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: string) => emit('update:modelValue', value)
|
||||
const displayOptions = computed(() => {
|
||||
const list = options.value
|
||||
const legacy = legacyOption.value
|
||||
if (!legacy) return list
|
||||
if (list.some(item => item.id === legacy.id)) return list
|
||||
// 历史回显优先,仍控制总量不超过默认展示数 + 1(回显项)
|
||||
return [legacy, ...list].slice(0, DROPDOWN_PAGE_SIZE + 1)
|
||||
})
|
||||
|
||||
const innerLng = computed({
|
||||
get: () => props.lng ?? null,
|
||||
set: (value: number | null) => emit('update:lng', value)
|
||||
})
|
||||
|
||||
const innerLat = computed({
|
||||
get: () => props.lat ?? null,
|
||||
set: (value: number | null) => emit('update:lat', value)
|
||||
})
|
||||
function optionLabel(item: TransportAddress): string {
|
||||
const name = (item.addressName || '').trim()
|
||||
const full = (item.fullAddress || '').trim()
|
||||
if (name && full) return `${name}(${full})`
|
||||
return name || full || '—'
|
||||
}
|
||||
|
||||
function formatAddressContact(row: TransportAddress): string {
|
||||
const name = (row.contactName || '').trim()
|
||||
@@ -67,15 +101,124 @@ function formatAddressContact(row: TransportAddress): string {
|
||||
return name || phone
|
||||
}
|
||||
|
||||
function handleLibrarySelect(row: TransportAddress) {
|
||||
innerAddress.value = row.fullAddress
|
||||
innerLng.value = row.lng != null ? Number(row.lng) : null
|
||||
innerLat.value = row.lat != null ? Number(row.lat) : null
|
||||
function applyAddressRow(row: TransportAddress) {
|
||||
selectedId.value = row.id
|
||||
legacyOption.value = null
|
||||
emit('update:modelValue', row.fullAddress || '')
|
||||
emit('update:lng', row.lng != null ? Number(row.lng) : null)
|
||||
emit('update:lat', row.lat != null ? Number(row.lat) : null)
|
||||
const contactText = formatAddressContact(row)
|
||||
if (contactText) {
|
||||
emit('update:contact', contactText)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 与「从地址库选择」弹窗同源(启用中的运输地址库)。
|
||||
* 模糊检索走后端 q:仅匹配地址名称、详细地址(/transport/address/all)。
|
||||
*/
|
||||
async function searchAddresses(keyword: string) {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await transportAddressApi.listAll({
|
||||
q: keyword.trim() || undefined
|
||||
})
|
||||
options.value = pickBxList<TransportAddress>(res).slice(0, DROPDOWN_PAGE_SIZE)
|
||||
syncSelectedFromModel()
|
||||
} catch (error) {
|
||||
console.error('加载运输地址列表失败', error)
|
||||
options.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function handleFocus() {
|
||||
if (options.value.length === 0) {
|
||||
searchAddresses('')
|
||||
}
|
||||
}
|
||||
|
||||
function handleClear() {
|
||||
selectedId.value = ''
|
||||
legacyOption.value = null
|
||||
emit('update:modelValue', '')
|
||||
emit('update:lng', null)
|
||||
emit('update:lat', null)
|
||||
}
|
||||
|
||||
function handleSelectChange(id: string) {
|
||||
if (!id) {
|
||||
handleClear()
|
||||
return
|
||||
}
|
||||
const row = displayOptions.value.find(item => item.id === id)
|
||||
if (!row) return
|
||||
if (row.id.startsWith('legacy-')) {
|
||||
selectedId.value = row.id
|
||||
emit('update:modelValue', row.fullAddress || '')
|
||||
return
|
||||
}
|
||||
applyAddressRow(row)
|
||||
}
|
||||
|
||||
function handleLibrarySelect(row: TransportAddress) {
|
||||
// 弹窗选中后并入当前 options,保证下拉可回显
|
||||
if (!options.value.some(item => item.id === row.id)) {
|
||||
options.value = [row, ...options.value].slice(0, DROPDOWN_PAGE_SIZE)
|
||||
}
|
||||
applyAddressRow(row)
|
||||
}
|
||||
|
||||
function buildLegacyOption(address: string): TransportAddress {
|
||||
return {
|
||||
id: `legacy-${address}`,
|
||||
addressName: address,
|
||||
fullAddress: address,
|
||||
lng: props.lng != null ? Number(props.lng) : 0,
|
||||
lat: props.lat != null ? Number(props.lat) : 0,
|
||||
status: '1',
|
||||
createTime: '',
|
||||
updateTime: ''
|
||||
}
|
||||
}
|
||||
|
||||
function syncSelectedFromModel() {
|
||||
const current = (props.modelValue || '').trim()
|
||||
if (!current) {
|
||||
selectedId.value = ''
|
||||
legacyOption.value = null
|
||||
return
|
||||
}
|
||||
|
||||
const matched =
|
||||
options.value.find(item => item.fullAddress === current) ||
|
||||
(selectedId.value
|
||||
? options.value.find(item => item.id === selectedId.value)
|
||||
: undefined)
|
||||
|
||||
if (matched) {
|
||||
selectedId.value = matched.id
|
||||
legacyOption.value = null
|
||||
return
|
||||
}
|
||||
|
||||
// 已选中的库内 id 仍在 options 中
|
||||
if (selectedId.value && options.value.some(item => item.id === selectedId.value)) {
|
||||
return
|
||||
}
|
||||
|
||||
legacyOption.value = buildLegacyOption(current)
|
||||
selectedId.value = legacyOption.value.id
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => {
|
||||
syncSelectedFromModel()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -93,10 +236,51 @@ function handleLibrarySelect(row: TransportAddress) {
|
||||
.pl-address-with-library__picker {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pl-address-with-library__library-btn {
|
||||
flex: 0 0 auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pl-address-option {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
line-height: 1.4;
|
||||
padding: 2px 0;
|
||||
}
|
||||
|
||||
.pl-address-option__name {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.pl-address-option__full {
|
||||
color: var(--el-text-color-secondary, var(--mint-text-muted, #64748b));
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss">
|
||||
/* teleported 下拉挂到 body,需非 scoped;增高选项避免双行地址被裁切 */
|
||||
.pl-address-select-dropdown {
|
||||
.el-select-dropdown__wrap {
|
||||
/* 约 10 条 × 较高选项高度 */
|
||||
max-height: 560px;
|
||||
}
|
||||
|
||||
.el-select-dropdown__item {
|
||||
height: auto !important;
|
||||
min-height: 56px;
|
||||
padding: 10px 20px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -784,17 +784,81 @@ function handleCustomerSelectFocus() {
|
||||
}
|
||||
}
|
||||
|
||||
const MSG_SAME_CUSTOMER = '供方与需方不能为同一客户'
|
||||
const MSG_SAME_ADDRESS = '取货地址与送货地址不能相同'
|
||||
|
||||
/** 已确认的客户 id,用于冲突时回滚 el-select */
|
||||
const committedSupplierId = ref('')
|
||||
const committedCustomerId = ref('')
|
||||
/** 加载/重置表单时跳过地址互斥回滚 */
|
||||
const suppressAddressMutex = ref(false)
|
||||
|
||||
function isSamePartyCustomer(supplierId?: string, customerId?: string) {
|
||||
const s = String(supplierId || '').trim()
|
||||
const c = String(customerId || '').trim()
|
||||
return Boolean(s && c && s === c)
|
||||
}
|
||||
|
||||
function normalizeAddressText(value?: string | null) {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
function isSameCoordPair(
|
||||
lng1: number | null | undefined,
|
||||
lat1: number | null | undefined,
|
||||
lng2: number | null | undefined,
|
||||
lat2: number | null | undefined
|
||||
) {
|
||||
if (lng1 == null || lat1 == null || lng2 == null || lat2 == null) return false
|
||||
const aLng = Number(lng1)
|
||||
const aLat = Number(lat1)
|
||||
const bLng = Number(lng2)
|
||||
const bLat = Number(lat2)
|
||||
if ([aLng, aLat, bLng, bLat].some(n => Number.isNaN(n))) return false
|
||||
return aLng === bLng && aLat === bLat
|
||||
}
|
||||
|
||||
function isSameLogisticsAddress(
|
||||
addressA?: string | null,
|
||||
lngA?: number | null,
|
||||
latA?: number | null,
|
||||
addressB?: string | null,
|
||||
lngB?: number | null,
|
||||
latB?: number | null
|
||||
) {
|
||||
const ta = normalizeAddressText(addressA)
|
||||
const tb = normalizeAddressText(addressB)
|
||||
if (ta && tb && ta === tb) return true
|
||||
if (isSameCoordPair(lngA, latA, lngB, latB)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
function syncCommittedPartyIds() {
|
||||
committedSupplierId.value = String(formData.supplierId || '')
|
||||
committedCustomerId.value = String(formData.customerId || '')
|
||||
}
|
||||
|
||||
function handleSupplierSelectChange(customerId?: string) {
|
||||
if (!customerId) {
|
||||
formData.supplierId = ''
|
||||
formData.supplierName = ''
|
||||
formData.supplierContracts = []
|
||||
committedSupplierId.value = ''
|
||||
return
|
||||
}
|
||||
const customer = customerOptions.value.find(item => String(item.id) === String(customerId))
|
||||
formData.supplierId = String(customerId)
|
||||
const nextId = String(customerId)
|
||||
if (isSamePartyCustomer(nextId, formData.customerId)) {
|
||||
ElMessage.warning(MSG_SAME_CUSTOMER)
|
||||
nextTick(() => {
|
||||
formData.supplierId = committedSupplierId.value
|
||||
})
|
||||
return
|
||||
}
|
||||
const customer = customerOptions.value.find(item => String(item.id) === nextId)
|
||||
formData.supplierId = nextId
|
||||
formData.supplierName = customer?.customerName || formData.supplierName || ''
|
||||
formData.supplierContracts = []
|
||||
committedSupplierId.value = nextId
|
||||
}
|
||||
|
||||
function handleDemanderSelectChange(customerId?: string) {
|
||||
@@ -806,15 +870,25 @@ function handleDemanderSelectChange(customerId?: string) {
|
||||
formData.demanderContracts = []
|
||||
formData.contactName = ''
|
||||
formData.contactPhone = ''
|
||||
committedCustomerId.value = ''
|
||||
return
|
||||
}
|
||||
const customer = customerOptions.value.find(item => String(item.id) === String(customerId))
|
||||
const nextId = String(customerId)
|
||||
if (isSamePartyCustomer(formData.supplierId, nextId)) {
|
||||
ElMessage.warning(MSG_SAME_CUSTOMER)
|
||||
nextTick(() => {
|
||||
formData.customerId = committedCustomerId.value
|
||||
})
|
||||
return
|
||||
}
|
||||
const customer = customerOptions.value.find(item => String(item.id) === nextId)
|
||||
const name = customer?.customerName || formData.customerName || ''
|
||||
formData.customerId = String(customerId)
|
||||
formData.customerId = nextId
|
||||
formData.customerName = name
|
||||
formData.destinationId = String(customerId)
|
||||
formData.destinationId = nextId
|
||||
formData.destinationName = name
|
||||
formData.demanderContracts = []
|
||||
committedCustomerId.value = nextId
|
||||
}
|
||||
|
||||
function openCustomerSelector(side: CustomerSide) {
|
||||
@@ -826,13 +900,23 @@ function handleCustomerConfirm(customer: CustomerConfirmRow) {
|
||||
if (!customer?.id) return
|
||||
const customerId = String(customer.id)
|
||||
const customerName = (customer.customerName || '').trim()
|
||||
ensureCustomerOption({ id: customerId, customerName })
|
||||
if (customerSelectorSide.value === 'supplier') {
|
||||
if (isSamePartyCustomer(customerId, formData.customerId)) {
|
||||
ElMessage.warning(MSG_SAME_CUSTOMER)
|
||||
return
|
||||
}
|
||||
ensureCustomerOption({ id: customerId, customerName })
|
||||
formData.supplierId = customerId
|
||||
formData.supplierName = customerName
|
||||
formData.supplierContracts = []
|
||||
committedSupplierId.value = customerId
|
||||
return
|
||||
}
|
||||
if (isSamePartyCustomer(formData.supplierId, customerId)) {
|
||||
ElMessage.warning(MSG_SAME_CUSTOMER)
|
||||
return
|
||||
}
|
||||
ensureCustomerOption({ id: customerId, customerName })
|
||||
formData.customerId = customerId
|
||||
formData.customerName = customerName
|
||||
formData.destinationId = customerId
|
||||
@@ -840,8 +924,98 @@ function handleCustomerConfirm(customer: CustomerConfirmRow) {
|
||||
formData.demanderContracts = []
|
||||
formData.contactName = customer.contactName || ''
|
||||
formData.contactPhone = customer.mobile || ''
|
||||
committedCustomerId.value = customerId
|
||||
}
|
||||
|
||||
watch(
|
||||
() =>
|
||||
[formData.pickupAddress, formData.pickupLng, formData.pickupLat] as [
|
||||
string,
|
||||
number | null,
|
||||
number | null
|
||||
],
|
||||
(curr, prev) => {
|
||||
if (suppressAddressMutex.value || !prev) return
|
||||
if (
|
||||
!isSameLogisticsAddress(
|
||||
curr[0],
|
||||
curr[1],
|
||||
curr[2],
|
||||
formData.destinationAddress,
|
||||
formData.destinationLng,
|
||||
formData.destinationLat
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
// 仅当「取货侧」变化导致冲突时回滚取货
|
||||
if (
|
||||
isSameLogisticsAddress(
|
||||
prev[0],
|
||||
prev[1],
|
||||
prev[2],
|
||||
formData.destinationAddress,
|
||||
formData.destinationLng,
|
||||
formData.destinationLat
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
ElMessage.warning(MSG_SAME_ADDRESS)
|
||||
suppressAddressMutex.value = true
|
||||
formData.pickupAddress = prev[0] || ''
|
||||
formData.pickupLng = prev[1]
|
||||
formData.pickupLat = prev[2]
|
||||
nextTick(() => {
|
||||
suppressAddressMutex.value = false
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() =>
|
||||
[formData.destinationAddress, formData.destinationLng, formData.destinationLat] as [
|
||||
string,
|
||||
number | null,
|
||||
number | null
|
||||
],
|
||||
(curr, prev) => {
|
||||
if (suppressAddressMutex.value || !prev) return
|
||||
if (
|
||||
!isSameLogisticsAddress(
|
||||
formData.pickupAddress,
|
||||
formData.pickupLng,
|
||||
formData.pickupLat,
|
||||
curr[0],
|
||||
curr[1],
|
||||
curr[2]
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (
|
||||
isSameLogisticsAddress(
|
||||
formData.pickupAddress,
|
||||
formData.pickupLng,
|
||||
formData.pickupLat,
|
||||
prev[0],
|
||||
prev[1],
|
||||
prev[2]
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
ElMessage.warning(MSG_SAME_ADDRESS)
|
||||
suppressAddressMutex.value = true
|
||||
formData.destinationAddress = prev[0] || ''
|
||||
formData.destinationLng = prev[1]
|
||||
formData.destinationLat = prev[2]
|
||||
nextTick(() => {
|
||||
suppressAddressMutex.value = false
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
async function handleProductConfirm(products: Array<Record<string, unknown>>) {
|
||||
for (const product of products) {
|
||||
const brandMeta = initLineBrandMetaFromProduct(product)
|
||||
@@ -1079,6 +1253,7 @@ function resetForm() {
|
||||
remark: '',
|
||||
products: []
|
||||
})
|
||||
syncCommittedPartyIds()
|
||||
freightCalc.resetFreightCalc()
|
||||
basicFormRef.value?.clearValidate()
|
||||
}
|
||||
@@ -1113,6 +1288,7 @@ function handleOpened() {
|
||||
|
||||
async function loadPlanForEdit(planId: string) {
|
||||
detailLoading.value = true
|
||||
suppressAddressMutex.value = true
|
||||
try {
|
||||
resetForm()
|
||||
const res = await planApi.get(planId)
|
||||
@@ -1152,6 +1328,7 @@ async function loadPlanForEdit(planId: string) {
|
||||
products: (data.products || []).map(mapPlanProductToFormRow)
|
||||
})
|
||||
loadedTransportStatus.value = data.transportStatus || 'pending'
|
||||
syncCommittedPartyIds()
|
||||
|
||||
formData.products = await enrichPlanProductLinesAlias(
|
||||
await enrichPlanProductsHazardFromCrm((data.products || []).map(mapPlanProductToFormRow))
|
||||
@@ -1168,12 +1345,15 @@ async function loadPlanForEdit(planId: string) {
|
||||
}
|
||||
syncSelectedCustomerOptions()
|
||||
} finally {
|
||||
await nextTick()
|
||||
suppressAddressMutex.value = false
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadPlanForCopy(planId: string) {
|
||||
detailLoading.value = true
|
||||
suppressAddressMutex.value = true
|
||||
try {
|
||||
resetForm()
|
||||
const res = await planApi.get(planId)
|
||||
@@ -1212,6 +1392,7 @@ async function loadPlanForCopy(planId: string) {
|
||||
products: (data.products || []).map(mapPlanProductToCopyFormRow)
|
||||
})
|
||||
loadedTransportStatus.value = 'pending'
|
||||
syncCommittedPartyIds()
|
||||
|
||||
formData.products = await enrichPlanProductLinesAlias(
|
||||
await enrichPlanProductsHazardFromCrm((data.products || []).map(mapPlanProductToCopyFormRow))
|
||||
@@ -1228,6 +1409,8 @@ async function loadPlanForCopy(planId: string) {
|
||||
ElMessage.error(message.includes('加载') ? message : `加载源计划失败:${message}`)
|
||||
emit('update:visible', false)
|
||||
} finally {
|
||||
await nextTick()
|
||||
suppressAddressMutex.value = false
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
@@ -1307,6 +1490,23 @@ function validateBusinessRules() {
|
||||
ElMessage.warning('请选择需方客户')
|
||||
return false
|
||||
}
|
||||
if (isSamePartyCustomer(formData.supplierId, formData.customerId)) {
|
||||
ElMessage.warning(MSG_SAME_CUSTOMER)
|
||||
return false
|
||||
}
|
||||
if (
|
||||
isSameLogisticsAddress(
|
||||
formData.pickupAddress,
|
||||
formData.pickupLng,
|
||||
formData.pickupLat,
|
||||
formData.destinationAddress,
|
||||
formData.destinationLng,
|
||||
formData.destinationLat
|
||||
)
|
||||
) {
|
||||
ElMessage.warning(MSG_SAME_ADDRESS)
|
||||
return false
|
||||
}
|
||||
if (!formData.products.length) {
|
||||
ElMessage.warning('请至少保留一条产品明细')
|
||||
return false
|
||||
|
||||
@@ -108,41 +108,45 @@
|
||||
<el-tab-pane label="运输信息" name="transport">
|
||||
<section v-if="showArrangeLinks" class="pl-plan-form-section pl-plan-form-section--plain pl-plan-arrange-links">
|
||||
<h3 class="pl-plan-form-section-title">运输链接</h3>
|
||||
<div class="pl-arrange-link-row">
|
||||
<span class="pl-arrange-link-label">司机链接</span>
|
||||
<el-input :model-value="arrangeDriverUrl" readonly />
|
||||
<el-button @click="copyArrangeDriverUrl">
|
||||
<el-icon><CopyDocument /></el-icon>复制链接
|
||||
</el-button>
|
||||
</div>
|
||||
<template v-if="hasArrangeSiteLinks">
|
||||
<div v-if="arrangeSiteRecords.length === 1" class="pl-arrange-link-row">
|
||||
<span class="pl-arrange-link-label">现场链接</span>
|
||||
<el-input :model-value="arrangeSiteRecords[0].siteUrl || ''" readonly />
|
||||
<el-button @click="copyArrangeSiteUrl(arrangeSiteRecords[0].siteUrl)">
|
||||
<div class="pl-arrange-links-body">
|
||||
<div class="pl-arrange-link-row">
|
||||
<span class="pl-arrange-link-label">司机链接</span>
|
||||
<el-input :model-value="arrangeDriverUrl" readonly />
|
||||
<el-button @click="copyArrangeDriverUrl">
|
||||
<el-icon><CopyDocument /></el-icon>复制链接
|
||||
</el-button>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div
|
||||
v-for="record in arrangeSiteRecords"
|
||||
:key="record.siteLinkId"
|
||||
class="pl-arrange-link-row"
|
||||
<div class="pl-arrange-site-col">
|
||||
<template v-if="hasArrangeSiteLinks">
|
||||
<div v-if="arrangeSiteRecords.length === 1" class="pl-arrange-link-row">
|
||||
<span class="pl-arrange-link-label">现场链接</span>
|
||||
<el-input :model-value="arrangeSiteRecords[0].siteUrl || ''" readonly />
|
||||
<el-button @click="copyArrangeSiteUrl(arrangeSiteRecords[0].siteUrl)">
|
||||
<el-icon><CopyDocument /></el-icon>复制链接
|
||||
</el-button>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div
|
||||
v-for="record in arrangeSiteRecords"
|
||||
:key="record.siteLinkId"
|
||||
class="pl-arrange-link-row"
|
||||
>
|
||||
<span class="pl-arrange-link-label">{{ record.productName || '现场链接' }}</span>
|
||||
<el-input :model-value="record.siteUrl || ''" readonly />
|
||||
<el-button @click="copyArrangeSiteUrl(record.siteUrl)">
|
||||
<el-icon><CopyDocument /></el-icon>复制链接
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<p
|
||||
v-else-if="showArrangeLinks && planSupportsInventory"
|
||||
class="pl-plan-form-empty-hint pl-plan-arrange-links-hint"
|
||||
>
|
||||
<span class="pl-arrange-link-label">{{ record.productName || '现场链接' }}</span>
|
||||
<el-input :model-value="record.siteUrl || ''" readonly />
|
||||
<el-button @click="copyArrangeSiteUrl(record.siteUrl)">
|
||||
<el-icon><CopyDocument /></el-icon>复制链接
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<p
|
||||
v-else-if="showArrangeLinks && planSupportsInventory"
|
||||
class="pl-plan-form-empty-hint pl-plan-arrange-links-hint"
|
||||
>
|
||||
暂无现场链接
|
||||
</p>
|
||||
暂无现场链接
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="pl-plan-form-section pl-plan-form-section--plain">
|
||||
@@ -1412,24 +1416,46 @@
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.pl-arrange-links-body {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
gap: 12px 16px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.pl-arrange-site-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pl-plan-arrange-links-hint {
|
||||
margin-top: 2px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pl-arrange-link-row {
|
||||
display: grid;
|
||||
grid-template-columns: 72px 1fr auto;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
|
||||
&--readonly {
|
||||
grid-template-columns: 72px 1fr;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.pl-arrange-link-label {
|
||||
font-size: 13px;
|
||||
color: #64748b;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.pl-arrange-links-body {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-plan-view-remark {
|
||||
|
||||
@@ -75,12 +75,24 @@ export const staticRoutes: AppRouteRecordRaw[] = [
|
||||
component: () => import('@views/public/pl/site/index.vue'),
|
||||
meta: { title: '运输现场', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/public/pl/inbound/:token/history',
|
||||
name: 'PublicPlInboundHistory',
|
||||
component: () => import('@views/public/pl/inbound/history.vue'),
|
||||
meta: { title: '现场记录', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/public/pl/inbound/:token',
|
||||
name: 'PublicPlInboundOrder',
|
||||
component: () => import('@views/public/pl/inbound/index.vue'),
|
||||
meta: { title: '入库单', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/public/pl/outbound/:token/history',
|
||||
name: 'PublicPlOutboundHistory',
|
||||
component: () => import('@views/public/pl/outbound/history.vue'),
|
||||
meta: { title: '现场记录', isHideTab: true, isPublicMobile: true }
|
||||
},
|
||||
{
|
||||
path: '/public/pl/outbound/:token',
|
||||
name: 'PublicPlOutboundOrder',
|
||||
|
||||
@@ -174,6 +174,14 @@
|
||||
>
|
||||
<el-icon><DocumentCopy /></el-icon>三方人车快速创建
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canForceFollowStatus"
|
||||
class="btn-ghost"
|
||||
:disabled="!selectedPlan"
|
||||
@click="openForceFollowStatusDialog"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>强制改状态
|
||||
</el-button>
|
||||
|
||||
<ListToolbarEndActions
|
||||
:loading="loading"
|
||||
@@ -530,6 +538,64 @@
|
||||
<PlSubpackSlipPrintDialog ref="subpackSlipPrintRef" />
|
||||
|
||||
<PlPasteRecognizeDialog v-model:visible="pasteVisible" mode="vehicle-bundle" />
|
||||
|
||||
<el-dialog
|
||||
v-model="forceFollowDialogVisible"
|
||||
title="强制修改跟进状态"
|
||||
width="640px"
|
||||
align-center
|
||||
class="dialog-form-layout"
|
||||
modal-class="order-module-dialog-mask"
|
||||
destroy-on-close
|
||||
@closed="resetForceFollowDialog"
|
||||
>
|
||||
<el-form label-position="top" class="form-grid-2">
|
||||
<el-form-item label="计划编号" style="margin-bottom: 0">
|
||||
<span>{{ selectedPlan?.planNo || '—' }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="单据类型" style="margin-bottom: 0">
|
||||
<span>{{ getPlanTypeLabel(selectedPlan?.planType) }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="供方" style="margin-bottom: 0">
|
||||
<span>{{ selectedPlan?.supplierName || '—' }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="需方" style="margin-bottom: 0">
|
||||
<span>{{ selectedPlan?.customerName || '—' }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品信息" class="form-col-span-2" style="margin-bottom: 0">
|
||||
<PlPlanListProductCell :products="selectedPlan?.products || []" />
|
||||
</el-form-item>
|
||||
<el-form-item label="当前跟进状态" style="margin-bottom: 0">
|
||||
<el-tag
|
||||
v-if="selectedPlan"
|
||||
:type="getPlPlanFollowStatusTagType(selectedPlan.followStatus)"
|
||||
size="small"
|
||||
>
|
||||
{{ getPlPlanFollowStatusLabel(selectedPlan.followStatus) }}
|
||||
</el-tag>
|
||||
<span v-else>—</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="目标跟进状态" required style="margin-bottom: 0">
|
||||
<el-select v-model="forceFollowStatusValue" placeholder="请选择" style="width: 100%">
|
||||
<el-option
|
||||
v-for="opt in PL_PLAN_FOLLOW_STATUS_OPTIONS"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<p class="form-tip form-col-span-2">仅修改跟进状态字段,不会联动作废或运输安排。</p>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="forceFollowDialogVisible = false">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button type="primary" :loading="forceFollowLoading" @click="submitForceFollowStatus">
|
||||
<el-icon><Check /></el-icon>确定
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -537,16 +603,20 @@
|
||||
import {
|
||||
ArrowDown,
|
||||
Bell,
|
||||
Check,
|
||||
CircleClose,
|
||||
Close,
|
||||
CopyDocument,
|
||||
DocumentCopy,
|
||||
Edit,
|
||||
EditPen,
|
||||
Plus,
|
||||
Printer,
|
||||
RefreshLeft,
|
||||
Search,
|
||||
Van
|
||||
} from '@element-plus/icons-vue'
|
||||
import { fetchGetMenuCodes } from '@/api/auth'
|
||||
import { planApi, type Plan } from '@/api/pl'
|
||||
import PlInboundSlipPrintDialog from '@/components/business/pl-inbound-slip-print-dialog/index.vue'
|
||||
import PlDeliverySlipPrintDialog from '@/components/business/pl-delivery-slip-print-dialog/index.vue'
|
||||
@@ -587,6 +657,10 @@ const router = useRouter()
|
||||
const loading = ref(false)
|
||||
const voidLoading = ref(false)
|
||||
const waitNoticeLoading = ref(false)
|
||||
const canForceFollowStatus = ref(false)
|
||||
const forceFollowDialogVisible = ref(false)
|
||||
const forceFollowLoading = ref(false)
|
||||
const forceFollowStatusValue = ref('')
|
||||
const formDialogVisible = ref(false)
|
||||
const pasteVisible = ref(false)
|
||||
const editingPlanId = ref('')
|
||||
@@ -1056,6 +1130,53 @@ function handleToolbarVoid() {
|
||||
handleVoid(selectedRows.value[0])
|
||||
}
|
||||
|
||||
function openForceFollowStatusDialog() {
|
||||
if (!selectedPlan.value) return
|
||||
forceFollowStatusValue.value = selectedPlan.value.followStatus || ''
|
||||
forceFollowDialogVisible.value = true
|
||||
}
|
||||
|
||||
function resetForceFollowDialog() {
|
||||
forceFollowStatusValue.value = ''
|
||||
}
|
||||
|
||||
async function submitForceFollowStatus() {
|
||||
if (!selectedPlan.value) return
|
||||
const next = (forceFollowStatusValue.value || '').trim()
|
||||
if (!next) {
|
||||
ElMessage.warning('请选择目标跟进状态')
|
||||
return
|
||||
}
|
||||
if (next === selectedPlan.value.followStatus) {
|
||||
ElMessage.warning('目标状态与当前状态相同')
|
||||
return
|
||||
}
|
||||
forceFollowLoading.value = true
|
||||
try {
|
||||
await planApi.forceFollowStatus(selectedPlan.value.id, next)
|
||||
ElMessage.success('跟进状态已更新')
|
||||
forceFollowDialogVisible.value = false
|
||||
fetchData()
|
||||
} catch (e) {
|
||||
const message = e instanceof Error ? e.message : '修改失败'
|
||||
ElMessage.error(message)
|
||||
} finally {
|
||||
forceFollowLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadForceFollowPermission() {
|
||||
try {
|
||||
const perm = await fetchGetMenuCodes()
|
||||
canForceFollowStatus.value =
|
||||
!!perm?.all ||
|
||||
!!perm?.isSuperAdmin ||
|
||||
(perm?.menuCodes || []).includes('pl:plan:force-follow-status')
|
||||
} catch {
|
||||
canForceFollowStatus.value = false
|
||||
}
|
||||
}
|
||||
|
||||
useDbInstantSearch(
|
||||
() => ({
|
||||
planNo: searchForm.planNo,
|
||||
@@ -1073,6 +1194,7 @@ useDbInstantSearch(
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
loadForceFollowPermission()
|
||||
fetchData()
|
||||
openArrangeFromQuery()
|
||||
})
|
||||
|
||||
@@ -0,0 +1,446 @@
|
||||
<template>
|
||||
<PublicMobileShell>
|
||||
<div class="public-pl-history-page">
|
||||
<van-nav-bar
|
||||
title="现场记录"
|
||||
left-arrow
|
||||
:border="false"
|
||||
class="site-nav-bar"
|
||||
@click-left="goBack"
|
||||
/>
|
||||
|
||||
<div class="filters">
|
||||
<div class="filter-row">
|
||||
<van-field
|
||||
class="date-field"
|
||||
readonly
|
||||
is-link
|
||||
clickable
|
||||
:model-value="pickDate"
|
||||
placeholder="选择日期"
|
||||
@click="openDatePicker"
|
||||
/>
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="search"
|
||||
class="search-input"
|
||||
placeholder="供方/需方"
|
||||
enterkeyhint="search"
|
||||
/>
|
||||
</div>
|
||||
<div class="chips">
|
||||
<button
|
||||
v-for="q in quickOptions"
|
||||
:key="q.offset"
|
||||
type="button"
|
||||
class="chip"
|
||||
:class="{ on: pickDate === q.ymd }"
|
||||
@click="setQuick(q.offset)"
|
||||
>
|
||||
{{ q.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<van-popup v-model:show="showDatePicker" position="bottom" round>
|
||||
<van-date-picker
|
||||
v-model="datePickerValue"
|
||||
title="选择日期"
|
||||
:min-date="minDate"
|
||||
:max-date="maxDate"
|
||||
@confirm="onDateConfirm"
|
||||
@cancel="showDatePicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
|
||||
<van-empty v-if="errorMessage" :description="errorMessage" />
|
||||
<van-list
|
||||
v-else
|
||||
v-model:loading="listLoading"
|
||||
:finished="finished"
|
||||
:immediate-check="false"
|
||||
finished-text="没有更多了"
|
||||
@load="loadMore"
|
||||
>
|
||||
<van-empty v-if="!records.length && !listLoading" description="暂无现场记录" />
|
||||
<div
|
||||
v-for="(row, index) in records"
|
||||
:key="`${row.kind}-${row.orderId}`"
|
||||
class="record-card"
|
||||
role="button"
|
||||
@click="openRecord(row)"
|
||||
>
|
||||
<span class="index-tag">{{ index + 1 }}</span>
|
||||
<div class="record-top">
|
||||
<span class="plan-no">{{ row.orderNo || row.planNo || '—' }}</span>
|
||||
<span class="tag" :class="tagClass(row)">{{ row.statusLabel || '进行中' }}</span>
|
||||
</div>
|
||||
<div class="meta">类型:{{ kindLabel(row.kind) }} · 计划:{{ row.planNo || '—' }}</div>
|
||||
<div class="meta">
|
||||
往来:{{ row.partnerCompany || '—' }} · 车牌:{{ row.vehicleNo || '—' }}
|
||||
</div>
|
||||
<div class="meta">
|
||||
供方:{{ row.supplierName || '—' }} · 需方:{{ row.customerName || '—' }}
|
||||
</div>
|
||||
</div>
|
||||
</van-list>
|
||||
</div>
|
||||
</PublicMobileShell>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { showFailToast } from 'vant'
|
||||
import { watchDebounced } from '@vueuse/core'
|
||||
import {
|
||||
createPublicIoOrderApi,
|
||||
type PublicIoOrderHistoryRecord
|
||||
} from '@/api/pl/public-io-order'
|
||||
import PublicMobileShell from '@/layouts/PublicMobileShell.vue'
|
||||
|
||||
import 'vant/es/toast/style'
|
||||
import 'vant/es/list/style'
|
||||
import 'vant/es/field/style'
|
||||
import 'vant/es/popup/style'
|
||||
import 'vant/es/date-picker/style'
|
||||
import '@/styles/public-mobile-vant.scss'
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
const props = defineProps<{ kind: 'inbound' | 'outbound' }>()
|
||||
const api = createPublicIoOrderApi(props.kind)
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const token = computed(() => String(route.params.token || ''))
|
||||
|
||||
const listLoading = ref(false)
|
||||
const finished = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const records = ref<PublicIoOrderHistoryRecord[]>([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pickDate = ref(addDays(0))
|
||||
const keyword = ref('')
|
||||
const showDatePicker = ref(false)
|
||||
const datePickerValue = ref<string[]>(ymdToParts(pickDate.value))
|
||||
const minDate = new Date(new Date().getFullYear() - 2, 0, 1)
|
||||
const maxDate = new Date(new Date().getFullYear() + 2, 11, 31)
|
||||
let requestSeq = 0
|
||||
|
||||
const quickOptions = [
|
||||
{ label: '今日', offset: 0, ymd: addDays(0) },
|
||||
{ label: '明日', offset: 1, ymd: addDays(1) },
|
||||
{ label: '后天', offset: 2, ymd: addDays(2) }
|
||||
]
|
||||
|
||||
function formatYmd(d: Date) {
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
return `${y}-${m}-${day}`
|
||||
}
|
||||
|
||||
function addDays(n: number) {
|
||||
const d = new Date()
|
||||
d.setHours(0, 0, 0, 0)
|
||||
d.setDate(d.getDate() + n)
|
||||
return formatYmd(d)
|
||||
}
|
||||
|
||||
function ymdToParts(ymd: string): string[] {
|
||||
const [y, m, d] = String(ymd || '').split('-')
|
||||
if (!y || !m || !d) return ymdToParts(addDays(0))
|
||||
return [y, m, d]
|
||||
}
|
||||
|
||||
function openDatePicker() {
|
||||
datePickerValue.value = ymdToParts(pickDate.value)
|
||||
showDatePicker.value = true
|
||||
}
|
||||
|
||||
function onDateConfirm({ selectedValues }: { selectedValues: string[] }) {
|
||||
pickDate.value = selectedValues.join('-')
|
||||
showDatePicker.value = false
|
||||
reload()
|
||||
}
|
||||
|
||||
function kindLabel(kind?: string) {
|
||||
if (kind === 'inbound') return '入库'
|
||||
if (kind === 'outbound') return '出库'
|
||||
return '—'
|
||||
}
|
||||
|
||||
function tagClass(row: PublicIoOrderHistoryRecord) {
|
||||
if (row.orderVoided || row.statusLabel === '已作废') return 'tag--danger'
|
||||
if (row.planArchived || row.statusLabel === '已归档') return 'tag--muted'
|
||||
return 'tag--success'
|
||||
}
|
||||
|
||||
function detailRouteName() {
|
||||
return props.kind === 'inbound' ? 'PublicPlInboundOrder' : 'PublicPlOutboundOrder'
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
router.push({ name: detailRouteName(), params: { token: token.value } })
|
||||
}
|
||||
|
||||
function setQuick(offset: number) {
|
||||
pickDate.value = addDays(offset)
|
||||
datePickerValue.value = ymdToParts(pickDate.value)
|
||||
reload()
|
||||
}
|
||||
|
||||
function openRecord(row: PublicIoOrderHistoryRecord) {
|
||||
const accessToken = (row.siteAccessToken || '').trim()
|
||||
if (!accessToken) {
|
||||
showFailToast('该记录暂无现场链接')
|
||||
return
|
||||
}
|
||||
const name = row.kind === 'outbound' ? 'PublicPlOutboundOrder' : 'PublicPlInboundOrder'
|
||||
router.push({ name, params: { token: accessToken } })
|
||||
}
|
||||
|
||||
function reload() {
|
||||
page.value = 1
|
||||
finished.value = false
|
||||
records.value = []
|
||||
total.value = 0
|
||||
errorMessage.value = ''
|
||||
loadMore()
|
||||
}
|
||||
|
||||
async function loadMore() {
|
||||
if (finished.value && page.value > 1) {
|
||||
listLoading.value = false
|
||||
return
|
||||
}
|
||||
const seq = ++requestSeq
|
||||
listLoading.value = true
|
||||
try {
|
||||
const data = await api.getHistory(
|
||||
token.value,
|
||||
pickDate.value,
|
||||
keyword.value,
|
||||
page.value,
|
||||
PAGE_SIZE
|
||||
)
|
||||
if (seq !== requestSeq) return
|
||||
errorMessage.value = ''
|
||||
const rows = data?.records || []
|
||||
total.value = Number(data?.total || 0)
|
||||
if (page.value === 1) {
|
||||
records.value = rows
|
||||
} else {
|
||||
records.value = records.value.concat(rows)
|
||||
}
|
||||
const loaded = records.value.length
|
||||
finished.value = loaded >= total.value || rows.length < PAGE_SIZE
|
||||
if (!finished.value) {
|
||||
page.value += 1
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (seq !== requestSeq) return
|
||||
errorMessage.value = e?.message || '链接无效或已失效'
|
||||
records.value = []
|
||||
total.value = 0
|
||||
finished.value = true
|
||||
} finally {
|
||||
if (seq === requestSeq) {
|
||||
listLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
watchDebounced(
|
||||
keyword,
|
||||
() => {
|
||||
reload()
|
||||
},
|
||||
{ debounce: 300 }
|
||||
)
|
||||
|
||||
onMounted(reload)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.site-nav-bar {
|
||||
margin: -12px -16px 12px;
|
||||
border-radius: 0 0 12px 12px;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.van-nav-bar) {
|
||||
background: #059669;
|
||||
}
|
||||
|
||||
:deep(.van-nav-bar__title),
|
||||
:deep(.van-nav-bar__arrow) {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
:deep(.van-nav-bar__title) {
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.filters {
|
||||
margin-bottom: 12px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.filter-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.date-field {
|
||||
padding: 0 12px;
|
||||
min-height: 40px;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
|
||||
:deep(.van-field__control) {
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
:deep(.van-field__right-icon) {
|
||||
margin-right: 0;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.search-input {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
height: 40px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.chip {
|
||||
height: 30px;
|
||||
padding: 0 12px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #d1fae5;
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.chip.on {
|
||||
background: #059669;
|
||||
border-color: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
padding: 16px 14px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.index-tag {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-width: 24px;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px 0 10px 0;
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.record-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.plan-no {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.tag {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.tag--success {
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tag--danger {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tag--muted {
|
||||
background: #94a3b8;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.meta {
|
||||
font-size: 13px;
|
||||
color: #64748b;
|
||||
line-height: 1.45;
|
||||
word-break: break-all;
|
||||
|
||||
& + .meta {
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -179,13 +179,28 @@
|
||||
<van-cell-group v-if="page.siteFeedbackTime" inset class="section-card">
|
||||
<van-cell title="上次保存" :value="formatDateTime(page.siteFeedbackTime)" />
|
||||
</van-cell-group>
|
||||
</template>
|
||||
|
||||
<footer v-if="!isReadOnly" class="page-footer">
|
||||
<footer v-if="page && !errorMessage && !loading" class="page-footer">
|
||||
<div v-if="!page.archived && !isReadOnly" class="btn-row">
|
||||
<van-button block round type="primary" class="history-btn" @click="goHistory">
|
||||
现场记录
|
||||
</van-button>
|
||||
<van-button type="primary" block round :loading="saving" @click="handleSave">
|
||||
提交
|
||||
</van-button>
|
||||
</footer>
|
||||
</template>
|
||||
</div>
|
||||
<van-button
|
||||
v-else
|
||||
block
|
||||
round
|
||||
type="primary"
|
||||
class="history-btn"
|
||||
@click="goHistory"
|
||||
>
|
||||
现场记录
|
||||
</van-button>
|
||||
</footer>
|
||||
</div>
|
||||
</PublicMobileShell>
|
||||
</template>
|
||||
@@ -218,6 +233,7 @@
|
||||
const props = defineProps<{ kind: 'inbound' | 'outbound' }>()
|
||||
const api = createPublicIoOrderApi(props.kind)
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const token = computed(() => String(route.params.token || ''))
|
||||
const navTitle = computed(() =>
|
||||
props.kind === 'inbound' ? '入库单 · 现场回执' : '出库单 · 现场回执'
|
||||
@@ -287,6 +303,11 @@
|
||||
return (s && map[s]) || s || '—'
|
||||
}
|
||||
|
||||
function goHistory() {
|
||||
const name = props.kind === 'inbound' ? 'PublicPlInboundHistory' : 'PublicPlOutboundHistory'
|
||||
router.push({ name, params: { token: token.value } })
|
||||
}
|
||||
|
||||
function resolveFileUrl(url: string) {
|
||||
if (!url) return ''
|
||||
if (/^https?:\/\//i.test(url)) return url
|
||||
@@ -512,6 +533,16 @@
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.history-btn {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.multiline-cell :deep(.van-cell__value) {
|
||||
text-align: left;
|
||||
line-height: 1.35;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<PublicIoOrderHistoryPage kind="inbound" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import PublicIoOrderHistoryPage from '../_shared/PublicIoOrderHistoryPage.vue'
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<PublicIoOrderHistoryPage kind="outbound" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import PublicIoOrderHistoryPage from '../_shared/PublicIoOrderHistoryPage.vue'
|
||||
</script>
|
||||
@@ -13,30 +13,51 @@
|
||||
<van-empty v-else-if="errorMessage" :description="errorMessage" />
|
||||
<template v-else>
|
||||
<div class="filters">
|
||||
<div class="chips">
|
||||
<button
|
||||
v-for="q in quickOptions"
|
||||
:key="q.offset"
|
||||
type="button"
|
||||
class="chip"
|
||||
:class="{ on: pickDate === q.ymd }"
|
||||
@click="setQuick(q.offset)"
|
||||
>
|
||||
{{ q.label }}
|
||||
</button>
|
||||
<div class="filter-row">
|
||||
<van-field
|
||||
class="date-field"
|
||||
readonly
|
||||
is-link
|
||||
clickable
|
||||
:model-value="pickDate"
|
||||
placeholder="选择日期"
|
||||
@click="openDatePicker"
|
||||
/>
|
||||
<div class="chips">
|
||||
<button
|
||||
v-for="q in quickOptions"
|
||||
:key="q.offset"
|
||||
type="button"
|
||||
class="chip"
|
||||
:class="{ on: pickDate === q.ymd }"
|
||||
@click="setQuick(q.offset)"
|
||||
>
|
||||
{{ q.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<input v-model="pickDate" type="date" class="date-input" @change="load" />
|
||||
<div class="hint">{{ filterHint }}</div>
|
||||
</div>
|
||||
|
||||
<van-popup v-model:show="showDatePicker" position="bottom" round>
|
||||
<van-date-picker
|
||||
v-model="datePickerValue"
|
||||
title="选择日期"
|
||||
:min-date="minDate"
|
||||
:max-date="maxDate"
|
||||
@confirm="onDateConfirm"
|
||||
@cancel="showDatePicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
|
||||
<van-empty v-if="!records.length" description="暂无运输记录" />
|
||||
<div
|
||||
v-for="row in records"
|
||||
v-for="(row, index) in records"
|
||||
:key="row.planId"
|
||||
class="record-card"
|
||||
role="button"
|
||||
@click="openRecord(row)"
|
||||
>
|
||||
<span class="index-tag">{{ index + 1 }}</span>
|
||||
<div class="record-top">
|
||||
<span class="plan-no">{{ row.planNo }}</span>
|
||||
<span class="tag" :class="tagClass(row)">{{ row.statusLabel || '进行中' }}</span>
|
||||
@@ -62,6 +83,9 @@
|
||||
import PublicMobileShell from '@/layouts/PublicMobileShell.vue'
|
||||
|
||||
import 'vant/es/toast/style'
|
||||
import 'vant/es/field/style'
|
||||
import 'vant/es/popup/style'
|
||||
import 'vant/es/date-picker/style'
|
||||
import '@/styles/public-mobile-vant.scss'
|
||||
|
||||
const route = useRoute()
|
||||
@@ -72,15 +96,17 @@
|
||||
const errorMessage = ref('')
|
||||
const records = ref<PublicTransportHistoryRecord[]>([])
|
||||
const pickDate = ref(addDays(0))
|
||||
const showDatePicker = ref(false)
|
||||
const datePickerValue = ref<string[]>(ymdToParts(pickDate.value))
|
||||
const minDate = new Date(new Date().getFullYear() - 2, 0, 1)
|
||||
const maxDate = new Date(new Date().getFullYear() + 2, 11, 31)
|
||||
|
||||
const quickOptions = [
|
||||
{ label: '今天', offset: 0, ymd: addDays(0) },
|
||||
{ label: '明天', offset: 1, ymd: addDays(1) },
|
||||
{ label: '今日', offset: 0, ymd: addDays(0) },
|
||||
{ label: '明日', offset: 1, ymd: addDays(1) },
|
||||
{ label: '后天', offset: 2, ymd: addDays(2) }
|
||||
]
|
||||
|
||||
const filterHint = computed(() => `筛选日期:${pickDate.value}(取货或送货落在当天)`)
|
||||
|
||||
function formatYmd(d: Date) {
|
||||
const y = d.getFullYear()
|
||||
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||
@@ -95,6 +121,23 @@
|
||||
return formatYmd(d)
|
||||
}
|
||||
|
||||
function ymdToParts(ymd: string): string[] {
|
||||
const [y, m, d] = String(ymd || '').split('-')
|
||||
if (!y || !m || !d) return ymdToParts(addDays(0))
|
||||
return [y, m, d]
|
||||
}
|
||||
|
||||
function openDatePicker() {
|
||||
datePickerValue.value = ymdToParts(pickDate.value)
|
||||
showDatePicker.value = true
|
||||
}
|
||||
|
||||
function onDateConfirm({ selectedValues }: { selectedValues: string[] }) {
|
||||
pickDate.value = selectedValues.join('-')
|
||||
showDatePicker.value = false
|
||||
load()
|
||||
}
|
||||
|
||||
function formatDay(value?: string) {
|
||||
if (!value) return '—'
|
||||
const normalized = value.replace('T', ' ')
|
||||
@@ -113,6 +156,7 @@
|
||||
|
||||
function setQuick(offset: number) {
|
||||
pickDate.value = addDays(offset)
|
||||
datePickerValue.value = ymdToParts(pickDate.value)
|
||||
load()
|
||||
}
|
||||
|
||||
@@ -174,25 +218,66 @@
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.filter-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.date-field {
|
||||
flex: 0 1 11.5em;
|
||||
min-width: 0;
|
||||
padding: 0 10px;
|
||||
min-height: 40px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
|
||||
:deep(.van-field__control) {
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
:deep(.van-field__right-icon) {
|
||||
margin-right: 0;
|
||||
color: #64748b;
|
||||
}
|
||||
}
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 0;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.chip {
|
||||
height: 30px;
|
||||
padding: 0 12px;
|
||||
padding: 0 10px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid #d1fae5;
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.chip.on {
|
||||
@@ -201,32 +286,33 @@
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.date-input {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: #1e293b;
|
||||
background: #fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #64748b;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
padding: 14px;
|
||||
padding: 16px 14px 14px;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
cursor: pointer;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.index-tag {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-width: 24px;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 12px 0 10px 0;
|
||||
background: #059669;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.record-top {
|
||||
@@ -235,6 +321,7 @@
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.plan-no {
|
||||
|
||||
@@ -204,12 +204,23 @@
|
||||
|
||||
<footer v-if="page && !errorMessage && !loading" class="page-footer">
|
||||
<div v-if="!page.planVoided && !page.planArchived" class="btn-row">
|
||||
<van-button block round plain type="primary" @click="goHistory">运输记录</van-button>
|
||||
<van-button block round type="primary" class="history-btn" @click="goHistory">
|
||||
运输记录
|
||||
</van-button>
|
||||
<van-button type="primary" block round :loading="saving" @click="handleSave">
|
||||
保存回执
|
||||
</van-button>
|
||||
</div>
|
||||
<van-button v-else block round plain type="primary" @click="goHistory">运输记录</van-button>
|
||||
<van-button
|
||||
v-else
|
||||
block
|
||||
round
|
||||
type="primary"
|
||||
class="history-btn"
|
||||
@click="goHistory"
|
||||
>
|
||||
运输记录
|
||||
</van-button>
|
||||
</footer>
|
||||
</div>
|
||||
</PublicMobileShell>
|
||||
@@ -714,4 +725,8 @@
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.history-btn {
|
||||
color: #fff !important;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user