提交
This commit is contained in:
1 parent
4529166e16
commit
05559def40
268 files changed
+15319
-15336
No files matched your search
@@ -9,7 +9,7 @@
|
||||
export interface ContractQuery {
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
/** 即时检索:合同编号 / 合同产品名称 / 产品拼音首字母 */
|
||||
/** 即时检索:合同编号 / 合同名称 / 客户名称 / 合同产品名称 / 产品拼音首字母 */
|
||||
keyword?: string
|
||||
contractNo?: string
|
||||
contractName?: string
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
|
||||
/**
|
||||
* 合同编辑弹窗组件实例会复用(el-dialog destroy-on-close 只清 DOM)。
|
||||
* 打开下一份合同时必须无条件用字段重建附件列表。
|
||||
*
|
||||
* 错误:`if (field) list = build(field)` → 无附件合同残留上一份合同的 list
|
||||
* 正确:始终 `list = build(field)`(空字段 → 空列表)
|
||||
*/
|
||||
function syncAttachmentList(
|
||||
previous: string[],
|
||||
field: string | null | undefined,
|
||||
build: (f: string | null | undefined) => string[]
|
||||
): string[] {
|
||||
return build(field)
|
||||
}
|
||||
|
||||
function buggySyncAttachmentList(
|
||||
previous: string[],
|
||||
field: string | null | undefined,
|
||||
build: (f: string | null | undefined) => string[]
|
||||
): string[] {
|
||||
if (field) return build(field)
|
||||
return previous
|
||||
}
|
||||
|
||||
const build = (field: string | null | undefined) => {
|
||||
const raw = (field || '').trim()
|
||||
if (!raw || raw === '[]') return []
|
||||
return ['file-from-field']
|
||||
}
|
||||
|
||||
describe('contract form attachment list sync', () => {
|
||||
it('buggy conditional keeps previous list when next contract has no attachments', () => {
|
||||
const previous = ['contract-a-attachment']
|
||||
const next = buggySyncAttachmentList(previous, '', build)
|
||||
assert.deepEqual(next, ['contract-a-attachment'])
|
||||
})
|
||||
|
||||
it('fixed sync always replaces previous list when field is empty', () => {
|
||||
const previous = ['contract-a-attachment']
|
||||
assert.deepEqual(syncAttachmentList(previous, '', build), [])
|
||||
assert.deepEqual(syncAttachmentList(previous, null, build), [])
|
||||
assert.deepEqual(syncAttachmentList(previous, undefined, build), [])
|
||||
assert.deepEqual(syncAttachmentList(previous, '[]', build), [])
|
||||
assert.deepEqual(syncAttachmentList(previous, '[{"ossId":"x"}]', build), ['file-from-field'])
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,6 @@
|
||||
/** 送(提)货单:按送货客户聚合(一车多卸) */
|
||||
import type { Plan, PlanDelivery, PlanProduct, PlanStopProduct } from '@/api/pl'
|
||||
import { mergeBrandQtys } from '@/utils/pl-slip-product-brand'
|
||||
|
||||
export interface DeliveryPrintCustomerOption {
|
||||
customerId: string
|
||||
@@ -59,13 +60,31 @@ export function listDeliveryPrintCustomers(plan?: Pick<Plan, 'deliveries'> | nul
|
||||
}))
|
||||
}
|
||||
|
||||
function stopProductToPlanProduct(product: PlanStopProduct, planId: string): PlanProduct {
|
||||
function stopProductToPlanProduct(
|
||||
product: PlanStopProduct,
|
||||
planId: string,
|
||||
planProducts: PlanProduct[] = []
|
||||
): PlanProduct {
|
||||
const planProductId = String(product.planProductId || '').trim()
|
||||
const productId = String(product.productId || '').trim()
|
||||
const matched =
|
||||
planProducts.find((item) => planProductId && item.id === planProductId) ||
|
||||
planProducts.find((item) => productId && item.productId === productId)
|
||||
|
||||
const stopBrandQtys = product.brandQtys
|
||||
const brandQtys =
|
||||
stopBrandQtys && stopBrandQtys.length ? stopBrandQtys : matched?.brandQtys
|
||||
|
||||
return {
|
||||
id: product.id || product.planProductId || product.productId,
|
||||
planId,
|
||||
productId: product.productId,
|
||||
productNo: product.productNo,
|
||||
productName: product.productName,
|
||||
brandMode: matched?.brandMode,
|
||||
brandId: matched?.brandId,
|
||||
brandName: matched?.brandName,
|
||||
brandQtys,
|
||||
model: product.model,
|
||||
unit: product.unit,
|
||||
packageSpec: product.packageSpec,
|
||||
@@ -103,6 +122,14 @@ function mergePlanProducts(products: PlanProduct[]): PlanProduct[] {
|
||||
existing.outboundEstimateQty = sum(existing.outboundEstimateQty, product.outboundEstimateQty)
|
||||
existing.outboundQty = sum(existing.outboundQty, product.outboundQty)
|
||||
existing.inboundQty = sum(existing.inboundQty, product.inboundQty)
|
||||
existing.brandQtys = mergeBrandQtys(existing.brandQtys, product.brandQtys)
|
||||
const nameA = String(existing.brandName || '').trim()
|
||||
const nameB = String(product.brandName || '').trim()
|
||||
if (nameA && nameB && nameA !== nameB) {
|
||||
existing.brandName = undefined
|
||||
} else if (!nameA && nameB) {
|
||||
existing.brandName = product.brandName
|
||||
}
|
||||
if (!String(existing.remark || '').trim() && String(product.remark || '').trim()) {
|
||||
existing.remark = product.remark
|
||||
}
|
||||
@@ -124,9 +151,12 @@ export function applyDeliveryCustomerToPlan(plan: Plan, customerId: string): Pla
|
||||
throw new Error('未找到匹配的送货客户')
|
||||
}
|
||||
const primary = deliveries[0]
|
||||
const planProducts = plan.products || []
|
||||
const products = mergePlanProducts(
|
||||
deliveries.flatMap((delivery) =>
|
||||
(delivery.products || []).map((product) => stopProductToPlanProduct(product, plan.id))
|
||||
(delivery.products || []).map((product) =>
|
||||
stopProductToPlanProduct(product, plan.id, planProducts)
|
||||
)
|
||||
)
|
||||
)
|
||||
return {
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { SlipPlanProduct } from '@/utils/pl-batch-print'
|
||||
import { formatRemarkForSlipHtml } from '@/utils/pl-batch-print'
|
||||
import { getPlSlipSealSrc, type PlSlipCompanyKey } from '@/utils/pl-slip-company'
|
||||
import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
|
||||
import { expandPlanProductsForSlipPrint } from '@/utils/pl-slip-product-brand'
|
||||
|
||||
/** 送(提)货单打印默认公司信息(可在富文本中修改) */
|
||||
export const DELIVERY_SLIP_DEFAULTS = {
|
||||
@@ -206,7 +207,8 @@ function buildProductRows(
|
||||
return `<tr><td class="delivery-slip-product-cell" colspan="8" style="${PRODUCT_CELL}">暂无产品信息</td></tr>`
|
||||
}
|
||||
|
||||
const dataRows = products
|
||||
const expanded = expandPlanProductsForSlipPrint(products, 'outbound')
|
||||
const dataRows = expanded
|
||||
.map((product) => {
|
||||
const rowPlanNo = (product as SlipPlanProduct).slipPlanNo || planNo
|
||||
const planNoText = formatDeliverySlipProductGridCellContent(rowPlanNo)
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Plan, PlanProduct } from '@/api/pl'
|
||||
import type { SlipPlanProduct } from '@/utils/pl-batch-print'
|
||||
import { formatRemarkForSlipHtml } from '@/utils/pl-batch-print'
|
||||
import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
|
||||
import { expandPlanProductsForSlipPrint } from '@/utils/pl-slip-product-brand'
|
||||
|
||||
/** 入库单打印默认公司信息(可在富文本中修改) */
|
||||
export const INBOUND_SLIP_DEFAULTS = {
|
||||
@@ -197,7 +198,8 @@ function buildProductRows(
|
||||
return `<tr><td class="inbound-slip-product-cell" colspan="8" style="${PRODUCT_CELL}">暂无产品信息</td></tr>`
|
||||
}
|
||||
|
||||
const dataRows = products
|
||||
const expanded = expandPlanProductsForSlipPrint(products, 'inbound')
|
||||
const dataRows = expanded
|
||||
.map((product) => {
|
||||
const rowPlanNo = (product as SlipPlanProduct).slipPlanNo || planNo
|
||||
const planNoText = formatInboundSlipProductGridCellContent(rowPlanNo)
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
import type { PlanProduct } from '../api/pl'
|
||||
import {
|
||||
expandPlanProductsForSlipPrint,
|
||||
formatSlipProductNameWithBrand,
|
||||
mergeBrandQtys
|
||||
} from './pl-slip-product-brand'
|
||||
|
||||
function baseProduct(overrides: Partial<PlanProduct> = {}): PlanProduct {
|
||||
return {
|
||||
id: 'pp1',
|
||||
planId: 'plan1',
|
||||
productId: 'p1',
|
||||
productNo: 'NO1',
|
||||
productName: '片碱',
|
||||
unit: '吨',
|
||||
isExplosive: 0,
|
||||
isToxic: 0,
|
||||
quantity: 20,
|
||||
inboundQty: 20,
|
||||
outboundQty: 20,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
describe('formatSlipProductNameWithBrand', () => {
|
||||
it('appends brand in parentheses', () => {
|
||||
assert.equal(formatSlipProductNameWithBrand('片碱', '红四方'), '片碱(红四方)')
|
||||
})
|
||||
|
||||
it('skips empty brand', () => {
|
||||
assert.equal(formatSlipProductNameWithBrand('片碱', ''), '片碱')
|
||||
assert.equal(formatSlipProductNameWithBrand('片碱', null), '片碱')
|
||||
})
|
||||
|
||||
it('does not double-append same brand suffix', () => {
|
||||
assert.equal(formatSlipProductNameWithBrand('片碱(红四方)', '红四方'), '片碱(红四方)')
|
||||
})
|
||||
})
|
||||
|
||||
describe('expandPlanProductsForSlipPrint', () => {
|
||||
it('keeps row when no brand', () => {
|
||||
const rows = expandPlanProductsForSlipPrint([baseProduct()], 'inbound')
|
||||
assert.equal(rows.length, 1)
|
||||
assert.equal(rows[0].productName, '片碱')
|
||||
assert.equal(rows[0].inboundQty, 20)
|
||||
})
|
||||
|
||||
it('appends single brandName without splitting', () => {
|
||||
const rows = expandPlanProductsForSlipPrint([baseProduct({ brandName: '红四方' })], 'inbound')
|
||||
assert.equal(rows.length, 1)
|
||||
assert.equal(rows[0].productName, '片碱(红四方)')
|
||||
assert.equal(rows[0].inboundQty, 20)
|
||||
})
|
||||
|
||||
it('splits brandQtys into rows with brand qty', () => {
|
||||
const rows = expandPlanProductsForSlipPrint(
|
||||
[
|
||||
baseProduct({
|
||||
brandQtys: [
|
||||
{ brandId: 'b1', brandName: '红四方', qty: 10 },
|
||||
{ brandId: 'b2', brandName: '君正', qty: 5 }
|
||||
]
|
||||
})
|
||||
],
|
||||
'outbound'
|
||||
)
|
||||
assert.equal(rows.length, 2)
|
||||
assert.equal(rows[0].productName, '片碱(红四方)')
|
||||
assert.equal(rows[0].outboundQty, 10)
|
||||
assert.equal(rows[0].quantity, 10)
|
||||
assert.equal(rows[1].productName, '片碱(君正)')
|
||||
assert.equal(rows[1].outboundQty, 5)
|
||||
})
|
||||
|
||||
it('ignores brandQtys with zero qty or empty name', () => {
|
||||
const rows = expandPlanProductsForSlipPrint(
|
||||
[
|
||||
baseProduct({
|
||||
brandName: '红四方',
|
||||
brandQtys: [
|
||||
{ brandId: 'b1', brandName: '红四方', qty: 0 },
|
||||
{ brandId: 'b2', brandName: '', qty: 3 }
|
||||
]
|
||||
})
|
||||
],
|
||||
'inbound'
|
||||
)
|
||||
assert.equal(rows.length, 1)
|
||||
assert.equal(rows[0].productName, '片碱(红四方)')
|
||||
})
|
||||
|
||||
it('preserves slipPlanNo when splitting', () => {
|
||||
const rows = expandPlanProductsForSlipPrint(
|
||||
[
|
||||
{
|
||||
...baseProduct({
|
||||
brandQtys: [
|
||||
{ brandId: 'b1', brandName: 'A', qty: 1 },
|
||||
{ brandId: 'b2', brandName: 'B', qty: 2 }
|
||||
]
|
||||
}),
|
||||
slipPlanNo: 'JH001'
|
||||
} as PlanProduct & { slipPlanNo?: string }
|
||||
],
|
||||
'inbound'
|
||||
)
|
||||
assert.equal((rows[0] as { slipPlanNo?: string }).slipPlanNo, 'JH001')
|
||||
assert.equal((rows[1] as { slipPlanNo?: string }).slipPlanNo, 'JH001')
|
||||
})
|
||||
})
|
||||
|
||||
describe('mergeBrandQtys', () => {
|
||||
it('sums qty by brandId', () => {
|
||||
const merged = mergeBrandQtys(
|
||||
[{ brandId: 'b1', brandName: '红四方', qty: 10 }],
|
||||
[{ brandId: 'b1', brandName: '红四方', qty: 5 }]
|
||||
)
|
||||
assert.deepEqual(merged, [{ brandId: 'b1', brandName: '红四方', qty: 15 }])
|
||||
})
|
||||
|
||||
it('keeps distinct brands', () => {
|
||||
const merged = mergeBrandQtys(
|
||||
[{ brandId: 'b1', brandName: '红四方', qty: 10 }],
|
||||
[{ brandId: 'b2', brandName: '君正', qty: 5 }]
|
||||
)
|
||||
assert.equal(merged?.length, 2)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,113 @@
|
||||
import type { PlanArchiveBrandQtyItem, PlanProduct } from '@/api/pl'
|
||||
|
||||
/** 打印单据产品名:有品牌则 `产品名(品牌)` */
|
||||
export function formatSlipProductNameWithBrand(
|
||||
productName: string,
|
||||
brandName?: string | null
|
||||
): string {
|
||||
const name = String(productName || '').trim()
|
||||
const brand = String(brandName || '').trim()
|
||||
if (!brand) return name
|
||||
const suffix = `(${brand})`
|
||||
if (name.endsWith(suffix)) return name
|
||||
return `${name}${suffix}`
|
||||
}
|
||||
|
||||
function listValidBrandQtys(
|
||||
brandQtys?: PlanArchiveBrandQtyItem[] | null
|
||||
): PlanArchiveBrandQtyItem[] {
|
||||
return (brandQtys || []).filter((row) => {
|
||||
const qty = Number(row.qty)
|
||||
const brand = String(row.brandName || '').trim()
|
||||
return Number.isFinite(qty) && qty > 0 && !!brand
|
||||
})
|
||||
}
|
||||
|
||||
function applyBrandQty(
|
||||
product: PlanProduct,
|
||||
qty: number,
|
||||
qtyMode: 'inbound' | 'outbound'
|
||||
): PlanProduct {
|
||||
const next: PlanProduct = {
|
||||
...product,
|
||||
quantity: qty,
|
||||
brandQtys: undefined
|
||||
}
|
||||
if (qtyMode === 'inbound') {
|
||||
next.inboundQty = qty
|
||||
} else {
|
||||
next.outboundQty = qty
|
||||
}
|
||||
return next
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印前展开产品行:
|
||||
* - 有效 brandQtys → 按品牌拆行,名称带品牌,数量用该品牌 qty
|
||||
* - 仅有 brandName → 单行拼接名称
|
||||
* - 皆无 → 原样浅拷贝
|
||||
*/
|
||||
export function expandPlanProductsForSlipPrint(
|
||||
products: PlanProduct[] = [],
|
||||
qtyMode: 'inbound' | 'outbound'
|
||||
): PlanProduct[] {
|
||||
const result: PlanProduct[] = []
|
||||
for (const product of products) {
|
||||
const brandRows = listValidBrandQtys(product.brandQtys)
|
||||
if (brandRows.length) {
|
||||
for (const row of brandRows) {
|
||||
const brandName = String(row.brandName || '').trim()
|
||||
const qty = Number(row.qty)
|
||||
result.push(
|
||||
applyBrandQty(
|
||||
{
|
||||
...product,
|
||||
productName: formatSlipProductNameWithBrand(product.productName, brandName),
|
||||
brandName,
|
||||
brandId: row.brandId
|
||||
},
|
||||
qty,
|
||||
qtyMode
|
||||
)
|
||||
)
|
||||
}
|
||||
continue
|
||||
}
|
||||
const brandName = String(product.brandName || '').trim()
|
||||
if (brandName) {
|
||||
result.push({
|
||||
...product,
|
||||
productName: formatSlipProductNameWithBrand(product.productName, brandName)
|
||||
})
|
||||
continue
|
||||
}
|
||||
result.push({ ...product })
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** 合并同产品多段的品牌数量(按 brandId,无则按品牌名) */
|
||||
export function mergeBrandQtys(
|
||||
a?: PlanArchiveBrandQtyItem[] | null,
|
||||
b?: PlanArchiveBrandQtyItem[] | null
|
||||
): PlanArchiveBrandQtyItem[] | undefined {
|
||||
const list = [...(a || []), ...(b || [])]
|
||||
if (!list.length) return undefined
|
||||
const map = new Map<string, PlanArchiveBrandQtyItem>()
|
||||
for (const row of list) {
|
||||
const brandId = String(row.brandId || '').trim()
|
||||
const brandName = String(row.brandName || '').trim()
|
||||
const key = brandId ? `id:${brandId}` : brandName ? `name:${brandName}` : ''
|
||||
if (!key) continue
|
||||
const existing = map.get(key)
|
||||
if (!existing) {
|
||||
map.set(key, { ...row, qty: Number(row.qty) || 0 })
|
||||
continue
|
||||
}
|
||||
existing.qty = Number(existing.qty || 0) + Number(row.qty || 0)
|
||||
if (!String(existing.brandName || '').trim() && brandName) {
|
||||
existing.brandName = row.brandName
|
||||
}
|
||||
}
|
||||
return [...map.values()]
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Plan, PlanProduct } from '@/api/pl'
|
||||
import { formatRemarkForSlipHtml } from '@/utils/pl-batch-print'
|
||||
import { applyPdfStableTableCellBorders } from '@/utils/pl-slip-pdf-render'
|
||||
import { expandPlanProductsForSlipPrint } from '@/utils/pl-slip-product-brand'
|
||||
|
||||
/** 分装单打印默认公司信息(可在富文本中修改) */
|
||||
export const SUBPACK_SLIP_DEFAULTS = {
|
||||
@@ -211,11 +212,12 @@ function buildSubpackSlipProductRow(
|
||||
}
|
||||
|
||||
function buildProductRows(products: PlanProduct[] = [], ctx?: SubpackSlipRenderContext): string {
|
||||
const rowCount = Math.max(products.length, SUBPACK_SLIP_PRODUCT_MIN_ROWS)
|
||||
const expanded = expandPlanProductsForSlipPrint(products, 'outbound')
|
||||
const rowCount = Math.max(expanded.length, SUBPACK_SLIP_PRODUCT_MIN_ROWS)
|
||||
const rows: string[] = []
|
||||
|
||||
for (let index = 0; index < rowCount; index += 1) {
|
||||
rows.push(buildSubpackSlipProductRow(index + 1, products[index], ctx))
|
||||
rows.push(buildSubpackSlipProductRow(index + 1, expanded[index], ctx))
|
||||
}
|
||||
|
||||
return rows.join('')
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="list-toolbar-row">
|
||||
<ListQuickSearchInput
|
||||
v-model="quickSearchKeyword"
|
||||
placeholder="申请单号/申请原因"
|
||||
placeholder="申请单号/申请人"
|
||||
@search="handleQuickSearch"
|
||||
@clear="handleQuickSearchClear"
|
||||
/>
|
||||
@@ -528,8 +528,9 @@ import ColumnHeaderFilter from '@/components/business/column-header-filter/index
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick, provide } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import {
|
||||
@@ -596,6 +597,26 @@ const {
|
||||
onChange: () => runListSearch()
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => runListSearch()
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = advanceApplyColumnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -628,6 +649,7 @@ const visibleFilterProps = computed(() => {
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -740,7 +762,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
function buildSearchQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="list-toolbar-row">
|
||||
<ListQuickSearchInput
|
||||
v-model="pendingQuickSearchKeyword"
|
||||
placeholder="申请单号/申请原因"
|
||||
placeholder="申请单号/申请人"
|
||||
@search="handlePendingQuickSearch"
|
||||
@clear="handlePendingQuickSearchClear"
|
||||
/>
|
||||
@@ -252,7 +252,7 @@
|
||||
<div class="list-toolbar-row">
|
||||
<ListQuickSearchInput
|
||||
v-model="approvedQuickSearchKeyword"
|
||||
placeholder="申请单号/申请原因"
|
||||
placeholder="申请单号/申请人"
|
||||
@search="handleApprovedQuickSearch"
|
||||
@clear="handleApprovedQuickSearchClear"
|
||||
/>
|
||||
@@ -604,7 +604,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick, provide } from 'vue'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
@@ -613,6 +613,7 @@ import ListQuickSearchInput from '@/components/business/list-quick-search-input/
|
||||
import ColumnHeaderFilter from '@/components/business/column-header-filter/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Close, Filter } from '@element-plus/icons-vue'
|
||||
import { advanceApi } from '@/api/bx'
|
||||
@@ -770,6 +771,32 @@ const {
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
if (activeTab.value === 'pending') {
|
||||
searchPending(buildPendingQuery())
|
||||
} else {
|
||||
searchApproved(buildApprovedQuery())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = advanceApproveColumnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -785,6 +812,7 @@ const visibleFilterProps = computed(() => {
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -792,7 +820,7 @@ function handleResetColumns() {
|
||||
}
|
||||
|
||||
function buildPendingQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
delete q.statusIn
|
||||
const kw = pendingQuickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
@@ -800,7 +828,7 @@ function buildPendingQuery() {
|
||||
}
|
||||
|
||||
function buildApprovedQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = approvedQuickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -693,8 +693,9 @@ import ListColumnStatsRow from '@/components/business/list-column-stats-row/inde
|
||||
import ColumnHeaderFilter from '@/components/business/column-header-filter/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick, provide } from 'vue'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Close, Filter } from '@element-plus/icons-vue'
|
||||
@@ -827,6 +828,26 @@ const {
|
||||
onChange: () => runListSearch()
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => runListSearch()
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
/** 待发放 Tab 不计发放时间/发放人;切回待发放时自动清掉对应条件 */
|
||||
const visibleFilterProps = computed(() => {
|
||||
const props: string[] = ['applyCode']
|
||||
@@ -843,6 +864,7 @@ const visibleFilterProps = computed(() => {
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -850,7 +872,7 @@ function handleResetColumns() {
|
||||
}
|
||||
|
||||
function buildSearchQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -341,7 +341,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, nextTick } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, nextTick, provide, watch } from 'vue'
|
||||
import { Upload, Close, Check, Filter, View } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
@@ -349,6 +349,7 @@
|
||||
import ListColumnStatsRow from '@/components/business/list-column-stats-row/index.vue'
|
||||
import ColumnHeaderFilter from '@/components/business/column-header-filter/index.vue'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import type { StatsRowColumn } from '@/utils/list-column-stats'
|
||||
import BxInvoiceFileSelect from '@/components/bx/base/BxInvoiceFileSelect.vue'
|
||||
@@ -400,6 +401,32 @@
|
||||
onChange: () => loadLedgers()
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
if (activeTab.value === 'invoices') loadInvoices()
|
||||
else loadLedgers()
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
watch(activeTab, () => {
|
||||
clearSort()
|
||||
})
|
||||
|
||||
const hasActiveFilters = computed(
|
||||
() => hasInvoiceFilters.value || hasLedgerFilters.value
|
||||
)
|
||||
@@ -535,14 +562,14 @@
|
||||
}
|
||||
|
||||
function buildInvoiceQuery() {
|
||||
const q: Record<string, string> = { ...toInvoiceQueryParams() }
|
||||
const q: Record<string, string> = { ...toInvoiceQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
}
|
||||
|
||||
function buildLedgerQuery() {
|
||||
const q: Record<string, string> = { ...toLedgerQueryParams() }
|
||||
const q: Record<string, string> = { ...toLedgerQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -854,7 +854,8 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import ColumnHeaderFilter from '@/components/business/column-header-filter/index.vue'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { reactive, ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import { reactive, ref, computed, onMounted, nextTick, provide } from 'vue'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
@@ -1010,6 +1011,32 @@ const {
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
if (activeTab.value === 'pending') {
|
||||
runPendingSearch()
|
||||
} else {
|
||||
runProcessedSearch()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
/** 待处理 Tab 不计处理状态/处理时间;切回待处理时自动清掉对应条件 */
|
||||
const visibleFilterProps = computed(() => {
|
||||
const props: string[] = ['applyCode']
|
||||
@@ -1025,6 +1052,7 @@ const visibleFilterProps = computed(() => {
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -1208,7 +1236,7 @@ function handleToolbarOffset() {
|
||||
}
|
||||
|
||||
function buildPendingQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
delete q.statusIn
|
||||
delete q.status
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
@@ -1217,7 +1245,7 @@ function buildPendingQuery() {
|
||||
}
|
||||
|
||||
function buildProcessedQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = processedQuickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -324,6 +324,7 @@
|
||||
align-center
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
@closed="onAddDialogClosed"
|
||||
>
|
||||
<el-form label-position="top" class="bx-dialog-form">
|
||||
<div class="form-grid-3">
|
||||
@@ -522,7 +523,7 @@
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button class="btn-ghost" @click="dialogs.add = false">
|
||||
<el-button class="btn-ghost" @click="closeAddDialog">
|
||||
<el-icon><Close /></el-icon>取消
|
||||
</el-button>
|
||||
<el-button
|
||||
@@ -774,8 +775,9 @@ import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { type ColumnFilterDef } from '@/composables/useClientColumnFilters'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick, provide } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
Plus,
|
||||
@@ -898,6 +900,26 @@ const {
|
||||
onChange: () => runListSearch()
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => runListSearch()
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = columnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -946,6 +968,7 @@ const visibleFilterProps = computed(() => {
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -964,7 +987,7 @@ const { tableHeight, recalc: recalcTableHeight } = useListTableViewportHeight({
|
||||
})
|
||||
|
||||
function buildSearchQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
@@ -1382,6 +1405,8 @@ async function handleViewDelete() {
|
||||
}
|
||||
|
||||
async function openEditDialog(row: any) {
|
||||
// 先清空上一张单的发票/附件,避免打开无发票单据时短暂残留或保存串单
|
||||
selectedInvoicePicks.value = []
|
||||
applyAttachments.value = []
|
||||
try {
|
||||
const res: any = await reimburseApi.getById(row.id)
|
||||
@@ -1634,6 +1659,22 @@ function resetAddForm() {
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function closeAddDialog() {
|
||||
dialogs.add = false
|
||||
}
|
||||
|
||||
/** 关闭后清空发票/附件等状态,避免下一张单打开前残留 */
|
||||
function onAddDialogClosed() {
|
||||
selectedInvoicePicks.value = []
|
||||
applyAttachments.value = []
|
||||
addForm.applicantId = currentUserId()
|
||||
addForm.reimburseDate = todayYmd()
|
||||
addForm.title = ''
|
||||
addForm.remark = ''
|
||||
addForm.details = [{ expenseItemId: '', amount: '', remark: '', occurDate: '' }]
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
/** 保存报销单,成功返回 id;校验失败返回 null */
|
||||
async function saveAddForm(payload: AddPayload): Promise<string | null> {
|
||||
if (editingId.value) {
|
||||
|
||||
@@ -712,7 +712,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { reactive, ref, computed, onMounted, nextTick, provide } from 'vue'
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import ListExportDropdown from '@/components/business/list-export-dropdown/index.vue'
|
||||
import ListColumnStatsRow from '@/components/business/list-column-stats-row/index.vue'
|
||||
@@ -721,6 +721,7 @@ import ColumnHeaderFilter from '@/components/business/column-header-filter/index
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Close, Filter } from '@element-plus/icons-vue'
|
||||
import { reimburseApi } from '@/api/bx'
|
||||
@@ -891,6 +892,32 @@ const {
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
if (activeTab.value === 'pending') {
|
||||
searchPending(buildPendingQuery())
|
||||
} else {
|
||||
searchApproved(buildApprovedQuery())
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = reimburseApproveColumnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -906,6 +933,7 @@ const visibleFilterProps = computed(() => {
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -913,7 +941,7 @@ function handleResetColumns() {
|
||||
}
|
||||
|
||||
function buildPendingQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
delete q.statusIn
|
||||
delete q.status
|
||||
const kw = pendingQuickSearchKeyword.value.trim()
|
||||
@@ -922,7 +950,7 @@ function buildPendingQuery() {
|
||||
}
|
||||
|
||||
function buildApprovedQuery() {
|
||||
const q: Record<string, string> = { ...toQueryParams() }
|
||||
const q: Record<string, string> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = approvedQuickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -440,7 +440,8 @@
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { computed, onMounted, reactive, ref, nextTick } from 'vue'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import { computed, onMounted, reactive, ref, nextTick, provide } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Filter } from '@element-plus/icons-vue'
|
||||
import { advanceApi, paymentApi, reimburseApi } from '@/api/bx'
|
||||
@@ -514,7 +515,7 @@
|
||||
}
|
||||
|
||||
function getBxViewExportFilterParams() {
|
||||
const q: Record<string, any> = { ...toQueryParams() }
|
||||
const q: Record<string, any> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
@@ -563,6 +564,29 @@
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
pager.currentPage.value = 1
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = bxViewAllColumnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -576,6 +600,7 @@
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -717,6 +742,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
function sortMergedRows(rows: any[]) {
|
||||
const field = sortField.value || 'applyTime'
|
||||
const order = sortOrder.value || 'desc'
|
||||
return [...rows].sort((a, b) => {
|
||||
const av = String(a[field] || '')
|
||||
const bv = String(b[field] || '')
|
||||
if (!av && !bv) return 0
|
||||
if (!av) return order === 'asc' ? -1 : 1
|
||||
if (!bv) return order === 'asc' ? 1 : -1
|
||||
const cmp = av.localeCompare(bv)
|
||||
return order === 'asc' ? cmp : -cmp
|
||||
})
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -724,7 +763,11 @@
|
||||
const sides = resolveViewBizSides(filters)
|
||||
const tasks: Promise<any[]>[] = []
|
||||
if (sides.advance) {
|
||||
const apiQuery = buildViewSideQuery(toQueryParams, 'advance', kw)
|
||||
const apiQuery = buildViewSideQuery(
|
||||
() => ({ ...toQueryParams(), ...toSortQueryParams() }),
|
||||
'advance',
|
||||
kw
|
||||
)
|
||||
tasks.push(
|
||||
fetchAllPagedRecords(async (page, pageSize) =>
|
||||
pickBxPageResult(await advanceApi.list({ page, pageSize, ...apiQuery }))
|
||||
@@ -734,7 +777,11 @@
|
||||
tasks.push(Promise.resolve([]))
|
||||
}
|
||||
if (sides.reimburse) {
|
||||
const apiQuery = buildViewSideQuery(toQueryParams, 'reimburse', kw)
|
||||
const apiQuery = buildViewSideQuery(
|
||||
() => ({ ...toQueryParams(), ...toSortQueryParams() }),
|
||||
'reimburse',
|
||||
kw
|
||||
)
|
||||
tasks.push(
|
||||
fetchAllPagedRecords(async (page, pageSize) =>
|
||||
pickBxPageResult(await reimburseApi.list({ page, pageSize, ...apiQuery }))
|
||||
@@ -744,7 +791,7 @@
|
||||
tasks.push(Promise.resolve([]))
|
||||
}
|
||||
const [advRows, reimRows] = await Promise.all(tasks)
|
||||
mergedRows.value = [...advRows, ...reimRows]
|
||||
mergedRows.value = sortMergedRows([...advRows, ...reimRows])
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
|
||||
@@ -416,7 +416,8 @@
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { computed, onActivated, onMounted, reactive, ref } from 'vue'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import { computed, onActivated, onMounted, reactive, ref, provide } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Filter } from '@element-plus/icons-vue'
|
||||
import { advanceApi, paymentApi, reimburseApi } from '@/api/bx'
|
||||
@@ -489,7 +490,7 @@
|
||||
}
|
||||
|
||||
function getBxViewExportFilterParams() {
|
||||
const q: Record<string, any> = { ...toQueryParams() }
|
||||
const q: Record<string, any> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
@@ -537,6 +538,29 @@
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
currentPage.value = 1
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = bxViewMineColumnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -550,6 +574,7 @@
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -695,9 +720,17 @@
|
||||
}
|
||||
|
||||
function sortMergedRows(rows: any[]) {
|
||||
return [...rows].sort((a, b) =>
|
||||
String(b.applyTime || '').localeCompare(String(a.applyTime || ''))
|
||||
)
|
||||
const field = sortField.value || 'applyTime'
|
||||
const order = sortOrder.value || 'desc'
|
||||
return [...rows].sort((a, b) => {
|
||||
const av = String(a[field] || '')
|
||||
const bv = String(b[field] || '')
|
||||
if (!av && !bv) return 0
|
||||
if (!av) return order === 'asc' ? -1 : 1
|
||||
if (!bv) return order === 'asc' ? 1 : -1
|
||||
const cmp = av.localeCompare(bv)
|
||||
return order === 'asc' ? cmp : -cmp
|
||||
})
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
@@ -707,7 +740,11 @@
|
||||
const sides = resolveViewBizSides(filters)
|
||||
const tasks: Promise<any[]>[] = []
|
||||
if (sides.advance) {
|
||||
const apiQuery = buildViewSideQuery(toQueryParams, 'advance', kw)
|
||||
const apiQuery = buildViewSideQuery(
|
||||
() => ({ ...toQueryParams(), ...toSortQueryParams() }),
|
||||
'advance',
|
||||
kw
|
||||
)
|
||||
tasks.push(
|
||||
fetchAllPagedRecords(async (page, pageSize) =>
|
||||
pickBxPageResult(await advanceApi.my({ page, pageSize, ...apiQuery }))
|
||||
@@ -717,7 +754,11 @@
|
||||
tasks.push(Promise.resolve([]))
|
||||
}
|
||||
if (sides.reimburse) {
|
||||
const apiQuery = buildViewSideQuery(toQueryParams, 'reimburse', kw)
|
||||
const apiQuery = buildViewSideQuery(
|
||||
() => ({ ...toQueryParams(), ...toSortQueryParams() }),
|
||||
'reimburse',
|
||||
kw
|
||||
)
|
||||
tasks.push(
|
||||
fetchAllPagedRecords(async (page, pageSize) =>
|
||||
pickBxPageResult(await reimburseApi.my({ page, pageSize, ...apiQuery }))
|
||||
|
||||
@@ -489,8 +489,9 @@
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import { useListTableViewportHeight } from '@/composables/useListTableViewportHeight'
|
||||
import { useServerColumnFilters } from '@/composables/useServerColumnFilters'
|
||||
import { useColumnSort } from '@/composables/useColumnSort'
|
||||
import ListQuickSearchInput from '@/components/business/list-quick-search-input/index.vue'
|
||||
import { computed, onActivated, onMounted, reactive, ref, nextTick } from 'vue'
|
||||
import { computed, onActivated, onMounted, reactive, ref, nextTick, provide } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Check, Close, Filter } from '@element-plus/icons-vue'
|
||||
import { advanceApi, paymentApi, reimburseApi } from '@/api/bx'
|
||||
@@ -571,6 +572,29 @@
|
||||
}
|
||||
})
|
||||
|
||||
const {
|
||||
sortField,
|
||||
sortOrder,
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
toQueryParams: toSortQueryParams,
|
||||
watchVisibleColumns: watchSortVisibleColumns
|
||||
} = useColumnSort({
|
||||
onChange: () => {
|
||||
currentPage.value = 1
|
||||
loadData()
|
||||
}
|
||||
})
|
||||
|
||||
provide('crmColumnSort', {
|
||||
setSort,
|
||||
clearSort,
|
||||
isSortActive,
|
||||
sortField,
|
||||
sortOrder
|
||||
})
|
||||
|
||||
function enumOptionsFor(prop: string) {
|
||||
const def = bxViewTodoColumnFilterDefs.find((d) => d.prop === prop)
|
||||
return (def?.enumOptions || []).map((o) => ({ ...o, count: 0 }))
|
||||
@@ -584,6 +608,7 @@
|
||||
return props
|
||||
})
|
||||
watchVisibleColumns(visibleFilterProps)
|
||||
watchSortVisibleColumns(visibleFilterProps)
|
||||
|
||||
function handleResetColumns() {
|
||||
resetToDefault()
|
||||
@@ -733,6 +758,20 @@
|
||||
await refreshMenuBadges(menuStore.menuList)
|
||||
}
|
||||
|
||||
function sortMergedRows(rows: any[]) {
|
||||
const field = sortField.value || 'applyTime'
|
||||
const order = sortOrder.value || 'desc'
|
||||
return [...rows].sort((a, b) => {
|
||||
const av = String(a[field] || '')
|
||||
const bv = String(b[field] || '')
|
||||
if (!av && !bv) return 0
|
||||
if (!av) return order === 'asc' ? -1 : 1
|
||||
if (!bv) return order === 'asc' ? 1 : -1
|
||||
const cmp = av.localeCompare(bv)
|
||||
return order === 'asc' ? cmp : -cmp
|
||||
})
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
tableLoading.value = true
|
||||
try {
|
||||
@@ -740,7 +779,11 @@
|
||||
const sides = resolveViewBizSides(filters)
|
||||
const tasks: Promise<any[]>[] = []
|
||||
if (sides.advance) {
|
||||
const apiQuery = buildViewSideQuery(toQueryParams, 'advance', kw)
|
||||
const apiQuery = buildViewSideQuery(
|
||||
() => ({ ...toQueryParams(), ...toSortQueryParams() }),
|
||||
'advance',
|
||||
kw
|
||||
)
|
||||
tasks.push(
|
||||
fetchAllPagedRecords(async (page, pageSize) =>
|
||||
pickBxPageResult(await advanceApi.pendingApproval({ page, pageSize, ...apiQuery }))
|
||||
@@ -750,7 +793,11 @@
|
||||
tasks.push(Promise.resolve([]))
|
||||
}
|
||||
if (sides.reimburse) {
|
||||
const apiQuery = buildViewSideQuery(toQueryParams, 'reimburse', kw)
|
||||
const apiQuery = buildViewSideQuery(
|
||||
() => ({ ...toQueryParams(), ...toSortQueryParams() }),
|
||||
'reimburse',
|
||||
kw
|
||||
)
|
||||
tasks.push(
|
||||
fetchAllPagedRecords(async (page, pageSize) =>
|
||||
pickBxPageResult(await reimburseApi.pendingApproval({ page, pageSize, ...apiQuery }))
|
||||
@@ -760,7 +807,7 @@
|
||||
tasks.push(Promise.resolve([]))
|
||||
}
|
||||
const [advRows, reimRows] = await Promise.all(tasks)
|
||||
mergedRows.value = [...advRows, ...reimRows]
|
||||
mergedRows.value = sortMergedRows([...advRows, ...reimRows])
|
||||
} catch {
|
||||
// error handled by interceptor
|
||||
} finally {
|
||||
@@ -859,7 +906,7 @@
|
||||
}
|
||||
|
||||
function getBxViewExportFilterParams() {
|
||||
const q: Record<string, any> = { ...toQueryParams() }
|
||||
const q: Record<string, any> = { ...toQueryParams(), ...toSortQueryParams() }
|
||||
const kw = quickSearchKeyword.value.trim()
|
||||
if (kw) q.keyword = kw
|
||||
return q
|
||||
|
||||
@@ -1350,6 +1350,8 @@ interface QuoteVO {
|
||||
/** 对话框打开后的初始化 */
|
||||
const handleOpened = async () => {
|
||||
resetPartyExpand()
|
||||
// 组件实例复用时必须先清空;否则无附件合同会残留上一份合同的 attachmentList
|
||||
resetForm()
|
||||
const isEdit = !!props.editId
|
||||
const isCopy = !!props.copySource
|
||||
if (isEdit || isCopy) {
|
||||
@@ -1439,7 +1441,8 @@ const resetForm = () => {
|
||||
deliveryTerms: '',
|
||||
contractTerms: '',
|
||||
products: [] as ExtendedContractProductForm[],
|
||||
remark: ''
|
||||
remark: '',
|
||||
attachmentFiles: ''
|
||||
}
|
||||
isPartiesSwapped.value = false
|
||||
resetPartyExpand()
|
||||
@@ -1610,9 +1613,8 @@ const loadContractDetail = async (id: number | string) => {
|
||||
contractDateRange.value = [form.value.startDate, form.value.endDate]
|
||||
}
|
||||
|
||||
if (form.value.attachmentFiles) {
|
||||
await handleAttachmentData()
|
||||
}
|
||||
// 无条件同步:空附件也必须清空列表,避免沿用上一份合同的附件
|
||||
await handleAttachmentData()
|
||||
|
||||
customerShortName.value = ''
|
||||
customerInvoiceName.value = ''
|
||||
@@ -2739,14 +2741,12 @@ const handleSaveDraft = async () => {
|
||||
rebuildContractName()
|
||||
saveDraftLoading.value = true
|
||||
try {
|
||||
// 以界面列表为准(含空列表),避免 form 残留字段把上一份合同附件写回
|
||||
const attachmentJson = serializeContractAttachments(attachmentList.value)
|
||||
const data: any = { ...form.value }
|
||||
data.status = 'draft'
|
||||
data.approvalStatus = null
|
||||
|
||||
if (attachmentJson) {
|
||||
data.attachmentFiles = attachmentJson
|
||||
}
|
||||
data.attachmentFiles = attachmentJson
|
||||
|
||||
omitEmptyExceptPartyFields(data)
|
||||
|
||||
@@ -2936,12 +2936,10 @@ const handleSubmit = async () => {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
rebuildContractName()
|
||||
// 以界面列表为准(含空列表),避免 form 残留字段把上一份合同附件写回
|
||||
const attachmentJson = serializeContractAttachments(attachmentList.value)
|
||||
const data: any = { ...form.value }
|
||||
|
||||
if (attachmentJson) {
|
||||
data.attachmentFiles = attachmentJson
|
||||
}
|
||||
data.attachmentFiles = attachmentJson
|
||||
|
||||
omitEmptyExceptPartyFields(data)
|
||||
|
||||
|
||||
@@ -853,10 +853,8 @@ const loadContractDetail = async (id: number | string) => {
|
||||
contractDateRange.value = [form.value.startDate, form.value.endDate];
|
||||
}
|
||||
|
||||
// 7. 加载附件列表
|
||||
if (form.value.attachmentFiles) {
|
||||
await handleAttachmentData();
|
||||
}
|
||||
// 7. 加载附件列表(无条件同步,空附件也必须清空,避免残留)
|
||||
await handleAttachmentData();
|
||||
};
|
||||
|
||||
/** 选择客户 */
|
||||
@@ -1762,15 +1760,13 @@ const handleSaveDraft = async () => {
|
||||
|
||||
saveDraftLoading.value = true;
|
||||
try {
|
||||
// 以界面列表为准(含空列表),避免 form 残留字段把上一份合同附件写回
|
||||
const attachmentJson = serializeContractAttachments(attachmentList.value);
|
||||
|
||||
const data: any = { ...form.value };
|
||||
data.status = 'draft';
|
||||
data.approvalStatus = null; // 草稿状态下,审批状态应该为空
|
||||
|
||||
if (attachmentJson) {
|
||||
data.attachmentFiles = attachmentJson;
|
||||
}
|
||||
data.attachmentFiles = attachmentJson;
|
||||
|
||||
// 清理未填写的字段;供/需方空字符串保留,以便清空落库
|
||||
omitEmptyExceptPartyFields(data);
|
||||
@@ -1969,10 +1965,8 @@ const handleSubmit = async () => {
|
||||
const attachmentJson = serializeContractAttachments(attachmentList.value);
|
||||
|
||||
const data: any = { ...form.value };
|
||||
|
||||
if (attachmentJson) {
|
||||
data.attachmentFiles = attachmentJson;
|
||||
}
|
||||
// 以界面列表为准(含空列表),避免 form 残留字段把上一份合同附件写回
|
||||
data.attachmentFiles = attachmentJson;
|
||||
|
||||
// 清理未填写的字段;供/需方空字符串保留,以便清空落库
|
||||
omitEmptyExceptPartyFields(data);
|
||||
|
||||
@@ -865,6 +865,11 @@
|
||||
applyFoundToFormSlot(custom, s)
|
||||
slots.push(custom)
|
||||
}
|
||||
} else if (detail?.id) {
|
||||
// 已有值班日但班次已全部清空:勿回落到「默认启用早/晚班」
|
||||
for (const fs of slots) {
|
||||
fs.enabled = false
|
||||
}
|
||||
}
|
||||
formSlots.value = slots
|
||||
addShiftDraft.value = ''
|
||||
@@ -1030,10 +1035,6 @@
|
||||
personName: a.personName
|
||||
}))
|
||||
}))
|
||||
if (!slots.length) {
|
||||
ElMessage.warning('请至少启用一个班次')
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const detail = (await saveDutyDay({
|
||||
@@ -1044,7 +1045,7 @@
|
||||
dayDetail.value = detail
|
||||
ElMessage.success('保存成功')
|
||||
await loadMonth()
|
||||
resetFormSlots(detail)
|
||||
dialogVisible.value = false
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '保存失败')
|
||||
} finally {
|
||||
|
||||
@@ -39,5 +39,11 @@ export const plPlanColumnFilterDefs: ColumnFilterDef[] = [
|
||||
type: 'text',
|
||||
queryKey: 'customerName'
|
||||
},
|
||||
{ prop: 'productName', label: '产品名称', type: 'text', queryKey: 'productName' }
|
||||
{ prop: 'productName', label: '产品名称', type: 'text', queryKey: 'productName' },
|
||||
{
|
||||
prop: 'productPackageSpec',
|
||||
label: '包装规格',
|
||||
type: 'text',
|
||||
queryKey: 'packageSpec'
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user