plus-pro-components
Version:
Page level components developed based on Element Plus.
84 lines (81 loc) • 3.05 kB
JavaScript
import { defineComponent, computed, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, normalizeStyle, toDisplayString } from 'vue';
import '../../../constants/index.mjs';
import '../../utils/index.mjs';
import { ElTableColumn } from 'element-plus';
import { isNumber } from 'lodash-es';
import { DefaultPageInfo } from '../../../constants/page.mjs';
import { isFunction, isPlainObject } from '../../utils/is.mjs';
var _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "PlusTableTableColumnIndex"
},
__name: "table-column-index",
props: {
pageInfo: { default: () => ({ ...DefaultPageInfo }) },
indexTableColumnProps: { default: () => ({}) },
indexContentStyle: { type: [Object, Function], default: () => ({}) }
},
setup(__props) {
var _a, _b, _c;
const props = __props;
const getTableIndex = isNumber((_a = props.indexTableColumnProps) == null ? void 0 : _a.index) ? computed(() => {
var _a2;
return (_a2 = props.indexTableColumnProps) == null ? void 0 : _a2.index;
}) : isFunction((_b = props.indexTableColumnProps) == null ? void 0 : _b.index) ? (_c = props.indexTableColumnProps) == null ? void 0 : _c.index : (index) => {
var _a2, _b2;
const i = ((((_a2 = props.pageInfo) == null ? void 0 : _a2.page) || DefaultPageInfo.page) - 1) * (((_b2 = props.pageInfo) == null ? void 0 : _b2.pageSize) || DefaultPageInfo.page) + index + 1;
return +i;
};
const indexContentStyle = (row, index) => {
if (isFunction(props.indexContentStyle)) {
return props.indexContentStyle(
row,
index
);
} else if (isPlainObject(props.indexContentStyle)) {
return props.indexContentStyle;
} else {
return {};
}
};
return (_ctx, _cache) => {
return openBlock(), createBlock(unref(ElTableColumn), mergeProps({
key: "index",
label: "#",
fixed: "left",
type: "index",
"class-name": "plus-table-column-index",
width: "60",
align: "center",
index: unref(getTableIndex)
}, _ctx.indexTableColumnProps), {
default: withCtx(({ row, $index }) => [
unref(isFunction)(unref(getTableIndex)) ? (openBlock(), createElementBlock(
"div",
{
key: 0,
class: "plus-table-column-index__content",
style: normalizeStyle(indexContentStyle(row, $index))
},
toDisplayString(unref(getTableIndex)($index)),
5
/* TEXT, STYLE */
)) : (openBlock(), createElementBlock(
"div",
{
key: 1,
class: "plus-table-column-index__content",
style: normalizeStyle(indexContentStyle(row, $index))
},
toDisplayString(unref(getTableIndex)),
5
/* TEXT, STYLE */
))
]),
_: 1
/* STABLE */
}, 16, ["index"]);
};
}
});
export { _sfc_main as default };