yuang-framework-ui-pc
Version:
yuang-framework-ui-pc Library
126 lines (125 loc) • 4.38 kB
JavaScript
"use strict";
const vue = require("vue");
const util = require("../util");
const HeaderCell = require("./header-cell");
const _sfc_main = vue.defineComponent({
name: "HeaderRow",
components: { HeaderCell },
props: {
/** 表头行配置 */
headerCols: Array,
/** 表头所有行列宽 */
headerColSizes: Array,
/** 当前行索引 */
headerIndex: Number,
/** 表格排序状态 */
sortBy: Object,
/** 表格筛选值 */
filtered: Object,
/** 表格是否是全选状态 */
isCheckAll: Boolean,
/** 表格是否是半选状态 */
isIndeterminate: Boolean,
/** 是否禁用表头选择框 */
disabledCheckbox: Boolean,
/** 表格尺寸 */
tableSize: String,
/** 表头单元格类名自定义 */
headerCellClass: [String, Function],
/** 表头单元样式自定义 */
headerCellStyle: [Object, Function],
/** 表头单元格是否溢出省略 */
headerEllipsis: Boolean,
/** 表格行高 */
rowHeight: Number
},
emits: {
/** 多选框选中改变事件 */
checkedChange: (_checked) => true,
/** 列筛选改变事件 */
filterChange: (_params) => true,
/** 单元格点击事件 */
cellClick: (_col, _e) => true,
/** 单元格右键事件 */
cellContextmenu: (_col, _e) => true,
/** 单元格鼠标移入事件 */
cellMouseenter: (_col, _e) => true
},
setup(props, { emit }) {
const getKey = (column, columnIndex) => {
return props.headerIndex + "-" + (column.key ?? columnIndex);
};
const getFiltered = (column) => {
return util.getColFiltered(column.originalCol, props.filtered);
};
const handleCellCheckedChange = (checked) => {
emit("checkedChange", checked);
};
const handleCellFilterChange = (params) => {
emit("filterChange", params);
};
const handleCellClick = (col, e) => {
emit("cellClick", col, e);
};
const handleCellContextmenu = (col, e) => {
emit("cellContextmenu", col, e);
};
const handleCellMouseenter = (col, e) => {
emit("cellMouseenter", col, e);
};
return {
getKey,
getFiltered,
handleCellCheckedChange,
handleCellFilterChange,
handleCellClick,
handleCellContextmenu,
handleCellMouseenter
};
}
});
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_HeaderCell = vue.resolveComponent("HeaderCell");
return vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.headerCols, (column, index) => {
return vue.openBlock(), vue.createBlock(_component_HeaderCell, {
key: _ctx.getKey(column, index),
column,
columnIndex: index,
headerIndex: _ctx.headerIndex,
colSize: _ctx.headerColSizes ? _ctx.headerColSizes[index] : void 0,
sortBy: _ctx.sortBy,
filterValue: _ctx.getFiltered(column),
isCheckAll: _ctx.isCheckAll,
isIndeterminate: _ctx.isIndeterminate,
disabledCheckbox: _ctx.disabledCheckbox,
tableSize: _ctx.tableSize,
headerCellClass: _ctx.headerCellClass,
headerCellStyle: _ctx.headerCellStyle,
headerEllipsis: _ctx.headerEllipsis,
rowHeight: _ctx.rowHeight,
onCheckedChange: _ctx.handleCellCheckedChange,
onFilterChange: _ctx.handleCellFilterChange,
onClick: _ctx.handleCellClick,
onContextmenu: _ctx.handleCellContextmenu,
onMouseenter: _ctx.handleCellMouseenter
}, vue.createSlots({ _: 2 }, [
vue.renderList(Object.keys(_ctx.$slots), (name) => {
return {
name,
fn: vue.withCtx((slotProps) => [
vue.renderSlot(_ctx.$slots, name, vue.mergeProps({ ref_for: true }, slotProps || {}))
])
};
})
]), 1032, ["column", "columnIndex", "headerIndex", "colSize", "sortBy", "filterValue", "isCheckAll", "isIndeterminate", "disabledCheckbox", "tableSize", "headerCellClass", "headerCellStyle", "headerEllipsis", "rowHeight", "onCheckedChange", "onFilterChange", "onClick", "onContextmenu", "onMouseenter"]);
}), 128);
}
const headerRow = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
module.exports = headerRow;