SettingFilter.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. import { ref as w, resolveComponent as S, openBlock as f, createBlock as $, withCtx as a, createElementVNode as v, createVNode as o, createTextVNode as i, toDisplayString as r, createElementBlock as y, Fragment as g, renderList as q } from "vue";
  2. import Q from "./CustomInput.js";
  3. import { n as W, dn as X, dp as Y, a6 as Z, a7 as ee, B as le } from "./index2.js";
  4. import { _ as ne } from "./index8.js";
  5. import { _ as te, a as ae } from "./index11.js";
  6. const oe = { class: "drawer-wrap" }, ue = { class: "content-wrap" }, se = { class: "remove-filter-wrap" }, ie = { class: "drawer-footer" }, re = /* @__PURE__ */ Object.assign({ name: "SFilter" }, {
  7. __name: "SettingFilter",
  8. props: {
  9. // 表格列配置(只有带 filterConfig 的列才能作为查询条件)
  10. columns: {
  11. type: Array,
  12. default: () => []
  13. }
  14. },
  15. emits: ["reset", "submit"],
  16. setup(U, { expose: F, emit: N }) {
  17. const x = U, T = N, I = [
  18. { id: "includes", name: window.$l("包含") },
  19. { id: "excludes", name: window.$l("不包含") },
  20. { id: "equal", name: window.$l("等于") },
  21. { id: "notequal", name: window.$l("不等于") },
  22. { id: "null", name: window.$l("为空") },
  23. { id: "notnull", name: window.$l("不为空") }
  24. ], O = ["equal", "notequal", "null", "notnull"], P = I.map((l) => l.id), h = ["null", "notnull"], d = w(!1), _ = w({ filter: 1 }), u = w([]), C = w([]);
  25. function B() {
  26. C.value = (x.columns || []).filter((e) => !!e.filterConfig);
  27. const l = new Set((x.columns || []).map((e) => e.dataIndex));
  28. u.value = u.value.filter((e) => l.has(e.dataIndex)), d.value = !0;
  29. }
  30. function A() {
  31. d.value = !1;
  32. }
  33. function L(l) {
  34. const e = l == null ? void 0 : l.filterType, c = !e || e === "INPUT" ? P : O;
  35. return I.filter((p) => c.includes(p.id));
  36. }
  37. function k(l) {
  38. return !l || l === "INPUT" ? "includes" : "equal";
  39. }
  40. function M() {
  41. u.value.push({
  42. id: window.$utils.uuid(),
  43. dataIndex: void 0,
  44. name: "",
  45. filterType: "",
  46. equals: "",
  47. value: ""
  48. });
  49. }
  50. function V(l, e) {
  51. const s = C.value.find((p) => p.dataIndex === l);
  52. if (e.dataIndex = l, !s) {
  53. e.name = "", e.filterType = "", e.filterConfig = null, e.equals = "", e.value = "";
  54. return;
  55. }
  56. const c = s.filterConfig || {};
  57. e.name = s.name || s.title || "", e.filterType = c.filterType || "INPUT", e.filterConfig = c, e.equals = k(e.filterType), e.value = e.filterType === "MULTIPLE_SELECT" ? [] : "";
  58. }
  59. function D() {
  60. u.value = [], _.value = { filter: 1 }, d.value = !1, T("reset");
  61. }
  62. function R() {
  63. const l = u.value.filter((e) => !!e.dataIndex).filter((e) => h.includes(e.equals) || !j(e.value)).map((e) => ({
  64. dataIndex: e.dataIndex,
  65. name: e.name,
  66. filterType: e.filterType,
  67. equals: e.equals || k(e.filterType),
  68. value: h.includes(e.equals) ? "" : e.value
  69. }));
  70. d.value = !1, T("submit", l, _.value.filter);
  71. }
  72. function j(l) {
  73. return l == null || l === "" ? !0 : Array.isArray(l) ? l.length === 0 : !1;
  74. }
  75. function z(l) {
  76. u.value = u.value.filter((e) => e.id !== l.id) || [];
  77. }
  78. return F({
  79. show: B,
  80. visible: d,
  81. filters: u,
  82. superFilter: _
  83. }), (l, e) => {
  84. const s = Y, c = X, p = ae, b = ee, E = Z, G = S("MinusCircleOutlined"), H = te, J = S("PlusOutlined"), m = le, K = ne;
  85. return f(), $(K, {
  86. rootClassName: "filter-drawer-wrap",
  87. title: `${l.$l("高级搜索")}`,
  88. placement: "right",
  89. width: 500,
  90. visible: d.value,
  91. onClose: A
  92. }, {
  93. default: a(() => [
  94. v("div", oe, [
  95. v("div", ue, [
  96. o(H, null, {
  97. default: a(() => [
  98. o(p, null, {
  99. default: a(() => [
  100. o(c, {
  101. value: _.value.filter,
  102. "onUpdate:value": e[0] || (e[0] = (n) => _.value.filter = n)
  103. }, {
  104. default: a(() => [
  105. o(s, { value: 1 }, {
  106. default: a(() => [
  107. i(r(l.$l("以下全部条件")), 1)
  108. ]),
  109. _: 1
  110. }),
  111. o(s, { value: 2 }, {
  112. default: a(() => [
  113. i(r(l.$l("以下任意条件")), 1)
  114. ]),
  115. _: 1
  116. })
  117. ]),
  118. _: 1
  119. }, 8, ["value"])
  120. ]),
  121. _: 1
  122. }),
  123. o(p, null, {
  124. default: a(() => [
  125. (f(!0), y(g, null, q(u.value, (n) => (f(), y("div", {
  126. class: "filter-item",
  127. key: n.id
  128. }, [
  129. o(E, {
  130. style: { width: "240px" },
  131. value: n.dataIndex,
  132. "onUpdate:value": (t) => n.dataIndex = t,
  133. placeholder: l.$l("请选择"),
  134. "show-search": "",
  135. "allow-clear": "",
  136. "option-filter-prop": "children",
  137. onChange: (t) => V(t, n)
  138. }, {
  139. default: a(() => [
  140. (f(!0), y(g, null, q(C.value, (t) => (f(), $(b, {
  141. key: t.dataIndex,
  142. value: t.dataIndex
  143. }, {
  144. default: a(() => [
  145. i(r(t.name || t.title), 1)
  146. ]),
  147. _: 2
  148. }, 1032, ["value"]))), 128))
  149. ]),
  150. _: 1
  151. }, 8, ["value", "onUpdate:value", "placeholder", "onChange"]),
  152. e[5] || (e[5] = v("div", { class: "divider" }, null, -1)),
  153. o(E, {
  154. style: { width: "240px" },
  155. value: n.equals,
  156. "onUpdate:value": (t) => n.equals = t,
  157. placeholder: l.$l("请选择"),
  158. disabled: !n.dataIndex
  159. }, {
  160. default: a(() => [
  161. (f(!0), y(g, null, q(L(n), (t) => (f(), $(b, {
  162. key: t.id,
  163. value: t.id
  164. }, {
  165. default: a(() => [
  166. i(r(t.name), 1)
  167. ]),
  168. _: 2
  169. }, 1032, ["value"]))), 128))
  170. ]),
  171. _: 2
  172. }, 1032, ["value", "onUpdate:value", "placeholder", "disabled"]),
  173. e[6] || (e[6] = v("div", { class: "divider" }, null, -1)),
  174. v("div", se, [
  175. o(Q, {
  176. style: { width: "240px" },
  177. data: n
  178. }, null, 8, ["data"]),
  179. o(G, {
  180. style: { "font-size": "16px", "margin-left": "6px", color: "var(--s-color-error)" },
  181. onClick: (t) => z(n)
  182. }, null, 8, ["onClick"])
  183. ])
  184. ]))), 128))
  185. ]),
  186. _: 1
  187. })
  188. ]),
  189. _: 1
  190. }),
  191. o(m, {
  192. onClick: e[1] || (e[1] = (n) => M()),
  193. class: "add-filter",
  194. type: "link"
  195. }, {
  196. default: a(() => [
  197. o(J),
  198. i(" " + r(l.$l("添加筛选条件")), 1)
  199. ]),
  200. _: 1
  201. })
  202. ]),
  203. v("div", ie, [
  204. o(m, {
  205. class: "cancel",
  206. onClick: e[2] || (e[2] = (n) => d.value = !1)
  207. }, {
  208. default: a(() => [
  209. i(r(l.$l("取消")), 1)
  210. ]),
  211. _: 1
  212. }),
  213. o(m, {
  214. class: "reset",
  215. onClick: e[3] || (e[3] = (n) => D())
  216. }, {
  217. default: a(() => [
  218. i(r(l.$l("重置")), 1)
  219. ]),
  220. _: 1
  221. }),
  222. o(m, {
  223. class: "submit",
  224. type: "primary",
  225. onClick: e[4] || (e[4] = (n) => R())
  226. }, {
  227. default: a(() => [
  228. i(r(l.$l("确定")), 1)
  229. ]),
  230. _: 1
  231. })
  232. ])
  233. ])
  234. ]),
  235. _: 1
  236. }, 8, ["title", "visible"]);
  237. };
  238. }
  239. }), _e = /* @__PURE__ */ W(re, [["__scopeId", "data-v-6154ec79"]]);
  240. export {
  241. _e as default
  242. };