File tree Expand file tree Collapse file tree 3 files changed +42
-4
lines changed
frontend/packages/web/src/components/business Expand file tree Collapse file tree 3 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,8 @@ export default {
178178 'crmFormDesign.calculation' : 'Calculation' ,
179179 'crmFormDesign.formula' : 'Formula' ,
180180 'crmFormDesign.formulaTooltip' : 'Calculation method not set, please contact the administrator' ,
181+ 'crmFormDesign.formulaFieldChanged' :
182+ 'Formula field has been modified not exist, please contact the administrator to update the formula!' ,
181183 'crmFormDesign.formulaSetting' : 'Formula Settings' ,
182184 'crmFormDesign.formulaEquals' : 'Formula =' ,
183185 'crmFormDesign.formulaPricing' : 'Price' ,
Original file line number Diff line number Diff line change @@ -176,6 +176,7 @@ export default {
176176 'crmFormDesign.calculation' : '计算' ,
177177 'crmFormDesign.formula' : '公式' ,
178178 'crmFormDesign.formulaTooltip' : '未设置计算方式,请联系管理员' ,
179+ 'crmFormDesign.formulaFieldChanged' : '字段已变更不存在,请联系管理员更新公式!' ,
179180 'crmFormDesign.formulaSetting' : '公式设置' ,
180181 'crmFormDesign.formulaPricing' : '定价' ,
181182 'crmFormDesign.formulaDiscount' : '折扣' ,
Original file line number Diff line number Diff line change 5050 default: 0 ,
5151 });
5252
53- const formulaTooltip = computed (
54- () => safeParseFormula (props .fieldConfig .formula ?? ' ' ).display || t (' crmFormDesign.formulaTooltip' )
55- );
53+ function buildFormFieldKeySet(formulaFields : { fieldId: string }[], formDetail : Record <string , any >): Set <string > {
54+ const keys = new Set <string >();
55+
56+ Object .keys (formDetail ).forEach ((key ) => {
57+ keys .add (key );
58+ });
59+
60+ formulaFields .forEach ((f ) => {
61+ if (f .fieldId .includes (' .' )) {
62+ const [tableKey] = f .fieldId .split (' .' );
63+ if (Array .isArray (formDetail [tableKey ])) {
64+ keys .add (f .fieldId );
65+ }
66+ }
67+ });
68+
69+ return keys ;
70+ }
71+
72+ const formulaTooltip = computed (() => {
73+ const { formula } = props .fieldConfig ;
74+ if (! formula ) {
75+ return t (' crmFormDesign.formulaTooltip' );
76+ }
77+
78+ const parsed = safeParseFormula (formula );
79+ const { display, fields } = parsed ;
80+
81+ const fieldKeySet = buildFormFieldKeySet (fields , props .formDetail as Record <string , any >);
82+
83+ const hasInvalidField = fields .some ((f : any ) => ! fieldKeySet .has (f .fieldId ));
84+
85+ if (hasInvalidField ) {
86+ return t (' crmFormDesign.formulaFieldChanged' );
87+ }
88+
89+ return display || t (' crmFormDesign.formulaTooltip' );
90+ });
5691
5792 function getScalarFieldValue(
5893 fieldId : string ,
112147 if (Object .is (next , value .value )) return ;
113148 value .value = next ;
114149 emit (' change' , next );
115- }, 0 );
150+ }, 100 );
116151
117152 watch (
118153 () => props .fieldConfig .defaultValue ,
You can’t perform that action at this time.
0 commit comments