SFormItem.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. var _ = Object.defineProperty;
  2. var s = Object.getOwnPropertySymbols;
  3. var S = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable;
  4. var c = (r, t, o) => t in r ? _(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o, a = (r, t) => {
  5. for (var o in t || (t = {}))
  6. S.call(t, o) && c(r, o, t[o]);
  7. if (s)
  8. for (var o of s(t))
  9. y.call(t, o) && c(r, o, t[o]);
  10. return r;
  11. };
  12. import { useAttrs as g, computed as u, openBlock as i, createElementBlock as d, createVNode as w, mergeProps as C, withCtx as A, renderSlot as m, createCommentVNode as B } from "vue";
  13. import { _ as O } from "./index4.js";
  14. const k = { class: "s-form-item" }, x = {
  15. key: 0,
  16. class: "label"
  17. }, D = {
  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. },
  34. setup(r) {
  35. const t = g(), o = r, f = /* @__PURE__ */ new Set([
  36. "disabled",
  37. "allowClear",
  38. "clearable",
  39. "showSearch",
  40. "multiple",
  41. "readonly",
  42. "autofocus",
  43. "bordered",
  44. "checked",
  45. "open",
  46. "autoClearSearchValue",
  47. "noDrag",
  48. "isManual",
  49. "expandAll",
  50. "recursionChildren",
  51. "treeCheckable",
  52. "showOnlyOrganization",
  53. "isDataScopeFilter"
  54. ]), p = (e) => typeof e == "boolean" ? e : e === "" || e === null || e === void 0 ? e === "" ? !0 : e : typeof e == "string" ? !(e === "false" || e === "0") : !!e, b = u(() => {
  55. const e = {};
  56. return Object.keys(t || {}).forEach((n) => {
  57. const l = t[n];
  58. e[n] = f.has(n) ? p(l) : l;
  59. }), e;
  60. }), h = u(() => {
  61. const e = o.labelWidth + "";
  62. return {
  63. labelCol: {
  64. style: {
  65. width: e.includes("px") ? e : e + "px"
  66. }
  67. }
  68. };
  69. });
  70. return (e, n) => {
  71. const l = O;
  72. return i(), d("div", k, [
  73. w(l, C({
  74. label: r.label,
  75. name: r.name
  76. }, a(a({}, h.value), b.value), { class: "s-form-item" }), {
  77. default: A(() => [
  78. e.$slots.label ? (i(), d("div", x, [
  79. m(e.$slots, "label")
  80. ])) : B("", !0),
  81. m(e.$slots, "default")
  82. ]),
  83. _: 3
  84. }, 16, ["label", "name"])
  85. ]);
  86. };
  87. }
  88. };
  89. export {
  90. D as default
  91. };