|
@@ -10,7 +10,7 @@
|
|
|
v-bind="$attrs"
|
|
|
:disabled="attrs.disabled"
|
|
|
:label-width="attrs.labelWidth"
|
|
|
- :rules="attrs.readonly?[]:attrs.rules"
|
|
|
+ :rules="attrs.readonly?{}:attrs.rules"
|
|
|
:label-position="attrs.labelPosition ? attrs.labelPosition : ''">
|
|
|
<el-row class="form-row" v-for="(itemChild,index) of columns" :key="index">
|
|
|
<el-col v-for="(item,_ind) of itemChild" :span="item.span" :key="'itemChild'+_ind">
|
|
@@ -25,7 +25,7 @@
|
|
|
<component v-bind:is="item.component"
|
|
|
class="form-comp"
|
|
|
:propConfig="item.compConfig"
|
|
|
- :ref="item.prop+'Comp'"
|
|
|
+ :ref="item.prop+suffixCode"
|
|
|
:parentValue="value"
|
|
|
:propValue="value[item.prop]"
|
|
|
@onChange="onChange($event,item)"
|
|
@@ -79,7 +79,7 @@ import VueViews from '@/benyun/compVue/VueViews'
|
|
|
@Component
|
|
|
export default class ByForm extends VueViews {
|
|
|
value:any={}
|
|
|
-
|
|
|
+ suffixCode="--comp"
|
|
|
get columns(){
|
|
|
let columns:Array<any> = this.config?.columns ? this.config.columns : []
|
|
|
//分栏设置
|
|
@@ -149,8 +149,8 @@ export default class ByForm extends VueViews {
|
|
|
if(this.columns.length > 0){
|
|
|
for(const itemData of this.columns){
|
|
|
for(const item of itemData){
|
|
|
- if(this.$refs[item.prop+'Comp'] && (this.$refs[item.prop+'Comp'] as any)[0] && (this.$refs[item.prop+'Comp'] as any)[0].setConfig){
|
|
|
- (this.$refs[item.prop+'Comp'] as any)[0].setConfig(item.compConfig)
|
|
|
+ if(this.$refs[item.prop+this.suffixCode] && (this.$refs[item.prop+this.suffixCode] as any)[0] && (this.$refs[item.prop+this.suffixCode] as any)[0].setConfig){
|
|
|
+ (this.$refs[item.prop+this.suffixCode] as any)[0].setConfig(item.compConfig)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -160,7 +160,7 @@ export default class ByForm extends VueViews {
|
|
|
//清除下级组件组件值
|
|
|
clearChildrenComp(){
|
|
|
for(const key in this.$refs){
|
|
|
- if(key.indexOf('Comp') >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].clearValue){
|
|
|
+ if(key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].clearValue){
|
|
|
(this as any).$refs[key][0].clearValue()
|
|
|
}
|
|
|
}
|
|
@@ -168,7 +168,7 @@ export default class ByForm extends VueViews {
|
|
|
//下级组件默认值
|
|
|
defaultHandle(){
|
|
|
for(const key in this.$refs){
|
|
|
- if(key.indexOf('Comp') >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].defaultHandle){
|
|
|
+ if(key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key][0] && (this as any).$refs[key][0].defaultHandle){
|
|
|
(this as any).$refs[key][0].defaultHandle()
|
|
|
}
|
|
|
}
|
|
@@ -177,8 +177,8 @@ export default class ByForm extends VueViews {
|
|
|
//设置下级组件值
|
|
|
setChildrenComValue(){
|
|
|
for(const key in (this as any).$refs){
|
|
|
- if(key.indexOf('Comp') >= 0 && (this as any).$refs[key] && (this as any).$refs[key][0] && (this as any).$refs[key][0].setValue){
|
|
|
- const code = key.split('Comp')[0];
|
|
|
+ if(key.indexOf(this.suffixCode) >= 0 && (this as any).$refs[key] && (this as any).$refs[key][0] && (this as any).$refs[key][0].setValue){
|
|
|
+ const code = key.split(this.suffixCode)[0];
|
|
|
if(this.value){
|
|
|
(this as any).$refs[key][0].setValue(this.value[code])
|
|
|
}else{
|