1111 ' ' +
1212 formItemClass +
1313 '__' +
14- name +
14+ dataNameKey +
1515 ' ' +
1616 errorClasses +
1717 ' ' +
@@ -86,7 +86,7 @@ import { isNumeric } from '../common/validator';
8686import TIcon from ' ../icon/icon.vue' ;
8787import usingConfig from ' ../mixins/using-config' ;
8888
89- import { validateRules , ValidateStatus } from ' ./form-model' ;
89+ import { validateRules , ValidateStatus , getByPath } from ' ./form-model' ;
9090import props from ' ./props' ;
9191
9292const parentComponentName = ' form' ;
@@ -160,6 +160,10 @@ export default {
160160 const contentAlign = this .dataContentAlign ;
161161 return contentAlign ? ` text-align: ${ contentAlign} ` : ' ' ;
162162 },
163+ // 供 :class 拼接使用:name="pat.acctType" → "pat-acctType",避免 CSS class 里的点号被当成选择器分隔符
164+ dataNameKey () {
165+ return String (this .name || ' ' ).replace (/ \. / g , ' -' );
166+ },
163167 },
164168 watch: {},
165169 created () {
@@ -217,7 +221,8 @@ export default {
217221 const { name } = this ;
218222 if (name && this .form ) {
219223 const { formData } = this .form ;
220- this .initialValue = formData[name];
224+ // 支持 name="pat.acctType" 嵌套路径:走 form 表单层的 data 兜底(form-item 拿不到时回退到 form.data)
225+ this .initialValue = coalesce (getByPath (formData, name), getByPath (this .form .data , name));
221226 }
222227 },
223228
@@ -234,7 +239,7 @@ export default {
234239 const { name } = this ;
235240 if (name && this .form ) {
236241 const { formData } = this .form ;
237- return formData[ name] ;
242+ return coalesce ( getByPath ( formData, name), getByPath ( this . form . data , name)) ;
238243 }
239244 return undefined ;
240245 },
@@ -267,7 +272,7 @@ export default {
267272 return { [this .name ]: true };
268273 }
269274
270- const value = data[ this .name ] ;
275+ const value = getByPath ( data, this .name ) ;
271276 const context = { formData: data, name: this .name };
272277 const results = await validateRules (value, filteredRules, context);
273278
0 commit comments