UNPKG

@wocwin/t-ui-plus

Version:

Page level components developed based on Element Plus.

128 lines (125 loc) 4.61 kB
import { defineComponent, ref, useSlots, useAttrs, computed, resolveComponent, createElementBlock, openBlock, createVNode, withCtx, Fragment, renderList, createBlock, normalizeClass, renderSlot, createCommentVNode, mergeProps, unref, createSlots, normalizeProps, guardReactiveProps, createElementVNode, toDisplayString } from 'vue'; const _hoisted_1 = { class: "t_form" }; const _hoisted_2 = { class: "collapse-item_title" }; const _hoisted_3 = { key: 0, class: "t_btn" }; var _sfc_main = /* @__PURE__ */ defineComponent({ ...{ name: "ModuleForm" }, __name: "moduleForm", props: { // 表单配置项 formOpts: { type: Object, default: () => ({}) }, // 是否Title文字加粗 titleBold: { type: Boolean, default: false } }, emits: ["handleEvent"], setup(__props, { expose: __expose, emit: __emit }) { const props = __props; const dashboardRef = ref({}); const slots = useSlots(); const attrs = useAttrs(); const getChildRef = (index) => { const childRef = dashboardRef.value[index]; return childRef; }; __expose({ getChildRef }); const defaultActiveKey = computed({ get() { return Object.keys(props.formOpts); }, set(val) { return val; } }); const emits = __emit; const handleEvent = (val, type) => { emits("handleEvent", val, type); }; return (_ctx, _cache) => { const _component_t_form = resolveComponent("t-form"); const _component_el_collapse_item = resolveComponent("el-collapse-item"); const _component_el_collapse = resolveComponent("el-collapse"); return openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(_component_el_collapse, { modelValue: defaultActiveKey.value, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => defaultActiveKey.value = $event) }, { default: withCtx(() => [ (openBlock(true), createElementBlock( Fragment, null, renderList(__props.formOpts, (formOpt, formIndex) => { return openBlock(), createBlock(_component_el_collapse_item, { class: normalizeClass([ formOpt.className, { noTitle: !formOpt.title, disabledStyle: formOpt.disabled, title_bold: __props.titleBold } ]), key: formIndex, name: formOpt.name, disabled: formOpt.disabled }, { title: withCtx(() => [ createElementVNode( "span", _hoisted_2, toDisplayString(formOpt.title), 1 /* TEXT */ ), formOpt.btn ? (openBlock(), createElementBlock("div", _hoisted_3, [ renderSlot(_ctx.$slots, formOpt.btn) ])) : createCommentVNode("v-if", true) ]), default: withCtx(() => [ formOpt.slotName ? renderSlot(_ctx.$slots, formOpt.slotName, { key: 0 }) : createCommentVNode("v-if", true), createVNode(_component_t_form, mergeProps({ ref_for: true, ref: (el) => { dashboardRef.value[formIndex] = el; }, formOpts: formOpt.opts, widthSize: formOpt.widthSize || 3 }, unref(attrs), { onHandleEvent: handleEvent }), createSlots({ _: 2 /* DYNAMIC */ }, [ renderList(unref(slots), (_index, name) => { return { name, fn: withCtx((data) => [ renderSlot(_ctx.$slots, name, normalizeProps(guardReactiveProps(data))) ]) }; }) ]), 1040, ["formOpts", "widthSize"]) ]), _: 2 /* DYNAMIC */ }, 1032, ["class", "name", "disabled"]); }), 128 /* KEYED_FRAGMENT */ )) ]), _: 3 /* FORWARDED */ }, 8, ["modelValue"]) ]); }; } }); export { _sfc_main as default };