UNPKG

yanzhen-design-vue

Version:

67 lines (66 loc) 1.69 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const lodashEs = require("lodash-es"); const utils = require("@yanzhen-libs/utils"); function useVxeTableProps(props) { const { rowConfig: rowConfigRef } = vue.toRefs(props); const dataSource = vue.computed({ get: () => { return lodashEs.isArray(props.data) ? props.data : []; }, set(value) { } }); const loading = vue.computed(() => props.loading); const rowKey = vue.computed(() => { const rowConfig = vue.unref(rowConfigRef); const keyField = (rowConfig == null ? void 0 : rowConfig.useKey) ? rowConfig == null ? void 0 : rowConfig.keyField : void 0; if (!utils.isEmptyValue(keyField)) { return keyField; } return "key"; }); const vxeIgnoreTableProps = { data: vue.unref(dataSource) }; const vxeTableProps = vue.computed(() => { const tableProps = {}; const _props = lodashEs.omit( props, "data", ...Object.keys(tableProps), ...Object.keys(vxeIgnoreTableProps) ); return { ..._props, ...tableProps }; }); const elTableProps = vue.computed(() => { return { data: vue.unref(dataSource), border: true, rowKey: vue.unref(rowKey) }; }); const aTableProps = vue.computed(() => { return { dataSource: vue.unref(dataSource), scroll: { scrollToFirstRowOnChange: true, x: "max-content" }, pagination: false }; }); return { rowKey, dataSource, loading, elTableProps, aTableProps, vxeTableProps }; } exports.useVxeTableProps = useVxeTableProps;