提交
This commit is contained in:
1 parent
4611dbc2b2
commit
ebf006eeff
46 files changed
+36802
-20974
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<!-- eslint-disable vue/no-v-model-argument -->
|
||||
<!-- 运输计划合同完善:仅缺合同计划,行内展开分侧保存 -->
|
||||
<!-- 运输计划合同完善:仅缺合同计划,按段次客户弹窗补充合同 -->
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<section class="panel">
|
||||
@@ -17,15 +17,15 @@
|
||||
<el-form-item label="缺口类型">
|
||||
<el-select v-model="searchForm.gapType" placeholder="全部缺口" clearable>
|
||||
<el-option label="全部缺口" value="" />
|
||||
<el-option label="仅缺供方合同" value="supplier" />
|
||||
<el-option label="仅缺需方合同" value="demander" />
|
||||
<el-option label="两侧均缺" value="both" />
|
||||
<el-option label="装货段缺合同" value="supplier" />
|
||||
<el-option label="送货段缺合同" value="demander" />
|
||||
<el-option label="装货与送货均缺" value="both" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="供方 / 需方">
|
||||
<el-form-item label="客户名称">
|
||||
<el-input
|
||||
v-model="searchForm.customerKeyword"
|
||||
placeholder="客户名称"
|
||||
placeholder="段次客户名称"
|
||||
clearable
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
@@ -66,7 +66,7 @@
|
||||
/>
|
||||
<ListQuickSearchInput
|
||||
v-model="quickSearch"
|
||||
placeholder="计划编号/供方/需方"
|
||||
placeholder="计划编号/客户名称"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
/>
|
||||
@@ -87,107 +87,14 @@
|
||||
|
||||
<div class="list-body list-wrap">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
class="list-table pl-plan-merge-list-table"
|
||||
:data="displayRows"
|
||||
v-loading="loading"
|
||||
row-key="rowKey"
|
||||
:span-method="planListSpanMethod"
|
||||
:row-class-name="getPlPlanListRowClassName"
|
||||
:expand-row-keys="expandedRowKeys"
|
||||
@expand-change="handleExpandChange"
|
||||
@row-dblclick="handleDisplayRowDblClick"
|
||||
>
|
||||
<el-table-column type="expand" class-name="pl-contract-expand-col" width="1">
|
||||
<template #default="{ row }">
|
||||
<div class="pl-contract-expand" v-if="expandDraft[row.plan.id]">
|
||||
<div class="pl-contract-expand__grid">
|
||||
<div
|
||||
class="pl-contract-side"
|
||||
:class="sideBoxClass(asGapItem(row), 'supplier')"
|
||||
>
|
||||
<div class="pl-contract-side__head">
|
||||
<h4>供方合同</h4>
|
||||
<el-tag
|
||||
:type="sideTagType(asGapItem(row), 'supplier')"
|
||||
size="small"
|
||||
:effect="asGapItem(row).supplierContractExempt ? 'plain' : 'dark'"
|
||||
>
|
||||
{{ sideTagLabel(asGapItem(row), 'supplier') }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p class="pl-contract-side__customer">
|
||||
{{ asGapItem(row).supplierName || '—' }}
|
||||
</p>
|
||||
<template v-if="asGapItem(row).supplierContractExempt">
|
||||
<p class="pl-contract-side__exempt">内置公司,合同可免</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="expandDraft[row.plan.id].supplierContracts"
|
||||
:customer-id="asGapItem(row).supplierId"
|
||||
:disabled="!asGapItem(row).supplierId"
|
||||
:required="false"
|
||||
/>
|
||||
<div class="pl-contract-side__actions">
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="savingKey === `${row.plan.id}:supplier`"
|
||||
@click="handleSaveSide(asGapItem(row), 'supplier')"
|
||||
>
|
||||
<el-icon><Check /></el-icon>保存供方合同
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="pl-contract-side"
|
||||
:class="sideBoxClass(asGapItem(row), 'demander')"
|
||||
>
|
||||
<div class="pl-contract-side__head">
|
||||
<h4>需方合同</h4>
|
||||
<el-tag
|
||||
:type="sideTagType(asGapItem(row), 'demander')"
|
||||
size="small"
|
||||
:effect="asGapItem(row).demanderContractExempt ? 'plain' : 'dark'"
|
||||
>
|
||||
{{ sideTagLabel(asGapItem(row), 'demander') }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p class="pl-contract-side__customer">
|
||||
{{ asGapItem(row).customerName || '—' }}
|
||||
</p>
|
||||
<template v-if="asGapItem(row).demanderContractExempt">
|
||||
<p class="pl-contract-side__exempt">内置公司,合同可免</p>
|
||||
</template>
|
||||
<template v-else>
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="expandDraft[row.plan.id].demanderContracts"
|
||||
:customer-id="asGapItem(row).customerId"
|
||||
:disabled="!asGapItem(row).customerId"
|
||||
:required="false"
|
||||
/>
|
||||
<div class="pl-contract-side__actions">
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="savingKey === `${row.plan.id}:demander`"
|
||||
@click="handleSaveSide(asGapItem(row), 'demander')"
|
||||
>
|
||||
<el-icon><Check /></el-icon>保存需方合同
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="序号"
|
||||
@@ -278,28 +185,19 @@
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="pl-gap-contract-cell">
|
||||
<div class="pl-plan-contract-cell">
|
||||
<div
|
||||
v-for="(line, index) in getContractGapStopLines(row)"
|
||||
:key="`${line.side}-${line.no}-${index}`"
|
||||
class="pl-plan-contract-cell__row"
|
||||
>
|
||||
<span class="pl-plan-contract-cell__side">{{ line.side }}</span>
|
||||
<span
|
||||
class="pl-plan-contract-cell__no"
|
||||
:class="{ 'is-pending': line.pending }"
|
||||
>{{ line.no }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<PlPlanContractCell
|
||||
:lines="getContractGapStopLines(row)"
|
||||
@open="openContractDetail"
|
||||
/>
|
||||
<el-button
|
||||
v-if="showGapSupplementAction(row)"
|
||||
link
|
||||
type="warning"
|
||||
class="pl-gap-contract-cell__action"
|
||||
@click.stop="toggleExpand(asGapItem(row))"
|
||||
@click.stop="openSupplementDialog(row)"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>
|
||||
{{ isExpanded(asGapItem(row).id) ? '收起' : '补充' }}
|
||||
补充
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -382,6 +280,7 @@
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<PlPlanListProductCell
|
||||
:stop-kind="row.kind"
|
||||
:stop-products="getStopProducts(row)"
|
||||
:plan-products="asGapItem(row).products"
|
||||
field="actualQty"
|
||||
@@ -441,22 +340,108 @@
|
||||
:plan-id="viewPlanId"
|
||||
show-inbound-outbound-qty
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
v-model="supplementVisible"
|
||||
class="dialog-form-layout pl-contract-supplement-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
width="960px"
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
:before-close="handleSupplementBeforeClose"
|
||||
>
|
||||
<template #header>
|
||||
<span class="pl-contract-supplement-dialog__title">
|
||||
补充合同 · {{ supplementStopKindLabel }} · {{ supplementPlanNo }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<div v-if="supplementRow" class="pl-contract-supplement-body">
|
||||
<div class="pl-contract-supplement-summary">
|
||||
<div class="pl-contract-supplement-kv">
|
||||
<div class="k">计划日期</div>
|
||||
<div class="v">{{ asGapItem(supplementRow).planDate || '—' }}</div>
|
||||
</div>
|
||||
<div class="pl-contract-supplement-kv">
|
||||
<div class="k">跟进状态</div>
|
||||
<div class="v">
|
||||
<el-tag
|
||||
:type="getPlPlanFollowStatusTagType(asGapItem(supplementRow).followStatus)"
|
||||
size="small"
|
||||
effect="dark"
|
||||
>
|
||||
{{ getPlPlanFollowStatusLabel(asGapItem(supplementRow).followStatus) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pl-contract-supplement-kv">
|
||||
<div class="k">本段客户</div>
|
||||
<div class="v">{{ getStopCustomerName(supplementRow) }}</div>
|
||||
</div>
|
||||
<div class="pl-contract-supplement-kv">
|
||||
<div class="k">地址 / 时间</div>
|
||||
<div class="v">
|
||||
{{ getStopAddress(supplementRow) }}
|
||||
<template v-if="getStopTime(supplementRow)">
|
||||
· {{ getStopTime(supplementRow) }}
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pl-contract-side" :class="supplementSideBoxClass">
|
||||
<div class="pl-contract-side__head">
|
||||
<h4>{{ supplementStopKindLabel }}合同</h4>
|
||||
<el-tag :type="supplementSideTagType" size="small" effect="dark">
|
||||
{{ supplementSideTagLabel }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p class="pl-contract-side__customer">{{ getStopCustomerName(supplementRow) }}</p>
|
||||
<PlPlanContractMultiSelect
|
||||
v-model="supplementDraft.contracts"
|
||||
:customer-id="supplementRow.stop.customerId"
|
||||
:disabled="!supplementRow.stop.customerId"
|
||||
:required="false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="requestCloseSupplement">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-main"
|
||||
type="primary"
|
||||
:disabled="!supplementDraft.stopId || !supplementRow?.stop.customerId"
|
||||
:loading="supplementSaving"
|
||||
@click="handleSaveStopContracts"
|
||||
>
|
||||
<el-icon><Check /></el-icon>保存本段合同
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Check, EditPen, Refresh, RefreshLeft, Search } from '@element-plus/icons-vue'
|
||||
import { Check, Close, EditPen, Refresh, RefreshLeft, Search } from '@element-plus/icons-vue'
|
||||
import {
|
||||
planApi,
|
||||
type PlanContractGapItem,
|
||||
type PlanContractLink
|
||||
} from '@/api/pl'
|
||||
import PlPlanContractCell from '@/components/business/pl-plan-contract-cell/index.vue'
|
||||
import PlPlanContractMultiSelect from '@/components/business/pl-plan-contract-multi-select/index.vue'
|
||||
import PlPlanListProductCell from '@/components/business/pl-plan-list-product-cell/index.vue'
|
||||
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import ListToolbarDateShortcuts from '@/components/core/list-toolbar-date-shortcuts/index.vue'
|
||||
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
|
||||
import { useListDateShortcut } from '@/composables/useListDateShortcut'
|
||||
import { usePlPlanMergeListTable } from '@/composables/usePlPlanMergeListTable'
|
||||
import {
|
||||
@@ -481,24 +466,29 @@ import { useMenuStore } from '@/store/modules/menu'
|
||||
const PLAN_MERGE_COLUMN_PROPS = ['planDate', 'planType', 'followStatus'] as const
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail } = useContractDetailDialog()
|
||||
const loading = ref(false)
|
||||
const tableRef = ref()
|
||||
const tableData = ref<PlanContractGapItem[]>([])
|
||||
const dateRange = ref<string[]>([])
|
||||
const quickSearch = ref('')
|
||||
const expandedRowKeys = ref<string[]>([])
|
||||
const expandDraft = reactive<
|
||||
Record<
|
||||
string,
|
||||
{
|
||||
supplierContracts: PlanContractLink[]
|
||||
demanderContracts: PlanContractLink[]
|
||||
baselineSupplier: string
|
||||
baselineDemander: string
|
||||
}
|
||||
>
|
||||
>({})
|
||||
const savingKey = ref('')
|
||||
const supplementVisible = ref(false)
|
||||
const supplementSaving = ref(false)
|
||||
const supplementRow = ref<PlPlanListDisplayRow | null>(null)
|
||||
const supplementDraft = reactive<{
|
||||
contracts: PlanContractLink[]
|
||||
baseline: string
|
||||
stopType: 'load' | 'delivery'
|
||||
stopId: string
|
||||
planId: string
|
||||
rowKey: string
|
||||
}>({
|
||||
contracts: [],
|
||||
baseline: '',
|
||||
stopType: 'load',
|
||||
stopId: '',
|
||||
planId: '',
|
||||
rowKey: ''
|
||||
})
|
||||
const viewDialogRef = ref<InstanceType<typeof PlPlanViewDialog>>()
|
||||
const viewVisible = ref(false)
|
||||
const viewPlanId = ref('')
|
||||
@@ -523,8 +513,7 @@ const {
|
||||
displayRows,
|
||||
planListSpanMethod,
|
||||
getDisplayRowIndex,
|
||||
handleDisplayRowDblClick,
|
||||
findPlanFirstDisplayRow
|
||||
handleDisplayRowDblClick
|
||||
} = usePlPlanMergeListTable({
|
||||
planList: planListForDisplay,
|
||||
visiblePlanMergeProps,
|
||||
@@ -533,11 +522,28 @@ const {
|
||||
onView: (plan) => handleView(plan as unknown as PlanContractGapItem)
|
||||
})
|
||||
|
||||
const supplementStopKindLabel = computed(() =>
|
||||
supplementRow.value ? getStopKindLabel(supplementRow.value) : ''
|
||||
)
|
||||
const supplementPlanNo = computed(() =>
|
||||
supplementRow.value ? asGapItem(supplementRow.value).planNo || '—' : '—'
|
||||
)
|
||||
const supplementSideBoxClass = computed(() => {
|
||||
if (!supplementDraft.contracts.length) return 'is-need'
|
||||
return 'is-ok'
|
||||
})
|
||||
const supplementSideTagLabel = computed(() =>
|
||||
supplementDraft.contracts.length ? '已选' : '待补充'
|
||||
)
|
||||
const supplementSideTagType = computed(() =>
|
||||
supplementDraft.contracts.length ? 'success' : 'warning'
|
||||
)
|
||||
|
||||
function asGapItem(row: PlPlanListDisplayRow): PlanContractGapItem {
|
||||
return row.plan as unknown as PlanContractGapItem
|
||||
}
|
||||
|
||||
/** 段内合同缺口:装货行展示供方,送货行展示需方 */
|
||||
/** 段内合同:优先段上 contracts;无则回退旧计划级供/需合同 */
|
||||
function getContractGapStopLines(row: PlPlanListDisplayRow) {
|
||||
if ((row.stop.contracts?.length ?? 0) > 0) {
|
||||
return getStopContractLines(row)
|
||||
@@ -557,16 +563,19 @@ function getContractGapStopLines(row: PlPlanListDisplayRow) {
|
||||
)
|
||||
}
|
||||
|
||||
function showGapSupplementAction(row: PlPlanListDisplayRow): boolean {
|
||||
const gap = asGapItem(row)
|
||||
if (row.kind === 'load') {
|
||||
return !gap.supplierContractExempt && (gap.gapSides || []).includes('supplier')
|
||||
}
|
||||
return !gap.demanderContractExempt && (gap.gapSides || []).includes('demander')
|
||||
function isStopContractExempt(row: PlPlanListDisplayRow): boolean {
|
||||
return isPlInternalCustomerName(getStopCustomerName(row))
|
||||
}
|
||||
|
||||
function gapExpandRowKey(planId: string) {
|
||||
return `${planId}-load`
|
||||
function stopHasContracts(row: PlPlanListDisplayRow): boolean {
|
||||
return getContractGapStopLines(row).some((line) => !!line.contractId && !line.pending)
|
||||
}
|
||||
|
||||
/** 仅非内置客户、且本段缺合同时显示「补充」 */
|
||||
function showGapSupplementAction(row: PlPlanListDisplayRow): boolean {
|
||||
if (isStopContractExempt(row)) return false
|
||||
if (!row.stop.id) return false
|
||||
return !stopHasContracts(row)
|
||||
}
|
||||
|
||||
function getContractGapExportFilterParams() {
|
||||
@@ -591,17 +600,17 @@ const contractGapExportColumns = [
|
||||
'gapType'
|
||||
]
|
||||
|
||||
|
||||
function cloneLinks(links?: PlanContractLink[]): PlanContractLink[] {
|
||||
return (links || []).map(item => ({
|
||||
return (links || []).map((item) => ({
|
||||
contractId: item.contractId,
|
||||
contractNo: item.contractNo
|
||||
contractNo: item.contractNo,
|
||||
stopId: item.stopId
|
||||
}))
|
||||
}
|
||||
|
||||
function linksFingerprint(links: PlanContractLink[]) {
|
||||
return cloneLinks(links)
|
||||
.map(item => item.contractId)
|
||||
.map((item) => item.contractId)
|
||||
.sort()
|
||||
.join(',')
|
||||
}
|
||||
@@ -615,116 +624,75 @@ function getPlanTypeLabel(type?: string | null) {
|
||||
return type ? map[type] || type : '—'
|
||||
}
|
||||
|
||||
function sideBoxClass(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
const exempt = side === 'supplier' ? row.supplierContractExempt : row.demanderContractExempt
|
||||
if (exempt) return 'is-exempt'
|
||||
const missing = (row.gapSides || []).includes(side)
|
||||
return missing ? 'is-need' : 'is-ok'
|
||||
function resolveStopDraftContracts(row: PlPlanListDisplayRow): PlanContractLink[] {
|
||||
if ((row.stop.contracts?.length ?? 0) > 0) {
|
||||
return cloneLinks(row.stop.contracts)
|
||||
}
|
||||
const gap = asGapItem(row)
|
||||
if (row.kind === 'load') return cloneLinks(gap.supplierContracts)
|
||||
return cloneLinks(gap.demanderContracts)
|
||||
}
|
||||
|
||||
function sideTagLabel(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
const exempt = side === 'supplier' ? row.supplierContractExempt : row.demanderContractExempt
|
||||
if (exempt) return '可免'
|
||||
return (row.gapSides || []).includes(side) ? '待补充' : '已齐'
|
||||
function isSupplementDirty() {
|
||||
return linksFingerprint(supplementDraft.contracts) !== supplementDraft.baseline
|
||||
}
|
||||
|
||||
function sideTagType(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
const exempt = side === 'supplier' ? row.supplierContractExempt : row.demanderContractExempt
|
||||
if (exempt) return 'info'
|
||||
return (row.gapSides || []).includes(side) ? 'warning' : 'success'
|
||||
function resetSupplementDraft() {
|
||||
supplementRow.value = null
|
||||
supplementDraft.contracts = []
|
||||
supplementDraft.baseline = ''
|
||||
supplementDraft.stopType = 'load'
|
||||
supplementDraft.stopId = ''
|
||||
supplementDraft.planId = ''
|
||||
supplementDraft.rowKey = ''
|
||||
}
|
||||
|
||||
function isExpanded(id: string) {
|
||||
return expandedRowKeys.value.includes(gapExpandRowKey(id))
|
||||
function openSupplementDialog(row: PlPlanListDisplayRow) {
|
||||
if (!row.stop.id) {
|
||||
ElMessage.warning('该段次缺少段 ID,无法补充合同')
|
||||
return
|
||||
}
|
||||
if (isStopContractExempt(row)) {
|
||||
ElMessage.info('内置客户无需补充合同')
|
||||
return
|
||||
}
|
||||
const contracts = resolveStopDraftContracts(row)
|
||||
supplementRow.value = row
|
||||
supplementDraft.contracts = contracts
|
||||
supplementDraft.baseline = linksFingerprint(contracts)
|
||||
supplementDraft.stopType = row.kind
|
||||
supplementDraft.stopId = String(row.stop.id || '').trim()
|
||||
supplementDraft.planId = row.plan.id
|
||||
supplementDraft.rowKey = row.rowKey
|
||||
supplementVisible.value = true
|
||||
}
|
||||
|
||||
function ensureDraft(row: PlanContractGapItem) {
|
||||
if (expandDraft[row.id]) return
|
||||
const supplierContracts = cloneLinks(row.supplierContracts)
|
||||
const demanderContracts = cloneLinks(row.demanderContracts)
|
||||
expandDraft[row.id] = {
|
||||
supplierContracts,
|
||||
demanderContracts,
|
||||
baselineSupplier: linksFingerprint(supplierContracts),
|
||||
baselineDemander: linksFingerprint(demanderContracts)
|
||||
async function confirmDiscardIfDirty(): Promise<boolean> {
|
||||
if (!isSupplementDirty()) return true
|
||||
try {
|
||||
await ElMessageBox.confirm('当前有未保存的合同变更,确认关闭吗?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '关闭',
|
||||
cancelButtonText: '继续编辑'
|
||||
})
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function isDraftDirty(id: string) {
|
||||
const draft = expandDraft[id]
|
||||
if (!draft) return false
|
||||
return (
|
||||
linksFingerprint(draft.supplierContracts) !== draft.baselineSupplier ||
|
||||
linksFingerprint(draft.demanderContracts) !== draft.baselineDemander
|
||||
)
|
||||
async function requestCloseSupplement() {
|
||||
const ok = await confirmDiscardIfDirty()
|
||||
if (!ok) return
|
||||
supplementVisible.value = false
|
||||
resetSupplementDraft()
|
||||
}
|
||||
|
||||
async function collapseRow(id: string) {
|
||||
if (isDraftDirty(id)) {
|
||||
try {
|
||||
await ElMessageBox.confirm('当前有未保存的合同变更,确认收起吗?', '提示', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '收起',
|
||||
cancelButtonText: '继续编辑'
|
||||
})
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
delete expandDraft[id]
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter((key) => key !== gapExpandRowKey(id))
|
||||
return true
|
||||
}
|
||||
|
||||
async function expandRow(row: PlanContractGapItem) {
|
||||
const currentKey = expandedRowKeys.value[0]
|
||||
const currentId = currentKey?.replace(/-load$/, '')
|
||||
if (currentId && currentId !== row.id) {
|
||||
const ok = await collapseRow(currentId)
|
||||
if (!ok) return
|
||||
}
|
||||
ensureDraft(row)
|
||||
expandedRowKeys.value = [gapExpandRowKey(row.id)]
|
||||
}
|
||||
|
||||
async function toggleExpand(row: PlanContractGapItem) {
|
||||
if (isExpanded(row.id)) {
|
||||
await collapseRow(row.id)
|
||||
} else {
|
||||
await expandRow(row)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExpandChange(
|
||||
displayRow: PlPlanListDisplayRow,
|
||||
expandedRows: PlPlanListDisplayRow[]
|
||||
) {
|
||||
const gap = asGapItem(displayRow)
|
||||
const willExpand = expandedRows.some((item) => item.rowKey === displayRow.rowKey)
|
||||
if (willExpand) {
|
||||
const currentKey = expandedRowKeys.value[0]
|
||||
const currentId = currentKey?.replace(/-load$/, '')
|
||||
if (currentId && currentId !== gap.id) {
|
||||
const ok = await collapseRow(currentId)
|
||||
if (!ok) {
|
||||
nextTick(() => {
|
||||
const firstRow = findPlanFirstDisplayRow(gap.id)
|
||||
if (firstRow) tableRef.value?.toggleRowExpansion?.(firstRow, false)
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
ensureDraft(gap)
|
||||
expandedRowKeys.value = [gapExpandRowKey(gap.id)]
|
||||
} else if (expandedRowKeys.value.includes(gapExpandRowKey(gap.id))) {
|
||||
const ok = await collapseRow(gap.id)
|
||||
if (!ok) {
|
||||
nextTick(() => {
|
||||
const firstRow = findPlanFirstDisplayRow(gap.id)
|
||||
if (firstRow) tableRef.value?.toggleRowExpansion?.(firstRow, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
async function handleSupplementBeforeClose(done: () => void) {
|
||||
const ok = await confirmDiscardIfDirty()
|
||||
if (!ok) return
|
||||
resetSupplementDraft()
|
||||
done()
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
@@ -744,15 +712,6 @@ async function fetchData() {
|
||||
const data = (res as any).data ?? res
|
||||
tableData.value = data.list || []
|
||||
pagination.total = data.total || 0
|
||||
// 收起已不在列表中的展开行
|
||||
const ids = new Set(tableData.value.map((item) => item.id))
|
||||
expandedRowKeys.value = expandedRowKeys.value.filter((key) => {
|
||||
const planId = key.replace(/-load$/, '')
|
||||
return ids.has(planId)
|
||||
})
|
||||
Object.keys(expandDraft).forEach(id => {
|
||||
if (!ids.has(id)) delete expandDraft[id]
|
||||
})
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -804,37 +763,37 @@ function handleView(row: PlanContractGapItem) {
|
||||
viewVisible.value = true
|
||||
}
|
||||
|
||||
async function handleSaveSide(row: PlanContractGapItem, side: 'supplier' | 'demander') {
|
||||
const draft = expandDraft[row.id]
|
||||
if (!draft) return
|
||||
const contracts =
|
||||
side === 'supplier' ? draft.supplierContracts : draft.demanderContracts
|
||||
savingKey.value = `${row.id}:${side}`
|
||||
async function handleSaveStopContracts() {
|
||||
if (!supplementDraft.stopId) {
|
||||
ElMessage.warning('该段次缺少段 ID,无法保存')
|
||||
return
|
||||
}
|
||||
if (!supplementRow.value?.stop.customerId) {
|
||||
ElMessage.warning('请先维护本段客户后再选择合同')
|
||||
return
|
||||
}
|
||||
if (!supplementDraft.contracts.length) {
|
||||
ElMessage.warning('请先选择至少 1 份合同')
|
||||
return
|
||||
}
|
||||
supplementSaving.value = true
|
||||
try {
|
||||
const res = await planApi.updateSideContracts(row.id, side, contracts)
|
||||
const updated = ((res as any).data ?? res) as PlanContractGapItem
|
||||
ElMessage.success(side === 'supplier' ? '供方合同已保存' : '需方合同已保存')
|
||||
await planApi.updateStopContracts(supplementDraft.planId, {
|
||||
stopType: supplementDraft.stopType,
|
||||
stopId: supplementDraft.stopId,
|
||||
contracts: supplementDraft.contracts
|
||||
})
|
||||
ElMessage.success('本段合同已保存')
|
||||
|
||||
if (!(updated.gapSides || []).length) {
|
||||
tableData.value = tableData.value.filter(item => item.id !== row.id)
|
||||
pagination.total = Math.max(0, pagination.total - 1)
|
||||
delete expandDraft[row.id]
|
||||
expandedRowKeys.value = []
|
||||
await refreshMenuBadges(menuStore.menuList)
|
||||
return
|
||||
}
|
||||
// 先对齐 baseline,避免关闭时被 before-close 当成未保存变更
|
||||
supplementDraft.baseline = linksFingerprint(supplementDraft.contracts)
|
||||
supplementVisible.value = false
|
||||
resetSupplementDraft()
|
||||
|
||||
const idx = tableData.value.findIndex(item => item.id === row.id)
|
||||
if (idx >= 0) {
|
||||
tableData.value[idx] = updated
|
||||
}
|
||||
draft.supplierContracts = cloneLinks(updated.supplierContracts)
|
||||
draft.demanderContracts = cloneLinks(updated.demanderContracts)
|
||||
draft.baselineSupplier = linksFingerprint(draft.supplierContracts)
|
||||
draft.baselineDemander = linksFingerprint(draft.demanderContracts)
|
||||
await fetchData()
|
||||
await refreshMenuBadges(menuStore.menuList)
|
||||
} finally {
|
||||
savingKey.value = ''
|
||||
supplementSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -873,21 +832,48 @@ onMounted(() => {
|
||||
border: 1px solid rgba(217, 119, 6, 0.2);
|
||||
}
|
||||
|
||||
.pl-contract-expand {
|
||||
padding: 12px 16px 16px;
|
||||
background: #f8fffb;
|
||||
border-top: 1px dashed #a7f3d0;
|
||||
.pl-contract-supplement-dialog__title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text, #1e293b);
|
||||
}
|
||||
|
||||
.pl-contract-expand__grid {
|
||||
.pl-contract-supplement-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.pl-contract-supplement-summary {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 14px;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
padding: 12px 14px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #eef2f6;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.pl-contract-expand__grid {
|
||||
grid-template-columns: 1fr;
|
||||
@media (max-width: 700px) {
|
||||
.pl-contract-supplement-summary {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-contract-supplement-kv {
|
||||
min-width: 0;
|
||||
|
||||
.k {
|
||||
font-size: 11px;
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
}
|
||||
|
||||
.v {
|
||||
margin-top: 2px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--text, #1e293b);
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,7 +881,7 @@ onMounted(() => {
|
||||
background: #fff;
|
||||
border: 1px solid var(--el-border-color, #d9e8e2);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.pl-contract-side.is-need {
|
||||
@@ -908,11 +894,6 @@ onMounted(() => {
|
||||
background: #f6fffb;
|
||||
}
|
||||
|
||||
.pl-contract-side.is-exempt {
|
||||
border-color: #e2e8f0;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.pl-contract-side__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -922,43 +903,16 @@ onMounted(() => {
|
||||
|
||||
h4 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-contract-side__customer {
|
||||
margin: 0 0 10px;
|
||||
margin: 0 0 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.pl-contract-side__exempt {
|
||||
margin: 0;
|
||||
padding: 14px;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary, #64748b);
|
||||
font-size: 12px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.pl-contract-side__actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
:deep(.pl-contract-expand-col) {
|
||||
.cell {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.el-table__expand-icon {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.pl-gap-contract-cell {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
||||
Reference in new issue
Block a user