UNPKG

@pi-form-create/component-subform

Version:

@pi-form-create 内置组件

8 lines (7 loc) 1.58 kB
/*! * @pi-form-create/component-subform v3.0.0-alpha.1 * (c) 2018-2025 xaboy * Github https://github.com/xaboy/form-create with subform * Released under the Apache-2.0 License. */ import{defineComponent as e,reactive as t,markRaw as i,nextTick as a,createVNode as s}from"vue";import"@pi-form-create/utils/lib/toline";import o from"@pi-form-create/utils/lib/type";var l=e({name:"fcSubForm",props:{rule:Array,options:{type:Object,default:()=>t({submitBtn:!1,resetBtn:!1})},modelValue:{type:Object,default:()=>({})},disabled:{type:[Boolean,void 0],default:void 0},syncDisabled:{type:Boolean,default:!0},formCreateInject:Object},data(){return{cacheValue:{},subApi:{},form:i(this.formCreateInject.form.$form())}},emits:["fc:subform","update:modelValue","change","itemMounted"],watch:{disabled(e){o.Boolean(e)&&this.syncDisabled&&this.subApi.disabled(e)},modelValue(e){this.setValue(e)}},methods:{formData(e){this.cacheValue=JSON.stringify(e),this.$emit("update:modelValue",e),this.$emit("change",e)},setValue(e){const t=JSON.stringify(e);this.cacheValue!==t&&(this.cacheValue=t,this.subApi.coverValue(e||{}))},add$f(e){this.subApi=e,a((()=>{o.Boolean(this.disabled)&&this.syncDisabled&&e.disabled(this.disabled),this.$emit("itemMounted",e)}))}},render(){const e=this.form;return s(e,{disabled:this.disabled,"onUpdate:modelValue":this.formData,modelValue:this.modelValue,"onEmit-event":this.$emit,"onUpdate:api":this.add$f,rule:this.rule,option:this.options,extendOption:!0,dataScope:this.formCreateInject.dataScope,utils:this.formCreateInject.utils},null)}});export{l as default};