UNPKG

d-render

Version:

基于 Element Plus 二次封装的数据驱动渲染组件库 - 表单、搜索表单、表格配置化渲染

67 lines (64 loc) 2.09 kB
import { defineComponent, computed, provide, createVNode, h } from 'vue'; import { getInputComponent, getH5InputComponent } from '../utils'; var __defProp = Object.defineProperty; var __defProps = Object.defineProperties; var __getOwnPropDescs = Object.getOwnPropertyDescriptors; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); var index = /* @__PURE__ */ defineComponent({ props: { schema: { type: Object, required: true }, model: {}, equipment: { type: String, default: "pc" }, service: Object }, setup(props) { const config = computed(() => { return Object.keys(props.schema).reduce((acc, key) => { if (key !== "list") { acc[key] = props.schema[key]; } return acc; }, {}); }); const Component = () => { const tableProps = { modelValue: props.model, config: __spreadProps(__spreadValues({}, config.value), { options: props.equipment === "pc" ? [{ key: "default", children: props.schema.list }] : props.schema.list }) }; if (props.equipment === "pc") { return h(getInputComponent("table"), tableProps); } else { return h(getH5InputComponent("table"), tableProps); } }; provide("cipForm", props); return () => createVNode(Component, null, null); } }); export { index as default };