Mirror pending_arrange behavior so the arranged tab forces followStatus filter to arranged. Co-authored-by: Cursor <cursoragent@cursor.com>
1742 lines
58 KiB
Vue
1742 lines
58 KiB
Vue
<!-- 运输计划管理 -->
|
||
<template>
|
||
<div class="page-container">
|
||
<section class="panel">
|
||
<PlPlanTypeTabs
|
||
:model-value="activePlanTypeTab"
|
||
:tabs="PL_PLAN_LIST_TABS"
|
||
@change="handlePlanTypeTabChange"
|
||
/>
|
||
|
||
<!-- 筛选区 -->
|
||
<div class="filter-block">
|
||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||
<div class="filter-grid">
|
||
<el-form-item label="计划编号">
|
||
<el-input
|
||
v-model="searchForm.planNo"
|
||
placeholder="搜索计划编号"
|
||
clearable
|
||
@keyup.enter="handleSearch"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="跟进状态">
|
||
<el-select
|
||
v-model="searchForm.followStatus"
|
||
placeholder="全部"
|
||
clearable
|
||
multiple
|
||
>
|
||
<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>
|
||
<el-form-item label="需方">
|
||
<el-input
|
||
v-model="searchForm.customerName"
|
||
placeholder="搜索需方客户名称"
|
||
clearable
|
||
@keyup.enter="handleSearch"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="产品名称">
|
||
<el-input
|
||
v-model="searchForm.productName"
|
||
placeholder="搜索产品名称"
|
||
clearable
|
||
@keyup.enter="handleSearch"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="车牌号">
|
||
<el-input
|
||
v-model="searchForm.licensePlate"
|
||
placeholder="搜索车牌号"
|
||
clearable
|
||
@keyup.enter="handleSearch"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="计划日期">
|
||
<el-date-picker
|
||
v-model="dateRange"
|
||
type="daterange"
|
||
range-separator="-"
|
||
start-placeholder="开始日期"
|
||
end-placeholder="结束日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="filter-actions">
|
||
<div class="filter-actions-start" />
|
||
<div class="filter-actions-end">
|
||
<el-button class="btn-ghost" :loading="loading" @click="handleReset">
|
||
<el-icon><RefreshLeft /></el-icon>重置
|
||
</el-button>
|
||
<el-button class="btn-main" type="primary" :loading="loading" @click="handleSearch">
|
||
<el-icon><Search /></el-icon>搜索
|
||
</el-button>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
|
||
<!-- 工具栏(单行:日期下拉 + 检索 + 操作 + 刷新/列设置) -->
|
||
<div class="list-toolbar">
|
||
<div class="list-toolbar-row pl-plan-list-toolbar-row">
|
||
<ListToolbarDateShortcuts
|
||
variant="pills"
|
||
:active="activeDateShortcut"
|
||
aria-label="计划日期快捷筛选"
|
||
@change="handleDateShortcut"
|
||
/>
|
||
<ListQuickSearchInput
|
||
v-model="quickSearch"
|
||
placeholder="计划编号/供方/需方/产品名称/车牌号"
|
||
@search="handleQuickSearch"
|
||
@clear="handleQuickSearchClear"
|
||
/>
|
||
<el-button class="btn-main" type="primary" @click="handleAdd">
|
||
<el-icon><Plus /></el-icon>新增计划
|
||
</el-button>
|
||
<el-button class="btn-ghost" :disabled="!selectedPlan" @click="handleToolbarCopy">
|
||
<el-icon><CopyDocument /></el-icon>复制
|
||
</el-button>
|
||
<el-button
|
||
class="btn-ghost"
|
||
:disabled="!selectedPlan || !canArrangeTransport(selectedPlan)"
|
||
@click="handleToolbarArrange"
|
||
>
|
||
<el-icon><Van /></el-icon>
|
||
{{ selectedPlan ? arrangeTransportLabel(selectedPlan) : '安排运输' }}
|
||
</el-button>
|
||
<el-button
|
||
class="btn-ghost"
|
||
:disabled="!selectedPlan || !canWaitNotice(selectedPlan)"
|
||
:loading="waitNoticeLoading"
|
||
@click="handleToolbarWaitNotice"
|
||
>
|
||
<el-icon><Bell /></el-icon>等客户通知
|
||
</el-button>
|
||
<el-dropdown trigger="click" @command="handleToolbarPrintSlip">
|
||
<el-button class="btn-ghost">
|
||
<el-icon><Printer /></el-icon>打印单据
|
||
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
||
</el-button>
|
||
<template #dropdown>
|
||
<el-dropdown-menu>
|
||
<el-dropdown-item
|
||
command="inbound"
|
||
:disabled="!canBatchPrintSlip(selectedRows, 'inbound').ok"
|
||
>
|
||
入库单
|
||
</el-dropdown-item>
|
||
<el-dropdown-item
|
||
command="delivery"
|
||
:disabled="!canBatchPrintSlip(selectedRows, 'delivery').ok"
|
||
>
|
||
送(提)货单
|
||
</el-dropdown-item>
|
||
<el-dropdown-item
|
||
command="subpack"
|
||
:disabled="!canBatchPrintSlip(selectedRows, 'subpack').ok"
|
||
>
|
||
分装单
|
||
</el-dropdown-item>
|
||
<el-dropdown-item divided command="blank-inbound">空白入库单</el-dropdown-item>
|
||
<el-dropdown-item command="blank-delivery">空白送(提)货单</el-dropdown-item>
|
||
<el-dropdown-item command="blank-subpack">空白分装单</el-dropdown-item>
|
||
</el-dropdown-menu>
|
||
</template>
|
||
</el-dropdown>
|
||
<el-button
|
||
class="btn-ghost"
|
||
type="danger"
|
||
:disabled="!selectedPlan || !canVoidPlan(selectedPlan)"
|
||
:loading="voidLoading"
|
||
@click="handleToolbarVoid"
|
||
>
|
||
<el-icon><CircleClose /></el-icon>作废
|
||
</el-button>
|
||
<el-button type="danger" class="pl-plan-paste-create-btn" @click="pasteVisible = true">
|
||
<el-icon><DocumentCopy /></el-icon>三方人车快速创建
|
||
</el-button>
|
||
<ListExportDropdown
|
||
:export-fn="planApi.export"
|
||
:get-filter-params="getPlanExportFilterParams"
|
||
:has-selection="true"
|
||
:selected-ids="selectedRows.map((r) => r.id)"
|
||
:visible-columns="planExportColumns"
|
||
filename="计划列表.xlsx"
|
||
/>
|
||
|
||
<ListToolbarEndActions
|
||
:loading="loading"
|
||
:column-defs="listColumnDefs"
|
||
v-model:visible-columns="visibleColumns"
|
||
v-model:check-all="checkAll"
|
||
:is-indeterminate="isIndeterminate"
|
||
@refresh="fetchData"
|
||
@reset-columns="resetToDefault"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 数据表格 -->
|
||
<div class="list-body list-wrap">
|
||
<div ref="planTableWrapRef" class="table-scroll bx-list-table-wrap">
|
||
<ListTable
|
||
ref="planTableRef"
|
||
table-key="pl-plan"
|
||
:height="tableHeight"
|
||
class="list-table pl-plan-merge-list-table"
|
||
:data="displayRows"
|
||
v-loading="loading"
|
||
row-key="rowKey"
|
||
:span-method="planListSpanMethod"
|
||
:row-class-name="getPlPlanListRowClassName"
|
||
@selection-change="handleDisplaySelectionChange"
|
||
@row-dblclick="handleDisplayRowDblClick"
|
||
@header-dragend="() => planStatsRowRef?.resync?.()"
|
||
>
|
||
<el-table-column
|
||
type="selection"
|
||
width="55"
|
||
align="center"
|
||
header-align="center"
|
||
:selectable="isPlanFirstRowSelectable"
|
||
/>
|
||
<el-table-column
|
||
type="index"
|
||
label="序号"
|
||
width="68"
|
||
align="center"
|
||
header-align="center"
|
||
:index="getDisplayRowIndex"
|
||
/>
|
||
<el-table-column prop="planNo" label="计划编号" min-width="180" show-overflow-tooltip>
|
||
<template #default="{ row }">
|
||
<el-link type="primary" @click="handleView(row.plan)">{{
|
||
row.plan.planNo
|
||
}}</el-link>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('followStatus')"
|
||
prop="followStatus"
|
||
label="跟进状态"
|
||
min-width="100"
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-tag :type="getPlPlanFollowStatusTagType(row.plan.followStatus)" size="small">
|
||
{{ getPlPlanFollowStatusLabel(row.plan.followStatus) }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('planDate')"
|
||
prop="planDate"
|
||
label="计划日期"
|
||
min-width="120"
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">{{ row.plan.planDate || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('planType')"
|
||
prop="planType"
|
||
label="单据类型"
|
||
min-width="100"
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{ getPlanTypeLabel(row.plan.planType) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('licensePlate')"
|
||
prop="licensePlate"
|
||
label="车牌号"
|
||
min-width="160"
|
||
show-overflow-tooltip
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{ formatPlVehiclePlateDisplay(row.plan.licensePlate, row.plan.trailerNo) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('personnelSummary')"
|
||
prop="personnelSummary"
|
||
label="人员"
|
||
min-width="180"
|
||
show-overflow-tooltip
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
{{ normalizePlPersonnelSummaryDisplay(row.plan.personnelSummary) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('followUserName')"
|
||
prop="followUserName"
|
||
label="跟进人"
|
||
min-width="100"
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">{{ row.plan.followUserName || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('arrangeCopy')"
|
||
label="链接复制"
|
||
min-width="88"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<div v-if="row.plan.canCopyPoundQrcode" class="pl-plan-arrange-copy-cell">
|
||
<el-button
|
||
class="btn-ghost"
|
||
title="复制磅单二维码"
|
||
:loading="
|
||
arrangeCopyLoadingId === row.plan.id && arrangeCopyLoadingAction === 'qrcode'
|
||
"
|
||
@click.stop="handleListCopyPoundQrcode(row.plan)"
|
||
>
|
||
磅单码
|
||
</el-button>
|
||
</div>
|
||
<span v-else>—</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('stopKind')"
|
||
prop="stopKind"
|
||
label="段次"
|
||
min-width="88"
|
||
align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<span class="pl-plan-stop-kind-text">{{ getStopKindLabel(row) }}</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('stopCustomer')"
|
||
prop="stopCustomer"
|
||
label="客户"
|
||
min-width="200"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<span>{{ getStopCustomerName(row) }}</span>
|
||
<el-tag
|
||
v-if="isPlInternalCustomerName(getStopCustomerName(row))"
|
||
type="success"
|
||
size="small"
|
||
class="pl-plan-internal-customer-tag"
|
||
>
|
||
内部
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('stopAddressTime')"
|
||
prop="stopAddressTime"
|
||
label="地址 / 时间"
|
||
min-width="220"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
>
|
||
<template #default="{ row }">
|
||
<div class="pl-plan-stop-address-time">
|
||
<div class="pl-plan-stop-address-time__addr">{{ getStopAddress(row) }}</div>
|
||
<div class="pl-plan-stop-address-time__time">{{ getStopTime(row) }}</div>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productName')"
|
||
label="产品名称"
|
||
min-width="160"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="name"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productSpec')"
|
||
label="型号/规格"
|
||
min-width="96"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="spec"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productPackageSpec')"
|
||
label="包装规格"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="packageSpec"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productUnit')"
|
||
label="单位"
|
||
min-width="64"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="unit"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productPlanQty')"
|
||
label="计划数量"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="planQty"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productActualQty')"
|
||
label="实际数量"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-kind="row.kind"
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="actualQty"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('planAttachments')"
|
||
label="计划附件"
|
||
min-width="200"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListCertCell
|
||
:products="resolveStopCertProducts(row.plan, getStopProducts(row))"
|
||
compact
|
||
hide-product
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('stopContract')"
|
||
label="合同"
|
||
min-width="180"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanContractCell
|
||
:lines="getStopContractLines(row)"
|
||
@open="openContractDetail"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productInboundQty')"
|
||
label="入库数量"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="inboundQty"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productOutboundQty')"
|
||
label="出库数量"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="outboundQty"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('stopDibang')"
|
||
prop="stopDibang"
|
||
label="地磅"
|
||
min-width="72"
|
||
align="center"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-tag
|
||
v-if="formatStopDibangLabel(row.stop)"
|
||
:type="getStopDibangTagType(row.stop)"
|
||
size="small"
|
||
>
|
||
{{ formatStopDibangLabel(row.stop) }}
|
||
</el-tag>
|
||
<span v-else>—</span>
|
||
</template>
|
||
</el-table-column>
|
||
</ListTable>
|
||
</div>
|
||
<div ref="planBelowRef">
|
||
<ListColumnStatsRow
|
||
ref="planStatsRowRef"
|
||
storage-key="pl-plan-column-stats-v2"
|
||
:columns="planStatsRowColumns"
|
||
:data="displayRows"
|
||
:table-wrap-el="planTableWrapRef"
|
||
:get-cell-value="getDisplayStatCellValue"
|
||
/>
|
||
|
||
<div class="pagination list-pager-bar pl-plan-list-pager-bar">
|
||
<div class="list-pager-selected">
|
||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||
</div>
|
||
<el-pagination
|
||
v-model:current-page="pagination.page"
|
||
v-model:page-size="pagination.pageSize"
|
||
:total="pagination.total"
|
||
:page-sizes="[10, 20, 100, 500]"
|
||
layout="total, sizes, prev, pager, next"
|
||
@size-change="handleSizeChange"
|
||
@current-change="handlePageChange"
|
||
/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<PlPlanFormDialog
|
||
v-model:visible="formDialogVisible"
|
||
:plan-id="editingPlanId"
|
||
:copy-from-plan-id="copyFromPlanId"
|
||
:open-for-arrange="formOpenForArrange"
|
||
@success="handlePlanMutationSuccess"
|
||
/>
|
||
|
||
<PlPlanViewDialog
|
||
ref="viewDialogRef"
|
||
v-model:visible="viewVisible"
|
||
:plan-id="viewPlanId"
|
||
show-inbound-outbound-qty
|
||
>
|
||
<template v-if="viewingPlan" #hero-actions>
|
||
<el-button
|
||
v-if="canEditPlan(viewingPlan)"
|
||
class="btn-main"
|
||
type="primary"
|
||
@click="handleEdit(viewingPlan)"
|
||
>
|
||
<el-icon><Edit /></el-icon>编辑
|
||
</el-button>
|
||
<el-button class="btn-ghost" @click="handleCopy(viewingPlan)">
|
||
<el-icon><CopyDocument /></el-icon>复制
|
||
</el-button>
|
||
<el-button
|
||
v-if="canArrangeTransport(viewingPlan)"
|
||
class="btn-ghost"
|
||
@click="handleArrange(viewingPlan)"
|
||
>
|
||
<el-icon><Van /></el-icon>{{ arrangeTransportLabel(viewingPlan) }}
|
||
</el-button>
|
||
<el-button
|
||
v-if="canWaitNotice(viewingPlan)"
|
||
class="btn-ghost"
|
||
:loading="waitNoticeLoading"
|
||
@click="handleWaitNotice(viewingPlan)"
|
||
>
|
||
<el-icon><Bell /></el-icon>等客户通知
|
||
</el-button>
|
||
<el-button
|
||
v-if="canCancelWaitNotice(viewingPlan)"
|
||
class="btn-ghost"
|
||
:loading="waitNoticeLoading"
|
||
@click="handleCancelWaitNotice(viewingPlan)"
|
||
>
|
||
<el-icon><RefreshLeft /></el-icon>取消等通知
|
||
</el-button>
|
||
<el-dropdown trigger="click" @command="handleViewPrintSlipCommand">
|
||
<el-button class="btn-ghost">
|
||
<el-icon><Printer /></el-icon>打印单据
|
||
<el-icon class="el-icon--right"><ArrowDown /></el-icon>
|
||
</el-button>
|
||
<template #dropdown>
|
||
<el-dropdown-menu>
|
||
<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>
|
||
<el-button
|
||
v-if="canForceFollowStatus"
|
||
class="btn-ghost"
|
||
@click="openForceFollowStatusDialog"
|
||
>
|
||
<el-icon><EditPen /></el-icon>强制改状态
|
||
</el-button>
|
||
<el-button
|
||
v-if="canVoidPlan(viewingPlan)"
|
||
class="btn-ghost"
|
||
type="danger"
|
||
:loading="voidLoading"
|
||
@click="handleVoid(viewingPlan)"
|
||
>
|
||
<el-icon><CircleClose /></el-icon>作废
|
||
</el-button>
|
||
</template>
|
||
</PlPlanViewDialog>
|
||
|
||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||
|
||
<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"
|
||
/>
|
||
|
||
<PlInboundSlipPrintDialog ref="inboundSlipPrintRef" />
|
||
<PlDeliverySlipPrintDialog ref="deliverySlipPrintRef" />
|
||
<PlSubpackSlipPrintDialog ref="subpackSlipPrintRef" />
|
||
<PlPlanDeliveryCustomerSelectDialog ref="deliveryCustomerSelectRef" />
|
||
|
||
<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>{{ viewingPlan?.planNo || '—' }}</span>
|
||
</el-form-item>
|
||
<el-form-item label="单据类型" style="margin-bottom: 0">
|
||
<span>{{ getPlanTypeLabel(viewingPlan?.planType) }}</span>
|
||
</el-form-item>
|
||
<el-form-item label="供方" style="margin-bottom: 0">
|
||
<span>{{ viewingPlan?.supplierName || '—' }}</span>
|
||
</el-form-item>
|
||
<el-form-item label="需方" style="margin-bottom: 0">
|
||
<span>{{ viewingPlan?.customerName || '—' }}</span>
|
||
</el-form-item>
|
||
<el-form-item label="产品信息" class="form-col-span-2" style="margin-bottom: 0">
|
||
<PlPlanListProductCell :products="viewingPlan?.products || []" />
|
||
</el-form-item>
|
||
<el-form-item label="当前跟进状态" style="margin-bottom: 0">
|
||
<el-tag
|
||
v-if="viewingPlan"
|
||
:type="getPlPlanFollowStatusTagType(viewingPlan.followStatus)"
|
||
size="small"
|
||
>
|
||
{{ getPlPlanFollowStatusLabel(viewingPlan.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>
|
||
|
||
<script setup lang="ts">
|
||
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 DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||
import PlInboundSlipPrintDialog from '@/components/business/pl-inbound-slip-print-dialog/index.vue'
|
||
import PlDeliverySlipPrintDialog from '@/components/business/pl-delivery-slip-print-dialog/index.vue'
|
||
import PlSubpackSlipPrintDialog from '@/components/business/pl-subpack-slip-print-dialog/index.vue'
|
||
import PlPlanDeliveryCustomerSelectDialog from '@/components/business/pl-plan-delivery-customer-select-dialog/index.vue'
|
||
import PlPlanContractCell from '@/components/business/pl-plan-contract-cell/index.vue'
|
||
import PlPasteRecognizeDialog from '@/components/business/pl-paste-recognize-dialog/index.vue'
|
||
import PlPlanFormDialog from '@/components/business/pl-plan-form-dialog/index.vue'
|
||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||
import ListColumnStatsRow from '@/components/business/list-column-stats-row/index.vue'
|
||
import type { StatsRowColumn } from '@/utils/list-column-stats'
|
||
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
|
||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||
import { usePlPlanArrangeActions } from '@/composables/usePlPlanArrangeActions'
|
||
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 PlPlanPoundQrcodePickDialog from '@/components/business/pl-plan-pound-qrcode-pick-dialog/index.vue'
|
||
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
|
||
import PlPlanTypeTabs from '@/components/business/pl-plan-type-tabs/index.vue'
|
||
import ListToolbarDateShortcuts from '@/components/core/list-toolbar-date-shortcuts/index.vue'
|
||
import { useDbInstantSearch } from '@/composables/useDbInstantSearch'
|
||
import { useListDateShortcut } from '@/composables/useListDateShortcut'
|
||
import { canBatchPrintSlip } from '@/utils/pl-batch-print'
|
||
import { listDeliveryPrintCustomers } from '@/utils/pl-delivery-slip-print'
|
||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||
import {
|
||
buildPlPlanListSpanMethod,
|
||
flattenPlanListRows,
|
||
formatStopDibangLabel,
|
||
getPlanListDisplayIndex,
|
||
getPlPlanListRowClassName,
|
||
getStopAddress,
|
||
getStopContractLines,
|
||
getStopCustomerName,
|
||
getStopDibangTagType,
|
||
getStopKindLabel,
|
||
getStopProducts,
|
||
getStopTime,
|
||
resolveStopCertProducts,
|
||
sumStopArchiveActualQty,
|
||
sumStopProductsField,
|
||
type PlPlanListDisplayRow
|
||
} from '@/utils/pl-plan-list-display-rows'
|
||
import {
|
||
formatPlVehiclePlateDisplay,
|
||
getPlPlanFollowStatusLabel,
|
||
getPlPlanFollowStatusTagType,
|
||
normalizePlPersonnelSummaryDisplay,
|
||
PL_PLAN_DEFAULT_FOLLOW_STATUSES,
|
||
PL_PLAN_FOLLOW_STATUS_OPTIONS,
|
||
PL_PLAN_LIST_TABS,
|
||
isPlPlanFollowStatusListTab,
|
||
plPlanListTabToFilters,
|
||
type PlPlanListTab,
|
||
type PlPrintSlipCommand
|
||
} from '@/utils/pl-display'
|
||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||
|
||
/** 计划区可合并列(顺序须与表格左侧列一致,不含勾选/序号/计划编号) */
|
||
const PLAN_MERGE_COLUMN_PROPS = [
|
||
'followStatus',
|
||
'planDate',
|
||
'planType',
|
||
'licensePlate',
|
||
'personnelSummary',
|
||
'followUserName',
|
||
'arrangeCopy'
|
||
] as const
|
||
const route = useRoute()
|
||
const router = useRouter()
|
||
const { ContractDetailDialog, contractDetailRef, openContractDetail } = useContractDetailDialog()
|
||
|
||
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 formOpenForArrange = ref(false)
|
||
const pasteVisible = ref(false)
|
||
const editingPlanId = ref('')
|
||
const copyFromPlanId = ref('')
|
||
const viewVisible = ref(false)
|
||
const viewPlanId = ref('')
|
||
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
|
||
const inboundSlipPrintRef = ref<InstanceType<typeof PlInboundSlipPrintDialog>>()
|
||
const deliverySlipPrintRef = ref<InstanceType<typeof PlDeliverySlipPrintDialog>>()
|
||
const subpackSlipPrintRef = ref<InstanceType<typeof PlSubpackSlipPrintDialog>>()
|
||
const deliveryCustomerSelectRef = ref<InstanceType<typeof PlPlanDeliveryCustomerSelectDialog>>()
|
||
const planList = ref<Plan[]>([])
|
||
|
||
const listColumnDefs = [
|
||
{ prop: 'followStatus', label: '跟进状态' },
|
||
{ prop: 'planDate', label: '计划日期' },
|
||
{ prop: 'planType', label: '单据类型' },
|
||
{ prop: 'licensePlate', label: '车牌号' },
|
||
{ prop: 'personnelSummary', label: '人员' },
|
||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false },
|
||
{ prop: 'arrangeCopy', label: '链接复制' },
|
||
{ prop: 'stopKind', label: '段次' },
|
||
{ prop: 'stopCustomer', label: '客户' },
|
||
{ prop: 'stopAddressTime', label: '地址 / 时间' },
|
||
{ prop: 'productName', label: '产品名称' },
|
||
{ prop: 'productSpec', label: '型号/规格' },
|
||
{ prop: 'productPackageSpec', label: '包装规格' },
|
||
{ prop: 'productUnit', label: '单位' },
|
||
{ prop: 'productPlanQty', label: '计划数量' },
|
||
{ prop: 'productActualQty', label: '实际数量' },
|
||
{ prop: 'planAttachments', label: '计划附件' },
|
||
{ prop: 'stopContract', label: '合同' },
|
||
{ prop: 'productInboundQty', label: '入库数量', defaultVisible: false },
|
||
{ prop: 'productOutboundQty', label: '出库数量', defaultVisible: false },
|
||
{ prop: 'stopDibang', label: '地磅' }
|
||
]
|
||
|
||
const { visibleColumns, checkAll, isIndeterminate, isColumnVisible, resetToDefault } =
|
||
usePersistedListColumns('pl-plan-list-columns-v5', listColumnDefs)
|
||
|
||
const displayRows = computed(() => flattenPlanListRows(planList.value))
|
||
|
||
const visiblePlanMergeProps = computed(() =>
|
||
PLAN_MERGE_COLUMN_PROPS.filter((prop) => isColumnVisible(prop))
|
||
)
|
||
|
||
const planListSpanMethod = computed(() =>
|
||
buildPlPlanListSpanMethod([...visiblePlanMergeProps.value])
|
||
)
|
||
|
||
const planTableWrapRef = ref<HTMLElement | null>(null)
|
||
const planBelowRef = ref<HTMLElement | null>(null)
|
||
const planTableRef = ref<any>(null)
|
||
const { tableHeight, recalc: recalcTableHeight } = useListTableViewportHeight({
|
||
tableEl: planTableWrapRef,
|
||
pagerEl: planBelowRef,
|
||
tableRef: planTableRef
|
||
|
||
|
||
})
|
||
const planStatsRowRef = ref<{ resync?: () => void } | null>(null)
|
||
|
||
const {
|
||
plan: arrangeActionPlan,
|
||
qrcodeVisible,
|
||
selectedInventoryId,
|
||
selectedInventoryUnit,
|
||
qrcodeDialogRef,
|
||
poundQrcodePickVisible,
|
||
poundQrcodePickRecords,
|
||
loadArrangeActions,
|
||
copyPoundSlipQrcode,
|
||
handlePoundQrcodePickCopy,
|
||
handlePoundQrcodePickPreview
|
||
} = usePlPlanArrangeActions()
|
||
|
||
const arrangeCopyLoadingId = ref('')
|
||
const arrangeCopyLoadingAction = ref<'qrcode' | ''>('')
|
||
|
||
async function handleListCopyPoundQrcode(row: Plan) {
|
||
if (!row.id || arrangeCopyLoadingId.value) return
|
||
arrangeCopyLoadingId.value = row.id
|
||
arrangeCopyLoadingAction.value = 'qrcode'
|
||
try {
|
||
await loadArrangeActions(row.id)
|
||
await copyPoundSlipQrcode()
|
||
} catch {
|
||
ElMessage.error('复制失败,请稍后重试')
|
||
} finally {
|
||
arrangeCopyLoadingId.value = ''
|
||
arrangeCopyLoadingAction.value = ''
|
||
}
|
||
}
|
||
|
||
const selectedRows = ref<Plan[]>([])
|
||
|
||
const planStatsRowColumns = computed((): StatsRowColumn[] => {
|
||
const cols: StatsRowColumn[] = [
|
||
{ key: '__selection', interactive: false },
|
||
{ key: '__index', interactive: false },
|
||
{ key: 'planNo', interactive: true, prop: 'planNo' }
|
||
]
|
||
for (const def of listColumnDefs) {
|
||
if (!isColumnVisible(def.prop)) continue
|
||
cols.push({
|
||
key: def.prop,
|
||
interactive: def.prop !== 'arrangeCopy' && def.prop !== 'stopKind',
|
||
prop: def.prop
|
||
})
|
||
}
|
||
return cols
|
||
})
|
||
|
||
function getDisplayStatCellValue(row: PlPlanListDisplayRow, prop: string): unknown {
|
||
const plan = row.plan
|
||
const stopProducts = getStopProducts(row)
|
||
if (prop === 'planNo') return plan.planNo
|
||
if (prop === 'followStatus') return getPlPlanFollowStatusLabel(plan.followStatus)
|
||
if (prop === 'planType') return getPlanTypeLabel(plan.planType)
|
||
if (prop === 'planDate') return plan.planDate
|
||
if (prop === 'licensePlate') {
|
||
return formatPlVehiclePlateDisplay(plan.licensePlate, plan.trailerNo)
|
||
}
|
||
if (prop === 'personnelSummary') {
|
||
return normalizePlPersonnelSummaryDisplay(plan.personnelSummary)
|
||
}
|
||
if (prop === 'followUserName') return plan.followUserName
|
||
if (prop === 'stopKind') return getStopKindLabel(row)
|
||
if (prop === 'stopCustomer') return getStopCustomerName(row)
|
||
if (prop === 'stopAddressTime') {
|
||
return `${getStopAddress(row)} ${getStopTime(row)}`.trim()
|
||
}
|
||
if (prop === 'stopDibang') return formatStopDibangLabel(row.stop)
|
||
if (prop === 'stopContract') {
|
||
return getStopContractLines(row)
|
||
.map((l) => `${l.side}${l.no}`)
|
||
.join(' ')
|
||
}
|
||
if (prop === 'productPlanQty') return sumStopProductsField(stopProducts, 'planQty')
|
||
if (prop === 'productInboundQty') return sumStopProductsField(stopProducts, 'inboundQty')
|
||
if (prop === 'productOutboundQty') return sumStopProductsField(stopProducts, 'outboundQty')
|
||
if (prop === 'productActualQty') return sumStopArchiveActualQty(stopProducts, row.kind)
|
||
if (prop === 'productName') {
|
||
return stopProducts
|
||
.map((p) => p.productName || '')
|
||
.filter(Boolean)
|
||
.join('\n')
|
||
}
|
||
if (prop === 'productSpec') {
|
||
return stopProducts
|
||
.map((p) => p.model || p.packageSpec || '')
|
||
.filter(Boolean)
|
||
.join('\n')
|
||
}
|
||
if (prop === 'productPackageSpec') {
|
||
return stopProducts
|
||
.map((p) => p.packageSpec || '')
|
||
.filter(Boolean)
|
||
.join('\n')
|
||
}
|
||
if (prop === 'productUnit') {
|
||
return stopProducts
|
||
.map((p) => p.unit || '')
|
||
.filter(Boolean)
|
||
.join('\n')
|
||
}
|
||
if (prop === 'planAttachments' || prop === 'arrangeCopy') return ''
|
||
return ''
|
||
}
|
||
|
||
function getDisplayRowIndex(index: number) {
|
||
return getPlanListDisplayIndex(displayRows.value, index, pagination.page, pagination.pageSize)
|
||
}
|
||
|
||
function isPlanFirstRowSelectable(row: PlPlanListDisplayRow) {
|
||
return row.isPlanFirstRow
|
||
}
|
||
|
||
function handleDisplaySelectionChange(selection: PlPlanListDisplayRow[]) {
|
||
const seen = new Set<string>()
|
||
const plans: Plan[] = []
|
||
for (const item of selection || []) {
|
||
const plan = item?.plan
|
||
if (!plan?.id || seen.has(plan.id)) continue
|
||
seen.add(plan.id)
|
||
plans.push(plan)
|
||
}
|
||
selectedRows.value = plans
|
||
}
|
||
|
||
function handleDisplayRowDblClick(row: PlPlanListDisplayRow) {
|
||
if (row?.plan) handleView(row.plan)
|
||
}
|
||
|
||
function getPlanExportFilterParams() {
|
||
const keyword = quickSearch.value.trim()
|
||
const tabFilters = plPlanListTabToFilters(activePlanTypeTab.value)
|
||
return {
|
||
q: keyword || undefined,
|
||
planNo: keyword ? undefined : searchForm.planNo || undefined,
|
||
planType: tabFilters.planType || undefined,
|
||
followStatus: tabFilters.followStatus || formatFollowStatusParam(searchForm.followStatus),
|
||
customerName: keyword ? undefined : searchForm.customerName || undefined,
|
||
productName: keyword ? undefined : searchForm.productName || undefined,
|
||
licensePlate: keyword ? undefined : searchForm.licensePlate || undefined,
|
||
planDateFrom: dateRange.value?.[0] || undefined,
|
||
planDateTo: dateRange.value?.[1] || undefined
|
||
}
|
||
}
|
||
|
||
const planExportColumns = computed(() => {
|
||
const skip = new Set([
|
||
'arrangeCopy',
|
||
'stopKind',
|
||
'stopCustomer',
|
||
'stopAddressTime',
|
||
'stopDibang',
|
||
'stopContract'
|
||
])
|
||
const cols = [...visibleColumns.value].filter((col) => !skip.has(col))
|
||
if (!cols.includes('planNo')) cols.unshift('planNo')
|
||
return cols
|
||
})
|
||
|
||
const viewingPlan = ref<Plan | null>(null)
|
||
|
||
function syncViewingPlanFromList() {
|
||
syncViewRowFromFlatList(viewingPlan, planList.value)
|
||
}
|
||
|
||
async function refreshViewIfOpen() {
|
||
if (!viewVisible.value || !viewPlanId.value) return
|
||
syncViewingPlanFromList()
|
||
await viewDialogRef.value?.reload()
|
||
}
|
||
|
||
function getPlanArrangePrerequisiteGaps(plan: Plan): string[] {
|
||
const missing: string[] = []
|
||
if (!String(plan.createDate || '').trim()) missing.push('创建日期')
|
||
if (!String(plan.planDate || '').trim()) missing.push('计划日期')
|
||
if (!String(plan.belongsCompany || '').trim()) missing.push('归属公司')
|
||
if (!String(plan.planType || '').trim()) missing.push('单据类型')
|
||
if (!String(plan.followUserId || '').trim() && !String(plan.followUserName || '').trim()) {
|
||
missing.push('跟进人')
|
||
}
|
||
if (!String(plan.supplierId || '').trim() || !String(plan.supplierName || '').trim()) {
|
||
missing.push('供方客户')
|
||
}
|
||
if (!String(plan.customerId || '').trim() || !String(plan.customerName || '').trim()) {
|
||
missing.push('需方客户')
|
||
}
|
||
return missing
|
||
}
|
||
|
||
/** 安排运输前校验必填项;缺失则提示并打开编辑弹窗 */
|
||
async function ensurePlanReadyForArrange(plan: Plan): Promise<boolean> {
|
||
const missing = getPlanArrangePrerequisiteGaps(plan)
|
||
if (!missing.length) return true
|
||
|
||
try {
|
||
await ElMessageBox.alert(
|
||
`当前运输计划缺少:${missing.join('、')}。请先编辑完善后再安排运输。`,
|
||
'请先编辑运输计划',
|
||
{ type: 'warning', confirmButtonText: '去编辑' }
|
||
)
|
||
} catch {
|
||
// 关闭弹窗仍跳转编辑
|
||
}
|
||
|
||
if (viewVisible.value && viewingPlan.value?.id === plan.id) {
|
||
viewVisible.value = false
|
||
}
|
||
handleEdit(plan)
|
||
return false
|
||
}
|
||
|
||
async function handlePlanMutationSuccess(payload?: { planId?: string; arranged?: boolean }) {
|
||
formOpenForArrange.value = false
|
||
await fetchData()
|
||
await refreshViewIfOpen()
|
||
if (payload?.arranged && payload.planId) {
|
||
let plan = planList.value.find((item) => item.id === payload.planId)
|
||
if (!plan) {
|
||
try {
|
||
const res = await planApi.get(payload.planId)
|
||
plan = (res.data ?? res) as Plan
|
||
} catch {
|
||
ElMessage.error('获取运输计划失败,无法打开查看')
|
||
return
|
||
}
|
||
}
|
||
viewingPlan.value = plan
|
||
viewPlanId.value = payload.planId
|
||
viewVisible.value = true
|
||
await nextTick()
|
||
await viewDialogRef.value?.reload()
|
||
}
|
||
}
|
||
|
||
const selectedPlan = computed(() =>
|
||
selectedRows.value.length === 1 ? selectedRows.value[0] : null
|
||
)
|
||
const dateRange = ref<string[]>([])
|
||
const quickSearch = ref('')
|
||
const activePlanTypeTab = ref<PlPlanListTab>('pending_arrange')
|
||
|
||
const searchForm = reactive({
|
||
planNo: '',
|
||
planType: '',
|
||
followStatus: ['pending_arrange'] as string[],
|
||
customerName: '',
|
||
productName: '',
|
||
licensePlate: ''
|
||
})
|
||
|
||
const pagination = reactive({
|
||
page: 1,
|
||
pageSize: 20,
|
||
total: 0
|
||
})
|
||
|
||
function formatFollowStatusParam(statuses: string[]) {
|
||
return statuses.length ? statuses.join(',') : undefined
|
||
}
|
||
|
||
function getPlanTypeLabel(type?: string | null) {
|
||
if (!type) return '—'
|
||
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
|
||
return map[type] || type
|
||
}
|
||
|
||
async function fetchData() {
|
||
loading.value = true
|
||
try {
|
||
const keyword = quickSearch.value.trim()
|
||
const tabFilters = plPlanListTabToFilters(activePlanTypeTab.value)
|
||
const res = await planApi.list({
|
||
q: keyword || undefined,
|
||
planNo: keyword ? undefined : searchForm.planNo || undefined,
|
||
planType: tabFilters.planType || undefined,
|
||
followStatus: tabFilters.followStatus || formatFollowStatusParam(searchForm.followStatus),
|
||
customerName: keyword ? undefined : searchForm.customerName || undefined,
|
||
productName: keyword ? undefined : searchForm.productName || undefined,
|
||
licensePlate: keyword ? undefined : searchForm.licensePlate || undefined,
|
||
planDateFrom: dateRange.value?.[0] || undefined,
|
||
planDateTo: dateRange.value?.[1] || undefined,
|
||
page: pagination.page,
|
||
pageSize: pagination.pageSize
|
||
})
|
||
const data = res.data ?? res
|
||
planList.value = data.list || []
|
||
pagination.total = data.total || 0
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function handleSearch() {
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handlePlanTypeTabChange(tab: PlPlanListTab | string) {
|
||
const nextTab = tab as PlPlanListTab
|
||
const prevTab = activePlanTypeTab.value
|
||
activePlanTypeTab.value = nextTab
|
||
const filters = plPlanListTabToFilters(nextTab)
|
||
searchForm.planType = filters.planType
|
||
if (nextTab === 'pending_arrange') {
|
||
searchForm.followStatus = ['pending_arrange']
|
||
} else if (nextTab === 'arranged') {
|
||
searchForm.followStatus = ['arranged']
|
||
} else if (nextTab === 'drafting') {
|
||
searchForm.followStatus = ['drafting']
|
||
} else if (isPlPlanFollowStatusListTab(prevTab) && !isPlPlanFollowStatusListTab(nextTab)) {
|
||
searchForm.followStatus = [...PL_PLAN_DEFAULT_FOLLOW_STATUSES]
|
||
}
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleReset() {
|
||
activePlanTypeTab.value = 'pending_arrange'
|
||
searchForm.planNo = ''
|
||
searchForm.planType = ''
|
||
searchForm.followStatus = ['pending_arrange']
|
||
searchForm.customerName = ''
|
||
searchForm.productName = ''
|
||
searchForm.licensePlate = ''
|
||
quickSearch.value = ''
|
||
resetDateShortcut()
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleQuickSearch() {
|
||
searchForm.planNo = ''
|
||
searchForm.customerName = ''
|
||
searchForm.productName = ''
|
||
searchForm.licensePlate = ''
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleQuickSearchClear() {
|
||
quickSearch.value = ''
|
||
handleQuickSearch()
|
||
}
|
||
|
||
const { activeDateShortcut, handleDateShortcut, resetDateShortcut } = useListDateShortcut(
|
||
dateRange,
|
||
handleSearch
|
||
)
|
||
|
||
function handlePageChange() {
|
||
fetchData()
|
||
}
|
||
|
||
function handleSizeChange() {
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleAdd() {
|
||
editingPlanId.value = ''
|
||
copyFromPlanId.value = ''
|
||
formOpenForArrange.value = false
|
||
formDialogVisible.value = true
|
||
}
|
||
|
||
function handleView(row: Plan) {
|
||
viewingPlan.value = row
|
||
viewPlanId.value = row.id
|
||
viewVisible.value = true
|
||
}
|
||
|
||
function handleEdit(row: Plan) {
|
||
editingPlanId.value = row.id
|
||
copyFromPlanId.value = ''
|
||
formOpenForArrange.value = false
|
||
formDialogVisible.value = true
|
||
}
|
||
|
||
function handleCopy(row: Plan) {
|
||
editingPlanId.value = ''
|
||
copyFromPlanId.value = row.id
|
||
formOpenForArrange.value = false
|
||
formDialogVisible.value = true
|
||
}
|
||
|
||
function handleToolbarCopy() {
|
||
if (!selectedPlan.value) return
|
||
handleCopy(selectedPlan.value)
|
||
}
|
||
|
||
function canEditPlan(row: Plan) {
|
||
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
|
||
}
|
||
|
||
function canArrangeTransport(row: Plan) {
|
||
return (
|
||
(row.transportStatus === 'pending' || row.transportStatus === 'arranged') &&
|
||
row.archiveStatus !== 'archived' &&
|
||
row.followStatus !== 'cancelled'
|
||
)
|
||
}
|
||
|
||
function arrangeTransportLabel(row: Plan) {
|
||
return row.transportStatus === 'arranged' ? '调整运输' : '安排运输'
|
||
}
|
||
|
||
function canVoidPlan(row: Plan) {
|
||
return row.archiveStatus !== 'archived' && row.followStatus !== 'cancelled'
|
||
}
|
||
|
||
function canWaitNotice(row: Plan) {
|
||
return (
|
||
(row.followStatus === 'pending_arrange' || row.followStatus === 'drafting') &&
|
||
row.archiveStatus !== 'archived'
|
||
)
|
||
}
|
||
|
||
function canCancelWaitNotice(row: Plan) {
|
||
return row.followStatus === 'wait_notice' && row.archiveStatus !== 'archived'
|
||
}
|
||
|
||
function syncViewingPlan(updated: Plan) {
|
||
if (viewingPlan.value?.id === updated.id) {
|
||
viewingPlan.value = { ...viewingPlan.value, ...updated }
|
||
}
|
||
}
|
||
|
||
async function handleWaitNotice(row: Plan) {
|
||
waitNoticeLoading.value = true
|
||
try {
|
||
const res = await planApi.waitNotice(row.id)
|
||
const data = (res as any)?.data ?? res
|
||
ElMessage.success('已标记为等客户通知')
|
||
if (data?.id) syncViewingPlan(data as Plan)
|
||
fetchData()
|
||
} catch (e) {
|
||
const message = e instanceof Error ? e.message : '操作失败'
|
||
ElMessage.error(message)
|
||
} finally {
|
||
waitNoticeLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleCancelWaitNotice(row: Plan) {
|
||
waitNoticeLoading.value = true
|
||
try {
|
||
const res = await planApi.cancelWaitNotice(row.id)
|
||
const data = (res as any)?.data ?? res
|
||
ElMessage.success('已取消等通知,恢复为待安排')
|
||
if (data?.id) syncViewingPlan(data as Plan)
|
||
fetchData()
|
||
} catch (e) {
|
||
const message = e instanceof Error ? e.message : '操作失败'
|
||
ElMessage.error(message)
|
||
} finally {
|
||
waitNoticeLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleToolbarWaitNotice() {
|
||
if (!selectedPlan.value) return
|
||
handleWaitNotice(selectedPlan.value)
|
||
}
|
||
|
||
async function handleVoid(row: Plan) {
|
||
const hint =
|
||
row.transportStatus === 'arranged'
|
||
? '作废后将取消运输安排、作废关联入库/出库单与地磅出入库单,现场链接将失效。是否继续?'
|
||
: '确认作废该运输计划吗?作废后将无法恢复。'
|
||
await ElMessageBox.confirm(hint, '作废运输计划', { type: 'warning' })
|
||
voidLoading.value = true
|
||
try {
|
||
await planApi.cancel(row.id)
|
||
ElMessage.success('作废成功')
|
||
fetchData()
|
||
} catch (e) {
|
||
const message = e instanceof Error ? e.message : '作废失败'
|
||
ElMessage.error(message)
|
||
} finally {
|
||
voidLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleArrange(row: Plan) {
|
||
if (!(await ensurePlanReadyForArrange(row))) return
|
||
if (viewVisible.value && viewingPlan.value?.id === row.id) {
|
||
viewVisible.value = false
|
||
}
|
||
editingPlanId.value = row.id
|
||
copyFromPlanId.value = ''
|
||
formOpenForArrange.value = true
|
||
formDialogVisible.value = true
|
||
}
|
||
|
||
async function resolveDeliveryPrintCustomerId(
|
||
planId: string
|
||
): Promise<string | null | undefined> {
|
||
try {
|
||
const res = await planApi.get(planId)
|
||
const plan = (res.data ?? res) as Plan
|
||
const customers = listDeliveryPrintCustomers(plan)
|
||
if (!customers.length) return undefined
|
||
if (customers.length === 1) return customers[0].customerId
|
||
return (await deliveryCustomerSelectRef.value?.open(customers)) ?? null
|
||
} catch (error) {
|
||
console.error('加载送货客户失败', error)
|
||
ElMessage.error('加载送货客户失败')
|
||
return null
|
||
}
|
||
}
|
||
|
||
async function handlePrintSlip(command: PlPrintSlipCommand, row: Plan) {
|
||
if (command === 'inbound') {
|
||
inboundSlipPrintRef.value?.open(row.id)
|
||
return
|
||
}
|
||
if (command === 'delivery') {
|
||
const customerId = await resolveDeliveryPrintCustomerId(row.id)
|
||
if (customerId === null) return
|
||
deliverySlipPrintRef.value?.open(row.id, customerId ? { customerId } : undefined)
|
||
return
|
||
}
|
||
subpackSlipPrintRef.value?.open(row.id)
|
||
}
|
||
|
||
function handleViewPrintSlipCommand(command: string) {
|
||
if (!viewingPlan.value) return
|
||
handlePrintSlip(command as PlPrintSlipCommand, viewingPlan.value)
|
||
}
|
||
|
||
function handleToolbarPrintSlip(command: string) {
|
||
if (command === 'blank-inbound') {
|
||
inboundSlipPrintRef.value?.openBlank()
|
||
return
|
||
}
|
||
if (command === 'blank-delivery') {
|
||
deliverySlipPrintRef.value?.openBlank()
|
||
return
|
||
}
|
||
if (command === 'blank-subpack') {
|
||
subpackSlipPrintRef.value?.openBlank()
|
||
return
|
||
}
|
||
|
||
const cmd = command as PlPrintSlipCommand
|
||
const plans = selectedRows.value
|
||
const check = canBatchPrintSlip(plans, cmd)
|
||
if (!check.ok) {
|
||
ElMessage.warning(check.reason || '无法打印')
|
||
return
|
||
}
|
||
const ids = plans.map((p) => p.id)
|
||
if (cmd === 'inbound') {
|
||
inboundSlipPrintRef.value?.open(ids)
|
||
return
|
||
}
|
||
if (cmd === 'delivery') {
|
||
if (ids.length === 1) {
|
||
void handlePrintSlip('delivery', plans[0])
|
||
return
|
||
}
|
||
deliverySlipPrintRef.value?.open(ids)
|
||
return
|
||
}
|
||
subpackSlipPrintRef.value?.open(ids)
|
||
}
|
||
|
||
async function handleToolbarArrange() {
|
||
if (selectedRows.value.length !== 1) return
|
||
await handleArrange(selectedRows.value[0])
|
||
}
|
||
|
||
function handleToolbarVoid() {
|
||
if (selectedRows.value.length !== 1) return
|
||
handleVoid(selectedRows.value[0])
|
||
}
|
||
|
||
function openForceFollowStatusDialog() {
|
||
if (!viewingPlan.value) return
|
||
forceFollowStatusValue.value = viewingPlan.value.followStatus || ''
|
||
forceFollowDialogVisible.value = true
|
||
}
|
||
|
||
function resetForceFollowDialog() {
|
||
forceFollowStatusValue.value = ''
|
||
}
|
||
|
||
async function submitForceFollowStatus() {
|
||
if (!viewingPlan.value) return
|
||
const next = (forceFollowStatusValue.value || '').trim()
|
||
if (!next) {
|
||
ElMessage.warning('请选择目标跟进状态')
|
||
return
|
||
}
|
||
if (next === viewingPlan.value.followStatus) {
|
||
ElMessage.warning('目标状态与当前状态相同')
|
||
return
|
||
}
|
||
forceFollowLoading.value = true
|
||
try {
|
||
await planApi.forceFollowStatus(viewingPlan.value.id, next)
|
||
ElMessage.success('跟进状态已更新')
|
||
forceFollowDialogVisible.value = false
|
||
syncViewingPlan({ ...viewingPlan.value, followStatus: next })
|
||
await fetchData()
|
||
await refreshViewIfOpen()
|
||
} 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,
|
||
planType: searchForm.planType,
|
||
followStatus: searchForm.followStatus,
|
||
customerName: searchForm.customerName,
|
||
productName: searchForm.productName,
|
||
licensePlate: searchForm.licensePlate,
|
||
dateRange: dateRange.value
|
||
}),
|
||
() => {
|
||
quickSearch.value = ''
|
||
handleSearch()
|
||
}
|
||
)
|
||
|
||
onMounted(() => {
|
||
loadForceFollowPermission()
|
||
fetchData()
|
||
openArrangeFromQuery()
|
||
|
||
nextTick(() => recalcTableHeight())
|
||
})
|
||
|
||
async function openArrangeFromQuery() {
|
||
const arrangeId = route.query.arrange as string | undefined
|
||
if (!arrangeId) return
|
||
router.replace({ path: '/pl/plan' })
|
||
try {
|
||
const res = await planApi.get(arrangeId)
|
||
const plan = (res.data ?? res) as Plan
|
||
await handleArrange(plan)
|
||
} catch {
|
||
ElMessage.error('获取运输计划失败,无法安排运输')
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.bx-list-table-wrap {
|
||
min-width: 0;
|
||
}
|
||
|
||
.pl-plan-list-toolbar-row {
|
||
flex-wrap: nowrap;
|
||
overflow-x: auto;
|
||
-webkit-overflow-scrolling: touch;
|
||
|
||
> .list-toolbar-date-shortcuts,
|
||
> .quick-search-input,
|
||
> .quick-search-group,
|
||
> .el-button,
|
||
> .el-dropdown {
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* 工具栏全局把按钮刷成描边,需单独盖住才能显示危险实心红 */
|
||
> .el-button.pl-plan-paste-create-btn {
|
||
color: #fff !important;
|
||
background: var(--danger, #dc2626) !important;
|
||
border-color: var(--danger, #dc2626) !important;
|
||
|
||
&:hover,
|
||
&:focus {
|
||
color: #fff !important;
|
||
background: #b91c1c !important;
|
||
border-color: #b91c1c !important;
|
||
}
|
||
}
|
||
}
|
||
|
||
.pl-plan-list-pager-bar {
|
||
justify-content: space-between;
|
||
}
|
||
|
||
.list-pager-selected {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
flex-shrink: 0;
|
||
min-height: 32px;
|
||
margin-right: auto;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: var(--mint-text-muted, #64748b);
|
||
|
||
.sel-num {
|
||
margin: 0 2px;
|
||
color: var(--mint-primary-dark, #059669);
|
||
font-weight: 700;
|
||
}
|
||
}
|
||
|
||
.pl-plan-contract-cell {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: flex-start;
|
||
gap: 8px;
|
||
width: 100%;
|
||
text-align: left;
|
||
}
|
||
|
||
.pl-plan-arrange-copy-cell {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 8px;
|
||
width: 100%;
|
||
}
|
||
|
||
.pl-plan-arrange-copy-cell .btn-ghost.el-button {
|
||
margin: 0;
|
||
}
|
||
|
||
.pl-plan-contract-cell__row {
|
||
display: flex;
|
||
align-items: baseline;
|
||
gap: 6px;
|
||
width: 100%;
|
||
min-width: 0;
|
||
font-size: 13px;
|
||
line-height: 1.5;
|
||
color: var(--text, #1e293b);
|
||
}
|
||
|
||
.pl-plan-contract-cell__side {
|
||
flex-shrink: 0;
|
||
font-weight: 600;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
.pl-plan-contract-cell__no {
|
||
min-width: 0;
|
||
white-space: normal;
|
||
word-break: break-word;
|
||
overflow-wrap: anywhere;
|
||
|
||
&.is-pending {
|
||
font-weight: 600;
|
||
color: #d97706;
|
||
}
|
||
}
|
||
|
||
.pl-plan-stop-kind-text {
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
color: var(--text, #1e293b);
|
||
}
|
||
|
||
.pl-plan-stop-kind-text {
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
color: var(--text, #1e293b);
|
||
}
|
||
|
||
.pl-plan-internal-customer-tag {
|
||
margin-left: 6px;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
.pl-plan-stop-address-time {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 2px;
|
||
width: 100%;
|
||
text-align: left;
|
||
}
|
||
|
||
.pl-plan-stop-address-time__addr {
|
||
font-size: 13px;
|
||
line-height: 1.45;
|
||
color: var(--text, #1e293b);
|
||
word-break: break-word;
|
||
}
|
||
|
||
.pl-plan-stop-address-time__time {
|
||
font-size: 12px;
|
||
line-height: 1.4;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
:deep(.pl-plan-merge-list-table) {
|
||
/* 按计划条斑马纹:同一条计划下装货/送货各行同色 */
|
||
.pl-plan-list-row--plan-striped > td.el-table__cell {
|
||
background-color: #fafafa !important;
|
||
}
|
||
|
||
/* 装货段行:仅右侧段列浅绿,左侧合并的计划列仍随斑马纹 */
|
||
.pl-plan-list-row--load > td.pl-plan-stop-col {
|
||
background-color: #ecfdf5 !important;
|
||
}
|
||
|
||
/* 悬停用浅红;须压过斑马纹/装货段 !important 底色 */
|
||
tbody tr.pl-plan-list-row:hover > td.el-table__cell,
|
||
tbody tr.pl-plan-list-row.hover-row > td.el-table__cell {
|
||
background-color: #fee2e2 !important;
|
||
}
|
||
|
||
.pl-plan-list-row--plan-end > td {
|
||
border-bottom-color: #94a3b8;
|
||
border-bottom-width: 2px;
|
||
}
|
||
}
|
||
</style>
|