提交
This commit is contained in:
1 parent
98531845e4
commit
1ba1f38321
107 files changed
+65567
-36568
No files matched your search
@@ -2765,6 +2765,10 @@ const handleSaveDraft = async () => {
|
||||
for (let i = 0; i < form.value.products.length; i++) {
|
||||
const product = form.value.products[i]
|
||||
const rowNum = i + 1
|
||||
if (!product.productId || String(product.productId).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行请从产品库选择产品`)
|
||||
return
|
||||
}
|
||||
if (!product.productName || product.productName.trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行产品的产品名称不能为空`)
|
||||
return
|
||||
@@ -2816,6 +2820,10 @@ const handleSubmit = async () => {
|
||||
const requiresProducts = form.value.contractType === 'sale' || form.value.contractType === 'purchase' || isFrameworkContractType(form.value.contractType)
|
||||
|
||||
const validateProductRowCommon = (product: any, rowNum: number): boolean => {
|
||||
if (!product.productId || String(product.productId).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行请从产品库选择产品`)
|
||||
return false
|
||||
}
|
||||
if (!product.productName || String(product.productName).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行产品的产品名称不能为空`)
|
||||
return false
|
||||
|
||||
@@ -1841,6 +1841,10 @@ const handleSubmit = async () => {
|
||||
const requiresProducts = form.value.contractType === 'sale' || form.value.contractType === 'purchase' || isFrameworkContractType(form.value.contractType);
|
||||
|
||||
const validateProductRowCommon = (product: any, rowNum: number): boolean => {
|
||||
if (!product.productId || String(product.productId).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行请从产品库选择产品`);
|
||||
return false;
|
||||
}
|
||||
if (!product.productName || String(product.productName).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行产品的产品名称不能为空`);
|
||||
return false;
|
||||
|
||||
@@ -666,6 +666,7 @@ import {
|
||||
resolveAliasFromSavedName
|
||||
} from '@/utils/crm-product-brand'
|
||||
import { fetchProductDetail } from '@/api/crm/product'
|
||||
import { partitionQuoteLinesForCopy } from '@/utils/crm-quote-copy-products'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -1380,9 +1381,29 @@ const getQuoteInfoForCopy = async (copyId: string | number) => {
|
||||
});
|
||||
}
|
||||
|
||||
// 复制产品明细 - 将产品数量设置为0,其他信息完全复制
|
||||
// 复制产品明细:仅带入当前仍上架的产品,数量置 0
|
||||
if (quoteData.productList && Array.isArray(quoteData.productList)) {
|
||||
form.value.products = quoteData.productList.map((item: any) => ({
|
||||
const sourceLines = quoteData.productList as any[]
|
||||
const detailCache = new Map<string, any>()
|
||||
const uniqueIds = [
|
||||
...new Set(
|
||||
sourceLines
|
||||
.map((item) => String(item.productId ?? '').trim())
|
||||
.filter(Boolean)
|
||||
)
|
||||
]
|
||||
await Promise.all(
|
||||
uniqueIds.map(async (id) => {
|
||||
try {
|
||||
const res: any = await fetchProductDetail({ id })
|
||||
detailCache.set(id, res?.data ?? res ?? null)
|
||||
} catch {
|
||||
detailCache.set(id, null)
|
||||
}
|
||||
})
|
||||
)
|
||||
const { kept, skippedNames } = partitionQuoteLinesForCopy(sourceLines, detailCache)
|
||||
form.value.products = kept.map((item: any) => ({
|
||||
id: undefined, // 清空产品ID,为新增
|
||||
productId: item.productId,
|
||||
productName: item.productName,
|
||||
@@ -1406,7 +1427,12 @@ const getQuoteInfoForCopy = async (copyId: string | number) => {
|
||||
brandName: item.brandName || undefined,
|
||||
brandOptions: []
|
||||
}))
|
||||
await enrichQuoteProductBrandMeta(form.value.products)
|
||||
await enrichQuoteProductBrandMeta(form.value.products, detailCache)
|
||||
if (skippedNames.length) {
|
||||
$modal.msgWarning(
|
||||
`以下产品因已下架无法带入,请重新选择:${skippedNames.join('、')}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 清空附件
|
||||
@@ -1774,13 +1800,20 @@ function handleAliasBrandManaged(product: Record<string, any>) {
|
||||
)
|
||||
}
|
||||
|
||||
async function enrichQuoteProductBrandMeta(lines: QuoteProductForm[]) {
|
||||
async function enrichQuoteProductBrandMeta(
|
||||
lines: QuoteProductForm[],
|
||||
detailCache?: Map<string, any>
|
||||
) {
|
||||
await Promise.all(
|
||||
(lines || []).map(async (line) => {
|
||||
if (!line.productId) return
|
||||
try {
|
||||
const res: any = await fetchProductDetail({ id: String(line.productId) })
|
||||
const data = res?.data ?? res
|
||||
const cacheKey = String(line.productId)
|
||||
let data = detailCache?.get(cacheKey)
|
||||
if (!data) {
|
||||
const res: any = await fetchProductDetail({ id: cacheKey })
|
||||
data = res?.data ?? res
|
||||
}
|
||||
if (!data) return
|
||||
const meta = initLineBrandMetaFromProduct(data)
|
||||
line.standardProductName = meta.standardProductName
|
||||
@@ -2063,6 +2096,11 @@ const handleSaveDraft = () => {
|
||||
const product = form.value.products[i];
|
||||
const rowNum = i + 1;
|
||||
|
||||
if (!product.productId || String(product.productId).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行请从产品库选择产品`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!product.productName || product.productName.trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行产品的产品名称不能为空`);
|
||||
return;
|
||||
@@ -2169,6 +2207,11 @@ const handleSubmit = async () => {
|
||||
const product = form.value.products[i];
|
||||
const rowNum = i + 1;
|
||||
|
||||
if (!product.productId || String(product.productId).trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行请从产品库选择产品`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!product.productName || product.productName.trim() === '') {
|
||||
$modal.msgWarning(`第${rowNum}行产品的产品名称不能为空`);
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { ColumnFilterDef } from '@/composables/useClientColumnFilters'
|
||||
|
||||
/** 运费结算 · 未结算计划列头漏斗(服务端)。承运商 ID 在工具栏。 */
|
||||
/** 运费结算 · 未结算计划列头漏斗(服务端)。工具栏另有承运商 ID 精确筛选。 */
|
||||
export const plFreightUnsettledColumnFilterDefs: ColumnFilterDef[] = [
|
||||
{ prop: 'planNo', label: '计划编号', type: 'text', queryKey: 'planNo' },
|
||||
{
|
||||
@@ -14,5 +14,39 @@ export const plFreightUnsettledColumnFilterDefs: ColumnFilterDef[] = [
|
||||
{ value: 'outbound', label: '出库单' }
|
||||
]
|
||||
},
|
||||
{ prop: 'licensePlate', label: '车牌号', type: 'text', queryKey: 'licensePlate' }
|
||||
{ prop: 'licensePlate', label: '车牌号', type: 'text', queryKey: 'licensePlate' },
|
||||
{ prop: 'transportCompany', label: '承运商', type: 'text', queryKey: 'transportCompany' },
|
||||
{
|
||||
prop: 'freightAmount',
|
||||
label: '运费(元)',
|
||||
type: 'number',
|
||||
queryKeyPrefix: 'freightAmount'
|
||||
},
|
||||
{
|
||||
prop: 'freightType',
|
||||
label: '运费计算方式',
|
||||
type: 'enum',
|
||||
queryKey: 'freightType',
|
||||
enumOptions: [
|
||||
{ value: 'by_weight', label: '按重量' },
|
||||
{ value: 'by_trip', label: '按趟次' }
|
||||
]
|
||||
},
|
||||
{
|
||||
prop: 'transportQty',
|
||||
label: '运输量',
|
||||
type: 'number',
|
||||
queryKeyPrefix: 'transportQty'
|
||||
},
|
||||
{
|
||||
prop: 'hasInvoice',
|
||||
label: '是否开票',
|
||||
type: 'enum',
|
||||
queryKey: 'hasInvoice',
|
||||
enumOptions: [
|
||||
{ value: '1', label: '是' },
|
||||
{ value: '0', label: '否' }
|
||||
]
|
||||
},
|
||||
{ prop: 'freightRemark', label: '运费备注', type: 'text', queryKey: 'freightRemark' }
|
||||
]
|
||||
@@ -123,7 +123,7 @@
|
||||
prop="planType"
|
||||
label="单据类型"
|
||||
type="enum"
|
||||
:enum-options="enumOptionsFor('planType')"
|
||||
:options="enumOptionsFor('planType')"
|
||||
:is-active="isFilterActive('planType')"
|
||||
:model-value="filters.planType || null"
|
||||
@update:model-value="(v) => setFilterState('planType', v)"
|
||||
@@ -178,7 +178,21 @@
|
||||
label="承运商"
|
||||
min-width="140"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
>
|
||||
<template #header>
|
||||
<div class="col-header-with-filter">
|
||||
<span class="col-header-with-filter__label">承运商</span>
|
||||
<ColumnHeaderFilter
|
||||
prop="transportCompany"
|
||||
label="承运商"
|
||||
type="text"
|
||||
:is-active="isFilterActive('transportCompany')"
|
||||
:model-value="filters.transportCompany || null"
|
||||
@update:model-value="(v) => setFilterState('transportCompany', v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('freightAmount')"
|
||||
prop="freightAmount"
|
||||
@@ -186,8 +200,107 @@
|
||||
min-width="120"
|
||||
align="right"
|
||||
>
|
||||
<template #header>
|
||||
<div class="col-header-with-filter">
|
||||
<span class="col-header-with-filter__label is-right">运费(元)</span>
|
||||
<ColumnHeaderFilter
|
||||
prop="freightAmount"
|
||||
label="运费(元)"
|
||||
type="number"
|
||||
:is-active="isFilterActive('freightAmount')"
|
||||
:model-value="filters.freightAmount || null"
|
||||
@update:model-value="(v) => setFilterState('freightAmount', v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ row }">{{ formatAmount(row.freightAmount) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('freightType')"
|
||||
prop="freightType"
|
||||
label="运费计算方式"
|
||||
min-width="130"
|
||||
align="center"
|
||||
>
|
||||
<template #header>
|
||||
<div class="col-header-with-filter">
|
||||
<span class="col-header-with-filter__label">运费计算方式</span>
|
||||
<ColumnHeaderFilter
|
||||
prop="freightType"
|
||||
label="运费计算方式"
|
||||
type="enum"
|
||||
:options="enumOptionsFor('freightType')"
|
||||
:is-active="isFilterActive('freightType')"
|
||||
:model-value="filters.freightType || null"
|
||||
@update:model-value="(v) => setFilterState('freightType', v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="getFreightTypeLabel(row.freightType)" :type="getFreightTypeTagType(row.freightType)" size="small">
|
||||
{{ getFreightTypeLabel(row.freightType) }}
|
||||
</el-tag>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('transportQty')"
|
||||
prop="transportQty"
|
||||
label="运输量"
|
||||
min-width="110"
|
||||
align="right"
|
||||
>
|
||||
<template #header>
|
||||
<div class="col-header-with-filter">
|
||||
<span class="col-header-with-filter__label is-right">运输量</span>
|
||||
<ColumnHeaderFilter
|
||||
prop="transportQty"
|
||||
label="运输量"
|
||||
type="number"
|
||||
:is-active="isFilterActive('transportQty')"
|
||||
:model-value="filters.transportQty || null"
|
||||
@update:model-value="(v) => setFilterState('transportQty', v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ row }">{{ formatQty(row.transportQty) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('freightPrice')"
|
||||
prop="freightPrice"
|
||||
label="运输单价"
|
||||
min-width="120"
|
||||
align="right"
|
||||
>
|
||||
<template #default="{ row }">{{ formatPrice(row.freightPrice) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('hasInvoice')"
|
||||
prop="hasInvoice"
|
||||
label="是否开票"
|
||||
min-width="100"
|
||||
align="center"
|
||||
>
|
||||
<template #header>
|
||||
<div class="col-header-with-filter">
|
||||
<span class="col-header-with-filter__label">是否开票</span>
|
||||
<ColumnHeaderFilter
|
||||
prop="hasInvoice"
|
||||
label="是否开票"
|
||||
type="enum"
|
||||
:options="enumOptionsFor('hasInvoice')"
|
||||
:is-active="isFilterActive('hasInvoice')"
|
||||
:model-value="filters.hasInvoice || null"
|
||||
@update:model-value="(v) => setFilterState('hasInvoice', v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.hasInvoice === 1 ? 'success' : 'info'" size="small">
|
||||
{{ getPlYesNoLabel(row.hasInvoice) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="isColumnVisible('freightRemark')"
|
||||
prop="freightRemark"
|
||||
@@ -195,6 +308,19 @@
|
||||
min-width="160"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #header>
|
||||
<div class="col-header-with-filter">
|
||||
<span class="col-header-with-filter__label">运费备注</span>
|
||||
<ColumnHeaderFilter
|
||||
prop="freightRemark"
|
||||
label="运费备注"
|
||||
type="text"
|
||||
:is-active="isFilterActive('freightRemark')"
|
||||
:model-value="filters.freightRemark || null"
|
||||
@update:model-value="(v) => setFilterState('freightRemark', v)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ row }">{{ row.freightRemark || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
@@ -260,9 +386,15 @@ import { pickBxPageResult } from '@/utils/http/bx'
|
||||
import PlPlanViewDialog from '@/components/business/pl-plan-view-dialog/index.vue'
|
||||
import { getPlanTypeLabel, getPlanTypeTagType } from '@/views/pl/freight/freight-status'
|
||||
import { plFreightUnsettledColumnFilterDefs } from '@/views/pl/freight/columnFilterDefs'
|
||||
import { buildVehicleTrailerLookup, formatPlVehiclePlateDisplay } from '@/utils/pl-display'
|
||||
import {
|
||||
buildVehicleTrailerLookup,
|
||||
formatPlVehiclePlateDisplay,
|
||||
getPlFreightTypeLabel,
|
||||
getPlYesNoLabel
|
||||
} from '@/utils/pl-display'
|
||||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
|
||||
const emit = defineEmits<{ created: [settlementId: string] }>()
|
||||
|
||||
@@ -273,6 +405,10 @@ const listColumnDefs = [
|
||||
{ prop: 'licensePlate', label: '车牌号' },
|
||||
{ prop: 'transportCompany', label: '承运商' },
|
||||
{ prop: 'freightAmount', label: '运费(元)' },
|
||||
{ prop: 'freightType', label: '运费计算方式' },
|
||||
{ prop: 'transportQty', label: '运输量' },
|
||||
{ prop: 'freightPrice', label: '运输单价' },
|
||||
{ prop: 'hasInvoice', label: '是否开票' },
|
||||
{ prop: 'freightRemark', label: '运费备注' },
|
||||
{ prop: 'archiveTime', label: '归档时间' }
|
||||
]
|
||||
@@ -283,7 +419,7 @@ const {
|
||||
isIndeterminate,
|
||||
isColumnVisible,
|
||||
resetToDefault
|
||||
} = usePersistedListColumns('pl-freight-unsettled-plan-columns', listColumnDefs)
|
||||
} = usePersistedListColumns('pl-freight-unsettled-plan-columns-v3', listColumnDefs)
|
||||
|
||||
const {
|
||||
filters,
|
||||
@@ -339,7 +475,7 @@ const unsettledStatsRowColumns = computed((): StatsRowColumn[] => {
|
||||
key: def.prop,
|
||||
interactive: true,
|
||||
prop: def.prop,
|
||||
money: def.prop === 'freightAmount'
|
||||
money: def.prop === 'freightAmount' || def.prop === 'freightPrice'
|
||||
})
|
||||
}
|
||||
return cols
|
||||
@@ -351,6 +487,8 @@ function getUnsettledStatCellValue(row: UnsettledPlanItem, prop: string): unknow
|
||||
if (prop === 'licensePlate') {
|
||||
return formatPlVehiclePlateDisplay(row.licensePlate, undefined, vehicleTrailerLookup.value)
|
||||
}
|
||||
if (prop === 'freightType') return getFreightTypeLabel(row.freightType)
|
||||
if (prop === 'hasInvoice') return getPlYesNoLabel(row.hasInvoice)
|
||||
if (prop === 'archiveTime') {
|
||||
return row.archiveTime ? formatDateTime(row.archiveTime) : ''
|
||||
}
|
||||
@@ -407,6 +545,33 @@ function formatAmount(amount: number) {
|
||||
return formatMoneyDisplay(amount)
|
||||
}
|
||||
|
||||
const dictStore = useDictStore()
|
||||
|
||||
function getFreightTypeLabel(type?: string) {
|
||||
if (!type) return ''
|
||||
const dictLabel = dictStore.getLabel('pl_freight_type', type)
|
||||
if (dictLabel && dictLabel !== type) return dictLabel
|
||||
const mapped = getPlFreightTypeLabel(type)
|
||||
return mapped === '—' || mapped === type ? '' : mapped
|
||||
}
|
||||
|
||||
function getFreightTypeTagType(type?: string) {
|
||||
// Fresh Mint 下 primary/success 同色,按趟次用 warning 区分
|
||||
if (type === 'by_trip') return 'warning'
|
||||
if (type === 'by_weight') return 'success'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
function formatQty(qty?: number | null) {
|
||||
if (qty == null) return '—'
|
||||
return String(qty)
|
||||
}
|
||||
|
||||
function formatPrice(price?: number | null) {
|
||||
if (price == null) return '—'
|
||||
return formatMoneyDisplay(Number(price))
|
||||
}
|
||||
|
||||
async function fetchData() {
|
||||
loading.value = true
|
||||
try {
|
||||
|
||||
@@ -70,12 +70,11 @@
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
type="index"
|
||||
prop="seqNo"
|
||||
label="序号"
|
||||
width="68"
|
||||
align="center"
|
||||
header-align="center"
|
||||
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||||
/>
|
||||
<el-table-column prop="registerNo" label="登记单号" min-width="170" show-overflow-tooltip>
|
||||
<template #header>
|
||||
@@ -109,7 +108,7 @@
|
||||
prop="fuelCategory"
|
||||
label="加油类别"
|
||||
type="enum"
|
||||
:enum-options="enumOptionsFor('fuelCategory')"
|
||||
:options="enumOptionsFor('fuelCategory')"
|
||||
:is-active="isFilterActive('fuelCategory')"
|
||||
:model-value="filters.fuelCategory || null"
|
||||
@update:model-value="(v) => setFilterState('fuelCategory', v)"
|
||||
@@ -239,7 +238,7 @@
|
||||
prop="status"
|
||||
label="状态"
|
||||
type="enum"
|
||||
:enum-options="enumOptionsFor('status')"
|
||||
:options="enumOptionsFor('status')"
|
||||
:is-active="isFilterActive('status')"
|
||||
:model-value="filters.status || null"
|
||||
@update:model-value="(v) => setFilterState('status', v)"
|
||||
@@ -394,18 +393,23 @@
|
||||
modal-class="order-module-dialog-mask"
|
||||
append-to-body
|
||||
>
|
||||
<template v-if="viewingRecord?.status === 'normal'" #hero-actions>
|
||||
<el-button class="btn-main" type="primary" @click="handleEdit(viewingRecord!)">
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="warning"
|
||||
:loading="cancelLoadingMap[viewingRecord!.id]"
|
||||
@click="handleViewCancel"
|
||||
>
|
||||
<el-icon><CircleClose /></el-icon>作废
|
||||
<template #hero-actions>
|
||||
<el-button class="btn-ghost" @click="handleCopyFuelInfo(viewDetail || viewingRecord)">
|
||||
<el-icon><DocumentCopy /></el-icon>复制信息发微信群
|
||||
</el-button>
|
||||
<template v-if="viewingRecord?.status === 'normal'">
|
||||
<el-button class="btn-main" type="primary" @click="handleEdit(viewingRecord!)">
|
||||
<el-icon><Edit /></el-icon>编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
class="btn-ghost"
|
||||
type="warning"
|
||||
:loading="cancelLoadingMap[viewingRecord!.id]"
|
||||
@click="handleViewCancel"
|
||||
>
|
||||
<el-icon><CircleClose /></el-icon>作废
|
||||
</el-button>
|
||||
</template>
|
||||
</template>
|
||||
<template #attachments>
|
||||
<AttachmentUploadField
|
||||
@@ -429,7 +433,7 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { plVehicleFuelRegisterColumnFilterDefs } from '@/views/pl/vehicle-fuel-register/columnFilterDefs'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { Check, CircleClose, Close, Edit, Filter, Plus } from '@element-plus/icons-vue'
|
||||
import { Check, CircleClose, Close, DocumentCopy, Edit, Filter, Plus } from '@element-plus/icons-vue'
|
||||
import {
|
||||
vehicleApi,
|
||||
vehicleFuelRegisterApi,
|
||||
@@ -437,7 +441,7 @@ import {
|
||||
type Vehicle,
|
||||
type VehicleFuelRegister
|
||||
} from '@/api/pl'
|
||||
import { pickBxPageResult } from '@/utils/http/bx'
|
||||
import { pickBxData, pickBxPageResult } from '@/utils/http/bx'
|
||||
import { fetchAllPagedRecords } from '@/utils/fetch-paged-list'
|
||||
import { fetchUserOptions } from '@/api/admin'
|
||||
import AttachmentUploadField from '@/components/business/attachment-upload-field/index.vue'
|
||||
@@ -446,6 +450,7 @@ import PlVehicleSelect from '@/components/business/pl/PlVehicleSelect.vue'
|
||||
import SystemViewDialog, { type ViewSection } from '@/components/business/system-view-dialog/index.vue'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import {
|
||||
buildFuelRegisterCopyText,
|
||||
buildVehicleTrailerLookup,
|
||||
formatPlVehiclePlateDisplay,
|
||||
getPlFuelCategoryLabel,
|
||||
@@ -453,6 +458,7 @@ import {
|
||||
getPlFuelRegisterStatusLabel,
|
||||
getPlFuelRegisterStatusTagType
|
||||
} from '@/utils/pl-display'
|
||||
import { copyTextToClipboard } from '@/utils/clipboard'
|
||||
import { syncViewRowFromFlatList } from '@/utils/view-dialog-refresh'
|
||||
|
||||
defineOptions({ name: 'FuelRegisterListPage' })
|
||||
@@ -511,6 +517,9 @@ const {
|
||||
resetToInitial,
|
||||
watchVisibleColumns
|
||||
} = useServerColumnFilters(plVehicleFuelRegisterColumnFilterDefs, {
|
||||
initialFilters: {
|
||||
status: { text: '', selected: ['normal'] }
|
||||
},
|
||||
onChange: () => handleSearch()
|
||||
})
|
||||
|
||||
@@ -624,6 +633,7 @@ function getExportFilterParams() {
|
||||
const exportColumns = computed(() => {
|
||||
const cols = [...visibleColumns.value]
|
||||
if (!cols.includes('registerNo')) cols.unshift('registerNo')
|
||||
if (!cols.includes('seqNo')) cols.unshift('seqNo')
|
||||
return cols
|
||||
})
|
||||
|
||||
@@ -642,6 +652,10 @@ const viewSections = computed<ViewSection[]>(() => {
|
||||
{
|
||||
title: '登记信息',
|
||||
fields: [
|
||||
{
|
||||
label: '序号',
|
||||
value: d.seqNo != null ? String(d.seqNo) : '—'
|
||||
},
|
||||
{ label: '登记单号', value: d.registerNo },
|
||||
{
|
||||
label: '加油类别',
|
||||
@@ -819,6 +833,36 @@ async function handleViewCancel() {
|
||||
viewVisible.value = false
|
||||
}
|
||||
|
||||
async function handleCopyFuelInfo(row?: VehicleFuelRegister | null) {
|
||||
if (!row) {
|
||||
ElMessage.warning('暂无可复制的登记信息')
|
||||
return
|
||||
}
|
||||
const enriched: VehicleFuelRegister = { ...row }
|
||||
if (!enriched.registrantName && enriched.registrantId) {
|
||||
const u = userOptions.value.find((x) => x.userId === enriched.registrantId)
|
||||
if (u) enriched.registrantName = u.nickName || u.displayName
|
||||
}
|
||||
const text = buildFuelRegisterCopyText(enriched)
|
||||
const ok = await copyTextToClipboard(text)
|
||||
if (ok) ElMessage.success('已复制')
|
||||
else ElMessage.error('复制失败')
|
||||
}
|
||||
|
||||
async function promptCopyAfterSave(saved: VehicleFuelRegister, isUpdate: boolean) {
|
||||
try {
|
||||
await ElMessageBox.confirm(isUpdate ? '更新成功' : '创建成功', '提示', {
|
||||
confirmButtonText: '复制信息发微信群',
|
||||
cancelButtonText: '关闭',
|
||||
type: 'success',
|
||||
distinguishCancelAndClose: true
|
||||
})
|
||||
await handleCopyFuelInfo(saved)
|
||||
} catch {
|
||||
/* 关闭 / 取消 */
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await formRef.value?.validate()
|
||||
if (attachmentUploadRef.value?.hasUploading?.()) {
|
||||
@@ -838,16 +882,19 @@ async function handleSubmit() {
|
||||
remark: formData.remark || undefined
|
||||
}
|
||||
const params = mineParams()
|
||||
if (isEdit.value) {
|
||||
await vehicleFuelRegisterApi.update(formData.id, payload, params)
|
||||
ElMessage.success('更新成功')
|
||||
const editing = isEdit.value
|
||||
let saved: VehicleFuelRegister
|
||||
if (editing) {
|
||||
const res = await vehicleFuelRegisterApi.update(formData.id, payload, params)
|
||||
saved = pickBxData<VehicleFuelRegister>(res)
|
||||
} else {
|
||||
await vehicleFuelRegisterApi.create(payload, params)
|
||||
ElMessage.success('创建成功')
|
||||
const res = await vehicleFuelRegisterApi.create(payload, params)
|
||||
saved = pickBxData<VehicleFuelRegister>(res)
|
||||
}
|
||||
dialogVisible.value = false
|
||||
await fetchData()
|
||||
if (isEdit.value) await refreshViewIfOpen(formData.id)
|
||||
if (editing) await refreshViewIfOpen(formData.id)
|
||||
await promptCopyAfterSave(saved, editing)
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user