chore: sync local PL/CRM/BX and migration work to new Gogs host
Bundle pending backend/web-admin feature updates, data-migration scripts, and related docs so the V1.5 branch on the Tencent Cloud Gogs matches the current workspace (excluding local secrets). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5a9abfdd5d
commit
10c3c5470c
269 files changed
+1035435
-92885
No files matched your search
@@ -31,12 +31,16 @@ export function canBxPreview(file: BxAttachmentItem) {
|
||||
return isBxImageFile(file) || isBxVideoFile(file)
|
||||
}
|
||||
|
||||
export async function fillBxAttachmentPreviews(files: BxAttachmentItem[]) {
|
||||
export async function fillBxAttachmentPreviews(
|
||||
files: Array<BxAttachmentItem & { attachmentId?: number | string }>
|
||||
) {
|
||||
const tasks = files
|
||||
.filter((file) => isBxImageFile(file) && !file.previewUrl)
|
||||
.map(async (file) => {
|
||||
const id = file.id ?? file.attachmentId
|
||||
if (id == null || id === '') return
|
||||
try {
|
||||
const res: any = await attachmentApi.preview(file.id)
|
||||
const res: any = await attachmentApi.preview(id)
|
||||
file.previewUrl = res.data?.url || ''
|
||||
} catch {
|
||||
/* preview optional */
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { BxAttachmentItem } from '@/utils/bx/attachment'
|
||||
|
||||
/** 关联发票固定展示顺序:上传/创建时间从新到旧,同时间按附件 ID */
|
||||
export function sortInvoiceLinksByFixedOrder<
|
||||
T extends { createTime?: string; create_time?: string; attachmentId?: string | number; attachment_id?: string | number; id?: string | number }
|
||||
>(items: T[]): T[] {
|
||||
return items.slice().sort((a, b) => {
|
||||
const ta = String(a.createTime || a.create_time || '')
|
||||
const tb = String(b.createTime || b.create_time || '')
|
||||
if (ta !== tb) return tb.localeCompare(ta)
|
||||
const ia = String(a.attachmentId ?? a.attachment_id ?? a.id ?? '')
|
||||
const ib = String(b.attachmentId ?? b.attachment_id ?? b.id ?? '')
|
||||
return ib.localeCompare(ia)
|
||||
})
|
||||
}
|
||||
|
||||
/** 报销单关联发票 brief → 只读附件卡片数据 */
|
||||
export function invoicesToLinkedAttachmentFiles(invoices: any[]): BxAttachmentItem[] {
|
||||
const sorted = sortInvoiceLinksByFixedOrder(invoices || [])
|
||||
return sorted
|
||||
.map((inv: any) => {
|
||||
const id = inv.attachmentId || inv.attachment_id
|
||||
if (!id && !inv.fileName && !inv.file_name) return null
|
||||
return {
|
||||
id: id || inv.id,
|
||||
fileName: inv.fileName || inv.file_name || '发票附件',
|
||||
fileType: inv.fileType || inv.file_type || '',
|
||||
_existing: true
|
||||
} as BxAttachmentItem
|
||||
})
|
||||
.filter(Boolean) as BxAttachmentItem[]
|
||||
}
|
||||
@@ -14,16 +14,65 @@ export function buildProductNameOptions(
|
||||
return [...new Set(names.filter(Boolean))]
|
||||
}
|
||||
|
||||
/** 仅别名列表(不含标准名) */
|
||||
export function buildProductAliasOptions(
|
||||
aliases?: Array<{ aliasName?: string } | null> | null
|
||||
): string[] {
|
||||
const names: string[] = []
|
||||
for (const a of aliases || []) {
|
||||
const n = String(a?.aliasName || '').trim()
|
||||
if (n) names.push(n)
|
||||
}
|
||||
return [...new Set(names)]
|
||||
}
|
||||
|
||||
export function resolveLineProductName(
|
||||
standardName?: string | null,
|
||||
aliasName?: string | null
|
||||
): string {
|
||||
const alias = String(aliasName || '').trim()
|
||||
if (alias) return alias
|
||||
return String(standardName || '').trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* 从已存 productName 反推别名列。
|
||||
* 等于标准名或不在别名列表 → undefined(脏数据时别名列空,提交保留原 productName)。
|
||||
*/
|
||||
export function resolveAliasFromSavedName(
|
||||
savedProductName?: string | null,
|
||||
standardName?: string | null,
|
||||
aliasOptions?: string[] | null
|
||||
): string | undefined {
|
||||
const saved = String(savedProductName || '').trim()
|
||||
const standard = String(standardName || '').trim()
|
||||
if (!saved || saved === standard) return undefined
|
||||
if ((aliasOptions || []).includes(saved)) return saved
|
||||
return undefined
|
||||
}
|
||||
|
||||
export function formatBrandConstraintLabel(
|
||||
brandMode?: string | null,
|
||||
brandName?: string | null
|
||||
): string {
|
||||
if (!brandMode) return '—'
|
||||
if (brandMode === 'required') return String(brandName || '').trim() || '—'
|
||||
if (brandMode === 'any') return '不限品牌'
|
||||
if (brandMode === 'any') return '—'
|
||||
return '—'
|
||||
}
|
||||
|
||||
/** 打印表格:指定品牌显示名称,不限/无品牌显示 - */
|
||||
export function formatBrandForPrint(
|
||||
brandMode?: string | null,
|
||||
brandName?: string | null
|
||||
): string {
|
||||
if (brandMode === 'required') {
|
||||
const name = String(brandName || '').trim()
|
||||
return name || '-'
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
export function initLineBrandMetaFromProduct(product: {
|
||||
productName?: string
|
||||
brands?: Array<{ id?: string; brandName?: string; status?: string }>
|
||||
@@ -31,8 +80,11 @@ export function initLineBrandMetaFromProduct(product: {
|
||||
}) {
|
||||
const brands = (product.brands || []).filter((b) => (b.status || 'on') === 'on' && b.id && b.brandName)
|
||||
const standardProductName = String(product.productName || '').trim()
|
||||
const aliasOptions = buildProductAliasOptions(product.aliases)
|
||||
return {
|
||||
standardProductName,
|
||||
aliasOptions,
|
||||
aliasName: undefined as string | undefined,
|
||||
nameOptions: buildProductNameOptions(standardProductName, product.aliases),
|
||||
brandOptions: brands.map((b) => ({
|
||||
id: String(b.id),
|
||||
@@ -59,12 +111,90 @@ export function applyBrandModeChange(
|
||||
}
|
||||
}
|
||||
|
||||
/** 单一品牌下拉:有值=指定,清空=不限(有品牌选项时) */
|
||||
export function applyBrandSelectChange(
|
||||
row: { brandId?: string; brandName?: string },
|
||||
brandId: string | undefined,
|
||||
row: { brandId?: string; brandName?: string; brandMode?: string },
|
||||
brandId: string | undefined | null,
|
||||
options: BrandOption[]
|
||||
) {
|
||||
row.brandId = brandId
|
||||
const hit = options.find((o) => o.id === brandId)
|
||||
const id = brandId ? String(brandId) : ''
|
||||
if (!id) {
|
||||
row.brandId = undefined
|
||||
row.brandName = undefined
|
||||
row.brandMode = options.length ? 'any' : undefined
|
||||
return
|
||||
}
|
||||
row.brandId = id
|
||||
row.brandMode = 'required'
|
||||
const hit = options.find((o) => o.id === id)
|
||||
row.brandName = hit?.brandName
|
||||
}
|
||||
|
||||
type LineAliasBrand = {
|
||||
productName?: string
|
||||
standardProductName?: string
|
||||
aliasName?: string
|
||||
aliasOptions?: string[]
|
||||
brandMode?: string
|
||||
brandId?: string
|
||||
brandName?: string
|
||||
brandOptions?: BrandOption[]
|
||||
}
|
||||
|
||||
/** 提交前:折叠别名→productName,折叠品牌下拉→brandMode */
|
||||
export function prepareLineAliasAndBrandForSubmit(line: LineAliasBrand) {
|
||||
const standard = String(line.standardProductName || '').trim()
|
||||
const aliasOpts = line.aliasOptions || []
|
||||
const saved = String(line.productName || '').trim()
|
||||
const alias = String(line.aliasName || '').trim()
|
||||
|
||||
if (alias) {
|
||||
line.productName = alias
|
||||
} else if (
|
||||
saved &&
|
||||
standard &&
|
||||
saved !== standard &&
|
||||
!aliasOpts.includes(saved)
|
||||
) {
|
||||
// 脏数据:别名列空且已存名既非标准名也不在别名列表 → 保留原 productName
|
||||
} else {
|
||||
line.productName = resolveLineProductName(standard || saved, undefined)
|
||||
}
|
||||
|
||||
const brandOptions = line.brandOptions || []
|
||||
if (brandOptions.length) {
|
||||
if (line.brandId) {
|
||||
applyBrandSelectChange(line, line.brandId, brandOptions)
|
||||
} else {
|
||||
line.brandMode = 'any'
|
||||
line.brandId = undefined
|
||||
line.brandName = undefined
|
||||
}
|
||||
} else {
|
||||
line.brandMode = undefined
|
||||
line.brandId = undefined
|
||||
line.brandName = undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看态:用产品主数据回填标准名与别名展示字段 */
|
||||
export function applyAliasDisplayMeta(
|
||||
line: {
|
||||
productName?: string
|
||||
standardProductName?: string
|
||||
aliasName?: string
|
||||
},
|
||||
product: {
|
||||
productName?: string
|
||||
aliases?: Array<{ aliasName?: string } | null> | null
|
||||
}
|
||||
) {
|
||||
const standard = String(product.productName || '').trim()
|
||||
const aliasOptions = buildProductAliasOptions(product.aliases)
|
||||
line.standardProductName = standard || String(line.productName || '').trim()
|
||||
line.aliasName = resolveAliasFromSavedName(
|
||||
line.productName,
|
||||
line.standardProductName,
|
||||
aliasOptions
|
||||
)
|
||||
}
|
||||
@@ -208,17 +208,56 @@ export function resolveSiteBrandSummary(item: {
|
||||
return summary || '—'
|
||||
}
|
||||
|
||||
/** 司机公开页产品一行展示(含运输计划产品备注) */
|
||||
/**
|
||||
* 出入库「品牌数量」列:优先现场 brandQtys;
|
||||
* 其次归档拼出的「品牌 数量」摘要(排除纯品牌名)。
|
||||
*/
|
||||
export function resolveIoBrandQtyDisplay(item: {
|
||||
brandQtys?: Array<{ brandName?: string | null; qty?: number | string | null }> | null
|
||||
brandSummary?: string | null
|
||||
brandName?: string | null
|
||||
}) {
|
||||
const fromQtys = formatBrandQtySummary(item.brandQtys)
|
||||
if (fromQtys) return fromQtys
|
||||
const summary = (item.brandSummary || '').trim()
|
||||
if (!summary) return '—'
|
||||
const brandName = (item.brandName || '').trim()
|
||||
if (brandName && summary === brandName) return '—'
|
||||
// 归档摘要形如「君正 12 / 红四方 13」
|
||||
if (/\s\d/.test(summary)) return summary
|
||||
return '—'
|
||||
}
|
||||
|
||||
/** 计划品牌约束展示:指定品牌名 / 不限品牌 */
|
||||
export function resolvePlanBrandDisplayLabel(options: {
|
||||
brandMode?: string | null
|
||||
brandName?: string | null
|
||||
}) {
|
||||
const mode = (options.brandMode || '').trim()
|
||||
const name = (options.brandName || '').trim()
|
||||
if (mode === 'required') return name || '指定品牌'
|
||||
if (mode === 'any') return name || '不限品牌'
|
||||
return name || ''
|
||||
}
|
||||
|
||||
/** 司机/现场公开页产品一行展示(含别名、品牌、运输计划产品备注) */
|
||||
export function formatPublicTransportProductLine(product: {
|
||||
productName?: string
|
||||
aliasName?: string | null
|
||||
model?: string
|
||||
packageSpec?: string
|
||||
unit?: string
|
||||
quantity?: number | string | null
|
||||
remark?: string
|
||||
brandMode?: string | null
|
||||
brandName?: string | null
|
||||
}) {
|
||||
const name = product.productName?.trim() || '—'
|
||||
const parts: string[] = []
|
||||
const alias = product.aliasName?.trim()
|
||||
if (alias) parts.push(`别名 ${alias}`)
|
||||
const brand = resolvePlanBrandDisplayLabel(product)
|
||||
if (brand) parts.push(`品牌 ${brand}`)
|
||||
const model = product.model?.trim()
|
||||
const packageSpec = product.packageSpec?.trim()
|
||||
if (model) parts.push(model)
|
||||
|
||||
@@ -66,6 +66,12 @@ const createToggleButton = (filterBlock: HTMLElement): HTMLButtonElement => {
|
||||
const resolveFilterToggleAnchor = (
|
||||
toolbar: HTMLElement
|
||||
): { anchor: HTMLElement; quickSearchInput: HTMLElement | null } | null => {
|
||||
// 有日期快捷时,漏斗放在日期控件左侧(下拉 / 分段按钮组同一容器内)
|
||||
const dateShortcuts = toolbar.querySelector<HTMLElement>('.list-toolbar-date-shortcuts')
|
||||
if (dateShortcuts) {
|
||||
return { anchor: dateShortcuts, quickSearchInput: null }
|
||||
}
|
||||
|
||||
const quickSearchInput = toolbar.querySelector<HTMLElement>('.quick-search-input')
|
||||
if (quickSearchInput) {
|
||||
return { anchor: ensureQuickSearchGroup(quickSearchInput), quickSearchInput }
|
||||
|
||||
Reference in new issue
Block a user