This commit is contained in:
zlwu committed 2026-08-23 18:42:27 +08:00
1 parent b74d483682
commit dd1acdc787
50 files changed
+636156 -7218

No files matched your search

+15 -1
View File
@@ -393,6 +393,11 @@ export const driverApi = {
// 计划管理 API
// =============================================================================
export interface PlanDocumentAttachmentItem {
url: string
label: string
}
export interface PlanContractLink {
contractId: string
contractNo?: string
@@ -495,6 +500,7 @@ export interface Plan {
hazardCertReady?: number
hazardCertReadyBy?: string
hazardCertReadyTime?: string
erpEntered?: number
remark?: string
createBy?: string
createTime: string
@@ -507,6 +513,8 @@ export interface Plan {
canCopyToSite?: boolean
/** 列表:是否显示「复制磅单二维码」 */
canCopyPoundQrcode?: boolean
/** 列表:单据附件(司机/现场/出入库现场等) */
documentAttachments?: PlanDocumentAttachmentItem[]
}
export interface PlanQuery {
@@ -632,7 +640,11 @@ export interface TransportDriverProductFeedback {
export interface PlanArchiveProductItem {
id: string
actualQty: number
actualQty?: number
inboundQty?: number
inboundPrice?: number
outboundQty?: number
outboundPrice?: number
brandQtys?: PlanArchiveBrandQtyItem[]
}
@@ -723,6 +735,8 @@ export const planApi = {
) => request.patch<Plan>(`/transport/plan/${id}/product-certs`, { products }),
setHazardCertReady: (id: string, ready: boolean) =>
request.patch<Plan>(`/transport/plan/${id}/hazard-cert-ready`, { ready }),
setErpEntered: (id: string, entered: boolean) =>
request.patch<Plan>(`/transport/plan/${id}/erp-entered`, { entered }),
cancel: (id: string) => request.post<Plan>(`/transport/plan/${id}/cancel`),
waitNotice: (id: string) => request.post<Plan>(`/transport/plan/${id}/wait-notice`),
cancelWaitNotice: (id: string) =>
@@ -29,7 +29,9 @@
<PlPlanFormProductTable
:products="productRows"
show-actual-qty
show-archive-io-fields
editable-actual-qty-only
editable-archive-io-fields
/>
<div
v-for="row in brandedProductRows"
@@ -122,6 +124,7 @@
embedded
hide-nav
:tab="viewTab"
show-archive-io-fields
feedback-editable
:arrange-driver-url="driverUrl"
:arrange-site-records="siteRecords"
@@ -263,6 +266,7 @@
function isBrandQtySumMatch(row: PlanFormProductRow): boolean {
if (!row.brandMode) return true
if (row.actualQty == null) return true
return Math.abs(brandQtySum(row) - Number(row.actualQty ?? 0)) < 0.0005
}
@@ -288,6 +292,20 @@
unit: item.unit || '吨',
quantity: Number(item.quantity ?? item.inboundEstimateQty ?? item.outboundEstimateQty ?? 0),
actualQty: item.actualQty != null ? Number(item.actualQty) : undefined,
inboundQty: item.inboundQty != null ? Number(item.inboundQty) : undefined,
inboundPrice:
item.inboundPrice != null
? Number(item.inboundPrice)
: item.taxPrice != null
? Number(item.taxPrice)
: undefined,
outboundQty: item.outboundQty != null ? Number(item.outboundQty) : undefined,
outboundPrice:
item.outboundPrice != null
? Number(item.outboundPrice)
: item.taxPrice != null
? Number(item.taxPrice)
: undefined,
packageSpec: item.packageSpec,
deliveryMethod: item.deliveryMethod,
taxRate: item.taxRate != null ? Number(item.taxRate) : undefined,
@@ -506,8 +524,28 @@
ElMessage.error('产品明细缺少行 ID,无法提交')
return
}
if (productRows.value.some((row) => row.actualQty == null || Number(row.actualQty) < 0)) {
ElMessage.warning('请填写有效的实际数量')
if (productRows.value.some((row) => row.actualQty != null && Number(row.actualQty) < 0)) {
ElMessage.warning('实际数量不能为负数')
return
}
if (
productRows.value.some(
(row) =>
row.inboundQty != null && Number(row.inboundQty) < 0 ||
row.outboundQty != null && Number(row.outboundQty) < 0
)
) {
ElMessage.warning('入库/出库数量不能为负数')
return
}
if (
productRows.value.some(
(row) =>
row.inboundPrice != null && Number(row.inboundPrice) < 0 ||
row.outboundPrice != null && Number(row.outboundPrice) < 0
)
) {
ElMessage.warning('入库/出库价不能为负数')
return
}
const brandMismatch = brandedProductRows.value.find((row) => !isBrandQtySumMatch(row))
@@ -543,7 +581,11 @@
const body: PlanArchiveBody = {
products: productRows.value.map((row) => ({
id: row.id!,
actualQty: Number(row.actualQty ?? 0),
...(row.actualQty != null ? { actualQty: Number(row.actualQty) } : {}),
...(row.inboundQty != null ? { inboundQty: Number(row.inboundQty) } : {}),
...(row.inboundPrice != null ? { inboundPrice: Number(row.inboundPrice) } : {}),
...(row.outboundQty != null ? { outboundQty: Number(row.outboundQty) } : {}),
...(row.outboundPrice != null ? { outboundPrice: Number(row.outboundPrice) } : {}),
brandQtys: row.brandMode
? (row.brandQtyRows || [])
.filter((r) => Number(r.qty) > 0)
@@ -307,24 +307,9 @@
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
command="inbound"
:disabled="!canPrintSlipCommand(plan.planType, 'inbound')"
>
入库单
</el-dropdown-item>
<el-dropdown-item
command="delivery"
:disabled="!canPrintSlipCommand(plan.planType, 'delivery')"
>
送(提)货单
</el-dropdown-item>
<el-dropdown-item
command="subpack"
:disabled="!canPrintSlipCommand(plan.planType, 'subpack')"
>
分装单
</el-dropdown-item>
<el-dropdown-item command="inbound">入库单</el-dropdown-item>
<el-dropdown-item command="delivery">送(提)货单</el-dropdown-item>
<el-dropdown-item command="subpack">分装单</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@@ -375,7 +360,7 @@ import { useDictStore } from '@/store/modules/dict'
import { isTonProductUnit } from '@/utils/crm-product-display'
import { formatDate } from '@/utils/format'
import { pickBxData } from '@/utils/http/bx'
import { canPrintSlipCommand, formatPlVehiclePlateDisplay, type PlPrintSlipCommand } from '@/utils/pl-display'
import { formatPlVehiclePlateDisplay, type PlPrintSlipCommand } from '@/utils/pl-display'
import { getPersonnelAffiliationLabel } from '@/utils/pl-personnel-cert'
const dictStore = useDictStore()
@@ -879,10 +864,6 @@ function handlePrintSlip(command: string) {
return
}
const slipCommand = command as PlPrintSlipCommand
if (!canPrintSlipCommand(plan.value.planType, slipCommand)) {
ElMessage.warning('当前单据类型不支持打印该单据')
return
}
if (slipCommand === 'inbound') {
inboundSlipPrintRef.value?.open(planId)
return
@@ -0,0 +1,220 @@
<template>
<div v-if="items.length" class="pl-plan-document-attachment-cell">
<div
v-for="item in items"
:key="item.key"
class="pl-plan-document-attachment-cell__item"
:title="item.fullLabel"
>
<div class="pl-plan-document-attachment-cell__thumb">
<div
class="pl-plan-document-attachment-cell__preview"
:title="item.isImage || item.isPdf ? '点击在新标签页查看' : '点击查看'"
@click.stop="handlePreview(item)"
>
<div class="pl-plan-document-attachment-cell__placeholder is-clickable">
<el-icon :size="16" color="#10b981"><Picture /></el-icon>
</div>
</div>
<el-icon
class="pl-plan-document-attachment-cell__download"
title="下载"
@click.stop="handleDownload(item)"
>
<Download />
</el-icon>
<span class="pl-plan-document-attachment-cell__caption">{{ item.label }}</span>
</div>
</div>
</div>
<span v-else class="pl-plan-document-attachment-cell__none">—</span>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { Download, Picture } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import type { PlanDocumentAttachmentItem } from '@/api/pl'
import {
downloadAttachmentFile,
openAttachmentPreviewInNewTab
} from '@/utils/download-attachment'
import { resolvePhotoDisplayUrl } from '@/utils/pl-photo'
const props = withDefaults(
defineProps<{
attachments?: PlanDocumentAttachmentItem[] | null
mediaActive?: boolean
}>(),
{
attachments: () => [],
mediaActive: true
}
)
type ItemDef = {
key: string
label: string
fullLabel: string
url: string
isImage: boolean
isPdf: boolean
}
function isImageUrl(url: string) {
const path = String(url || '')
.split('?')[0]
.toLowerCase()
return /\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(path)
}
function isPdfUrl(url: string) {
const path = String(url || '')
.split('?')[0]
.toLowerCase()
return /\.pdf$/i.test(path)
}
function fileNameFromUrl(url: string) {
return (
String(url || '')
.split('?')[0]
.split('/')
.pop() || '附件'
)
}
async function handlePreview(item: ItemDef) {
if (!item.url) return
await openAttachmentPreviewInNewTab(
{ fileUrl: item.url, fileName: fileNameFromUrl(item.url) },
{
fullFileUrl: resolvePhotoDisplayUrl,
kind: item.isImage ? 'image' : item.isPdf ? 'pdf' : 'other'
}
)
}
async function handleDownload(item: ItemDef) {
if (!item.url) {
ElMessage.error('无法获取文件下载地址')
return
}
try {
await downloadAttachmentFile(
{ fileUrl: item.url, fileName: fileNameFromUrl(item.url) },
{ fullFileUrl: resolvePhotoDisplayUrl }
)
ElMessage.success('下载成功')
} catch {
ElMessage.error('下载失败,请稍后重试')
}
}
const items = computed<ItemDef[]>(() => {
const list = props.attachments || []
return list
.filter((item) => String(item?.url || '').trim())
.map((item, index) => {
const url = String(item.url).trim()
const fullLabel = String(item.label || '附件').trim() || '附件'
const label = fullLabel.length > 6 ? `${fullLabel.slice(0, 5)}…` : fullLabel
return {
key: `${url}-${index}`,
label,
fullLabel,
url,
isImage: isImageUrl(url),
isPdf: isPdfUrl(url)
}
})
})
</script>
<style scoped lang="scss">
.pl-plan-document-attachment-cell {
display: flex;
align-items: flex-start;
gap: 8px;
flex-wrap: wrap;
}
.pl-plan-document-attachment-cell__item {
display: flex;
flex-direction: column;
align-items: center;
width: 56px;
}
.pl-plan-document-attachment-cell__thumb {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 56px;
height: 40px;
overflow: hidden;
border: 1px solid var(--border, #d9e8e2);
border-radius: 6px;
background: var(--table-head, #f8fafc);
}
.pl-plan-document-attachment-cell__preview {
width: 100%;
height: 100%;
cursor: pointer;
}
.pl-plan-document-attachment-cell__placeholder {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
margin-bottom: 10px;
background: var(--primary-bg, #ecfdf5);
&.is-clickable {
cursor: pointer;
}
}
.pl-plan-document-attachment-cell__download {
position: absolute;
right: 1px;
top: 1px;
z-index: 2;
width: 16px;
height: 16px;
border-radius: 50%;
background: #fff;
border: 1px solid #e2e8f0;
color: #1e293b;
cursor: pointer;
font-size: 10px;
&:hover {
color: #1ca851;
border-color: #1ca851;
background: #e6f8ed;
}
}
.pl-plan-document-attachment-cell__caption {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 1px 2px;
background: rgba(15, 23, 42, 0.62);
color: #fff;
font-size: 10px;
line-height: 1.2;
text-align: center;
word-break: keep-all;
}
.pl-plan-document-attachment-cell__none {
color: var(--mint-text);
}
</style>
@@ -125,6 +125,98 @@
<span v-else>{{ row.actualQty ?? '—' }}</span>
</template>
</el-table-column>
<el-table-column
v-if="showInboundOutboundQty || showArchiveIoFields"
label="入库数量"
min-width="110"
align="right"
>
<template #default="{ row }">
<el-input-number
v-if="editableArchiveIoFields"
v-model="row.inboundQty"
:min="0"
:precision="3"
:controls="false"
style="width: 100%"
/>
<span v-else>{{ row.inboundQty ?? '—' }}</span>
</template>
</el-table-column>
<el-table-column
v-if="showArchiveIoFields"
label="入库单价(元)"
min-width="120"
align="right"
>
<template #default="{ row }">
<el-input-number
v-if="editableArchiveIoFields"
v-model="row.inboundPrice"
:min="0"
:precision="2"
:controls="false"
style="width: 100%"
/>
<span v-else>{{ row.inboundPrice ?? '—' }}</span>
</template>
</el-table-column>
<el-table-column
v-if="showArchiveIoFields"
label="入库金额"
min-width="110"
align="right"
>
<template #default="{ row }">
{{ formatPlanProductIoAmount(row.inboundQty, row.inboundPrice) }}
</template>
</el-table-column>
<el-table-column
v-if="showInboundOutboundQty || showArchiveIoFields"
label="出库数量"
min-width="110"
align="right"
>
<template #default="{ row }">
<el-input-number
v-if="editableArchiveIoFields"
v-model="row.outboundQty"
:min="0"
:precision="3"
:controls="false"
style="width: 100%"
/>
<span v-else>{{ row.outboundQty ?? '—' }}</span>
</template>
</el-table-column>
<el-table-column
v-if="showArchiveIoFields"
label="出库单价(元)"
min-width="120"
align="right"
>
<template #default="{ row }">
<el-input-number
v-if="editableArchiveIoFields"
v-model="row.outboundPrice"
:min="0"
:precision="2"
:controls="false"
style="width: 100%"
/>
<span v-else>{{ row.outboundPrice ?? '—' }}</span>
</template>
</el-table-column>
<el-table-column
v-if="showArchiveIoFields"
label="出库金额"
min-width="110"
align="right"
>
<template #default="{ row }">
{{ formatPlanProductIoAmount(row.outboundQty, row.outboundPrice) }}
</template>
</el-table-column>
<el-table-column
v-if="showBrandQty"
label="品牌数量"
@@ -250,6 +342,12 @@ const props = defineProps<{
showBrandQty?: boolean
/** 仅实际数量可编辑,计划数量只读(归档弹窗) */
editableActualQtyOnly?: boolean
/** 展示入库/出库数量列(不含价格) */
showInboundOutboundQty?: boolean
/** 展示入库/出库数量、单价与计算金额列 */
showArchiveIoFields?: boolean
/** 入库/出库数量与价格可编辑(归档弹窗) */
editableArchiveIoFields?: boolean
}>()
const emit = defineEmits<{
@@ -274,6 +372,17 @@ function isProductSelected(row: PlanFormProductRow) {
return selectedProductIdSet.value.has(String(row.productId))
}
/** 入库/出库金额:数量 × 单价,保留两位小数 */
function formatPlanProductIoAmount(
qty?: number | string | null,
price?: number | string | null
) {
if (qty == null || price == null || qty === '' || price === '') return '—'
const amount = Number(qty) * Number(price)
if (!Number.isFinite(amount)) return '—'
return amount.toFixed(2)
}
function handleAliasChange(row: PlanFormProductRow) {
row.productName = resolveLineProductName(row.standardProductName, row.aliasName)
}
@@ -9,7 +9,11 @@
class="pl-plan-list-product-cell__line"
:class="{
'pl-plan-list-product-cell__line--qty':
field === 'qty' || field === 'planQty' || field === 'actualQty',
field === 'qty' ||
field === 'planQty' ||
field === 'actualQty' ||
field === 'inboundQty' ||
field === 'outboundQty',
'pl-plan-list-product-cell__line--center':
field === 'spec' || field === 'model' || field === 'packageSpec' || field === 'unit'
}"
@@ -91,7 +95,9 @@ import { useDictStore } from '@/store/modules/dict'
import {
formatPlanProductListText,
getPlanProductActualQuantity,
getPlanProductInboundQuantity,
getPlanProductModel,
getPlanProductOutboundQuantity,
getPlanProductPackageSpec,
getPlanProductPlannedQuantity,
getPlanProductQuantity,
@@ -106,6 +112,8 @@ export type PlPlanListProductCellField =
| 'qty'
| 'planQty'
| 'actualQty'
| 'inboundQty'
| 'outboundQty'
| 'unit'
const props = withDefaults(
@@ -151,6 +159,12 @@ function formatFieldValue(product: PlanProduct) {
if (props.field === 'actualQty') {
return getPlanProductActualQuantity(product)
}
if (props.field === 'inboundQty') {
return getPlanProductInboundQuantity(product)
}
if (props.field === 'outboundQty') {
return getPlanProductOutboundQuantity(product)
}
if (props.field === 'unit') {
const unitRaw = product.unit || ''
if (!unitRaw) return '—'
@@ -9,6 +9,8 @@
:products="planProductRows"
show-actual-qty
show-brand-qty
:show-archive-io-fields="showArchiveIoFields"
:show-inbound-outbound-qty="!showArchiveIoFields"
/>
</section>
@@ -382,6 +384,8 @@
const props = withDefaults(
defineProps<{
feedbackEditable?: boolean
/** 仅运输计划归档:展示入库/出库单价与金额 */
showArchiveIoFields?: boolean
loading?: boolean
canEditDriverFeedback?: boolean
hasDriverFeedback?: boolean
@@ -402,6 +406,7 @@
}>(),
{
feedbackEditable: false,
showArchiveIoFields: false,
loading: false,
canEditDriverFeedback: false,
hasDriverFeedback: false,
@@ -38,6 +38,8 @@
:show-arrange-links="showArrangeActions"
:arrange-driver-url="driverUrl"
:arrange-site-records="siteRecords"
:show-archive-io-fields="showArchiveIoFields"
:show-inbound-outbound-qty="showInboundOutboundQty"
/>
<DbPoundSlipQrcodeDialog
@@ -60,6 +62,10 @@ import { usePlPlanArrangeActions } from '@/composables/usePlPlanArrangeActions'
const props = defineProps<{
visible: boolean
planId?: string
/** 仅运输计划归档:展示入库/出库单价与金额 */
showArchiveIoFields?: boolean
/** 计划概况产品表:展示入库/出库数量(不含单价与金额) */
showInboundOutboundQty?: boolean
}>()
const emit = defineEmits<{
@@ -15,7 +15,14 @@
<section class="pl-plan-form-section pl-plan-form-section--plain">
<h3 class="pl-plan-form-section-title">产品信息</h3>
<p v-if="!productRows.length && !loading" class="pl-plan-form-empty-hint">暂无产品明细</p>
<PlPlanFormProductTable v-else :products="productRows" show-actual-qty show-brand-qty />
<PlPlanFormProductTable
v-else
:products="productRows"
show-actual-qty
show-brand-qty
:show-archive-io-fields="showArchiveIoFields"
:show-inbound-outbound-qty="showInboundOutboundQty && !showArchiveIoFields"
/>
</section>
<section class="pl-plan-form-section pl-plan-form-section--plain">
@@ -431,6 +438,10 @@
hideNav?: boolean
/** 受控当前 Tab:overview / transport */
tab?: string
/** 仅运输计划归档:展示入库/出库单价与金额 */
showArchiveIoFields?: boolean
/** 计划概况产品表:展示入库/出库数量(不含单价与金额) */
showInboundOutboundQty?: boolean
}>(),
{
embedded: false,
@@ -440,7 +451,9 @@
feedbackEditable: false,
feedbackMirrorTo: null,
hideNav: false,
tab: undefined
tab: undefined,
showArchiveIoFields: false,
showInboundOutboundQty: false
}
)
@@ -1135,6 +1148,7 @@
const feedbackBlocksBind = computed(() => ({
feedbackEditable: props.feedbackEditable,
showArchiveIoFields: props.showArchiveIoFields,
loading: loading.value,
canEditDriverFeedback: canEditDriverFeedback.value,
hasDriverFeedback: hasDriverFeedback.value,
@@ -28,6 +28,10 @@ export interface PlanFormProductRow {
unit: string
quantity: number
actualQty?: number
inboundQty?: number
inboundPrice?: number
outboundQty?: number
outboundPrice?: number
packageSpec?: string
deliveryMethod?: string
taxRate?: number
@@ -56,9 +56,34 @@ export function mapPlanProductToFormRow(item: PlanProduct, index: number): PlanF
categoryName: item.categoryName,
unit: item.unit || '吨',
quantity: Number(item.quantity || item.inboundEstimateQty || item.outboundEstimateQty || 0),
actualQty: Number(
item.actualQty ?? item.quantity ?? item.inboundEstimateQty ?? item.outboundEstimateQty ?? 0
),
actualQty:
item.actualQty != null
? Number(item.actualQty)
: item.quantity != null ||
item.inboundEstimateQty != null ||
item.outboundEstimateQty != null
? Number(
item.actualQty ??
item.quantity ??
item.inboundEstimateQty ??
item.outboundEstimateQty ??
0
)
: undefined,
inboundQty: item.inboundQty != null ? Number(item.inboundQty) : undefined,
inboundPrice:
item.inboundPrice != null
? Number(item.inboundPrice)
: item.taxPrice != null
? Number(item.taxPrice)
: undefined,
outboundQty: item.outboundQty != null ? Number(item.outboundQty) : undefined,
outboundPrice:
item.outboundPrice != null
? Number(item.outboundPrice)
: item.taxPrice != null
? Number(item.taxPrice)
: undefined,
packageSpec: item.packageSpec,
deliveryMethod: item.deliveryMethod,
taxRate: item.taxRate != null ? Number(item.taxRate) : undefined,
+4 -28
View File
@@ -1,7 +1,6 @@
// web-admin/src/utils/pl-batch-print.ts
import type { Plan, PlanProduct } from '@/api/pl'
import type { PlPrintSlipCommand } from '@/utils/pl-display'
import { canPrintSlipCommand } from '@/utils/pl-display'
export type SlipPlanProduct = PlanProduct & { slipPlanNo?: string }
@@ -10,52 +9,29 @@ export function normalizeCustomerName(name?: string | null) {
}
export function canBatchPrintSlip(
plans: Array<Pick<Plan, 'planType' | 'customerName' | 'planDate'>>,
plans: Array<Pick<Plan, 'customerName' | 'planDate'>>,
command: PlPrintSlipCommand
): { ok: boolean; reason?: string } {
if (!plans?.length) return { ok: false, reason: '请先勾选运输计划' }
if (plans.length === 1) {
if (!canPrintSlipCommand(plans[0].planType, command)) {
return { ok: false, reason: '当前单据类型不支持打印该单据' }
}
return { ok: true }
}
if (command === 'inbound') {
if (!plans.every((p) => p.planType === 'inbound')) {
return { ok: false, reason: '合打入库单要求:均为入库类计划' }
}
if (command === 'inbound' || command === 'delivery') {
const c = normalizeCustomerName(plans[0].customerName)
const d = plans[0].planDate
const slipLabel = command === 'inbound' ? '入库单' : '送(提)货单'
if (!c || !d || !plans.every((p) => normalizeCustomerName(p.customerName) === c && p.planDate === d)) {
return {
ok: false,
reason: '合打入库单要求:客户名称一致且计划日期一致,且均为入库类计划'
}
}
return { ok: true }
}
if (command === 'delivery') {
if (!plans.every((p) => p.planType === 'outbound')) {
return { ok: false, reason: '合打送(提)货单要求:均为出库类计划' }
}
const c = normalizeCustomerName(plans[0].customerName)
const d = plans[0].planDate
if (!c || !d || !plans.every((p) => normalizeCustomerName(p.customerName) === c && p.planDate === d)) {
return {
ok: false,
reason: '合打送(提)货单要求:客户名称一致且计划日期一致,且均为出库类计划'
reason: `合打${slipLabel}要求:客户名称一致且计划日期一致`
}
}
return { ok: true }
}
if (command === 'subpack') {
if (!plans.every((p) => canPrintSlipCommand(p.planType, 'subpack'))) {
return { ok: false, reason: '分装单仅支持出库类计划' }
}
return { ok: true }
}
+28 -12
View File
@@ -130,6 +130,24 @@ export function getPlanProductActualQuantity(product: {
return String(qty)
}
/** 列表「入库数量」列 */
export function getPlanProductInboundQuantity(product: {
inboundQty?: number | string | null
}) {
const qty = product.inboundQty
if (qty === undefined || qty === null || qty === '') return '—'
return String(qty)
}
/** 列表「出库数量」列 */
export function getPlanProductOutboundQuantity(product: {
outboundQty?: number | string | null
}) {
const qty = product.outboundQty
if (qty === undefined || qty === null || qty === '') return '—'
return String(qty)
}
export function formatPlanProductListText(
product: {
productName?: string
@@ -306,20 +324,18 @@ export function getPlPlanTypeLabel(type?: string) {
/** 打印单据下拉项:入库单 / 送(提)货单 / 分装单 */
export type PlPrintSlipCommand = 'inbound' | 'delivery' | 'subpack'
/**
* 按运输计划单据类型返回可打印的单据命令。
* - inbound:仅入库单
* - outbound:送(提)货单、分装单
* - direct / 其他:不可打印
*/
export function getPrintableSlipCommands(planType?: string): PlPrintSlipCommand[] {
if (planType === 'inbound') return ['inbound']
if (planType === 'outbound') return ['delivery', 'subpack']
return []
/** 运输计划可打印的单据命令(不区分单据类型,由用户自行选择) */
export const PL_PRINT_SLIP_COMMANDS: PlPrintSlipCommand[] = ['inbound', 'delivery', 'subpack']
export function getPrintableSlipCommands(_planType?: string): PlPrintSlipCommand[] {
return PL_PRINT_SLIP_COMMANDS
}
export function canPrintSlipCommand(planType: string | undefined, command: PlPrintSlipCommand) {
return getPrintableSlipCommands(planType).includes(command)
export function canPrintSlipCommand(
_planType: string | undefined,
_command: PlPrintSlipCommand
) {
return true
}
export type PlPlanTypeTab = 'all' | 'inbound' | 'outbound' | 'direct'
+3 -3
View File
@@ -1453,15 +1453,15 @@
}
.day-num {
margin-bottom: 4px;
font-size: 14px;
font-size: 18px;
font-weight: 600;
}
.duty-cal td.today .day-num {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
width: 28px;
height: 28px;
color: #fff;
background: var(--el-color-primary, #10b981);
border-radius: 50%;
+121 -10
View File
@@ -100,7 +100,6 @@
:get-filter-params="getPlanArchiveExportFilterParams"
:has-selection="true"
:selected-ids="selectedRows.map((r) => r.id)"
:visible-columns="planArchiveExportColumns"
filename="计划归档.xlsx"
/>
@@ -209,10 +208,39 @@
label-class-name="col-name-wrap"
show-overflow-tooltip
/>
<el-table-column
v-if="isColumnVisible('documentAttachments')"
label="单据附件"
min-width="220"
align="left"
header-align="left"
>
<template #default="{ row }">
<PlPlanDocumentAttachmentCell :attachments="row.documentAttachments" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('erpEntered')"
label="ERP"
min-width="72"
align="center"
header-align="center"
>
<template #default="{ row }">
<div class="pl-plan-archive-erp-cell" @click.stop @mousedown.stop>
<el-checkbox
:model-value="Number(row.erpEntered) === 1"
:disabled="row.followStatus === 'cancelled' || erpUpdatingId === row.id"
@click.stop
@change="(checked) => handleErpEnteredChange(row, Boolean(checked))"
/>
</div>
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productName')"
label="产品名称"
min-width="240"
min-width="160"
align="left"
header-align="left"
class-name="col-name-wrap"
@@ -225,7 +253,7 @@
<el-table-column
v-if="isColumnVisible('productSpec')"
label="型号/规格"
min-width="120"
min-width="96"
align="center"
header-align="center"
show-overflow-tooltip
@@ -237,7 +265,7 @@
<el-table-column
v-if="isColumnVisible('productUnit')"
label="单位"
min-width="80"
min-width="64"
align="center"
header-align="center"
>
@@ -267,6 +295,28 @@
<PlPlanListProductCell :products="row.products" field="actualQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productInboundQty')"
label="入库数量"
min-width="100"
align="right"
header-align="right"
>
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="inboundQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productOutboundQty')"
label="出库数量"
min-width="100"
align="right"
header-align="right"
>
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="outboundQty" />
</template>
</el-table-column>
<el-table-column v-if="isColumnVisible('planAttachments')" label="计划附件" min-width="200">
<template #default="{ row }">
<PlPlanListCertCell :products="row.products" compact hide-product />
@@ -284,6 +334,21 @@
{{ formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo) }}
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('carrierName')"
prop="carrierName"
label="承运商"
min-width="140"
show-overflow-tooltip
align="left"
header-align="left"
class-name="col-name-wrap"
label-class-name="col-name-wrap"
>
<template #default="{ row }">
{{ row.resourceSnapshot?.carrierName || '' }}
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('personnelSummary')"
prop="personnelSummary"
@@ -336,6 +401,7 @@
ref="viewDialogRef"
v-model:visible="viewVisible"
:plan-id="viewPlanId"
show-archive-io-fields
>
<template v-if="viewingPlan" #hero-actions>
<el-button
@@ -376,6 +442,7 @@ import {
} from '@/composables/usePlToxicProductCertCheck'
import { pickBxData } from '@/utils/http/bx'
import PlPlanArchiveDialog from '@/components/business/pl-plan-archive-dialog/index.vue'
import PlPlanDocumentAttachmentCell from '@/components/business/pl-plan-document-attachment-cell/index.vue'
import PlPlanListCertCell from '@/components/business/pl-plan-list-cert-cell/index.vue'
import PlPlanListProductCell from '@/components/business/pl-plan-list-product-cell/index.vue'
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
@@ -405,6 +472,7 @@ const viewPlanId = ref('')
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
const archiveDialogVisible = ref(false)
const archivePlanId = ref('')
const erpUpdatingId = ref('')
const planList = ref<Plan[]>([])
const listColumnDefs = [
@@ -414,13 +482,18 @@ const listColumnDefs = [
{ prop: 'planType', label: '单据类型' },
{ prop: 'supplierName', label: '供方' },
{ prop: 'customerName', label: '需方' },
{ prop: 'documentAttachments', label: '单据附件' },
{ prop: 'erpEntered', label: 'ERP' },
{ prop: 'productName', label: '产品名称' },
{ prop: 'productSpec', label: '型号/规格' },
{ prop: 'productUnit', label: '单位' },
{ prop: 'productPlanQty', label: '计划数量' },
{ prop: 'productActualQty', label: '实际数量' },
{ prop: 'productInboundQty', label: '入库数量' },
{ prop: 'productOutboundQty', label: '出库数量' },
{ prop: 'planAttachments', label: '计划附件' },
{ prop: 'licensePlate', label: '车牌号' },
{ prop: 'carrierName', label: '承运商' },
{ prop: 'personnelSummary', label: '人员' },
{ prop: 'followUserName', label: '跟进人', defaultVisible: false }
]
@@ -463,6 +536,12 @@ function getArchiveStatCellValue(row: Plan, prop: string): unknown {
if (prop === 'productActualQty') {
return (row.products || []).reduce((sum, p) => sum + (Number(p.actualQty) || 0), 0)
}
if (prop === 'productInboundQty') {
return (row.products || []).reduce((sum, p) => sum + (Number(p.inboundQty) || 0), 0)
}
if (prop === 'productOutboundQty') {
return (row.products || []).reduce((sum, p) => sum + (Number(p.outboundQty) || 0), 0)
}
if (prop === 'productName') {
return (row.products || []).map((p) => p.productName || '').filter(Boolean).join('\n')
}
@@ -478,9 +557,18 @@ function getArchiveStatCellValue(row: Plan, prop: string): unknown {
if (prop === 'planAttachments') {
return ''
}
if (prop === 'documentAttachments') {
return ''
}
if (prop === 'erpEntered') {
return Number(row.erpEntered) === 1 ? '是' : '否'
}
if (prop === 'licensePlate') {
return formatPlVehiclePlateDisplay(row.licensePlate, row.trailerNo)
}
if (prop === 'carrierName') {
return row.resourceSnapshot?.carrierName || ''
}
if (prop === 'personnelSummary') {
return normalizePlPersonnelSummaryDisplay(row.personnelSummary)
}
@@ -491,6 +579,7 @@ const selectedRows = ref<Plan[]>([])
function getPlanArchiveExportFilterParams() {
const keyword = quickSearch.value.trim()
return {
exportFormat: 'archive',
q: keyword || undefined,
planNo: keyword ? undefined : searchForm.planNo || undefined,
planType: searchForm.planType || undefined,
@@ -504,12 +593,6 @@ function getPlanArchiveExportFilterParams() {
}
}
const planArchiveExportColumns = computed(() => {
const cols = [...visibleColumns.value]
if (!cols.includes('planNo')) cols.unshift('planNo')
return cols
})
const viewingPlan = ref<Plan | null>(null)
function syncViewingPlanFromList() {
@@ -682,6 +765,28 @@ function handleToolbarArchive() {
handleArchive(selectedRows.value[0])
}
async function handleErpEnteredChange(row: Plan, entered: boolean) {
if (row.followStatus === 'cancelled') return
const previous = Number(row.erpEntered) === 1
if (previous === entered) return
erpUpdatingId.value = row.id
row.erpEntered = entered ? 1 : 0
try {
const res = await planApi.setErpEntered(row.id, entered)
const data = pickBxData<Plan>(res)
if (data?.id) {
row.erpEntered = data.erpEntered ?? (entered ? 1 : 0)
}
} catch (error) {
row.erpEntered = previous ? 1 : 0
const message = error instanceof Error ? error.message : '更新 ERP 状态失败'
ElMessage.error(message.includes('失败') ? message : `更新 ERP 状态失败:${message}`)
} finally {
erpUpdatingId.value = ''
}
}
useDbInstantSearch(
() => ({
planNo: searchForm.planNo,
@@ -711,4 +816,10 @@ onMounted(() => {
.pl-plan-list-toolbar-row {
flex-wrap: wrap;
}
.pl-plan-archive-erp-cell {
display: inline-flex;
align-items: center;
justify-content: center;
}
</style>
@@ -304,6 +304,28 @@
<PlPlanListProductCell :products="row.products" field="actualQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productInboundQty')"
label="入库数量"
min-width="88"
align="right"
header-align="right"
>
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="inboundQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productOutboundQty')"
label="出库数量"
min-width="88"
align="right"
header-align="right"
>
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="outboundQty" />
</template>
</el-table-column>
<el-table-column v-if="isColumnVisible('planAttachments')" label="计划附件" min-width="280">
<template #default="{ row }">
<PlPlanListCertCell
@@ -371,6 +393,7 @@
ref="viewDialogRef"
v-model:visible="viewVisible"
:plan-id="viewPlanId"
show-inbound-outbound-qty
>
<template v-if="viewingPlan" #hero-actions>
<el-button
@@ -472,6 +495,8 @@ const listColumnDefs = [
{ prop: 'productUnit', label: '单位' },
{ prop: 'productPlanQty', label: '计划数量' },
{ prop: 'productActualQty', label: '实际数量' },
{ prop: 'productInboundQty', label: '入库数量' },
{ prop: 'productOutboundQty', label: '出库数量' },
{ prop: 'planAttachments', label: '计划附件' },
{ prop: 'licensePlate', label: '车牌号' },
{ prop: 'personnelSummary', label: '人员' },
@@ -319,6 +319,16 @@
<PlPlanListProductCell :products="row.products" field="actualQty" />
</template>
</el-table-column>
<el-table-column label="入库数量" min-width="100" align="right" header-align="right">
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="inboundQty" />
</template>
</el-table-column>
<el-table-column label="出库数量" min-width="100" align="right" header-align="right">
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="outboundQty" />
</template>
</el-table-column>
</el-table>
<div class="pagination list-pager-bar">
@@ -340,6 +350,7 @@
ref="viewDialogRef"
v-model:visible="viewVisible"
:plan-id="viewPlanId"
show-inbound-outbound-qty
/>
</div>
</template>
+34 -23
View File
@@ -365,6 +365,28 @@
<PlPlanListProductCell :products="row.products" field="actualQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productInboundQty')"
label="入库数量"
min-width="100"
align="right"
header-align="right"
>
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="inboundQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('productOutboundQty')"
label="出库数量"
min-width="100"
align="right"
header-align="right"
>
<template #default="{ row }">
<PlPlanListProductCell :products="row.products" field="outboundQty" />
</template>
</el-table-column>
<el-table-column
v-if="isColumnVisible('arrangeCopy')"
label="复制"
@@ -499,6 +521,7 @@
ref="viewDialogRef"
v-model:visible="viewVisible"
:plan-id="viewPlanId"
show-inbound-outbound-qty
>
<template v-if="viewingPlan" #hero-actions>
<el-button
@@ -542,24 +565,9 @@
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
command="inbound"
:disabled="!canPrintSlipCommand(viewingPlan?.planType, 'inbound')"
>
入库单
</el-dropdown-item>
<el-dropdown-item
command="delivery"
:disabled="!canPrintSlipCommand(viewingPlan?.planType, 'delivery')"
>
送(提)货单
</el-dropdown-item>
<el-dropdown-item
command="subpack"
:disabled="!canPrintSlipCommand(viewingPlan?.planType, 'subpack')"
>
分装单
</el-dropdown-item>
<el-dropdown-item command="inbound">入库单</el-dropdown-item>
<el-dropdown-item command="delivery">送(提)货单</el-dropdown-item>
<el-dropdown-item command="subpack">分装单</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@@ -697,7 +705,6 @@ import { useListDateShortcut } from '@/composables/useListDateShortcut'
import { canBatchPrintSlip } from '@/utils/pl-batch-print'
import { planContractLines } from '@/utils/pl-plan-contract-display'
import {
canPrintSlipCommand,
formatPlVehiclePlateDisplay,
getPlPlanFollowStatusLabel,
getPlPlanFollowStatusTagType,
@@ -746,6 +753,8 @@ const listColumnDefs = [
{ prop: 'productUnit', label: '单位' },
{ prop: 'productPlanQty', label: '计划数量' },
{ prop: 'productActualQty', label: '实际数量' },
{ prop: 'productInboundQty', label: '入库数量' },
{ prop: 'productOutboundQty', label: '出库数量' },
{ prop: 'arrangeCopy', label: '复制' },
{ prop: 'planAttachments', label: '计划附件' },
{ prop: 'personnelSummary', label: '人员' },
@@ -844,6 +853,12 @@ function getPlanStatCellValue(row: Plan, prop: string): unknown {
if (prop === 'productActualQty') {
return (row.products || []).reduce((sum, p) => sum + (Number(p.actualQty) || 0), 0)
}
if (prop === 'productInboundQty') {
return (row.products || []).reduce((sum, p) => sum + (Number(p.inboundQty) || 0), 0)
}
if (prop === 'productOutboundQty') {
return (row.products || []).reduce((sum, p) => sum + (Number(p.outboundQty) || 0), 0)
}
if (prop === 'productName') {
return (row.products || []).map((p) => p.productName || '').filter(Boolean).join('\n')
}
@@ -1209,10 +1224,6 @@ async function handleArrange(row: Plan) {
}
function handlePrintSlip(command: PlPrintSlipCommand, row: Plan) {
if (!canPrintSlipCommand(row.planType, command)) {
ElMessage.warning('当前单据类型不支持打印该单据')
return
}
if (command === 'inbound') {
inboundSlipPrintRef.value?.open(row.id)
return