planNo 可隐藏后不再硬编码插入,避免统计行按索引错位。 Co-authored-by: Cursor <cursoragent@cursor.com>
1771 lines
63 KiB
Vue
1771 lines
63 KiB
Vue
<!-- 运输计划归档 -->
|
||
<template>
|
||
<div class="page-container">
|
||
<section class="panel">
|
||
<PlPlanTypeTabs v-model="activePlanTypeTab" @change="handlePlanTypeTabChange" />
|
||
|
||
<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
|
||
v-if="canArchive"
|
||
class="btn-main"
|
||
type="primary"
|
||
:disabled="!selectedPlan || selectedPlan.followStatus === 'cancelled'"
|
||
@click="handleToolbarArchive"
|
||
>
|
||
<el-icon><FolderChecked /></el-icon>
|
||
{{ selectedPlan ? archiveButtonLabel(selectedPlan) : '归档' }}
|
||
</el-button>
|
||
<ListToolbarOverflow :items="toolbarOverflowItems">
|
||
<template #export>
|
||
<ListExportDropdown
|
||
:export-fn="planApi.export"
|
||
:get-filter-params="getPlanArchiveExportFilterParams"
|
||
:has-selection="true"
|
||
:selected-ids="selectedRows.map((r) => r.id)"
|
||
:visible-columns="planArchiveExportColumns"
|
||
:additional-menu-items="archiveZipMenuItems"
|
||
filename="计划归档.xlsx"
|
||
/>
|
||
</template>
|
||
</ListToolbarOverflow>
|
||
|
||
<ListToolbarEndActions
|
||
:loading="loading"
|
||
:column-defs="listColumnDefs"
|
||
v-model:visible-columns="visibleColumns"
|
||
v-model:check-all="checkAll"
|
||
:is-indeterminate="isIndeterminate"
|
||
@refresh="fetchData"
|
||
@reset-columns="handleResetColumns"
|
||
/>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="list-body list-wrap">
|
||
<div ref="archiveTableWrapRef" class="table-scroll bx-list-table-wrap">
|
||
<ListTable
|
||
ref="archiveTableRef"
|
||
table-key="pl-plan-archive"
|
||
: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="() => archiveStatsRowRef?.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
|
||
v-if="isColumnVisible('planNo')"
|
||
prop="planNo"
|
||
label="计划编号"
|
||
min-width="180"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">计划编号</span>
|
||
<ColumnHeaderFilter
|
||
prop="planNo"
|
||
label="计划编号"
|
||
type="enum"
|
||
:options="facetOptionsMap.planNo"
|
||
:options-loading="facetLoadingMap.planNo"
|
||
:is-active="isFilterActive('planNo')"
|
||
:model-value="filters.planNo || null"
|
||
@update:model-value="(v) => setFilterState('planNo', v)"
|
||
@open="onFilterOpen('planNo')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<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('planDate')"
|
||
prop="planDate"
|
||
label="计划日期"
|
||
min-width="120"
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">计划日期</span>
|
||
<ColumnHeaderFilter
|
||
prop="planDate"
|
||
label="计划日期"
|
||
type="datetime"
|
||
:is-active="isFilterActive('planDate')"
|
||
:model-value="filters.planDate || null"
|
||
@update:model-value="(v) => setFilterState('planDate', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<template #default="{ row }">{{ row.plan.planDate || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('deliveryTimes')"
|
||
prop="deliveryTimes"
|
||
label="送货时间"
|
||
min-width="130"
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">送货时间</span>
|
||
<ColumnHeaderFilter
|
||
prop="deliveryTimes"
|
||
label="送货时间"
|
||
type="datetime"
|
||
:is-active="isFilterActive('deliveryTimes')"
|
||
:model-value="filters.deliveryTimes || null"
|
||
@update:model-value="(v) => setFilterState('deliveryTimes', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<div
|
||
v-if="(row.plan.deliveryTimes || []).length"
|
||
class="pl-delivery-times-cell"
|
||
>
|
||
<div
|
||
v-for="(t, i) in row.plan.deliveryTimes"
|
||
:key="`${row.plan.id}-dt-${i}`"
|
||
>
|
||
{{ t }}
|
||
</div>
|
||
</div>
|
||
<span v-else>—</span>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('archiveStatus')"
|
||
prop="archiveStatus"
|
||
label="归档状态"
|
||
min-width="100"
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">归档状态</span>
|
||
<ColumnHeaderFilter
|
||
prop="archiveStatus"
|
||
label="归档状态"
|
||
type="enum"
|
||
:is-active="isFilterActive('archiveStatus')"
|
||
:model-value="filters.archiveStatus || null"
|
||
:options="enumOptionsFor('archiveStatus')"
|
||
@update:model-value="(v) => setFilterState('archiveStatus', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<template #default="{ row }">
|
||
<el-tag :type="getPlPlanArchiveStatusTagType(row.plan.archiveStatus)" size="small">
|
||
{{ getPlPlanArchiveStatusLabel(row.plan.archiveStatus) }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('belongsCompany')"
|
||
prop="belongsCompany"
|
||
label="归属公司"
|
||
min-width="110"
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">归属公司</span>
|
||
<ColumnHeaderFilter
|
||
prop="belongsCompany"
|
||
label="归属公司"
|
||
type="enum"
|
||
:is-active="isFilterActive('belongsCompany')"
|
||
:model-value="filters.belongsCompany || null"
|
||
:options="enumOptionsFor('belongsCompany')"
|
||
@update:model-value="(v) => setFilterState('belongsCompany', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<template #default="{ row }">
|
||
{{ getPlPlanCompanyLabel(row.plan.belongsCompany) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('followStatus')"
|
||
prop="followStatus"
|
||
label="跟进状态"
|
||
min-width="100"
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">跟进状态</span>
|
||
<ColumnHeaderFilter
|
||
prop="followStatus"
|
||
label="跟进状态"
|
||
type="enum"
|
||
:is-active="isFilterActive('followStatus')"
|
||
:model-value="filters.followStatus || null"
|
||
:options="enumOptionsFor('followStatus')"
|
||
@update:model-value="(v) => setFilterState('followStatus', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<template #default="{ row }">
|
||
<el-tag
|
||
class="pl-plan-follow-status"
|
||
:data-follow-status="row.plan.followStatus"
|
||
:type="getPlPlanFollowStatusTagType(row.plan.followStatus)"
|
||
size="small"
|
||
>
|
||
{{ getPlPlanFollowStatusLabel(row.plan.followStatus) }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('planType')"
|
||
prop="planType"
|
||
label="单据类型"
|
||
min-width="100"
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">单据类型</span>
|
||
<ColumnHeaderFilter
|
||
prop="planType"
|
||
label="单据类型"
|
||
type="enum"
|
||
:is-active="isFilterActive('planType')"
|
||
:model-value="filters.planType || null"
|
||
:options="enumOptionsFor('planType')"
|
||
@update:model-value="(v) => setFilterState('planType', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<template #default="{ row }">
|
||
{{ getPlanTypeLabel(row.plan.planType) }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('documentAttachments')"
|
||
prop="documentAttachments"
|
||
label="单据附件"
|
||
min-width="280"
|
||
align="left"
|
||
header-align="left"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanDocumentAttachmentCell
|
||
:attachments="row.plan.documentAttachments"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('erpEntered')"
|
||
prop="erpEntered"
|
||
label="ERP"
|
||
min-width="72"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">ERP</span>
|
||
<ColumnHeaderFilter
|
||
prop="erpEntered"
|
||
label="ERP"
|
||
type="enum"
|
||
:is-active="isFilterActive('erpEntered')"
|
||
:model-value="filters.erpEntered || null"
|
||
:options="enumOptionsFor('erpEntered')"
|
||
@update:model-value="(v) => setFilterState('erpEntered', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<div class="pl-plan-archive-erp-cell" @click.stop @mousedown.stop>
|
||
<el-checkbox
|
||
class="pl-plan-archive-erp-checkbox"
|
||
:model-value="Number(row.plan.erpEntered) === 1"
|
||
/>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('planAttachments')"
|
||
prop="planAttachments"
|
||
label="计划附件"
|
||
min-width="200"
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListCertCell :products="row.plan.products" compact hide-product />
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('licensePlate')"
|
||
prop="licensePlate"
|
||
label="车牌号"
|
||
min-width="160"
|
||
show-overflow-tooltip
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">车牌号</span>
|
||
<ColumnHeaderFilter
|
||
prop="licensePlate"
|
||
label="车牌号"
|
||
type="enum"
|
||
:options="facetOptionsMap.licensePlate"
|
||
:options-loading="facetLoadingMap.licensePlate"
|
||
:is-active="isFilterActive('licensePlate')"
|
||
:model-value="filters.licensePlate || null"
|
||
@update:model-value="(v) => setFilterState('licensePlate', v)"
|
||
@open="onFilterOpen('licensePlate')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
{{
|
||
formatPlVehiclePlateDisplay(row.plan.licensePlate, row.plan.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 #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">承运商</span>
|
||
<ColumnHeaderFilter
|
||
prop="carrierName"
|
||
label="承运商"
|
||
type="enum"
|
||
:options="facetOptionsMap.carrierName"
|
||
:options-loading="facetLoadingMap.carrierName"
|
||
:is-active="isFilterActive('carrierName')"
|
||
:model-value="filters.carrierName || null"
|
||
@update:model-value="(v) => setFilterState('carrierName', v)"
|
||
@open="onFilterOpen('carrierName')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
{{ row.plan.resourceSnapshot?.carrierName || '' }}
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('personnelSummary')"
|
||
prop="personnelSummary"
|
||
label="人员"
|
||
min-width="180"
|
||
show-overflow-tooltip
|
||
align="center"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">人员</span>
|
||
<ColumnHeaderFilter
|
||
prop="personnelSummary"
|
||
label="人员"
|
||
type="text"
|
||
:is-active="isFilterActive('personnelSummary')"
|
||
:model-value="filters.personnelSummary || null"
|
||
@update:model-value="(v) => setFilterState('personnelSummary', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<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 #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">跟进人</span>
|
||
<ColumnHeaderFilter
|
||
prop="followUserName"
|
||
label="跟进人"
|
||
type="text"
|
||
:is-active="isFilterActive('followUserName')"
|
||
:model-value="filters.followUserName || null"
|
||
@update:model-value="(v) => setFilterState('followUserName', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">{{ row.plan.followUserName || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('loadCustomer')"
|
||
prop="loadCustomer"
|
||
label="装货客户"
|
||
min-width="160"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">装货客户</span>
|
||
<ColumnHeaderFilter
|
||
prop="loadCustomer"
|
||
label="装货客户"
|
||
type="enum"
|
||
:options="facetOptionsMap.loadCustomer"
|
||
:options-loading="facetLoadingMap.loadCustomer"
|
||
:is-active="isFilterActive('loadCustomer')"
|
||
:model-value="filters.loadCustomer || null"
|
||
@update:model-value="(v) => setFilterState('loadCustomer', v)"
|
||
@open="onFilterOpen('loadCustomer')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<span>{{ getLoadCustomerNameFromRow(row) }}</span>
|
||
<el-tag
|
||
v-if="isPlInternalCustomerName(getPairLoadStop(row)?.customerName)"
|
||
type="success"
|
||
size="small"
|
||
class="pl-plan-internal-customer-tag"
|
||
>
|
||
内部
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('deliveryCustomer')"
|
||
prop="deliveryCustomer"
|
||
label="送货客户"
|
||
min-width="160"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">送货客户</span>
|
||
<ColumnHeaderFilter
|
||
prop="deliveryCustomer"
|
||
label="送货客户"
|
||
type="enum"
|
||
:options="facetOptionsMap.deliveryCustomer"
|
||
:options-loading="facetLoadingMap.deliveryCustomer"
|
||
:is-active="isFilterActive('deliveryCustomer')"
|
||
:model-value="filters.deliveryCustomer || null"
|
||
@update:model-value="(v) => setFilterState('deliveryCustomer', v)"
|
||
@open="onFilterOpen('deliveryCustomer')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<span>{{ getDeliveryCustomerNameFromRow(row) }}</span>
|
||
<el-tag
|
||
v-if="isPlInternalCustomerName(getPairDeliveryStop(row)?.customerName)"
|
||
type="success"
|
||
size="small"
|
||
class="pl-plan-internal-customer-tag"
|
||
>
|
||
内部
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('loadAddressTime')"
|
||
prop="loadAddressTime"
|
||
label="装货地址/时间"
|
||
min-width="240"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">装货地址/时间</span>
|
||
<ColumnHeaderFilter
|
||
prop="loadAddressTime"
|
||
label="装货地址/时间"
|
||
type="text"
|
||
:is-active="isFilterActive('loadAddressTime')"
|
||
:model-value="filters.loadAddressTime || null"
|
||
@update:model-value="(v) => setFilterState('loadAddressTime', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<div class="pl-plan-stop-address-time">
|
||
<div class="pl-plan-stop-address-time__addr">
|
||
{{ formatStopAddressText(getPairLoadStop(row)) }}
|
||
</div>
|
||
<div class="pl-plan-stop-address-time__time">
|
||
{{ formatLoadTimeText(getPairLoadStop(row)) }}
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('deliveryAddressTime')"
|
||
prop="deliveryAddressTime"
|
||
label="送货地址/时间"
|
||
min-width="240"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">送货地址/时间</span>
|
||
<ColumnHeaderFilter
|
||
prop="deliveryAddressTime"
|
||
label="送货地址/时间"
|
||
type="text"
|
||
:is-active="isFilterActive('deliveryAddressTime')"
|
||
:model-value="filters.deliveryAddressTime || null"
|
||
@update:model-value="(v) => setFilterState('deliveryAddressTime', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<div class="pl-plan-stop-address-time">
|
||
<div class="pl-plan-stop-address-time__addr">
|
||
{{ formatStopAddressText(getPairDeliveryStop(row)) }}
|
||
</div>
|
||
<div class="pl-plan-stop-address-time__time">
|
||
{{ formatDeliveryTimeText(getPairDeliveryStop(row)) }}
|
||
</div>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productContract')"
|
||
prop="productContract"
|
||
label="合同"
|
||
min-width="200"
|
||
align="left"
|
||
header-align="left"
|
||
class-name="col-name-wrap pl-plan-stop-col"
|
||
label-class-name="col-name-wrap"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">合同</span>
|
||
<ColumnHeaderFilter
|
||
prop="productContract"
|
||
label="合同"
|
||
type="enum"
|
||
:options="withPlanContractIoFacetOptions(facetOptionsMap.productContract)"
|
||
:options-loading="facetLoadingMap.productContract"
|
||
:extra-enum-options="PL_PLAN_CONTRACT_SIDE_FILTER_OPTIONS"
|
||
:is-active="isFilterActive('productContract')"
|
||
:model-value="filters.productContract || null"
|
||
@update:model-value="(v) => setFilterState('productContract', v)"
|
||
@open="onFilterOpen('productContract')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanContractCell
|
||
:lines="getProductContractLinesFromRow(row)"
|
||
@open="openContractDetail"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="productName"
|
||
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 #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-left">产品名称</span>
|
||
<ColumnHeaderFilter
|
||
prop="productName"
|
||
label="产品名称"
|
||
type="enum"
|
||
:options="facetOptionsMap.productName"
|
||
:options-loading="facetLoadingMap.productName"
|
||
:is-active="isFilterActive('productName')"
|
||
:model-value="filters.productName || null"
|
||
@update:model-value="(v) => setFilterState('productName', v)"
|
||
@open="onFilterOpen('productName')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="name"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="productBrand"
|
||
v-if="isColumnVisible('productBrand')"
|
||
label="品牌"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="brand"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="productAlias"
|
||
v-if="isColumnVisible('productAlias')"
|
||
label="别名"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="alias"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productSpec')"
|
||
prop="productSpec"
|
||
label="型号/规格"
|
||
min-width="96"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">型号/规格</span>
|
||
<ColumnHeaderFilter
|
||
prop="productSpec"
|
||
label="型号/规格"
|
||
type="enum"
|
||
:options="facetOptionsMap.productSpec"
|
||
:options-loading="facetLoadingMap.productSpec"
|
||
:is-active="isFilterActive('productSpec')"
|
||
:model-value="filters.productSpec || null"
|
||
@update:model-value="(v) => setFilterState('productSpec', v)"
|
||
@open="onFilterOpen('productSpec')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="spec"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('productUnit')"
|
||
prop="productUnit"
|
||
label="单位"
|
||
min-width="64"
|
||
align="center"
|
||
header-align="center"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label">单位</span>
|
||
<ColumnHeaderFilter
|
||
prop="productUnit"
|
||
label="单位"
|
||
type="enum"
|
||
:options="facetOptionsMap.productUnit"
|
||
:options-loading="facetLoadingMap.productUnit"
|
||
:is-active="isFilterActive('productUnit')"
|
||
:model-value="filters.productUnit || null"
|
||
@update:model-value="(v) => setFilterState('productUnit', v)"
|
||
@open="onFilterOpen('productUnit')"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="unit"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('planQty')"
|
||
prop="planQty"
|
||
label="计划量"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-right">计划量</span>
|
||
<ColumnHeaderFilter
|
||
prop="planQty"
|
||
label="计划量"
|
||
type="number"
|
||
:is-active="isFilterActive('planQty')"
|
||
:model-value="filters.planQty || null"
|
||
@update:model-value="(v) => setFilterState('planQty', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
:stop-kind="row.kind"
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="planQty"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isColumnVisible('actualQty')"
|
||
prop="actualQty"
|
||
label="实际量"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-right">实际量</span>
|
||
<ColumnHeaderFilter
|
||
prop="actualQty"
|
||
label="实际量"
|
||
type="number"
|
||
:is-active="isFilterActive('actualQty')"
|
||
:model-value="filters.actualQty || null"
|
||
@update:model-value="(v) => setFilterState('actualQty', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
archive-list-mode
|
||
:stop-kind="row.kind"
|
||
:stop-customer-name="row.stop?.customerName"
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="actualQty"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isArchiveColumnVisible('unitPrice')"
|
||
prop="unitPrice"
|
||
label="单价(元)"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-right">单价(元)</span>
|
||
<ColumnHeaderFilter
|
||
prop="unitPrice"
|
||
label="单价(元)"
|
||
type="number"
|
||
:is-active="isFilterActive('unitPrice')"
|
||
:model-value="filters.unitPrice || null"
|
||
@update:model-value="(v) => setFilterState('unitPrice', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
archive-list-mode
|
||
:stop-kind="row.kind"
|
||
:stop-customer-name="row.stop?.customerName"
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="unitPrice"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
v-if="isArchiveColumnVisible('amount')"
|
||
prop="amount"
|
||
label="金额(元)"
|
||
min-width="100"
|
||
align="right"
|
||
header-align="right"
|
||
class-name="pl-plan-stop-col"
|
||
>
|
||
<template #header>
|
||
<div class="col-header-with-filter">
|
||
<span class="col-header-with-filter__label is-right">金额(元)</span>
|
||
<ColumnHeaderFilter
|
||
prop="amount"
|
||
label="金额(元)"
|
||
type="number"
|
||
:is-active="isFilterActive('amount')"
|
||
:model-value="filters.amount || null"
|
||
@update:model-value="(v) => setFilterState('amount', v)"
|
||
/>
|
||
</div>
|
||
</template>
|
||
<template #default="{ row }">
|
||
<PlPlanListProductCell
|
||
archive-list-mode
|
||
:stop-kind="row.kind"
|
||
:stop-customer-name="row.stop?.customerName"
|
||
:stop-products="getRowStopProducts(row)"
|
||
:plan-products="row.plan.products"
|
||
field="amount"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
</ListTable>
|
||
</div>
|
||
<div ref="archiveBelowRef">
|
||
<ListColumnStatsRow
|
||
ref="archiveStatsRowRef"
|
||
storage-key="pl-plan-archive-column-stats"
|
||
:columns="archiveStatsRowColumns"
|
||
:data="displayRows"
|
||
:table-wrap-el="archiveTableWrapRef"
|
||
:get-cell-value="getArchiveStatCellValue"
|
||
/>
|
||
|
||
<div class="pagination 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>
|
||
|
||
<PlPlanViewDialog
|
||
ref="viewDialogRef"
|
||
v-model:visible="viewVisible"
|
||
:plan-id="viewPlanId"
|
||
:seed-plan="viewingPlan"
|
||
show-archive-io-fields
|
||
:show-archive-price-fields="canViewPrice"
|
||
>
|
||
<template v-if="viewingPlan" #hero-actions>
|
||
<el-button
|
||
v-if="canArchive && viewingPlan.followStatus !== 'cancelled'"
|
||
class="btn-main"
|
||
type="primary"
|
||
@click="handleArchive(viewingPlan)"
|
||
>
|
||
<el-icon><FolderChecked /></el-icon>{{ archiveButtonLabel(viewingPlan) }}
|
||
</el-button>
|
||
</template>
|
||
</PlPlanViewDialog>
|
||
|
||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||
|
||
<PlPlanArchiveDialog
|
||
v-model:visible="archiveDialogVisible"
|
||
:plan-id="archivePlanId"
|
||
@success="handlePlanMutationSuccess"
|
||
/>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||
import ListToolbarOverflow from '@/components/business/list-toolbar-overflow/index.vue'
|
||
import type { ListToolbarOverflowItem } from '@/components/business/list-toolbar-overflow/types'
|
||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||
import {
|
||
overflowClearFiltersItem,
|
||
overflowExportPlaceholder
|
||
} from '@/utils/list-toolbar-overflow-items'
|
||
import ListColumnStatsRow from '@/components/business/list-column-stats-row/index.vue'
|
||
import { buildStatsRowColumns, type StatsRowColumn } from '@/utils/list-column-stats'
|
||
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
|
||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||
import { usePlPlanMergeListTable } from '@/composables/usePlPlanMergeListTable'
|
||
import {
|
||
DocumentChecked,
|
||
FolderChecked
|
||
} from '@element-plus/icons-vue'
|
||
import { planApi, type Plan,
|
||
fetchPlanColumnFacetValues
|
||
} from '@/api/pl'
|
||
import { fetchGetMenuCodes } from '@/api/auth'
|
||
import { pickBxData } from '@/utils/http/bx'
|
||
import PlPlanContractCell from '@/components/business/pl-plan-contract-cell/index.vue'
|
||
const PlPlanArchiveDialog = defineAsyncComponent(
|
||
() => import('@/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'
|
||
const PlPlanViewDialog = defineAsyncComponent(
|
||
() => import('@/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 { formatBrandConstraintLabel } from '@/utils/crm-product-brand'
|
||
import {
|
||
formatPlVehiclePlateDisplay,
|
||
getPlPlanArchiveStatusLabel,
|
||
getPlPlanArchiveStatusTagType,
|
||
getPlPlanCompanyLabel,
|
||
getPlPlanFollowStatusLabel,
|
||
getPlPlanFollowStatusTagType,
|
||
normalizePlPersonnelSummaryDisplay,
|
||
plPlanTypeTabToFilter,
|
||
type PlPlanTypeTab
|
||
} from '@/utils/pl-display'
|
||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||
import ColumnHeaderFilter from '@/components/business/column-header-filter/index.vue'
|
||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||
import { useColumnFacetOptions } from '@/composables/useColumnFacetOptions'
|
||
import { useColumnSort } from '@/composables/useColumnSort'
|
||
import { plPlanArchiveColumnFilterDefs } from './columnFilterDefs'
|
||
import {
|
||
applyContractSideQueryParams,
|
||
selectedContractStopKinds
|
||
} from '@/utils/pl-plan-pair-list-query'
|
||
import {
|
||
PL_PLAN_CONTRACT_SIDE_FILTER_OPTIONS,
|
||
withPlanContractIoFacetOptions
|
||
} from '@/utils/pl-plan-contract-display'
|
||
import {
|
||
formatDeliveryTimeText,
|
||
formatLoadTimeText,
|
||
formatStopAddressText,
|
||
getDeliveryCustomerNameFromRow,
|
||
getLoadCustomerNameFromRow,
|
||
getPairDeliveryStop,
|
||
getPairLoadStop,
|
||
getPlPlanListRowClassName,
|
||
getProductContractLinesFromRow,
|
||
getRowActualQty,
|
||
getRowAmount,
|
||
getRowPlanQty,
|
||
getRowStopProduct,
|
||
getRowStopProducts,
|
||
getRowUnitPrice,
|
||
type PlPlanListDisplayRow
|
||
} from '@/utils/pl-plan-list-display-rows'
|
||
import { isPlInternalCustomerName } from '@/utils/pl-internal-customer'
|
||
import { refreshMenuBadges } from '@/utils/menu-badge-registry'
|
||
import { useMenuStore } from '@/store/modules/menu'
|
||
|
||
const menuStore = useMenuStore()
|
||
const { ContractDetailDialog, contractDetailRef, openContractDetail, hideProductPrice } =
|
||
useContractDetailDialog({ gateProductPriceByPerm: true })
|
||
|
||
/** 计划区可合并列(顺序须与表格左侧列一致,不含勾选/序号/计划编号) */
|
||
const PLAN_MERGE_COLUMN_PROPS = [
|
||
'planDate',
|
||
'deliveryTimes',
|
||
'archiveStatus',
|
||
'belongsCompany',
|
||
'followStatus',
|
||
'planType',
|
||
'documentAttachments',
|
||
'erpEntered',
|
||
'planAttachments',
|
||
'licensePlate',
|
||
'carrierName',
|
||
'personnelSummary',
|
||
'followUserName'
|
||
] as const
|
||
|
||
const loading = ref(false)
|
||
const canArchive = ref(false)
|
||
const canViewPrice = ref(false)
|
||
const viewVisible = ref(false)
|
||
const viewPlanId = ref('')
|
||
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
|
||
const archiveDialogVisible = ref(false)
|
||
const archivePlanId = ref('')
|
||
const erpBatchLoading = ref(false)
|
||
const planList = ref<Plan[]>([])
|
||
|
||
const PRICE_COLUMN_PROPS = new Set(['unitPrice', 'amount'])
|
||
|
||
const allListColumnDefs = [
|
||
{ prop: 'planNo', label: '计划编号' },
|
||
{ prop: 'planDate', label: '计划日期' },
|
||
{ prop: 'deliveryTimes', label: '送货时间' },
|
||
{ prop: 'archiveStatus', label: '归档状态' },
|
||
{ prop: 'belongsCompany', label: '归属公司' },
|
||
{ prop: 'followStatus', label: '跟进状态' },
|
||
{ prop: 'planType', label: '单据类型' },
|
||
{ prop: 'documentAttachments', label: '单据附件' },
|
||
{ prop: 'erpEntered', label: 'ERP' },
|
||
{ prop: 'planAttachments', label: '计划附件' },
|
||
{ prop: 'licensePlate', label: '车牌号' },
|
||
{ prop: 'carrierName', label: '承运商' },
|
||
{ prop: 'personnelSummary', label: '人员' },
|
||
{ prop: 'followUserName', label: '跟进人', defaultVisible: false },
|
||
{ prop: 'loadCustomer', label: '装货客户' },
|
||
{ prop: 'deliveryCustomer', label: '送货客户' },
|
||
{ prop: 'loadAddressTime', label: '装货地址/时间' },
|
||
{ prop: 'deliveryAddressTime', label: '送货地址/时间' },
|
||
{ prop: 'productContract', label: '合同' },
|
||
{ prop: 'productName', label: '产品名称' },
|
||
{ prop: 'productBrand', label: '品牌' },
|
||
{ prop: 'productAlias', label: '别名' },
|
||
{ prop: 'productSpec', label: '型号/规格' },
|
||
{ prop: 'productUnit', label: '单位' },
|
||
{ prop: 'planQty', label: '计划量' },
|
||
{ prop: 'actualQty', label: '实际量' },
|
||
{ prop: 'unitPrice', label: '单价(元)' },
|
||
{ prop: 'amount', label: '金额(元)' }
|
||
]
|
||
|
||
const listColumnDefs = computed(() =>
|
||
canViewPrice.value
|
||
? allListColumnDefs
|
||
: allListColumnDefs.filter((def) => !PRICE_COLUMN_PROPS.has(def.prop))
|
||
)
|
||
|
||
const {
|
||
visibleColumns,
|
||
checkAll,
|
||
isIndeterminate,
|
||
isColumnVisible,
|
||
resetToDefault
|
||
} = usePersistedListColumns('pl-plan-archive-list-columns-v17', allListColumnDefs)
|
||
|
||
const {
|
||
filters,
|
||
hasActiveFilters,
|
||
setFilterState,
|
||
clearAllFilters,
|
||
isFilterActive,
|
||
toQueryParams,
|
||
resetToInitial,
|
||
watchVisibleColumns
|
||
} = useServerColumnFilters(plPlanArchiveColumnFilterDefs, {
|
||
initialFilters: {},
|
||
onChange: () => handleSearch()
|
||
})
|
||
|
||
const { facetOptionsMap, facetLoadingMap, onFilterOpen } = useColumnFacetOptions({
|
||
facetFields: ['planNo', 'licensePlate', 'carrierName', 'loadCustomer', 'deliveryCustomer', 'productContract', 'productName', 'productSpec', 'productUnit'],
|
||
columnFilterDefs: plPlanArchiveColumnFilterDefs,
|
||
getContextParams: () => buildListQueryParams(),
|
||
fetchFacet: (payload) => fetchPlanColumnFacetValues(payload)
|
||
})
|
||
|
||
const {
|
||
sortField,
|
||
sortOrder,
|
||
setSort,
|
||
clearSort,
|
||
isSortActive,
|
||
toQueryParams: toSortQueryParams,
|
||
watchVisibleColumns: watchSortVisibleColumns
|
||
} = useColumnSort({
|
||
onChange: () => handleSearch()
|
||
})
|
||
|
||
provide('crmColumnSort', {
|
||
setSort,
|
||
clearSort,
|
||
isSortActive,
|
||
sortField,
|
||
sortOrder
|
||
})
|
||
|
||
function enumOptionsFor(prop: string) {
|
||
const def = plPlanArchiveColumnFilterDefs.find((d) => d.prop === prop)
|
||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||
}
|
||
|
||
const visibleFilterProps = computed(() => {
|
||
const props: string[] = []
|
||
for (const def of listColumnDefs.value) {
|
||
if (isColumnVisible(def.prop)) props.push(def.prop)
|
||
}
|
||
return props
|
||
})
|
||
watchVisibleColumns(visibleFilterProps)
|
||
watchSortVisibleColumns(visibleFilterProps)
|
||
|
||
function handleResetColumns() {
|
||
resetToDefault()
|
||
resetToInitial()
|
||
}
|
||
|
||
|
||
function isArchiveColumnVisible(prop: string) {
|
||
if (PRICE_COLUMN_PROPS.has(prop) && !canViewPrice.value) return false
|
||
return isColumnVisible(prop)
|
||
}
|
||
|
||
watch(canViewPrice, (ok) => {
|
||
if (ok) return
|
||
visibleColumns.value = visibleColumns.value.filter((prop) => !PRICE_COLUMN_PROPS.has(prop))
|
||
})
|
||
|
||
async function loadArchivePermissions() {
|
||
try {
|
||
const perm = await fetchGetMenuCodes()
|
||
const all = !!perm?.all || !!perm?.isSuperAdmin
|
||
const codes = perm?.menuCodes || []
|
||
canArchive.value = all || codes.includes('pl:plan-archive:archive')
|
||
canViewPrice.value = all || codes.includes('pl:plan-archive:price')
|
||
} catch {
|
||
canArchive.value = false
|
||
canViewPrice.value = false
|
||
}
|
||
}
|
||
|
||
const selectedRows = ref<Plan[]>([])
|
||
|
||
const pagination = reactive({
|
||
page: 1,
|
||
pageSize: 20,
|
||
total: 0
|
||
})
|
||
|
||
const visiblePlanMergeProps = computed(() =>
|
||
PLAN_MERGE_COLUMN_PROPS.filter((prop) => isColumnVisible(prop))
|
||
)
|
||
|
||
/** 装货客户漏斗(配对行客户端过滤)。 */
|
||
const archiveLoadCustomerKeywords = computed(() => {
|
||
const selected = (
|
||
(filters.loadCustomer as { selected?: string[] } | undefined)?.selected || []
|
||
)
|
||
.map((value) => String(value || '').trim())
|
||
.filter(Boolean)
|
||
return selected.length ? selected : null
|
||
})
|
||
|
||
/** 送货客户漏斗(配对行客户端过滤)。 */
|
||
const archiveDeliveryCustomerKeywords = computed(() => {
|
||
const selected = (
|
||
(filters.deliveryCustomer as { selected?: string[] } | undefined)?.selected || []
|
||
)
|
||
.map((value) => String(value || '').trim())
|
||
.filter(Boolean)
|
||
return selected.length ? selected : null
|
||
})
|
||
|
||
function textFilterKeywords(value: unknown): string[] | null {
|
||
if (value == null || value === '') return null
|
||
if (typeof value === 'string') {
|
||
const text = value.trim()
|
||
return text ? [text] : null
|
||
}
|
||
if (typeof value === 'object') {
|
||
const obj = value as { value?: unknown; keyword?: unknown; selected?: string[] }
|
||
if (Array.isArray(obj.selected)) {
|
||
const selected = obj.selected.map((item) => String(item || '').trim()).filter(Boolean)
|
||
return selected.length ? selected : null
|
||
}
|
||
const text = String(obj.value ?? obj.keyword ?? '').trim()
|
||
return text ? [text] : null
|
||
}
|
||
return null
|
||
}
|
||
|
||
const archiveProductKeywords = computed(() => textFilterKeywords(filters.productName))
|
||
const archiveContractStopKinds = computed(() =>
|
||
selectedContractStopKinds(filters.productContract as { selected?: string[] } | undefined)
|
||
)
|
||
|
||
const {
|
||
displayRows,
|
||
planListSpanMethod,
|
||
getDisplayRowIndex,
|
||
isPlanFirstRowSelectable,
|
||
handleDisplaySelectionChange,
|
||
handleDisplayRowDblClick
|
||
} = usePlPlanMergeListTable({
|
||
planList,
|
||
visiblePlanMergeProps,
|
||
selectedRows,
|
||
pagination,
|
||
onView: (plan) => handleView(plan),
|
||
archivePairMode: true,
|
||
loadCustomerKeywords: archiveLoadCustomerKeywords,
|
||
deliveryCustomerKeywords: archiveDeliveryCustomerKeywords,
|
||
productKeywords: archiveProductKeywords,
|
||
stopKinds: archiveContractStopKinds
|
||
})
|
||
|
||
const archiveStatsRowRef = ref<{ resync?: () => void } | null>(null)
|
||
|
||
/** 与表头可见列一一对应:勾选/序号占位 + 可见业务列(含可隐藏的 planNo) */
|
||
const archiveStatsRowColumns = computed((): StatsRowColumn[] =>
|
||
buildStatsRowColumns({
|
||
leadingSpacers: 2,
|
||
optionalDefs: listColumnDefs.value,
|
||
isColumnVisible: isArchiveColumnVisible,
|
||
moneyProps: PRICE_COLUMN_PROPS
|
||
})
|
||
)
|
||
|
||
function getArchiveStatCellValue(row: PlPlanListDisplayRow, prop: string): unknown {
|
||
const plan = row.plan
|
||
const loadStop = getPairLoadStop(row)
|
||
const deliveryStop = getPairDeliveryStop(row)
|
||
const product = getRowStopProduct(row)
|
||
if (prop === 'planNo') return plan.planNo
|
||
if (prop === 'archiveStatus') return getPlPlanArchiveStatusLabel(plan.archiveStatus)
|
||
if (prop === 'belongsCompany') return getPlPlanCompanyLabel(plan.belongsCompany)
|
||
if (prop === 'followStatus') return getPlPlanFollowStatusLabel(plan.followStatus)
|
||
if (prop === 'planType') return getPlanTypeLabel(plan.planType)
|
||
if (prop === 'loadCustomer') return getLoadCustomerNameFromRow(row)
|
||
if (prop === 'deliveryCustomer') return getDeliveryCustomerNameFromRow(row)
|
||
if (prop === 'loadAddressTime') {
|
||
return `${formatStopAddressText(loadStop)} ${formatLoadTimeText(loadStop)}`.trim()
|
||
}
|
||
if (prop === 'deliveryAddressTime') {
|
||
return `${formatStopAddressText(deliveryStop)} ${formatDeliveryTimeText(deliveryStop)}`.trim()
|
||
}
|
||
if (prop === 'productContract') {
|
||
return (
|
||
getProductContractLinesFromRow(row)
|
||
.map((line) => `${line.side}${line.no}`)
|
||
.join(' ') || '—'
|
||
)
|
||
}
|
||
if (prop === 'planQty') return getRowPlanQty(row)
|
||
if (prop === 'actualQty') return getRowActualQty(row)
|
||
if (prop === 'unitPrice') return getRowUnitPrice(row)
|
||
if (prop === 'amount') return getRowAmount(row)
|
||
if (prop === 'productName') return product?.productName || '—'
|
||
if (prop === 'productBrand' || prop === 'productAlias') {
|
||
const planProduct =
|
||
(product?.planProductId &&
|
||
row.plan.products?.find((item) => String(item.id) === String(product.planProductId))) ||
|
||
row.plan.products?.find((item) => String(item.productId) === String(product?.productId))
|
||
if (prop === 'productBrand') {
|
||
if (!planProduct) return '—'
|
||
return formatBrandConstraintLabel(planProduct.brandMode, planProduct.brandName)
|
||
}
|
||
return (planProduct?.aliasName || '').trim() || '—'
|
||
}
|
||
if (prop === 'productSpec') return product?.model || product?.packageSpec || '—'
|
||
if (prop === 'productUnit') return product?.unit || '—'
|
||
if (prop === 'planAttachments' || prop === 'documentAttachments') return ''
|
||
if (prop === 'erpEntered') return Number(plan.erpEntered) === 1 ? '是' : '否'
|
||
if (prop === 'licensePlate') {
|
||
return formatPlVehiclePlateDisplay(plan.licensePlate, plan.trailerNo)
|
||
}
|
||
if (prop === 'carrierName') return plan.resourceSnapshot?.carrierName || ''
|
||
if (prop === 'personnelSummary') {
|
||
return normalizePlPersonnelSummaryDisplay(plan.personnelSummary)
|
||
}
|
||
if (prop === 'followUserName') return plan.followUserName
|
||
if (prop === 'planDate') return plan.planDate
|
||
if (prop === 'deliveryTimes') {
|
||
return (plan.deliveryTimes || []).join('\n') || '—'
|
||
}
|
||
return ''
|
||
}
|
||
|
||
const archiveTableWrapRef = ref<HTMLElement | null>(null)
|
||
const archiveBelowRef = ref<HTMLElement | null>(null)
|
||
const archiveTableRef = ref<any>(null)
|
||
const { tableHeight, recalc: recalcTableHeight } = useListTableViewportHeight({
|
||
tableEl: archiveTableWrapRef,
|
||
pagerEl: archiveBelowRef,
|
||
tableRef: archiveTableRef
|
||
})
|
||
function buildListQueryParams(): Record<string, any> {
|
||
const colParams = { ...toQueryParams(), ...toSortQueryParams() }
|
||
const keyword = quickSearch.value.trim()
|
||
const params: Record<string, any> = { ...colParams }
|
||
if (keyword) params.q = keyword
|
||
|
||
// Tab 单据类型优先
|
||
const tabPlanType = plPlanTypeTabToFilter(activePlanTypeTab.value)
|
||
if (tabPlanType) {
|
||
params.planType = tabPlanType
|
||
delete params.planTypeIn
|
||
}
|
||
|
||
if (colParams.followStatusIn) {
|
||
params.followStatus = colParams.followStatusIn
|
||
delete params.followStatusIn
|
||
}
|
||
if (colParams.archiveStatusIn) {
|
||
params.archiveStatus = colParams.archiveStatusIn
|
||
delete params.archiveStatusIn
|
||
}
|
||
|
||
// 装/送客户分别筛 → 服务端仍用 stopCustomers(任一侧命中);客户端再按侧收窄配对行
|
||
const parseCustomerQueryParam = (raw: unknown): string[] => {
|
||
if (raw == null || raw === '') return []
|
||
if (Array.isArray(raw)) {
|
||
return raw.map((value) => String(value || '').trim()).filter(Boolean)
|
||
}
|
||
const text = String(raw).trim()
|
||
if (!text) return []
|
||
if (text.startsWith('[')) {
|
||
try {
|
||
const parsed = JSON.parse(text)
|
||
if (Array.isArray(parsed)) {
|
||
return parsed.map((value) => String(value || '').trim()).filter(Boolean)
|
||
}
|
||
} catch {
|
||
/* fall through */
|
||
}
|
||
}
|
||
return [text]
|
||
}
|
||
const mergedCustomerKeywords = [
|
||
...parseCustomerQueryParam(params.loadCustomers),
|
||
...parseCustomerQueryParam(params.deliveryCustomers)
|
||
]
|
||
delete params.loadCustomers
|
||
delete params.deliveryCustomers
|
||
if (mergedCustomerKeywords.length) {
|
||
params.stopCustomers = JSON.stringify(mergedCustomerKeywords)
|
||
}
|
||
|
||
// 归档页包含已安排运输及已取消归档的计划
|
||
params.archiveList = 1
|
||
// 仅归档列表需要单据附件聚合
|
||
params.includeDocumentAttachments = 1
|
||
|
||
if (!params.planDateFrom && !params.planDateTo) {
|
||
if (dateRange.value?.[0]) params.planDateFrom = dateRange.value[0]
|
||
if (dateRange.value?.[1]) params.planDateTo = dateRange.value[1]
|
||
}
|
||
applyContractSideQueryParams(
|
||
params,
|
||
filters.productContract as { selected?: string[] } | undefined
|
||
)
|
||
return params
|
||
}
|
||
|
||
function getPlanArchiveExportFilterParams() {
|
||
return { exportFormat: 'archive', ...buildListQueryParams() }
|
||
}
|
||
|
||
/** 列表 prop → 归档导出 field(与 PLAN_ARCHIVE_EXPORT_COLUMNS 对齐) */
|
||
const PLAN_ARCHIVE_EXPORT_COLUMN_FIELD_MAP: Record<string, string> = {
|
||
productBrand: 'brandName',
|
||
productAlias: 'aliasName',
|
||
productSpec: 'model',
|
||
productUnit: 'unit',
|
||
productContract: 'contractNo'
|
||
}
|
||
|
||
const PLAN_ARCHIVE_EXPORT_COLUMN_EXPAND: Record<string, string[]> = {
|
||
loadAddressTime: ['loadAddress', 'loadTime'],
|
||
deliveryAddressTime: ['deliveryAddress', 'deliveryTime']
|
||
}
|
||
|
||
const PLAN_ARCHIVE_EXPORT_SKIP_COLUMNS = new Set([
|
||
'documentAttachments',
|
||
'planAttachments',
|
||
'carrierName',
|
||
'personnelSummary',
|
||
'followUserName',
|
||
'belongsCompany',
|
||
'deliveryTimes'
|
||
])
|
||
|
||
const planArchiveExportColumns = computed(() => {
|
||
const cols: string[] = []
|
||
for (const col of visibleColumns.value) {
|
||
if (PLAN_ARCHIVE_EXPORT_SKIP_COLUMNS.has(col)) continue
|
||
const expanded = PLAN_ARCHIVE_EXPORT_COLUMN_EXPAND[col]
|
||
if (expanded) {
|
||
for (const field of expanded) {
|
||
if (!cols.includes(field)) cols.push(field)
|
||
}
|
||
continue
|
||
}
|
||
const field = PLAN_ARCHIVE_EXPORT_COLUMN_FIELD_MAP[col] || col
|
||
if (!cols.includes(field)) cols.push(field)
|
||
}
|
||
if (isColumnVisible('planNo') && !cols.includes('planNo')) cols.unshift('planNo')
|
||
const planNoIdx = cols.indexOf('planNo')
|
||
if (!cols.includes('stopSegment')) {
|
||
cols.splice((planNoIdx >= 0 ? planNoIdx : -1) + 1, 0, 'stopSegment')
|
||
}
|
||
if (!cols.includes('rowNo')) cols.unshift('rowNo')
|
||
const modelIdx = cols.indexOf('model')
|
||
if (!cols.includes('packageSpec')) {
|
||
if (modelIdx >= 0) cols.splice(modelIdx + 1, 0, 'packageSpec')
|
||
else cols.push('packageSpec')
|
||
}
|
||
for (const field of ['freightType', 'freightPrice', 'freightAmount', 'remark']) {
|
||
if (!cols.includes(field)) cols.push(field)
|
||
}
|
||
return cols
|
||
})
|
||
|
||
const toolbarOverflowItems = computed<ListToolbarOverflowItem[]>(() => [
|
||
{
|
||
key: 'erp',
|
||
label: 'ERP录入',
|
||
icon: DocumentChecked,
|
||
disabled: selectedRows.value.length === 0,
|
||
loading: erpBatchLoading.value,
|
||
children: [
|
||
{
|
||
key: 'entered',
|
||
label: '已录入ERP',
|
||
disabled: erpBatchLoading.value,
|
||
onClick: () => {
|
||
void handleBatchErpCommand('entered')
|
||
}
|
||
},
|
||
{
|
||
key: 'not_entered',
|
||
label: '未录入ERP',
|
||
disabled: erpBatchLoading.value,
|
||
onClick: () => {
|
||
void handleBatchErpCommand('not_entered')
|
||
}
|
||
}
|
||
]
|
||
},
|
||
overflowExportPlaceholder(),
|
||
overflowClearFiltersItem(hasActiveFilters.value, () => clearAllFilters())
|
||
])
|
||
|
||
const archiveZipMenuItems = [
|
||
{
|
||
command: 'filtered-zip',
|
||
label: '导出筛选结果(数据及附件 ZIP)',
|
||
withIds: false,
|
||
payloadExtra: { exportFormat: 'archive_zip' },
|
||
filename: '计划归档.zip'
|
||
},
|
||
{
|
||
command: 'selected-zip',
|
||
label: '导出已选(数据及附件 ZIP)',
|
||
withIds: true,
|
||
payloadExtra: { exportFormat: 'archive_zip' },
|
||
filename: '计划归档.zip'
|
||
}
|
||
]
|
||
|
||
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()
|
||
}
|
||
|
||
async function handlePlanMutationSuccess() {
|
||
await fetchData()
|
||
await refreshViewIfOpen()
|
||
await refreshMenuBadges(menuStore.menuList)
|
||
}
|
||
const selectedPlan = computed(() => (selectedRows.value.length === 1 ? selectedRows.value[0] : null))
|
||
const dateRange = ref<string[]>([])
|
||
const quickSearch = ref('')
|
||
const activePlanTypeTab = ref<PlPlanTypeTab>('all')
|
||
|
||
function getPlanTypeLabel(type: string) {
|
||
const map: Record<string, string> = { direct: '直销单', inbound: '入库单', outbound: '出库单' }
|
||
return map[type] || type
|
||
}
|
||
|
||
async function fetchData() {
|
||
loading.value = true
|
||
try {
|
||
const res = await planApi.list({
|
||
...buildListQueryParams(),
|
||
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: PlPlanTypeTab | string) {
|
||
activePlanTypeTab.value = tab as PlPlanTypeTab
|
||
pagination.page = 1
|
||
setFilterState('planType', null)
|
||
}
|
||
|
||
function handleReset() {
|
||
activePlanTypeTab.value = 'all'
|
||
quickSearch.value = ''
|
||
clearAllFilters()
|
||
resetDateShortcut()
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleQuickSearch() {
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleQuickSearchClear() {
|
||
quickSearch.value = ''
|
||
handleQuickSearch()
|
||
}
|
||
|
||
const {
|
||
activeDateShortcut,
|
||
handleDateShortcut: handleDateShortcutInner,
|
||
resetDateShortcut
|
||
} = useListDateShortcut(dateRange, handleSearch)
|
||
|
||
function handleDateShortcut(type: 'all' | 'today' | 'tomorrow' | 'yesterday' | 'week') {
|
||
if (filters.planDate) {
|
||
delete filters.planDate
|
||
}
|
||
handleDateShortcutInner(type)
|
||
}
|
||
|
||
function handlePageChange() {
|
||
fetchData()
|
||
}
|
||
|
||
function handleSizeChange() {
|
||
pagination.page = 1
|
||
fetchData()
|
||
}
|
||
|
||
function handleView(row: Plan) {
|
||
viewingPlan.value = row
|
||
viewPlanId.value = row.id
|
||
viewVisible.value = true
|
||
}
|
||
|
||
function archiveButtonLabel(row: Plan) {
|
||
return row.archiveStatus === 'archived' ? '调整' : '归档'
|
||
}
|
||
|
||
async function handleArchive(row: Plan) {
|
||
if (!canArchive.value) {
|
||
ElMessage.warning('无运输计划归档操作权限')
|
||
return
|
||
}
|
||
// 打开归档弹窗:已归档走调整;未归档/已暂存可直接打开(用证校验在「确认归档」时执行,以便支持暂存)
|
||
archivePlanId.value = row.id
|
||
archiveDialogVisible.value = true
|
||
}
|
||
|
||
function handleToolbarArchive() {
|
||
if (selectedRows.value.length !== 1) return
|
||
handleArchive(selectedRows.value[0])
|
||
}
|
||
|
||
async function handleBatchErpCommand(command: 'entered' | 'not_entered') {
|
||
const entered = command === 'entered'
|
||
const eligibleRows = selectedRows.value.filter((row) => row.followStatus !== 'cancelled')
|
||
if (eligibleRows.length === 0) {
|
||
ElMessage.warning('请选择未作废的计划')
|
||
return
|
||
}
|
||
|
||
const targets = eligibleRows.filter((row) => (Number(row.erpEntered) === 1) !== entered)
|
||
if (targets.length === 0) {
|
||
ElMessage.info(entered ? '所选计划均已录入 ERP' : '所选计划均未录入 ERP')
|
||
return
|
||
}
|
||
|
||
erpBatchLoading.value = true
|
||
try {
|
||
const results = await Promise.allSettled(
|
||
targets.map((row) => planApi.setErpEntered(row.id, entered))
|
||
)
|
||
let successCount = 0
|
||
results.forEach((result, index) => {
|
||
const row = targets[index]
|
||
if (result.status === 'fulfilled') {
|
||
const data = pickBxData<Plan>(result.value)
|
||
row.erpEntered = data?.erpEntered ?? (entered ? 1 : 0)
|
||
successCount += 1
|
||
return
|
||
}
|
||
const message =
|
||
result.reason instanceof Error ? result.reason.message : '更新 ERP 状态失败'
|
||
ElMessage.error(
|
||
`${row.planNo || row.id}:${message.includes('失败') ? message : `更新 ERP 状态失败:${message}`}`
|
||
)
|
||
})
|
||
|
||
if (successCount > 0) {
|
||
ElMessage.success(
|
||
entered ? `已将 ${successCount} 条计划标记为已录入 ERP` : `已将 ${successCount} 条计划标记为未录入 ERP`
|
||
)
|
||
await refreshViewIfOpen()
|
||
}
|
||
} finally {
|
||
erpBatchLoading.value = false
|
||
}
|
||
}
|
||
|
||
useDbInstantSearch(
|
||
() => ({
|
||
...toQueryParams(),
|
||
dateRange: dateRange.value,
|
||
tab: activePlanTypeTab.value
|
||
}),
|
||
() => {
|
||
quickSearch.value = ''
|
||
handleSearch()
|
||
}
|
||
)
|
||
|
||
onMounted(() => {
|
||
loadArchivePermissions()
|
||
fetchData()
|
||
|
||
nextTick(() => recalcTableHeight())
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
@use '@styles/business/pl-plan-merge-list-table.scss';
|
||
|
||
.bx-list-table-wrap {
|
||
min-width: 0;
|
||
}
|
||
|
||
.pl-plan-list-toolbar-row {
|
||
flex-wrap: nowrap;
|
||
overflow: hidden;
|
||
|
||
> .list-toolbar-date-shortcuts,
|
||
> .quick-search-input,
|
||
> .quick-search-group,
|
||
> .el-button,
|
||
> .list-toolbar-end {
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
> .list-toolbar-end {
|
||
margin-left: 0;
|
||
}
|
||
}
|
||
|
||
.pl-plan-archive-erp-cell {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
|
||
.pl-plan-archive-erp-checkbox {
|
||
pointer-events: none;
|
||
cursor: default;
|
||
}
|
||
|
||
.pl-delivery-times-cell {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 2px;
|
||
line-height: 1.35;
|
||
}
|
||
</style>
|