UNPKG

ideaz-element

Version:

<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>

143 lines (142 loc) 4.7 kB
import "../../../../node_modules/.pnpm/lodash-unified@1.0.3_@types_lodash-es@4.17.12_lodash-es@4.17.21_lodash@4.17.21/node_modules/lodash-unified/import.mjs"; import "../../../../utils/index.mjs"; import { tableKeys as q, FILTER_TABLE_KEYS as N } from "../props.mjs"; import { useCrudConfig as V } from "./useCrudConfig.mjs"; import { useTableColumns as Y } from "./useTableColumns.mjs"; import { ref as G, getCurrentInstance as H, useAttrs as J, computed as S, onMounted as Q, nextTick as W } from "vue"; import { isFunction as r, isString as b, isObject as p } from "../../../../utils/is.mjs"; import O from "../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/get.mjs"; import X from "../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/pick.mjs"; function Z(t) { const n = []; for (const i in t) if (Object.hasOwnProperty.call(t, i)) { const l = encodeURIComponent(t[i]), f = `${i}=${l}`; n.push(f); } return n.join("&"); } function R(t, n) { var f, d, h, m; const i = (f = n == null ? void 0 : n.alias) == null ? void 0 : f.list, l = (d = n == null ? void 0 : n.alias) == null ? void 0 : d.total; return { list: r(i) ? i(t) : b(i) ? O(t, i) : (h = t == null ? void 0 : t.data) == null ? void 0 : h.list, total: r(l) ? l(t) : b(l) ? O(t, l) : (m = t == null ? void 0 : t.data) == null ? void 0 : m.total }; } function ca(t, n) { const i = G({}), { proxy: l } = H(), { handleSearch: f, handleReset: d, handlePaginationChange: h, middleFormData: m, isUseFormDataStorage: w, middlePagination: c } = V(t, n), { tableColumns: T, isShowDialog: A, rowData: E, currentMode: $, isShowDrawer: x, refreshAfterRequest: j } = Y(t, n, u), B = J(), g = () => p(t.request) || b(t.request) || r(t.request), v = S({ get() { return t.loading || !1; }, set(a) { n("update:loading", a); } }), y = S({ get() { return t.data; }, set(a) { n("update:data", a); } }), k = S(() => ({ ...X(t, q.filter((a) => !N.includes(a))), columns: T.value, ...B, fullScreenElement: () => l == null ? void 0 : l.$refs.crudRef, pagination: c.value, data: y.value, loading: v.value, "onUpdate:data": (a) => y.value = a })); async function u(a) { const e = t.request || {}, o = C(a); if (p(e) && r(e.searchFunc)) { e.searchFunc({ params: o }); return; } v.value = !0; try { let s = null; return r(e) && (s = await e(o)), p(e) && r(e.searchApi) && (s = await e.searchApi(o)), y.value = r(e.tableData) ? e.tableData(R(s, e).list) : R(s, e).list, t.pagination !== !1 && D({ total: Number(R(s, e).total) }), v.value = !1, s; } catch { v.value = !1; } } function C(a) { const e = { ...t.formData, ...a, ...i.value }; return t.pagination !== !1 && (e.page = c.value.page, e.pageSize = c.value.pageSize), e; } function z() { if (d(), g()) { const a = l.$refs.zTableRef; a.clearSelection(), a.clearSort(), a.clearFilter(), D({ page: 1 }), u(); } } const P = () => { f(), g() && (D({ page: 1 }), u()); }, I = (a) => { a.preventDefault(), P(); }, K = (a) => { h(a), g() && (D(a), u()); }; function D(a) { const e = { ...c.value }; return Object.keys(a).forEach((o) => { Object.hasOwnProperty.call(c.value, o) && (e[o] = a[o]); }), c.value = e, { ...c.value }; } const L = (a) => { n("radio-change", a); }, U = ({ column: a, prop: e, order: o }) => { o ? i.value = { sort: { column: a, prop: e, order: o } } : i.value = {}, n("sort-change", { column: a, prop: e, order: o }), g() && u(i.value); }, F = async () => { var a, e; try { const o = (a = t.request) == null ? void 0 : a.beforeData, s = (e = t.request) == null ? void 0 : e.afterData; r(o) && await o(); const _ = await u(); r(s) && await s(_); } catch { } }, M = () => { const a = t.export, e = Z(C()); b(a) && (window.location.href = `${a}?${e}`), r(a) && (window.location.href = a(C())); }; return !w.value && g() && F(), Q(async () => { await W(), w.value && g() && F(); }), { handleSearch: P, tableProps: k, handleReset: z, handleKeyDown: I, handlePaginationChange: K, handleSortChange: U, middleFormData: m, isUseFormDataStorage: w, handleRadioChange: L, handleExport: M, getTableData: u, isShowDialog: A, rowData: E, currentMode: $, isShowDrawer: x, refreshAfterRequest: j }; } export { Z as stringifyObject, ca as useDataRequest }; //# sourceMappingURL=useDataRequest.mjs.map