From a2d9fcb259621829bf4ec9680b5dbeac95ab5805 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 15 十月 2026 16:19:54 +0800
Subject: [PATCH] fix(crm): 销售目标达成分析默认查当前季度
---
src/views/crm/salesTarget/analysis/data.ts | 36 +++++++++++++++++++++++++++++++-----
1 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/views/crm/salesTarget/analysis/data.ts b/src/views/crm/salesTarget/analysis/data.ts
index aef38c3..f447cfa 100644
--- a/src/views/crm/salesTarget/analysis/data.ts
+++ b/src/views/crm/salesTarget/analysis/data.ts
@@ -4,6 +4,25 @@
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
+import { SALES_TARGET_PERIOD_TYPE } from '../data';
+
+/**
+ * 鎸夊懆鏈熺被鍨嬬畻褰撳墠鍛ㄦ湡鍊硷細骞村害 2026 / 瀛e害 2026-Q4 / 鏈堝害 2026-10銆�
+ * 杈炬垚鍒嗘瀽鎵撳紑鏃堕粯璁よ惤鍦ㄣ�屽綋鍓嶅搴︺�嶏紝涓庨攢鍞洰鏍囩殑婕旂ず鏁版嵁鍛ㄦ湡涓�鑷淬��
+ */
+function currentPeriodValue(periodType?: number): string {
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = now.getMonth() + 1;
+ if (periodType === SALES_TARGET_PERIOD_TYPE.YEAR) {
+ return `${year}`;
+ }
+ if (periodType === SALES_TARGET_PERIOD_TYPE.MONTH) {
+ return `${year}-${String(month).padStart(2, '0')}`;
+ }
+ return `${year}-Q${Math.ceil(month / 3)}`;
+}
+
/** 杈炬垚鍒嗘瀽鐨勬煡璇㈣〃鍗� */
export function useGridFormSchema(): VbenFormSchema[] {
return [
@@ -12,11 +31,18 @@
label: '鍛ㄦ湡绫诲瀷',
component: 'Select',
rules: 'required',
- componentProps: {
- options: getDictOptions(DICT_TYPE.CRM_SALES_TARGET_PERIOD_TYPE, 'number'),
+ componentProps: (_values, form) => ({
+ options: getDictOptions(
+ DICT_TYPE.CRM_SALES_TARGET_PERIOD_TYPE,
+ 'number',
+ ),
placeholder: '璇烽�夋嫨鍛ㄦ湡绫诲瀷',
- },
- defaultValue: 1,
+ // 鍛ㄦ湡绫诲瀷涓�鍙樺氨鎶婂懆鏈熷�兼崲鎴愬綋鍓嶅搴斿懆鏈燂紝閬垮厤鐣欏湪涓婁竴涓被鍨嬬殑鍊间笂鏌ヤ笉鍒版暟鎹�
+ onChange: (value: number) => {
+ form.setFieldValue('periodValue', currentPeriodValue(value));
+ },
+ }),
+ defaultValue: SALES_TARGET_PERIOD_TYPE.QUARTER,
},
{
fieldName: 'periodValue',
@@ -26,7 +52,7 @@
componentProps: {
placeholder: '濡� 2026 / 2026-Q1 / 2026-07',
},
- defaultValue: new Date().getFullYear().toString(),
+ defaultValue: currentPeriodValue(SALES_TARGET_PERIOD_TYPE.QUARTER),
},
{
fieldName: 'targetDimension',
--
Gitblit v1.9.3