37 lines
6.1 KiB
JSON
37 lines
6.1 KiB
JSON
{
|
|
"slug": "summaryrowtable",
|
|
"mode": "single",
|
|
"examples": [
|
|
{
|
|
"id": "summaryrowtable-ex-1",
|
|
"title": "基础用法",
|
|
"titleSrc": "",
|
|
"desc": "",
|
|
"html": "<div class=\"kole-page\">\n <h2 class=\"kole-h2\">SummaryRowTable 统计汇总表格</h2>\n <p class=\"kole-desc\">表格底部显示汇总行(合计 / 平均值 / 最大值 / 最小值 / 计数),可配置汇总字段。</p>\n <div class=\"kole-demo\">\n <div class=\"kole-demo__title\">销售明细与汇总</div>\n <table class=\"kole-sumtable\" id=\"sumtable\">\n <thead>\n <tr>\n <th>产品</th>\n <th>数量</th>\n <th>单价</th>\n <th>金额</th>\n </tr>\n </thead>\n <tbody></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n</div>",
|
|
"preview": {
|
|
"show": [
|
|
[
|
|
0
|
|
]
|
|
],
|
|
"hide": [],
|
|
"mode": "single"
|
|
},
|
|
"previewSafe": true,
|
|
"previewUnsafeReasons": [],
|
|
"source": "curated",
|
|
"code": {
|
|
"html": "<h2>SummaryRowTable 统计汇总表格</h2>\n<p>表格底部显示汇总行(合计 / 平均值 / 最大值 / 最小值 / 计数),可配置汇总字段。</p>\n<div>销售明细与汇总</div>\n<table class=\"kole-sumtable\" id=\"sumtable\">\n <thead>\n <tr>\n <th>产品</th>\n <th>数量</th>\n <th>单价</th>\n <th>金额</th>\n </tr>\n </thead>\n <tbody></tbody>\n <tfoot></tfoot>\n</table>",
|
|
"jsx": "import { KoleSummaryRowTable } from 'kole-ui/react';\n\nconst columns = [\n { key: 'name', title: '产品' },\n { key: 'qty', title: '数量' },\n { key: 'price', title: '单价' },\n { key: 'amount', title: '金额' }\n];\n\nconst data = [\n { name: '基础版', qty: 10, price: 99, amount: 990 },\n { name: '标准版', qty: 6, price: 199, amount: 1194 },\n { name: '旗舰版', qty: 3, price: 499, amount: 1497 }\n];\n\n<KoleSummaryRowTable\n columns={columns}\n data={data}\n summary={{ qty: 'sum', price: 'avg', amount: 'sum' }}\n labelKey=\"name\"\n labelText=\"合计 / 平均\"\n/>",
|
|
"vue3": "<template>\n <KoleSummaryRowTable\n :columns=\"columns\"\n :data=\"data\"\n :summary=\"{ qty: 'sum', price: 'avg', amount: 'sum' }\"\n label-key=\"name\"\n label-text=\"合计 / 平均\"\n />\n</template>\n\n<script setup>\nimport { KoleSummaryRowTable } from 'kole-ui/vue3';\n\nconst columns = [\n { key: 'name', title: '产品' },\n { key: 'qty', title: '数量' },\n { key: 'price', title: '单价' },\n { key: 'amount', title: '金额' }\n];\n\nconst data = [\n { name: '基础版', qty: 10, price: 99, amount: 990 },\n { name: '标准版', qty: 6, price: 199, amount: 1194 },\n { name: '旗舰版', qty: 3, price: 499, amount: 1497 }\n];\n</script>",
|
|
"vue2": "<template>\n <KoleSummaryRowTable\n :columns=\"columns\"\n :data=\"data\"\n :summary=\"{ qty: 'sum', price: 'avg', amount: 'sum' }\"\n label-key=\"name\"\n label-text=\"合计 / 平均\"\n />\n</template>\n\n<script>\nimport { KoleSummaryRowTable } from 'kole-ui/vue2';\n\nexport default {\n name: 'SummaryRowTableBasic',\n components: { KoleSummaryRowTable },\n data() {\n return {\n columns: [\n { key: 'name', title: '产品' },\n { key: 'qty', title: '数量' },\n { key: 'price', title: '单价' },\n { key: 'amount', title: '金额' }\n ],\n data: [\n { name: '基础版', qty: 10, price: 99, amount: 990 },\n { name: '标准版', qty: 6, price: 199, amount: 1194 },\n { name: '旗舰版', qty: 3, price: 499, amount: 1497 }\n ]\n };\n }\n};\n</script>",
|
|
"tsx": "import { KoleSummaryRowTable } from 'kole-ui/react';\n\nexport default function KoleSummaryRowTableDemo(): JSX.Element {\n const columns = [\n { key: 'name', title: '产品' },\n { key: 'qty', title: '数量' },\n { key: 'price', title: '单价' },\n { key: 'amount', title: '金额' }\n ];\n \n const data = [\n { name: '基础版', qty: 10, price: 99, amount: 990 },\n { name: '标准版', qty: 6, price: 199, amount: 1194 },\n { name: '旗舰版', qty: 3, price: 499, amount: 1497 }\n ];\n return (\n <KoleSummaryRowTable\n columns={columns}\n data={data}\n summary={{ qty: 'sum', price: 'avg', amount: 'sum' }}\n labelKey=\"name\"\n labelText=\"合计 / 平均\"\n />\n );\n}",
|
|
"vue3ts": "<template>\n\n <KoleSummaryRowTable\n :columns=\"columns\"\n :data=\"data\"\n :summary=\"{ qty: 'sum', price: 'avg', amount: 'sum' }\"\n label-key=\"name\"\n label-text=\"合计 / 平均\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { KoleSummaryRowTable } from 'kole-ui/vue3';\n\nconst demoTitle = ref<string>('基础用法');\nconst columns = [\n { key: 'name', title: '产品' },\n { key: 'qty', title: '数量' },\n { key: 'price', title: '单价' },\n { key: 'amount', title: '金额' }\n];\n\nconst data = [\n { name: '基础版', qty: 10, price: 99, amount: 990 },\n { name: '标准版', qty: 6, price: 199, amount: 1194 },\n { name: '旗舰版', qty: 3, price: 499, amount: 1497 }\n];\n</script>",
|
|
"vue2ts": "<template>\n\n <KoleSummaryRowTable\n :columns=\"columns\"\n :data=\"data\"\n :summary=\"{ qty: 'sum', price: 'avg', amount: 'sum' }\"\n label-key=\"name\"\n label-text=\"合计 / 平均\"\n />\n</template>\n\n<script lang=\"ts\">\nimport Vue from 'vue';\nimport { KoleSummaryRowTable } from 'kole-ui/vue2';\n\nexport default {\n name: 'SummaryRowTableBasic',\n components: { KoleSummaryRowTable },\n data(): Record<string, unknown> {\n return {\n columns: [\n { key: 'name', title: '产品' },\n { key: 'qty', title: '数量' },\n { key: 'price', title: '单价' },\n { key: 'amount', title: '金额' }\n ],\n data: [\n { name: '基础版', qty: 10, price: 99, amount: 990 },\n { name: '标准版', qty: 6, price: 199, amount: 1194 },\n { name: '旗舰版', qty: 3, price: 499, amount: 1497 }\n ]\n };\n }\n};\n</script>"
|
|
},
|
|
"notes": "依据 frameworks/SummaryRowTable.html:26-30 data 三行实参、:32 summary={qty:sum, amount:sum, price:avg}、:33 cols 列顺序、:53 表尾标签「合计 / 平均」"
|
|
}
|
|
],
|
|
"curated": true
|
|
}
|