SettingColumns.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. var K = Object.defineProperty, G = Object.defineProperties;
  2. var J = Object.getOwnPropertyDescriptors;
  3. var v = Object.getOwnPropertySymbols;
  4. var I = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
  5. var F = (n, t, s) => t in n ? K(n, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : n[t] = s, C = (n, t) => {
  6. for (var s in t || (t = {}))
  7. I.call(t, s) && F(n, s, t[s]);
  8. if (v)
  9. for (var s of v(t))
  10. $.call(t, s) && F(n, s, t[s]);
  11. return n;
  12. }, b = (n, t) => G(n, J(t));
  13. var N = (n, t) => {
  14. var s = {};
  15. for (var a in n)
  16. I.call(n, a) && t.indexOf(a) < 0 && (s[a] = n[a]);
  17. if (n != null && v)
  18. for (var a of v(n))
  19. t.indexOf(a) < 0 && $.call(n, a) && (s[a] = n[a]);
  20. return s;
  21. };
  22. import { ref as B, watch as L, resolveComponent as D, openBlock as P, createBlock as Q, withCtx as f, createElementVNode as i, toDisplayString as u, createVNode as r, unref as X, createTextVNode as g } from "vue";
  23. import { d as Y } from "./vuedraggable.js";
  24. import { n as Z, dm as ee, B as ne } from "./index2.js";
  25. import { _ as te } from "./index8.js";
  26. import { _ as se } from "./index10.js";
  27. const oe = { class: "drawer-wrap" }, ie = { class: "content-wrap" }, ae = { class: "table-wrap" }, de = { class: "title" }, le = { class: "columns-wrap" }, ce = { class: "item" }, re = { class: "td-item flex-start" }, ue = { class: "drag-icon" }, he = { class: "checkbox" }, fe = { class: "checkbox" }, _e = { class: "name" }, pe = { class: "td-item" }, me = { style: { "margin-right": "8px" } }, ve = { class: "drawer-footer" }, ge = /* @__PURE__ */ Object.assign({ name: "SettingColumns" }, {
  28. __name: "SettingColumns",
  29. props: {
  30. pageCode: {
  31. type: String,
  32. required: !0
  33. },
  34. // 源列配置(SSuperListLayout 的 renderColumns);抽屉内改的是副本,点「确定」才回写
  35. columns: {
  36. type: Array,
  37. default: () => []
  38. }
  39. },
  40. emits: ["save", "reset"],
  41. setup(n, { expose: t, emit: s }) {
  42. const a = n, k = s, h = B(!1), p = B([]), w = /* @__PURE__ */ new Map();
  43. function x(e) {
  44. if (e == null || e === "") return;
  45. if (typeof e == "string") {
  46. const c = e.trim();
  47. if (!c || c.includes("%")) return;
  48. const d = parseInt(c, 10);
  49. return Number.isNaN(d) ? void 0 : d;
  50. }
  51. const o = Number(e);
  52. return Number.isFinite(o) ? Math.round(o) : void 0;
  53. }
  54. function O(e) {
  55. return e.fixed && !w.has(e.dataIndex) && w.set(e.dataIndex, e.fixed === "right" ? "right" : "left"), b(C({}, e), {
  56. // 像素宽度:百分比列留空,等用户自己填
  57. width: x(e.width),
  58. // 原始列宽声明(例如 "20%"),用户没填像素值时原样恢复,避免把百分比列写坏
  59. widthRaw: e.width,
  60. // 是否显示:默认显示,只有显式 false 才隐藏
  61. show: e.show !== !1,
  62. // 是否冻结:fixed 有值即冻结;操作列强制冻结且不可取消
  63. isFixed: !!e.fixed,
  64. disabledFixed: e.dataIndex === "action" || !!e.disabledFixed
  65. });
  66. }
  67. function S() {
  68. p.value = (a.columns || []).map(O);
  69. }
  70. function R() {
  71. return p.value.map((c) => {
  72. var d = c, { widthRaw: e } = d, o = N(d, ["widthRaw"]);
  73. const m = x(o.width);
  74. return b(C({}, o), {
  75. // 没填像素宽度就回到原始声明(百分比列保持原样)
  76. width: m === void 0 ? e : m,
  77. fixed: o.isFixed ? w.get(o.dataIndex) || "left" : !1
  78. });
  79. });
  80. }
  81. function U() {
  82. S(), h.value = !0;
  83. }
  84. function E() {
  85. k("reset");
  86. }
  87. function V() {
  88. k("save", R()), h.value = !1;
  89. }
  90. function z() {
  91. h.value = !1;
  92. }
  93. function H(e) {
  94. e.show = !e.show;
  95. }
  96. function M(e) {
  97. e.isFixed = !e.isFixed;
  98. }
  99. function T({ target: { value: e } }, o) {
  100. var d;
  101. const c = x(e);
  102. o.width = c, c === void 0 && !String((d = o.widthRaw) != null ? d : "").includes("%") && (o.widthRaw = void 0);
  103. }
  104. function W() {
  105. }
  106. function j() {
  107. }
  108. return L(
  109. () => a.columns,
  110. () => {
  111. h.value && S();
  112. },
  113. { deep: !0 }
  114. ), t({
  115. show: U,
  116. columns: p,
  117. visible: h
  118. }), (e, o) => {
  119. const c = D("HolderOutlined"), d = ee, m = se, q = D("UndoOutlined"), y = ne, A = te;
  120. return P(), Q(A, {
  121. rootClassName: "filter-columns-wrap",
  122. title: `${e.$l("高级表格")}`,
  123. placement: "right",
  124. width: 700,
  125. visible: h.value,
  126. onClose: z
  127. }, {
  128. default: f(() => [
  129. i("div", oe, [
  130. i("div", ie, [
  131. i("div", ae, [
  132. i("div", de, u(e.$l("勾选要显示的列,拖动排序")), 1),
  133. i("div", le, [
  134. r(X(Y), {
  135. list: p.value,
  136. itemKey: "dataIndex",
  137. handle: ".mover",
  138. animation: "300",
  139. "ghost-class": "ghost",
  140. "chosen-class": "chosenClass",
  141. touchStartThreshold: 20,
  142. onStart: W,
  143. onEnd: j
  144. }, {
  145. item: f(({ element: l }) => [
  146. i("div", ce, [
  147. i("div", re, [
  148. i("div", ue, [
  149. r(c),
  150. o[0] || (o[0] = i("div", { class: "mask mover" }, null, -1))
  151. ]),
  152. i("div", he, [
  153. r(d, {
  154. checked: l.show,
  155. onChange: (_) => H(l)
  156. }, {
  157. default: f(() => [
  158. g(u(e.$l("显示")), 1)
  159. ]),
  160. _: 1
  161. }, 8, ["checked", "onChange"])
  162. ]),
  163. i("div", fe, [
  164. r(d, {
  165. checked: l.isFixed,
  166. disabled: l.disabledFixed,
  167. onChange: (_) => M(l)
  168. }, {
  169. default: f(() => [
  170. g(u(e.$l("冻结")), 1)
  171. ]),
  172. _: 1
  173. }, 8, ["checked", "disabled", "onChange"])
  174. ]),
  175. i("div", _e, u(l.title || l.name), 1)
  176. ]),
  177. i("div", pe, [
  178. i("span", me, u(e.$l("宽度")), 1),
  179. r(m, {
  180. style: { width: "80px" },
  181. size: "small",
  182. min: 1,
  183. precision: 0,
  184. value: l.width,
  185. "onUpdate:value": (_) => l.width = _,
  186. onBlur: (_) => T(_, l)
  187. }, null, 8, ["value", "onUpdate:value", "onBlur"]),
  188. o[1] || (o[1] = i("span", { style: { "margin-left": "8px" } }, "px", -1))
  189. ])
  190. ])
  191. ]),
  192. _: 1
  193. }, 8, ["list"])
  194. ])
  195. ])
  196. ]),
  197. i("div", ve, [
  198. r(y, {
  199. class: "reset",
  200. onClick: E
  201. }, {
  202. default: f(() => [
  203. r(q),
  204. g(u(e.$l("重置")), 1)
  205. ]),
  206. _: 1
  207. }),
  208. r(y, {
  209. class: "submit",
  210. type: "primary",
  211. onClick: V
  212. }, {
  213. default: f(() => [
  214. g(u(e.$l("确定")), 1)
  215. ]),
  216. _: 1
  217. })
  218. ])
  219. ])
  220. ]),
  221. _: 1
  222. }, 8, ["title", "visible"]);
  223. };
  224. }
  225. }), ye = /* @__PURE__ */ Z(ge, [["__scopeId", "data-v-1e3ea8d6"]]);
  226. export {
  227. ye as default
  228. };