CustomInput.js 7.2 KB

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