| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import { useAttrs as h, ref as u, computed as s, watchEffect as y, openBlock as b, createElementBlock as F, createVNode as g, mergeProps as S, withCtx as V, renderSlot as _ } from "vue";
- import { n as w } from "./index2.js";
- import { F as v } from "./index4.js";
- const C = { class: "s-form" }, x = {
- __name: "SForm",
- props: {
- model: {
- type: Object,
- default() {
- return {};
- }
- },
- rules: {
- type: Object,
- default() {
- return {};
- }
- },
- layout: {
- type: String,
- default() {
- return "vertical";
- }
- },
- column: {
- type: [Number, String],
- default() {
- return 1;
- }
- },
- labelWidth: {
- type: [Number, String],
- default() {
- return 80;
- }
- }
- },
- setup(a, { expose: c }) {
- const n = h(), o = a, t = u(), d = u(o.column >= 5 ? 4 : o.column), i = /* @__PURE__ */ new Set([
- "disabled",
- "allowClear",
- "clearable",
- "showSearch",
- "multiple",
- "readonly",
- "autofocus",
- "bordered",
- "checked",
- "open",
- "autoClearSearchValue",
- "noDrag",
- "isManual",
- "expandAll",
- "recursionChildren",
- "treeCheckable",
- "showOnlyOrganization",
- "isDataScopeFilter"
- ]), f = (e) => typeof e == "boolean" ? e : e === "" || e === null || e === void 0 ? e === "" ? !0 : e : typeof e == "string" ? !(e === "false" || e === "0") : !!e, m = s(() => {
- const e = {};
- return Object.keys(n || {}).forEach((l) => {
- const r = n[l];
- e[l] = i.has(l) ? f(r) : r;
- }), e;
- }), p = s(() => {
- const e = o.layout, l = (o == null ? void 0 : o.labelWidth) + "";
- return e === "horizontal" ? {
- style: {
- width: l.includes("px") ? l : l + "px"
- }
- } : {};
- });
- return y(() => {
- o.column > 4 && console.warn(`当前设置表单列column【${o.column}】最多显示为4列,已默认为最多4列`);
- }), c({ validate: () => new Promise((e, l) => {
- t.value.validate().then((r) => {
- e(r);
- }).catch((r) => {
- l(r);
- });
- }), clearValidate: (e) => {
- t.value && t.value.clearValidate(e);
- }, resetFields: (e) => {
- t.value && t.value.resetFields(e);
- }, getFieldsValue: (e) => t.value ? t.value.getFieldsValue(e) : {}, setFieldsValue: (e) => {
- t.value && t.value.setFieldsValue(e);
- } }), (e, l) => {
- const r = v;
- return b(), F("div", C, [
- g(r, S({
- labelCol: p.value.labelCol,
- model: a.model,
- rules: a.rules,
- layout: a.layout
- }, m.value, {
- ref_key: "form",
- ref: t,
- style: {
- display: "grid",
- gridTemplateColumns: `repeat(${d.value}, 1fr)`,
- gap: "20px"
- }
- }), {
- default: V(() => [
- _(e.$slots, "default", {}, void 0, !0)
- ]),
- _: 3
- }, 16, ["labelCol", "model", "rules", "layout", "style"])
- ]);
- };
- }
- }, $ = /* @__PURE__ */ w(x, [["__scopeId", "data-v-4775fdd2"]]);
- export {
- $ as default
- };
|