tass-ui
Version:
A high quality UI Toolkit built on Vue.js3+.
102 lines (101 loc) • 3.71 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
require("../../../theme-chalk/src/table.scss.js");
const _hoisted_1 = { key: 0 };
const _hoisted_2 = { key: 1 };
const _hoisted_3 = { key: 1 };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "table",
props: {
// 传入数据,object类型
options: {
type: Object,
default: () => {
return {
// options定义的参数名字,对应name
fileds: [],
// 数据
datas: []
};
}
},
// 尺寸
size: {
type: String,
default: "default"
},
// 是否显示表头
showHeader: {
type: Boolean,
default: true
},
// 表头样式
headStyle: {
type: Object,
default: () => {
return {};
}
},
// 表格内容样式
rowStyle: {
type: Object,
default: () => {
return {};
}
},
customClass: String
},
setup(__props) {
const $slot = vue.useSlots();
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([`tas-table-${__props.size}`, __props.customClass])
}, [
vue.createElementVNode("table", null, [
__props.showHeader ? (vue.openBlock(), vue.createElementBlock("thead", _hoisted_1, [
vue.createElementVNode("tr", null, [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.options.fileds, (x, index) => {
return vue.openBlock(), vue.createElementBlock("th", {
key: index,
style: vue.normalizeStyle([__props.headStyle, { "text-align": x.align }])
}, [
vue.unref($slot)["head-" + x.field] ? vue.renderSlot(_ctx.$slots, "head-" + x.field, {
key: 0,
scope: x
}) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, vue.toDisplayString(x.title), 1))
], 4);
}), 128))
])
])) : vue.createCommentVNode("", true),
vue.createElementVNode("tbody", null, [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.options.datas, (v, i) => {
return vue.openBlock(), vue.createElementBlock("tr", { key: i }, [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.options.fileds, (m, j) => {
return vue.openBlock(), vue.createElementBlock("td", {
key: j,
style: vue.normalizeStyle(
[
__props.rowStyle,
{
width: __props.options.fileds[j].width ? __props.options.fileds[j].width : "",
"text-align": __props.options.fileds[j].align
}
]
)
}, [
vue.unref($slot)[__props.options.fileds[j].field] ? vue.renderSlot(_ctx.$slots, __props.options.fileds[j].field, {
key: 0,
scope: { rowIndex: i, cellIndex: j, row: v }
}) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, vue.toDisplayString(__props.options.datas[i][__props.options.fileds[j].field]), 1))
], 4);
}), 128))
]);
}), 128))
])
])
], 2);
};
}
});
exports.default = _sfc_main;