SFormItem.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. var y = Object.defineProperty;
  2. var c = Object.getOwnPropertySymbols;
  3. var S = Object.prototype.hasOwnProperty, g = Object.prototype.propertyIsEnumerable;
  4. var u = (l, t, o) => t in l ? y(l, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : l[t] = o, a = (l, t) => {
  5. for (var o in t || (t = {}))
  6. S.call(t, o) && u(l, o, t[o]);
  7. if (c)
  8. for (var o of c(t))
  9. g.call(t, o) && u(l, o, t[o]);
  10. return l;
  11. };
  12. import { useAttrs as C, computed as s, openBlock as i, createElementBlock as d, normalizeStyle as w, createVNode as B, mergeProps as A, withCtx as O, renderSlot as m, createCommentVNode as k, createElementVNode as N } from "vue";
  13. import { _ as V } from "./index5.js";
  14. const x = {
  15. key: 0,
  16. class: "label"
  17. }, E = { class: "s-form-item-content" }, F = {
  18. __name: "SFormItem",
  19. props: {
  20. label: {
  21. type: String,
  22. default: ""
  23. },
  24. labelWidth: {
  25. type: [Number, String],
  26. default: "100%"
  27. },
  28. // 支持嵌套字段:name 传字符串,或传数组路径(如 ['dsConfigRdb', 'dbCode']),与 a-form-item 一致
  29. name: {
  30. type: [String, Array],
  31. default: ""
  32. },
  33. // 多列布局(SForm column>1 或 SCollapsesItem column>1)时,本项独占一整行
  34. full: {
  35. type: Boolean,
  36. default: !1
  37. }
  38. },
  39. setup(l) {
  40. const t = C(), o = l, f = s(() => o.full ? { gridColumn: "1 / -1" } : {}), p = /* @__PURE__ */ new Set([
  41. "disabled",
  42. "allowClear",
  43. "clearable",
  44. "showSearch",
  45. "multiple",
  46. "readonly",
  47. "autofocus",
  48. "bordered",
  49. "checked",
  50. "open",
  51. "autoClearSearchValue",
  52. "noDrag",
  53. "isManual",
  54. "expandAll",
  55. "recursionChildren",
  56. "treeCheckable",
  57. "showOnlyOrganization",
  58. "isDataScopeFilter"
  59. ]), b = (e) => typeof e == "boolean" ? e : e === "" || e === null || e === void 0 ? e === "" ? !0 : e : typeof e == "string" ? !(e === "false" || e === "0") : !!e, h = s(() => {
  60. const e = {};
  61. return Object.keys(t || {}).forEach((n) => {
  62. const r = t[n];
  63. e[n] = p.has(n) ? b(r) : r;
  64. }), e;
  65. }), _ = s(() => {
  66. const e = o.labelWidth + "";
  67. return {
  68. labelCol: {
  69. style: {
  70. width: e.includes("px") ? e : e + "px"
  71. }
  72. }
  73. };
  74. });
  75. return (e, n) => {
  76. const r = V;
  77. return i(), d("div", {
  78. class: "s-form-item",
  79. style: w(f.value)
  80. }, [
  81. B(r, A({
  82. label: l.label,
  83. name: l.name
  84. }, a(a({}, _.value), h.value), { class: "s-form-item" }), {
  85. default: O(() => [
  86. e.$slots.label ? (i(), d("div", x, [
  87. m(e.$slots, "label")
  88. ])) : k("", !0),
  89. N("div", E, [
  90. m(e.$slots, "default")
  91. ])
  92. ]),
  93. _: 3
  94. }, 16, ["label", "name"])
  95. ], 4);
  96. };
  97. }
  98. };
  99. export {
  100. F as default
  101. };