CustomInput.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. var k = (o, f, a) => new Promise((l, T) => {
  2. var b = (n) => {
  3. try {
  4. E(a.next(n));
  5. } catch (_) {
  6. T(_);
  7. }
  8. }, I = (n) => {
  9. try {
  10. E(a.throw(n));
  11. } catch (_) {
  12. T(_);
  13. }
  14. }, E = (n) => n.done ? l(n.value) : Promise.resolve(n.value).then(b, I);
  15. E((a = a.apply(o, f)).next());
  16. });
  17. import { computed as v, ref as L, watch as V, resolveComponent as C, openBlock as s, createElementBlock as S, createBlock as c, createCommentVNode as m, withCtx as h, Fragment as Y, renderList as F, createTextVNode as O, toDisplayString as P } from "vue";
  18. import { I as g, a6 as B, a7 as G, dk as y, dl as H } from "./index2.js";
  19. import { _ as $ } from "./index10.js";
  20. import { D as R } from "./dayjs.js";
  21. const j = {
  22. key: 0,
  23. class: "custom-input"
  24. }, W = /* @__PURE__ */ Object.assign({ name: "CustomInput" }, {
  25. __name: "CustomInput",
  26. props: {
  27. // 查询条件整行(SettingFilter 的 filters 项),组件直接读写它的 value 字段
  28. data: {
  29. type: Object,
  30. default: () => ({})
  31. },
  32. disabled: {
  33. type: Boolean,
  34. default: !1
  35. }
  36. },
  37. setup(o) {
  38. const f = o, a = v({
  39. get: () => {
  40. var t;
  41. const e = (t = f.data) == null ? void 0 : t.value;
  42. return e === "" ? void 0 : e;
  43. },
  44. set: (e) => {
  45. f.data && (f.data.value = e == null ? "" : e);
  46. }
  47. }), l = v(() => {
  48. var e;
  49. return ((e = f.data) == null ? void 0 : e.filterConfig) || null;
  50. }), T = L(1), b = L(0), I = v(
  51. () => {
  52. var e;
  53. return ((e = l.value) == null ? void 0 : e.filterType) === "DATETIME" ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD";
  54. }
  55. ), E = v(() => {
  56. var t;
  57. const e = (t = l.value) == null ? void 0 : t.filterType;
  58. return !e || e === "INPUT";
  59. }), n = v(() => {
  60. var t;
  61. return ["SINGLE_SELECT", "MULTIPLE_SELECT", "GANDER", "IS"].includes((t = l.value) == null ? void 0 : t.filterType);
  62. }), _ = v(() => {
  63. var t;
  64. return ["INT", "FLOAT"].includes((t = l.value) == null ? void 0 : t.filterType);
  65. }), U = v(() => {
  66. var t;
  67. return ["DATE", "DATETIME"].includes((t = l.value) == null ? void 0 : t.filterType);
  68. });
  69. V(
  70. l,
  71. (e) => k(this, null, function* () {
  72. if (!e) return;
  73. const t = ["SINGLE_SELECT", "MULTIPLE_SELECT", "GANDER", "IS"];
  74. if (T.value = e.step || 1, b.value = e.precision === void 0 ? 0 : e.precision, t.includes(e.filterType) && !e.filterData && !!e.filterApi) {
  75. const r = yield e.filterApi({ type: "portal_config_type" }, { pageSize: 10, pageNo: 1 });
  76. e.filterData = (r.list || []).map((d) => {
  77. var p, D;
  78. return {
  79. value: d[(p = e.props) == null ? void 0 : p.value],
  80. name: d[(D = e.props) == null ? void 0 : D.key]
  81. };
  82. });
  83. }
  84. }),
  85. { immediate: !0, deep: !0 }
  86. );
  87. function w(e, t) {
  88. return H(e, t);
  89. }
  90. function x(e = y()) {
  91. var d, p;
  92. const t = (d = l.value) == null ? void 0 : d.startDate, i = (p = l.value) == null ? void 0 : p.endDate;
  93. if (!t && !i) return !1;
  94. const r = y(e).unix();
  95. if (t && i)
  96. return r < y(t).unix() || r > y(i).unix();
  97. if (t)
  98. return r <= y(t).unix();
  99. if (i)
  100. return r >= y(i).unix();
  101. }
  102. return (e, t) => {
  103. const i = g, r = G, d = B, p = $, D = R, M = C("s-office-select"), N = C("s-tree-select");
  104. return l.value ? (s(), S("div", j, [
  105. E.value ? (s(), c(i, {
  106. key: 0,
  107. style: { width: "100%" },
  108. disabled: o.disabled,
  109. value: a.value,
  110. "onUpdate:value": t[0] || (t[0] = (u) => a.value = u),
  111. placeholder: e.$l("请输入"),
  112. maxLength: l.value.length || 200
  113. }, null, 8, ["disabled", "value", "placeholder", "maxLength"])) : m("", !0),
  114. n.value ? (s(), c(d, {
  115. key: 1,
  116. style: { width: "100%" },
  117. disabled: o.disabled,
  118. value: a.value,
  119. "onUpdate:value": t[1] || (t[1] = (u) => a.value = u),
  120. mode: l.value.filterType === "MULTIPLE_SELECT" ? "multiple" : void 0,
  121. allowClear: !0,
  122. placeholder: e.$l("请选择")
  123. }, {
  124. default: h(() => [
  125. (s(!0), S(Y, null, F(l.value.filterData || [], (u, A) => (s(), c(r, {
  126. value: u.value,
  127. key: A
  128. }, {
  129. default: h(() => [
  130. O(P(u.name), 1)
  131. ]),
  132. _: 2
  133. }, 1032, ["value"]))), 128))
  134. ]),
  135. _: 1
  136. }, 8, ["disabled", "value", "mode", "placeholder"])) : m("", !0),
  137. _.value ? (s(), c(p, {
  138. key: 2,
  139. disabled: o.disabled,
  140. precision: b.value,
  141. step: T.value,
  142. style: { width: "100%" },
  143. value: a.value,
  144. "onUpdate:value": t[2] || (t[2] = (u) => a.value = u),
  145. placeholder: e.$l("请输入"),
  146. min: l.value.minValue,
  147. max: l.value.maxValue
  148. }, null, 8, ["disabled", "precision", "step", "value", "placeholder", "min", "max"])) : m("", !0),
  149. U.value ? (s(), c(D, {
  150. key: 3,
  151. style: { width: "100%" },
  152. disabled: o.disabled,
  153. value: a.value,
  154. "onUpdate:value": t[3] || (t[3] = (u) => a.value = u),
  155. "value-format": I.value,
  156. "show-time": l.value.filterType === "DATETIME" ? { format: "HH:mm:ss" } : !1,
  157. placeholder: e.$l("请选择"),
  158. "disabled-date": x
  159. }, null, 8, ["disabled", "value", "value-format", "show-time", "placeholder"])) : m("", !0),
  160. l.value.filterType === "USER" ? (s(), c(M, {
  161. key: 4,
  162. value: a.value,
  163. "onUpdate:value": t[4] || (t[4] = (u) => a.value = u)
  164. }, null, 8, ["value"])) : m("", !0),
  165. l.value.filterType === "OFFICE" ? (s(), c(N, {
  166. key: 5,
  167. value: a.value,
  168. "onUpdate:value": t[5] || (t[5] = (u) => a.value = u),
  169. recursionChildren: w
  170. }, null, 8, ["value"])) : m("", !0)
  171. ])) : m("", !0);
  172. };
  173. }
  174. });
  175. export {
  176. W as default
  177. };