feat(crm): add interactive column stats row on quote list
Let users pick sum/avg/max/min per column on the current page, with localStorage persistence for the quote management list. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6ce7554557
commit
072790989f
1 file changed
+142
@@ -379,6 +379,40 @@
|
||||
<el-table-column v-if="isColumnVisible('remark')" label="备注" align="center" prop="remark" min-width="200" show-overflow-tooltip />
|
||||
</ListTable>
|
||||
|
||||
<div class="quote-list-stats-row" aria-label="列表列统计">
|
||||
<div class="quote-list-stats-row__fixed">
|
||||
<div class="quote-list-stats-row__cell is-fixed" style="width: 55px" />
|
||||
<div class="quote-list-stats-row__cell is-fixed" style="width: 55px" />
|
||||
</div>
|
||||
<div class="quote-list-stats-row__scroll">
|
||||
<div
|
||||
v-for="col in statsBusinessColumns"
|
||||
:key="col.prop"
|
||||
class="quote-list-stats-row__cell is-stat"
|
||||
>
|
||||
<el-dropdown trigger="click" @command="(cmd: string | number) => onStatCommand(col.prop, cmd)">
|
||||
<span
|
||||
class="quote-list-stats-row__trigger"
|
||||
:class="{ 'is-empty': !statsCellText(col.prop, col.money) }"
|
||||
>
|
||||
{{ statsCellText(col.prop, col.money) || '统计' }}
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="opt in COLUMN_STAT_METHOD_OPTIONS"
|
||||
:key="opt.label"
|
||||
:command="opt.value"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pagination list-pager-bar">
|
||||
<div class="list-pager-selected">
|
||||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||||
@@ -815,6 +849,16 @@ import QuoteDetailDialog from './components/QuoteDetailDialog.vue'
|
||||
import ListToolbarDateShortcuts from '@/components/core/list-toolbar-date-shortcuts/index.vue'
|
||||
import ListToolbarEndActions from '@/components/business/list-toolbar-end-actions/index.vue'
|
||||
import { usePersistedListColumns } from '@/composables/usePersistedListColumns'
|
||||
import {
|
||||
COLUMN_STAT_METHOD_OPTIONS,
|
||||
QUOTE_MONEY_STAT_PROPS,
|
||||
formatColumnStatDisplay,
|
||||
loadColumnStatConfig,
|
||||
saveColumnStatConfig,
|
||||
setColumnStatMethod,
|
||||
type ColumnStatConfigMap,
|
||||
type ColumnStatMethod
|
||||
} from './quoteListColumnStats'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -1842,6 +1886,53 @@ const formatQuoteProductInfoLines = (row: QuoteVO): string[] => {
|
||||
.filter((line) => line.length > 0)
|
||||
}
|
||||
|
||||
const columnStatConfig = ref<ColumnStatConfigMap>(loadColumnStatConfig())
|
||||
|
||||
const statsBusinessColumns = computed(() => {
|
||||
const cols: { prop: string; money: boolean }[] = [
|
||||
{ prop: 'quoteNo', money: false },
|
||||
{ prop: 'quoteTitle', money: false }
|
||||
]
|
||||
for (const def of listColumnDefs) {
|
||||
if (!isColumnVisible(def.prop)) continue
|
||||
cols.push({
|
||||
prop: def.prop,
|
||||
money: QUOTE_MONEY_STAT_PROPS.has(def.prop)
|
||||
})
|
||||
}
|
||||
return cols
|
||||
})
|
||||
|
||||
function getStatCellValues(prop: string): unknown[] {
|
||||
return quoteList.value.map((row) => {
|
||||
if (prop === 'finalAmount') return getQuoteFinalAmount(row)
|
||||
if (prop === 'productInfo') {
|
||||
const lines = formatQuoteProductInfoLines(row)
|
||||
return lines.length ? lines.join('\n') : null
|
||||
}
|
||||
return (row as Record<string, unknown>)[prop]
|
||||
})
|
||||
}
|
||||
|
||||
function statsCellText(prop: string, money: boolean): string {
|
||||
const method = columnStatConfig.value[prop]
|
||||
return formatColumnStatDisplay(method, getStatCellValues(prop), { money })
|
||||
}
|
||||
|
||||
function onSelectColumnStat(prop: string, method: ColumnStatMethod | '') {
|
||||
columnStatConfig.value = setColumnStatMethod(columnStatConfig.value, prop, method)
|
||||
saveColumnStatConfig(columnStatConfig.value)
|
||||
}
|
||||
|
||||
function onStatCommand(prop: string, cmd: string | number) {
|
||||
onSelectColumnStat(
|
||||
prop,
|
||||
(cmd === '' || cmd === 'sum' || cmd === 'avg' || cmd === 'max' || cmd === 'min'
|
||||
? cmd
|
||||
: '') as ColumnStatMethod | ''
|
||||
)
|
||||
}
|
||||
|
||||
const TEMPLATE_SUPPLIER_MARKER = /<!--\s*quote-template-supplier:([A-Z]+)\s*-->/
|
||||
const TEMPLATE_DYNAMIC_PRODUCTS_PATTERN =
|
||||
/<!--\s*quote-dynamic-products-start\s*-->[\s\S]*?<!--\s*quote-dynamic-products-end\s*-->/
|
||||
@@ -3068,4 +3159,55 @@ onMounted(() => {
|
||||
line-height: 1.4;
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.quote-list-stats-row {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
border-top: 2px solid var(--el-color-primary, #10b981);
|
||||
background: var(--mint-primary-bg, #ecfdf5);
|
||||
font-weight: 600;
|
||||
color: var(--mint-text, #1e293b);
|
||||
min-height: 44px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.quote-list-stats-row__fixed {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.quote-list-stats-row__scroll {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.quote-list-stats-row__cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8px 10px;
|
||||
box-sizing: border-box;
|
||||
border-right: 1px solid var(--mint-border, #e2e8f0);
|
||||
}
|
||||
|
||||
.quote-list-stats-row__cell.is-stat {
|
||||
flex: 1 1 120px;
|
||||
min-width: 120px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.quote-list-stats-row__trigger {
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
line-height: 1.4;
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.quote-list-stats-row__trigger.is-empty {
|
||||
color: var(--mint-text-muted, #64748b);
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user