UNPKG

@aplus-frontend/ui

Version:

73 lines (72 loc) 1.62 kB
import { isFunction as p } from "lodash-unified"; import { ROW_KEY as a } from "./constants.mjs"; function m(e, t, r) { let n = null; return { request: async (s) => { const i = e; if (!i) return r?.(0), { data: [], total: 0 }; n && (s = Object.assign(s, n)); const { records: l, total: u } = await i(Object.assign({}, s)); return r?.(l?.length || 0), { data: l?.map((c) => h(c, t)), total: u }; }, setExtraParams: (s) => { n = s || null; } }; } function h(e, t) { return p(t) ? { ...e, [a]: t(e) } : e; } function g(e) { return Reflect.deleteProperty(e, a), e; } function j(e) { const { renderSelectedItem: t, rightTitle: r, rightBottom: n, ...o } = e || {}; return { props: { ...o, layoutType: e && "two-column" }, slots: { renderSelectedItem: t, rightTitle: r, rightBottom: n } }; } class y { constructor() { this.p = null, this.operateFn = null; } buildPromise() { return this.operateFn && this.operateFn.reject("Ignored Reject: reuse"), this.p = new Promise((t, r) => { this.operateFn = { reject: r, resolve: t }; }), this.p; } clear() { this.p = null, this.operateFn = null; } /** 兑现回调 */ resolve(t) { this.operateFn && (this.operateFn.resolve(t), this.clear()); } /** 拒绝回调 */ reject(t) { this.operateFn && (this.operateFn.reject("Ignored Reject: " + t), this.clear()); } } export { y as AsyncCallback, h as addRowKeyField, g as delRowKeyField, m as genRequest, j as getModalLayoutConfig };