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>
48 lines (47 loc) • 1.99 kB
JavaScript
import { ElMessage as D } from "element-plus";
import "../../../../utils/index.mjs";
import C from "../../../dialog/src/dialog.mjs";
import { getCurrentInstance as g, ref as b, computed as p } from "vue";
import { useLocale as y } from "../../../../hooks/useLocale.mjs";
import { isObject as x, isFunction as m } from "../../../../utils/is.mjs";
function j(a, s, d, h, r) {
const { proxy: c } = g(), e = b(a.selectionData || []), { t: u } = y(), v = p(() => d.value.columns.filter((t) => t.type === "selection").length > 0 && e.value.length > 0);
return {
selectionData: e,
isSelection: v,
handleCheckboxChange: (t) => {
s("selection-change", t), s("update:selectionData", t), a.selectionData === void 0 && (e.value = t);
},
handleCloseAlert: () => {
c.$refs.zTableRef.clearSelection();
},
handleMultipleDelete: () => {
var f;
const t = (f = a.request) == null ? void 0 : f.deleteApi;
if (t) {
const l = x(a.delete) ? a.delete : {};
C({
type: "danger",
...l,
message: m(l.message) ? l.message({ selectionData: e.value }) : u("crud.multipleDeleteTip"),
onConfirm: m(l.onConfirm) ? ({ done: i, confirmButtonLoading: n }) => {
var o;
return (o = l.onConfirm) == null ? void 0 : o.call(l, { done: i, confirmButtonLoading: n, selectionData: e.value, tableRef: c.$refs.zTableRef, getTableData: r });
} : async ({ done: i, confirmButtonLoading: n }) => {
n.value = !0;
try {
await t({ [a.dataKey]: e.value.map((o) => o[a.dataKey]), selectionData: e.value }), n.value = !1, i(), D.success(u("common.success")), h();
} catch {
}
n.value = !1;
}
});
}
s("operate-delete", { selectionData: e.value, table: c.$refs.zTableRef, getTableData: r });
}
};
}
export {
j as useSelectionData
};
//# sourceMappingURL=useSelectionData.mjs.map