yuang-framework-ui-pc
Version:
yuang-framework-ui-pc Library
132 lines (131 loc) • 4.79 kB
JavaScript
"use strict";
const vue = require("vue");
const elementPlus = require("element-plus");
const icons = require("../../icons");
const util = require("../../ele-virtual-table/util");
const _sfc_main = vue.defineComponent({
name: "ToolPrintBodyCell",
components: { ElIcon: elementPlus.ElIcon, ArrowDown: icons.ArrowDown, CellRender: util.CellRender },
props: {
/** 列数据 */
col: {
type: Object,
required: true
},
/** 列索引 */
columnIndex: Number,
/** 单元格样式 */
bodyCellStyle: [Object, Function],
/** 单元格类名自定义 */
bodyCellClass: [String, Function]
},
setup(props, { slots }) {
const renderOpt = vue.computed(() => {
const { text, row, column, index: $index } = props.col;
const params = [{ row, column, $index }];
const slotName = column ? column.printSlot || column.slot : void 0;
if (column && "expand" !== column.type && slotName && typeof slots[slotName] === "function") {
return { render: slots[slotName], params };
}
return { render: () => text, params };
});
const cellParam = vue.computed(() => {
return {
column: props.col.column,
columnIndex: props.columnIndex,
rowIndex: props.col.index,
row: props.col.row
};
});
const cellStyle = vue.computed(() => {
if (typeof props.bodyCellStyle === "function") {
if (cellParam.value.column == null) {
return;
}
return props.bodyCellStyle(cellParam.value);
}
return props.bodyCellStyle;
});
const cellClass = vue.computed(() => {
const classes = [];
const column = cellParam.value.column;
if (column) {
if (column.align) {
classes.push("is-align-" + column.align);
}
if (typeof props.bodyCellClass === "function") {
const temp = props.bodyCellClass(cellParam.value);
if (temp) {
classes.push(temp);
}
} else if (props.bodyCellClass) {
classes.push(props.bodyCellClass);
}
if (column.className) {
classes.push(column.className);
}
}
return classes.join(" ");
});
return { renderOpt, cellStyle, cellClass };
}
});
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _hoisted_1 = ["colspan", "rowspan"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
var _a;
const _component_ArrowDown = vue.resolveComponent("ArrowDown");
const _component_ElIcon = vue.resolveComponent("ElIcon");
const _component_CellRender = vue.resolveComponent("CellRender");
return vue.openBlock(), vue.createElementBlock("td", {
colspan: _ctx.col.colspan,
rowspan: _ctx.col.rowspan,
style: vue.normalizeStyle(_ctx.cellStyle),
class: vue.normalizeClass(_ctx.cellClass)
}, [
"expand" === ((_a = _ctx.col.column) == null ? void 0 : _a.type) ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
_ctx.col.text ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
vue.createTextVNode(vue.toDisplayString(_ctx.col.text), 1)
], 64)) : (vue.openBlock(), vue.createBlock(_component_ElIcon, {
key: 1,
style: { "vertical-align": "middle" },
class: "ele-print-expand-icon"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_ArrowDown)
]),
_: 1
}))
], 64)) : (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
_ctx.col.isTreeCell ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
_ctx.col.indent ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
style: vue.normalizeStyle({ paddingLeft: `${_ctx.col.indent * 16}px` }),
class: "ele-print-tree-indent"
}, null, 4)) : vue.createCommentVNode("", true),
vue.createVNode(_component_ElIcon, {
style: vue.normalizeStyle({
verticalAlign: "middle",
marginRight: "2px",
visibility: _ctx.col.isTreeLeaf ? "hidden" : void 0
}),
class: "ele-print-tree-icon"
}, {
default: vue.withCtx(() => [
vue.createVNode(_component_ArrowDown)
]),
_: 1
}, 8, ["style"])
], 64)) : vue.createCommentVNode("", true),
vue.createVNode(_component_CellRender, vue.normalizeProps(vue.guardReactiveProps(_ctx.renderOpt)), null, 16)
], 64))
], 14, _hoisted_1);
}
const toolPrintBodyCell = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
module.exports = toolPrintBodyCell;