| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { useAttrs as m, ref as n, computed as f, watchEffect as i, openBlock as p, createElementBlock as y, createVNode as h, mergeProps as _, unref as b, withCtx as v, renderSlot as g } from "vue";
- import { k as x } from "./index2.js";
- import { F as S } from "./index5.js";
- const w = { class: "s-form" }, C = {
- __name: "SForm",
- props: {
- model: {
- type: Object,
- default() {
- return {};
- }
- },
- rules: {
- type: Object,
- default() {
- return {};
- }
- },
- layout: {
- type: String,
- default() {
- return "horizontal";
- }
- },
- column: {
- type: [Number, String],
- default() {
- return 1;
- }
- },
- labelWidth: {
- type: [Number, String],
- default() {
- return 80;
- }
- }
- },
- setup(r, { expose: u }) {
- const c = m(), e = r, a = n(), s = n(e.column >= 5 ? 4 : e.column), d = f(() => {
- const o = e.layout, t = (e == null ? void 0 : e.labelWidth) + "";
- return o === "horizontal" ? {
- style: {
- width: t.includes("px") ? t : t + "px"
- }
- } : {};
- });
- return i(() => {
- e.column > 4 && console.warn(`当前设置表单列column【${e.column}】最多显示为4列,已默认为最多4列`);
- }), u({ validate: () => new Promise((o, t) => {
- a.value.validate().then((l) => {
- o(l);
- }).catch((l) => {
- t(l);
- });
- }) }), (o, t) => {
- const l = S;
- return p(), y("div", w, [
- h(l, _({
- labelCol: d.value.labelCol,
- model: r.model,
- rules: r.rules,
- layout: r.layout
- }, b(c), {
- ref_key: "form",
- ref: a,
- style: {
- display: "grid",
- gridTemplateColumns: `repeat(${s.value}, 1fr)`,
- gap: "20px"
- }
- }), {
- default: v(() => [
- g(o.$slots, "default", {}, void 0, !0)
- ]),
- _: 3
- }, 16, ["labelCol", "model", "rules", "layout", "style"])
- ]);
- };
- }
- }, j = /* @__PURE__ */ x(C, [["__scopeId", "data-v-cad3adca"]]);
- export {
- j as default
- };
|