作废/取消计划仍展示已有分段回传;打开计划详情始终回源,避免列表 seed 滞后。 Co-authored-by: Cursor <cursoragent@cursor.com>
230 lines
7.0 KiB
Vue
230 lines
7.0 KiB
Vue
<!-- eslint-disable vue/no-v-model-argument -->
|
|
<template>
|
|
<el-dialog
|
|
v-model="innerVisible"
|
|
:title="dialogTitle"
|
|
width="100%"
|
|
align-center
|
|
destroy-on-close
|
|
append-to-body
|
|
class="dialog-form-layout pl-plan-view-dialog"
|
|
modal-class="order-module-dialog-mask"
|
|
style="backdrop-filter: none"
|
|
@closed="handleClosed"
|
|
@opened="handleOpened"
|
|
>
|
|
<div v-if="$slots['hero-actions'] || showArrangeActions" class="pl-plan-view-hero-actions">
|
|
<template v-if="showArrangeActions">
|
|
<el-button @click="copyPlanSummary()">
|
|
<el-icon><CopyDocument /></el-icon>复制给司机
|
|
</el-button>
|
|
<el-button v-if="hasSiteInventoryRecords" @click="copySiteSummary()">
|
|
<el-icon><CopyDocument /></el-icon>复制给现场
|
|
</el-button>
|
|
<el-button v-if="hasDibangInventoryRecords" @click="copyPoundSlipQrcode()">
|
|
<el-icon><CopyDocument /></el-icon>复制磅单二维码
|
|
</el-button>
|
|
</template>
|
|
<slot name="hero-actions" />
|
|
</div>
|
|
|
|
<PlPlanViewTabs
|
|
v-if="planId && detailReady"
|
|
ref="tabsRef"
|
|
:plan-id="planId"
|
|
:initial-plan="bootstrappedPlan"
|
|
:prefetched-arrange="prefetchedArrange"
|
|
:show-arrange-links="showArrangeActions"
|
|
:arrange-driver-url="driverUrl"
|
|
:arrange-site-records="siteRecords"
|
|
:arrange-inventory-records="inventoryRecords"
|
|
:show-archive-io-fields="showArchiveIoFields"
|
|
:show-archive-price-fields="showArchivePriceFields"
|
|
:show-inbound-outbound-qty="showInboundOutboundQty"
|
|
/>
|
|
|
|
<DbPoundSlipQrcodeDialog
|
|
v-model:visible="qrcodeVisible"
|
|
:inventory-id="selectedInventoryId"
|
|
:quantity-unit="selectedInventoryUnit"
|
|
ref="qrcodeDialogRef"
|
|
/>
|
|
|
|
<PlPlanPoundQrcodePickDialog
|
|
v-model:visible="poundQrcodePickVisible"
|
|
:records="poundQrcodePickRecords"
|
|
:plan="arrangeActionPlan"
|
|
@copy="handlePoundQrcodePickCopy"
|
|
@preview="handlePoundQrcodePickPreview"
|
|
/>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { CopyDocument } from '@element-plus/icons-vue'
|
|
import { planApi, type Plan } from '@/api/pl'
|
|
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
|
import PlPlanPoundQrcodePickDialog from '@/components/business/pl-plan-pound-qrcode-pick-dialog/index.vue'
|
|
import PlPlanViewTabs from '@/components/business/pl-plan-view-tabs/index.vue'
|
|
import { usePlPlanArrangeActions } from '@/composables/usePlPlanArrangeActions'
|
|
import { pickBxData } from '@/utils/http/bx'
|
|
|
|
const props = defineProps<{
|
|
visible: boolean
|
|
planId?: string
|
|
/** 列表行已有数据时传入,可跳过重复 plan.get(仍会在缺字段时回源) */
|
|
seedPlan?: Plan | null
|
|
/** 仅运输计划归档:展示入库/出库数量(及默认跟随的价格) */
|
|
showArchiveIoFields?: boolean
|
|
/** 归档查看:展示单价与金额;未传时跟随 showArchiveIoFields */
|
|
showArchivePriceFields?: boolean
|
|
/** 计划概况产品表:展示入库/出库数量(不含单价与金额) */
|
|
showInboundOutboundQty?: boolean
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
'update:visible': [value: boolean]
|
|
}>()
|
|
|
|
const innerVisible = computed({
|
|
get: () => props.visible,
|
|
set: (value) => emit('update:visible', value)
|
|
})
|
|
|
|
const tabsRef = ref<InstanceType<typeof PlPlanViewTabs> | null>(null)
|
|
const planNo = ref('')
|
|
const detailReady = ref(false)
|
|
const bootstrappedPlan = ref<Plan | null>(null)
|
|
const prefetchedArrange = ref<{
|
|
siteRecords: typeof siteRecords.value
|
|
inventoryRecords: typeof inventoryRecords.value
|
|
} | null>(null)
|
|
|
|
const {
|
|
plan: arrangeActionPlan,
|
|
showArrangeActions,
|
|
hasSiteInventoryRecords,
|
|
hasDibangInventoryRecords,
|
|
driverUrl,
|
|
siteRecords,
|
|
inventoryRecords,
|
|
qrcodeVisible,
|
|
selectedInventoryId,
|
|
selectedInventoryUnit,
|
|
qrcodeDialogRef,
|
|
poundQrcodePickVisible,
|
|
poundQrcodePickRecords,
|
|
resetArrangeActions,
|
|
loadArrangeActions,
|
|
copySiteSummary,
|
|
copyPlanSummary,
|
|
copyPoundSlipQrcode,
|
|
handlePoundQrcodePickCopy,
|
|
handlePoundQrcodePickPreview
|
|
} = usePlPlanArrangeActions()
|
|
|
|
const dialogTitle = computed(() =>
|
|
planNo.value ? `查看运输计划 · ${planNo.value}` : '查看运输计划'
|
|
)
|
|
|
|
async function bootstrapDetail() {
|
|
if (!props.planId) return
|
|
detailReady.value = false
|
|
prefetchedArrange.value = null
|
|
bootstrappedPlan.value = null
|
|
|
|
// 打开详情始终回源,避免列表 seed 数量/装卸段滞后于库内已修正数据
|
|
let data: Plan | null = null
|
|
try {
|
|
const res = await planApi.get(props.planId)
|
|
data = pickBxData<Plan>(res) || ((res as { data?: Plan }).data ?? null)
|
|
} catch {
|
|
data = props.seedPlan?.id === props.planId ? (props.seedPlan as Plan) : null
|
|
}
|
|
if (!data) {
|
|
throw new Error('运输计划数据无效')
|
|
}
|
|
|
|
bootstrappedPlan.value = data
|
|
planNo.value = data.planNo || ''
|
|
await loadArrangeActions(props.planId, data)
|
|
prefetchedArrange.value = {
|
|
siteRecords: [...siteRecords.value],
|
|
inventoryRecords: [...inventoryRecords.value]
|
|
}
|
|
detailReady.value = true
|
|
}
|
|
|
|
async function handleOpened() {
|
|
if (!props.planId) return
|
|
try {
|
|
await bootstrapDetail()
|
|
} catch {
|
|
innerVisible.value = false
|
|
ElMessage.error('加载运输计划详情失败')
|
|
}
|
|
}
|
|
|
|
function handleClosed() {
|
|
planNo.value = ''
|
|
detailReady.value = false
|
|
bootstrappedPlan.value = null
|
|
prefetchedArrange.value = null
|
|
resetArrangeActions()
|
|
}
|
|
|
|
async function reload() {
|
|
if (!props.visible || !props.planId) return
|
|
try {
|
|
// 强制回源,避免沿用可能过期的列表 seed
|
|
const res = await planApi.get(props.planId)
|
|
const data = pickBxData<Plan>(res) || ((res as { data?: Plan }).data ?? null)
|
|
if (!data) return
|
|
detailReady.value = false
|
|
bootstrappedPlan.value = data
|
|
planNo.value = data.planNo || ''
|
|
await loadArrangeActions(props.planId, data)
|
|
prefetchedArrange.value = {
|
|
siteRecords: [...siteRecords.value],
|
|
inventoryRecords: [...inventoryRecords.value]
|
|
}
|
|
detailReady.value = true
|
|
} catch {
|
|
/* 查看弹窗仍打开时静默失败,避免打断用户 */
|
|
}
|
|
}
|
|
|
|
defineExpose({ reload })
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.pl-plan-view-footer {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.pl-plan-view-hero-actions {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
justify-content: flex-end;
|
|
gap: 8px;
|
|
margin-bottom: 12px;
|
|
}
|
|
</style>
|
|
|
|
<style lang="scss">
|
|
.el-dialog.pl-plan-view-dialog.dialog-form-layout {
|
|
width: min(2000px, calc(100vw - 48px)) !important;
|
|
max-width: min(2000px, calc(100vw - 48px));
|
|
height: var(--dialog-max-height, calc(100vh - 40px));
|
|
max-height: var(--dialog-max-height, calc(100vh - 40px));
|
|
}
|
|
|
|
.el-dialog.pl-plan-view-dialog.dialog-form-layout .el-dialog__body {
|
|
overflow: auto;
|
|
}
|
|
</style>
|