提交
This commit is contained in:
1 parent
e56d227fe8
commit
4611dbc2b2
237 files changed
+1384060
-24942
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import { computed, ref, watch, type Ref } from 'vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { getProductUnitLabel } from '@/utils/crm-product-display'
|
||||
|
||||
export interface FreightCalcProductRow {
|
||||
quantity?: number | null
|
||||
@@ -24,8 +26,8 @@ export function sumProductQuantities(products: FreightCalcProductRow[]) {
|
||||
export function resolveFreightUnitLabel(products: FreightCalcProductRow[]) {
|
||||
const units = products.map(row => row.unit).filter(Boolean) as string[]
|
||||
if (!units.length) return '吨'
|
||||
const first = units[0]
|
||||
return first
|
||||
const dictStore = useDictStore()
|
||||
return getProductUnitLabel(dictStore.getLabel.bind(dictStore), units[0])
|
||||
}
|
||||
|
||||
export function usePlFreightCalc(options: {
|
||||
|
||||
@@ -8,11 +8,10 @@ import type {
|
||||
import { planApi } from '@/api/pl'
|
||||
import DbPoundSlipQrcodeDialog from '@/components/business/db/DbPoundSlipQrcodeDialog.vue'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import { appendAmapNavLine, buildAmapNavigationUrl } from '@/utils/amap/navigation'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import { formatPlanProductListText } from '@/utils/pl-display'
|
||||
import { buildSiteSummaryFromInventoryLinks } from '@/utils/db-site-summary'
|
||||
import { buildDriverSummaryFromPlan, buildDriverStopBlocksFromPlan } from '@/utils/pl-driver-summary'
|
||||
import { buildSiteSummaryFromInventoryLinks, buildSiteStopBlocksFromPlan } from '@/utils/db-site-summary'
|
||||
|
||||
export function usePlPlanArrangeActions() {
|
||||
const dictStore = useDictStore()
|
||||
@@ -27,23 +26,26 @@ export function usePlPlanArrangeActions() {
|
||||
const selectedInventoryId = ref('')
|
||||
const selectedInventoryUnit = ref('')
|
||||
const qrcodeDialogRef = ref<InstanceType<typeof DbPoundSlipQrcodeDialog> | null>(null)
|
||||
const poundQrcodePickVisible = ref(false)
|
||||
const poundQrcodePickRecords = ref<TransportInventoryLink[]>([])
|
||||
|
||||
const showArrangeActions = computed(
|
||||
() =>
|
||||
Boolean(
|
||||
plan.value?.transportStatus === 'arranged' &&
|
||||
plan.value?.followStatus !== 'cancelled' &&
|
||||
(driverUrl.value || siteRecords.value.length || inventoryRecords.value.length)
|
||||
)
|
||||
const showArrangeActions = computed(() =>
|
||||
Boolean(
|
||||
plan.value?.transportStatus === 'arranged' &&
|
||||
plan.value?.followStatus !== 'cancelled' &&
|
||||
(driverUrl.value || siteRecords.value.length || inventoryRecords.value.length)
|
||||
)
|
||||
)
|
||||
|
||||
const hasSiteInventoryRecords = computed(() => siteRecords.value.length > 0)
|
||||
|
||||
const hasSiteLinks = computed(() => siteRecords.value.some(item => Boolean(item.siteUrl?.trim())))
|
||||
const hasSiteLinks = computed(() =>
|
||||
siteRecords.value.some((item) => Boolean(item.siteUrl?.trim()))
|
||||
)
|
||||
|
||||
/** 勾选「生成地磅单」后才会关联 db_purchase_plan,磅单二维码仅针对这类记录 */
|
||||
const dibangInventoryRecords = computed(() =>
|
||||
inventoryRecords.value.filter(item => Boolean(item.dbPurchasePlanId?.trim()))
|
||||
inventoryRecords.value.filter((item) => Boolean(item.dbPurchasePlanId?.trim()))
|
||||
)
|
||||
|
||||
const hasDibangInventoryRecords = computed(() => dibangInventoryRecords.value.length > 0)
|
||||
@@ -62,6 +64,8 @@ export function usePlPlanArrangeActions() {
|
||||
qrcodeVisible.value = false
|
||||
selectedInventoryId.value = ''
|
||||
selectedInventoryUnit.value = ''
|
||||
poundQrcodePickVisible.value = false
|
||||
poundQrcodePickRecords.value = []
|
||||
}
|
||||
|
||||
function applyArrangeResult(
|
||||
@@ -122,58 +126,19 @@ export function usePlPlanArrangeActions() {
|
||||
licensePlate?: string
|
||||
driverUrl?: string
|
||||
}) {
|
||||
const plate =
|
||||
options?.licensePlate || licensePlate.value || plan.value?.licensePlate || '—'
|
||||
const lines = [`【${plate} - 运输安排】`, `计划号:${plan.value?.planNo || '—'}`]
|
||||
lines.push(`车牌:${plate}`)
|
||||
lines.push(
|
||||
`时间:${formatDate(plan.value?.pickupTime) || plan.value?.planDate || '—'}`
|
||||
)
|
||||
const productText = products.value
|
||||
.map(p => formatPlanProductListText(p, getUnitLabel, { usePlannedQuantity: true }))
|
||||
.join(';')
|
||||
lines.push(`产品:${productText || '—'}`)
|
||||
|
||||
const pickupAddress =
|
||||
options?.pickupAddress || plan.value?.pickupAddress || options?.startPoint || '—'
|
||||
const destinationAddress =
|
||||
options?.destinationAddress ||
|
||||
plan.value?.destinationAddress ||
|
||||
plan.value?.destinationName ||
|
||||
options?.endPoint ||
|
||||
'—'
|
||||
lines.push(`取货地址:${pickupAddress}`)
|
||||
lines.push(`送货地址:${destinationAddress}`)
|
||||
|
||||
const pickupLng = options?.pickupLng ?? plan.value?.pickupLng
|
||||
const pickupLat = options?.pickupLat ?? plan.value?.pickupLat
|
||||
const destinationLng = options?.destinationLng ?? plan.value?.destinationLng
|
||||
const destinationLat = options?.destinationLat ?? plan.value?.destinationLat
|
||||
appendAmapNavLine(
|
||||
lines,
|
||||
'取货导航',
|
||||
buildAmapNavigationUrl(pickupLng, pickupLat, pickupAddress !== '—' ? pickupAddress : '取货点')
|
||||
)
|
||||
appendAmapNavLine(
|
||||
lines,
|
||||
'送货导航',
|
||||
buildAmapNavigationUrl(
|
||||
destinationLng,
|
||||
destinationLat,
|
||||
destinationAddress !== '—' ? destinationAddress : '送货点'
|
||||
)
|
||||
)
|
||||
|
||||
lines.push(
|
||||
`取货联系方式:${options?.pickupContact || plan.value?.pickupContact || '—'}`
|
||||
)
|
||||
lines.push(`取货注意事项:${options?.pickupNotes || plan.value?.pickupNotes || '—'}`)
|
||||
lines.push(
|
||||
`送货联系方式:${options?.deliveryContact || plan.value?.deliveryContact || '—'}`
|
||||
)
|
||||
lines.push(`送货注意事项:${options?.destinationNotes || plan.value?.destinationNotes || '—'}`)
|
||||
lines.push(`司机链接:${options?.driverUrl || driverUrl.value || '—'}`)
|
||||
return lines.join('\n')
|
||||
return buildDriverSummaryFromPlan({
|
||||
plan: plan.value || undefined,
|
||||
planNo: plan.value?.planNo,
|
||||
licensePlate: options?.licensePlate || licensePlate.value || plan.value?.licensePlate,
|
||||
pickupTime: plan.value?.pickupTime,
|
||||
planDate: plan.value?.planDate,
|
||||
personnelSummary: plan.value?.personnelSummary,
|
||||
driverUrl: options?.driverUrl || driverUrl.value,
|
||||
products: products.value,
|
||||
getUnitLabel,
|
||||
stopBlocks: buildDriverStopBlocksFromPlan(plan.value, getUnitLabel),
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
async function copyDriverUrl(url?: string) {
|
||||
@@ -184,7 +149,7 @@ export function usePlPlanArrangeActions() {
|
||||
}
|
||||
|
||||
function resolveSiteRecordProductText(record: TransportSiteLink) {
|
||||
const product = products.value.find(item => item.id === record.planProductId)
|
||||
const product = products.value.find((item) => item.id === record.planProductId)
|
||||
if (product) {
|
||||
return formatPlanProductListText(product, getUnitLabel, { usePlannedQuantity: true })
|
||||
}
|
||||
@@ -197,10 +162,11 @@ export function usePlPlanArrangeActions() {
|
||||
licensePlate: options?.licensePlate || licensePlate.value || plan.value?.licensePlate,
|
||||
pickupTime: plan.value?.pickupTime,
|
||||
planDate: plan.value?.planDate,
|
||||
records: siteRecords.value.map(record => ({
|
||||
records: siteRecords.value.map((record) => ({
|
||||
...record,
|
||||
productText: resolveSiteRecordProductText(record)
|
||||
}))
|
||||
})),
|
||||
stopBlocks: buildSiteStopBlocksFromPlan(plan.value)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -234,11 +200,25 @@ export function usePlPlanArrangeActions() {
|
||||
}
|
||||
|
||||
function resolveInventoryUnitLabel(record: TransportInventoryLink) {
|
||||
const product = products.value.find(item => item.id === record.planProductId)
|
||||
const product = products.value.find((item) => item.id === record.planProductId)
|
||||
const unitRaw = product?.unit || ''
|
||||
return unitRaw ? getUnitLabel(unitRaw) : '吨'
|
||||
}
|
||||
|
||||
async function copyPoundSlipQrcodeForRecord(
|
||||
record: TransportInventoryLink,
|
||||
options?: { preview?: boolean }
|
||||
) {
|
||||
selectedInventoryId.value = record.dbInventoryId
|
||||
selectedInventoryUnit.value = resolveInventoryUnitLabel(record)
|
||||
qrcodeVisible.value = true
|
||||
await nextTick()
|
||||
if (options?.preview) {
|
||||
return
|
||||
}
|
||||
await qrcodeDialogRef.value?.copyQrcodeImage()
|
||||
}
|
||||
|
||||
async function copyPoundSlipQrcode() {
|
||||
const records = dibangInventoryRecords.value
|
||||
if (!records.length) {
|
||||
@@ -246,36 +226,19 @@ export function usePlPlanArrangeActions() {
|
||||
return
|
||||
}
|
||||
if (records.length === 1) {
|
||||
selectedInventoryId.value = records[0].dbInventoryId
|
||||
selectedInventoryUnit.value = resolveInventoryUnitLabel(records[0])
|
||||
qrcodeVisible.value = true
|
||||
await nextTick()
|
||||
await qrcodeDialogRef.value?.copyQrcodeImage()
|
||||
await copyPoundSlipQrcodeForRecord(records[0])
|
||||
return
|
||||
}
|
||||
poundQrcodePickRecords.value = records
|
||||
poundQrcodePickVisible.value = true
|
||||
}
|
||||
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt('请选择要复制二维码的产品行', '复制磅单二维码', {
|
||||
inputPlaceholder: records.map((item, idx) => `${idx + 1}. ${item.productName}`).join('\n'),
|
||||
confirmButtonText: '确定',
|
||||
inputValidator: val => {
|
||||
const index = Number(val) - 1
|
||||
if (!Number.isInteger(index) || index < 0 || index >= records.length) {
|
||||
return '请输入有效序号'
|
||||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
const index = Number(value) - 1
|
||||
const record = records[index]
|
||||
selectedInventoryId.value = record.dbInventoryId
|
||||
selectedInventoryUnit.value = resolveInventoryUnitLabel(record)
|
||||
qrcodeVisible.value = true
|
||||
await nextTick()
|
||||
await qrcodeDialogRef.value?.copyQrcodeImage()
|
||||
} catch {
|
||||
// 用户取消
|
||||
}
|
||||
async function handlePoundQrcodePickCopy(record: TransportInventoryLink) {
|
||||
await copyPoundSlipQrcodeForRecord(record)
|
||||
}
|
||||
|
||||
async function handlePoundQrcodePickPreview(record: TransportInventoryLink) {
|
||||
await copyPoundSlipQrcodeForRecord(record, { preview: true })
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -289,6 +252,8 @@ export function usePlPlanArrangeActions() {
|
||||
selectedInventoryId,
|
||||
selectedInventoryUnit,
|
||||
qrcodeDialogRef,
|
||||
poundQrcodePickVisible,
|
||||
poundQrcodePickRecords,
|
||||
showArrangeActions,
|
||||
hasSiteInventoryRecords,
|
||||
hasSiteLinks,
|
||||
@@ -302,6 +267,9 @@ export function usePlPlanArrangeActions() {
|
||||
copyDriverUrl,
|
||||
copySiteSummary,
|
||||
copyPlanSummary,
|
||||
copyPoundSlipQrcode
|
||||
copyPoundSlipQrcode,
|
||||
copyPoundSlipQrcodeForRecord,
|
||||
handlePoundQrcodePickCopy,
|
||||
handlePoundQrcodePickPreview
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
import type { ComputedRef, Ref } from 'vue'
|
||||
import {
|
||||
planApi,
|
||||
transportApi,
|
||||
type Plan,
|
||||
type PlanProduct,
|
||||
type TransportArrange,
|
||||
type TransportArrangeResult
|
||||
} from '@/api/pl'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import { planRequiresSiteLink } from '@/utils/pl-internal-customer'
|
||||
import type { PlanDeliveryForm, PlanLoadForm } from '@/utils/pl-plan-stop-form'
|
||||
|
||||
export interface ArrangeHistoricalFlags {
|
||||
hasHistoricalDibang: boolean
|
||||
hasHistoricalSiteLinks: boolean
|
||||
}
|
||||
|
||||
export async function loadArrangeHistoricalFlags(planId: string): Promise<ArrangeHistoricalFlags> {
|
||||
try {
|
||||
const infoRes = await planApi.getArrangeInfo(planId)
|
||||
const info = pickBxData<{
|
||||
inventoryRecords?: unknown[]
|
||||
siteRecords?: unknown[]
|
||||
}>(infoRes)
|
||||
return {
|
||||
hasHistoricalDibang: (info?.inventoryRecords?.length || 0) > 0,
|
||||
hasHistoricalSiteLinks: (info?.siteRecords?.length || 0) > 0
|
||||
}
|
||||
} catch {
|
||||
return { hasHistoricalDibang: false, hasHistoricalSiteLinks: false }
|
||||
}
|
||||
}
|
||||
|
||||
function buildTransportMediumText(
|
||||
products: PlanProduct[],
|
||||
getUnitLabel: (unit: string) => string
|
||||
) {
|
||||
return products
|
||||
.map((product) => {
|
||||
const name = product.productName?.trim()
|
||||
if (!name) return ''
|
||||
const model = (product.model || product.packageSpec || '').trim()
|
||||
const qty = product.quantity ?? product.inboundEstimateQty ?? product.outboundEstimateQty ?? ''
|
||||
const unit = getUnitLabel(product.unit || '吨')
|
||||
const detail = [model, qty, unit].filter((part) => part !== '' && part != null).join('、')
|
||||
return detail ? `${name}(${detail})` : name
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(';')
|
||||
}
|
||||
|
||||
function buildStopDibangOptions(
|
||||
plan: Plan,
|
||||
loadForm: PlanLoadForm,
|
||||
deliveryForms: PlanDeliveryForm[]
|
||||
) {
|
||||
const options: TransportArrange['stopDibangOptions'] = []
|
||||
if (plan.load?.id) {
|
||||
options.push({
|
||||
stopType: 'load',
|
||||
stopId: plan.load.id,
|
||||
generateDibang: loadForm.generateDibang === 1
|
||||
})
|
||||
}
|
||||
const deliveries = [...(plan.deliveries || [])].sort((a, b) => (a.seq ?? 0) - (b.seq ?? 0))
|
||||
deliveries.forEach((delivery, index) => {
|
||||
if (!delivery.id) return
|
||||
const form =
|
||||
deliveryForms.find((row) => row.id === delivery.id) ||
|
||||
deliveryForms.find((row) => row.seq === delivery.seq) ||
|
||||
deliveryForms[index]
|
||||
options.push({
|
||||
stopType: 'delivery',
|
||||
stopId: delivery.id,
|
||||
generateDibang: form?.generateDibang === 1
|
||||
})
|
||||
})
|
||||
return options
|
||||
}
|
||||
|
||||
export function planHasAnyDibangSelected(
|
||||
plan: Plan,
|
||||
loadForm: PlanLoadForm,
|
||||
deliveryForms: PlanDeliveryForm[]
|
||||
) {
|
||||
const stopOptions = buildStopDibangOptions(plan, loadForm, deliveryForms)
|
||||
if (stopOptions.length > 0) {
|
||||
return stopOptions.some((row) => row.generateDibang)
|
||||
}
|
||||
return loadForm.generateDibang === 1 || deliveryForms.some((row) => row.generateDibang === 1)
|
||||
}
|
||||
|
||||
export interface BuildArrangePayloadInput {
|
||||
plan: Plan
|
||||
vehicleId: string
|
||||
driverId: string
|
||||
carrierId: string
|
||||
loadForm: PlanLoadForm
|
||||
deliveryForms: PlanDeliveryForm[]
|
||||
products: PlanProduct[]
|
||||
remark: string
|
||||
distanceKm: number | null
|
||||
freightType: string
|
||||
hasFreight: number
|
||||
freightCalc: {
|
||||
freightPrice: Ref<number | null>
|
||||
calculatedFreight: ComputedRef<number>
|
||||
freightAmount: Ref<number | null>
|
||||
}
|
||||
getUnitLabel: (unit: string) => string
|
||||
}
|
||||
|
||||
export function buildArrangePayloadFromPlanForm(input: BuildArrangePayloadInput): TransportArrange {
|
||||
const firstDelivery = input.deliveryForms[0]
|
||||
const useMultiStopDibang = Boolean(input.plan.load?.id && (input.plan.deliveries?.length || 0) > 0)
|
||||
const stopDibangOptions = useMultiStopDibang
|
||||
? buildStopDibangOptions(input.plan, input.loadForm, input.deliveryForms)
|
||||
: undefined
|
||||
const generateDibangPlan = !useMultiStopDibang
|
||||
? input.loadForm.generateDibang === 1 || Boolean(firstDelivery?.generateDibang === 1)
|
||||
: undefined
|
||||
|
||||
return {
|
||||
vehicleId: input.vehicleId,
|
||||
driverId: input.driverId || undefined,
|
||||
carrierId: input.carrierId || undefined,
|
||||
pickupAddress: input.loadForm.address || undefined,
|
||||
pickupLng: input.loadForm.lng,
|
||||
pickupLat: input.loadForm.lat,
|
||||
pickupTime: input.loadForm.loadTime || undefined,
|
||||
pickupContact: input.loadForm.contact || undefined,
|
||||
pickupNotes: input.loadForm.notes || undefined,
|
||||
destinationAddress: firstDelivery?.address || undefined,
|
||||
destinationLng: firstDelivery?.lng,
|
||||
destinationLat: firstDelivery?.lat,
|
||||
deliveryTime: firstDelivery?.deliveryTime || undefined,
|
||||
deliveryContact: firstDelivery?.contact || undefined,
|
||||
destinationNotes: firstDelivery?.notes || undefined,
|
||||
transportMedium: buildTransportMediumText(input.products, input.getUnitLabel) || undefined,
|
||||
distanceKm: input.distanceKm ?? undefined,
|
||||
freightType: input.freightType,
|
||||
freightPrice:
|
||||
input.freightType === 'by_weight'
|
||||
? (input.freightCalc.freightPrice.value ?? undefined)
|
||||
: undefined,
|
||||
freightAmount:
|
||||
input.hasFreight === 1
|
||||
? input.freightCalc.calculatedFreight.value ||
|
||||
input.freightCalc.freightAmount.value ||
|
||||
undefined
|
||||
: undefined,
|
||||
remark: input.remark || undefined,
|
||||
generateDibangPlan: useMultiStopDibang ? undefined : generateDibangPlan,
|
||||
stopDibangOptions: useMultiStopDibang && stopDibangOptions?.length ? stopDibangOptions : undefined
|
||||
}
|
||||
}
|
||||
|
||||
export async function confirmBeforePlanArrange(options: {
|
||||
isRearrange: boolean
|
||||
plan: Plan
|
||||
hasHistoricalDibang: boolean
|
||||
hasHistoricalSiteLinks: boolean
|
||||
hasAnyDibangSelected: boolean
|
||||
}) {
|
||||
const planSupportsSiteInventory = planRequiresSiteLink(options.plan)
|
||||
|
||||
if (options.isRearrange) {
|
||||
let confirmMessage = '司机链接将更新,旧链接将失效。是否继续?'
|
||||
if (options.hasHistoricalDibang) {
|
||||
confirmMessage = options.hasAnyDibangSelected
|
||||
? '将作废此前自动生成的地磅出入库单,并按当前勾选段重新进行地磅单生成。司机链接将更新,旧链接将失效。已执行或已关联磅单的单据不会被自动作废。是否继续?'
|
||||
: '将作废此前自动生成的地磅出入库单,且不会重新生成地磅联动单据。司机链接将更新,旧链接将失效。已执行或已关联磅单的单据不会被自动作废。是否继续?'
|
||||
} else if (options.hasHistoricalSiteLinks && planSupportsSiteInventory) {
|
||||
confirmMessage = '司机与现场链接将更新,旧链接将失效。是否继续?'
|
||||
} else if (options.hasAnyDibangSelected && planSupportsSiteInventory) {
|
||||
confirmMessage =
|
||||
'将按当前勾选段进行地磅单生成。司机链接将更新,旧链接将失效。是否继续?'
|
||||
}
|
||||
await ElMessageBox.confirm(confirmMessage, '调整运输确认', {
|
||||
type: 'warning',
|
||||
confirmButtonText: '继续调整',
|
||||
cancelButtonText: '取消'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (options.hasAnyDibangSelected && options.plan.transportId) {
|
||||
await ElMessageBox.confirm(
|
||||
'将作废本运输单此前待处理的出入库单,并按当前计划产品重新生成。已执行或已关联磅单的单据不会被自动作废。是否继续?',
|
||||
'地磅联动确认',
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: '继续安排',
|
||||
cancelButtonText: '取消'
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function submitPlanArrange(
|
||||
planId: string,
|
||||
payload: TransportArrange
|
||||
): Promise<TransportArrangeResult> {
|
||||
const res = await transportApi.arrange(planId, payload)
|
||||
const result = pickBxData<TransportArrangeResult>(res)
|
||||
if (!result) {
|
||||
throw new Error('安排失败:未返回结果')
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { computed, unref, type ComputedRef, type Ref } from 'vue'
|
||||
import type { Plan } from '@/api/pl'
|
||||
import {
|
||||
buildPlPlanListSpanMethod,
|
||||
flattenPlanListRows,
|
||||
getPlanListDisplayIndex,
|
||||
type PlPlanListDisplayRow
|
||||
} from '@/utils/pl-plan-list-display-rows'
|
||||
|
||||
export function usePlPlanMergeListTable(options: {
|
||||
planList: Ref<Plan[]> | ComputedRef<Plan[]>
|
||||
visiblePlanMergeProps: ComputedRef<string[]>
|
||||
selectedRows: Ref<Plan[]>
|
||||
pagination: { page: number; pageSize: number }
|
||||
onView?: (plan: Plan) => void
|
||||
}) {
|
||||
const displayRows = computed(() => flattenPlanListRows(unref(options.planList)))
|
||||
|
||||
const planListSpanMethod = computed(() =>
|
||||
buildPlPlanListSpanMethod([...options.visiblePlanMergeProps.value])
|
||||
)
|
||||
|
||||
function getDisplayRowIndex(index: number) {
|
||||
return getPlanListDisplayIndex(
|
||||
displayRows.value,
|
||||
index,
|
||||
options.pagination.page,
|
||||
options.pagination.pageSize
|
||||
)
|
||||
}
|
||||
|
||||
function isPlanFirstRowSelectable(row: PlPlanListDisplayRow) {
|
||||
return row.isPlanFirstRow
|
||||
}
|
||||
|
||||
function handleDisplaySelectionChange(selection: PlPlanListDisplayRow[]) {
|
||||
const seen = new Set<string>()
|
||||
const plans: Plan[] = []
|
||||
for (const item of selection || []) {
|
||||
const plan = item?.plan
|
||||
if (!plan?.id || seen.has(plan.id)) continue
|
||||
seen.add(plan.id)
|
||||
plans.push(plan)
|
||||
}
|
||||
options.selectedRows.value = plans
|
||||
}
|
||||
|
||||
function handleDisplayRowDblClick(row: PlPlanListDisplayRow) {
|
||||
if (row?.plan && options.onView) options.onView(row.plan)
|
||||
}
|
||||
|
||||
function findPlanFirstDisplayRow(planId: string) {
|
||||
return displayRows.value.find((item) => item.plan.id === planId && item.isPlanFirstRow)
|
||||
}
|
||||
|
||||
return {
|
||||
displayRows,
|
||||
planListSpanMethod,
|
||||
getDisplayRowIndex,
|
||||
isPlanFirstRowSelectable,
|
||||
handleDisplaySelectionChange,
|
||||
handleDisplayRowDblClick,
|
||||
findPlanFirstDisplayRow
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user