Commit ecc7b804 by liimin

feat(ai): 添加语义上下文支持并优化页面生成逻辑

- 在增量补丁计划契约中添加 semanticContext 定义
- 实现过滤器上下文、主表格、工具栏操作等语义化功能
- 重构代码生成器以支持结构化的语义角色识别
- 优化表格生成逻辑,移除默认操作列的硬编码
- 添加字段分组功能和对话框目标映射机制
- 更新示例项目以验证新的语义化生成功能
- 改进动作处理器以支持范围化的操作处理
1 parent 700e4613
...@@ -14,6 +14,26 @@ ...@@ -14,6 +14,26 @@
"routePath": "/allocation/confirmation", "routePath": "/allocation/confirmation",
"routeName": "AllocationConfirmation" "routeName": "AllocationConfirmation"
}, },
"semanticContext": {
"filterContext": null,
"primaryTable": {
"id": "table-1-1592",
"role": "primary-table",
"columnCount": 6,
"hasRowActions": false
},
"toolbarActions": [],
"rowActions": [],
"dialogContext": null,
"actionClassification": {
"filterActions": [],
"toolbarActions": [],
"rowActions": [],
"dialogTriggers": [],
"navigateActions": [],
"requestActions": []
}
},
"routeRegistration": { "routeRegistration": {
"strategy": "static-routes-array", "strategy": "static-routes-array",
"routeFile": "src/router/index.ts", "routeFile": "src/router/index.ts",
...@@ -25,12 +45,7 @@ ...@@ -25,12 +45,7 @@
"insertionScope": "Layout.children", "insertionScope": "Layout.children",
"insertBeforeRoutePath": "/:pathMatch(.*)*", "insertBeforeRoutePath": "/:pathMatch(.*)*",
"insertionHint": "Insert the new route into Layout.children before the catch-all 404 route.", "insertionHint": "Insert the new route into Layout.children before the catch-all 404 route.",
"detectedSignals": [ "detectedSignals": ["routes-array", "layout-parent-route", "layout-children-array", "catch-all-route"],
"routes-array",
"layout-parent-route",
"layout-children-array",
"catch-all-route"
],
"menuConfigTarget": "src/config/menus.ts", "menuConfigTarget": "src/config/menus.ts",
"menuAnchorPath": "/allocation", "menuAnchorPath": "/allocation",
"menuAnchorConfidence": "high", "menuAnchorConfidence": "high",
...@@ -45,14 +60,8 @@ ...@@ -45,14 +60,8 @@
"exportName": "VTable", "exportName": "VTable",
"packageName": "@vui/vue", "packageName": "@vui/vue",
"sourceManifest": "packages/vui/vue/src/components/VTable/VTable.manifest.json", "sourceManifest": "packages/vui/vue/src/components/VTable/VTable.manifest.json",
"usedIn": [ "usedIn": ["block:table-1-1592"],
"block:table-1-1592" "recommendedScenarios": ["后台列表页", "带行操作的数据展示", "查询结果表格"]
],
"recommendedScenarios": [
"后台列表页",
"带行操作的数据展示",
"查询结果表格"
]
} }
], ],
"operations": [ "operations": [
...@@ -79,9 +88,7 @@ ...@@ -79,9 +88,7 @@
"description": "Register the generated route using the detected static-routes-array strategy.", "description": "Register the generated route using the detected static-routes-array strategy.",
"patchStrategy": "append-snippet", "patchStrategy": "append-snippet",
"snippet": "import { AllocationConfirmationRoute } from \"../views/AllocationConfirmation.route-snippet\";\n\n/*\nInsert into the static routes array:\nInsert before route: /:pathMatch(.*)*\nInsert the new route into Layout.children before the catch-all 404 route.\nAllocationConfirmationRoute,\n*/", "snippet": "import { AllocationConfirmationRoute } from \"../views/AllocationConfirmation.route-snippet\";\n\n/*\nInsert into the static routes array:\nInsert before route: /:pathMatch(.*)*\nInsert the new route into Layout.children before the catch-all 404 route.\nAllocationConfirmationRoute,\n*/",
"dependsOn": [ "dependsOn": ["create-route-snippet"],
"create-route-snippet"
],
"reason": "The project context indicates that route registration is required for new pages and the router file matches static-routes-array." "reason": "The project context indicates that route registration is required for new pages and the router file matches static-routes-array."
}, },
{ {
...@@ -102,10 +109,7 @@ ...@@ -102,10 +109,7 @@
} }
], ],
"validation": { "validation": {
"commands": [ "commands": ["pnpm lint", "pnpm run check:type"],
"pnpm lint",
"pnpm run check:type"
],
"notes": [ "notes": [
"Review the generated route snippet before patching the live router file.", "Review the generated route snippet before patching the live router file.",
"Prefer reusing the existing project UI library rather than introducing raw UI markup." "Prefer reusing the existing project UI library rather than introducing raw UI markup."
...@@ -115,6 +119,7 @@ ...@@ -115,6 +119,7 @@
"changes must respect workspace-level quality gates", "changes must respect workspace-level quality gates",
"new pages should include route registration planning", "new pages should include route registration planning",
"state additions should align with the current pinia store layout", "state additions should align with the current pinia store layout",
"component library manifest loaded from packages/vui/vue/meta/index.json" "component library manifest loaded from packages/vui/vue/meta/index.json",
"detected primary table: primary-table"
] ]
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
"planId": { "type": "string" }, "planId": { "type": "string" },
"targetProject": { "$ref": "#/$defs/targetProject" }, "targetProject": { "$ref": "#/$defs/targetProject" },
"page": { "$ref": "#/$defs/page" }, "page": { "$ref": "#/$defs/page" },
"semanticContext": { "$ref": "#/$defs/semanticContext" },
"routeRegistration": { "$ref": "#/$defs/routeRegistration" }, "routeRegistration": { "$ref": "#/$defs/routeRegistration" },
"componentSelections": { "componentSelections": {
"type": "array", "type": "array",
...@@ -25,6 +26,82 @@ ...@@ -25,6 +26,82 @@
}, },
"additionalProperties": false, "additionalProperties": false,
"$defs": { "$defs": {
"semanticContext": {
"type": "object",
"properties": {
"filterContext": {
"type": "object",
"properties": {
"role": { "type": "string" },
"fieldCount": { "type": "integer" },
"fields": {
"type": "array",
"items": { "type": "string" }
}
}
},
"primaryTable": {
"type": "object",
"properties": {
"role": { "type": "string" },
"blockId": { "type": "string" },
"columns": {
"type": "array",
"items": { "type": "string" }
}
}
},
"toolbarActions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"label": { "type": "string" },
"scope": { "type": "string" },
"targetKind": { "type": "string" }
}
}
},
"rowActions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"label": { "type": "string" },
"scope": { "type": "string" },
"targetKind": { "type": "string" },
"targetBlockId": { "type": "string" }
}
}
},
"dialogContext": {
"type": "object",
"properties": {
"triggerCount": { "type": "integer" },
"formCount": { "type": "integer" },
"triggers": {
"type": "array",
"items": { "type": "string" }
}
}
},
"actionClassification": {
"type": "object",
"properties": {
"filter": { "type": "integer" },
"toolbar": { "type": "integer" },
"row": { "type": "integer" },
"dialog": { "type": "integer" },
"navigate": { "type": "integer" },
"request": { "type": "integer" },
"other": { "type": "integer" }
}
}
},
"additionalProperties": false
},
"targetProject": { "targetProject": {
"type": "object", "type": "object",
"required": ["projectName", "projectRoot", "framework"], "required": ["projectName", "projectRoot", "framework"],
...@@ -49,6 +126,7 @@ ...@@ -49,6 +126,7 @@
}, },
"additionalProperties": false "additionalProperties": false
}, },
"semanticContext": { "$ref": "#/$defs/semanticContext" },
"componentSelection": { "componentSelection": {
"type": "object", "type": "object",
"required": ["hint", "exportName", "packageName", "sourceManifest"], "required": ["hint", "exportName", "packageName", "sourceManifest"],
......
...@@ -99,3 +99,4 @@ ...@@ -99,3 +99,4 @@
- `packages/ai/codegen/examples/generated-from-figma-allocation-confirmation/` - `packages/ai/codegen/examples/generated-from-figma-allocation-confirmation/`
- 为 `figma-frame.schema.json` 与 `page-schema.schema.json` 的表格节点补充 `columns` 契约,允许显式保存表头与样例单元格值,而不是只写入描述文本。 - 为 `figma-frame.schema.json` 与 `page-schema.schema.json` 的表格节点补充 `columns` 契约,允许显式保存表头与样例单元格值,而不是只写入描述文本。
- `packages/ai/figma-ingest` 已把 MCP 设计上下文中的表头和首行样例透传到 schema;`packages/ai/codegen` 已消费这些列信息,生成更贴近真实 Figma 表格的 Vue 示例页。 - `packages/ai/figma-ingest` 已把 MCP 设计上下文中的表头和首行样例透传到 schema;`packages/ai/codegen` 已消费这些列信息,生成更贴近真实 Figma 表格的 Vue 示例页。
- 已开始补第 1 优先级的结构语义:`section.role`、`block.role`、`field.group`、`action.scope/target*` 已进入 contract 与 `figma-ingest`,用于表达筛选区、结果区、字段分组以及 dialog/row/toolbar 触发关系。
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import { VButton, VTable } from "@vui/vue"; import { VTable } from "@vui/vue";
const tableColumns = [ const tableColumns = [
{ {
...@@ -27,11 +27,6 @@ const tableColumns = [ ...@@ -27,11 +27,6 @@ const tableColumns = [
{ {
"key": "column6", "key": "column6",
"label": "调入仓" "label": "调入仓"
},
{
"key": "actions",
"label": "Actions",
"width": 220
} }
]; ];
const rows = ref([ const rows = ref([
...@@ -44,14 +39,6 @@ const rows = ref([ ...@@ -44,14 +39,6 @@ const rows = ref([
"column6": "上海仓" "column6": "上海仓"
} }
]); ]);
function handleToolbarAction(actionId: string) {
console.log("toolbar-action", actionId);
}
function handleRowAction(actionId: string, row: Record<string, unknown>) {
console.log("row-action", actionId, row);
}
</script> </script>
<template> <template>
...@@ -63,16 +50,8 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) { ...@@ -63,16 +50,8 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) {
<section class="page-section"> <section class="page-section">
<div class="section-header"> <div class="section-header">
<h2>调拨明细表</h2> <h2>调拨明细表</h2>
<VButton @click="handleToolbarAction('default-action')">
Create
</VButton>
</div> </div>
<VTable :columns="tableColumns" :data="rows"> <VTable :columns="tableColumns" :data="rows">
<template #actions="{ row }">
<VButton @click="handleRowAction('default-action', row)">
View
</VButton>
</template>
</VTable> </VTable>
</section> </section>
</div> </div>
...@@ -106,4 +85,17 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) { ...@@ -106,4 +85,17 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.field-group {
display: grid;
gap: 12px;
padding: 12px;
border: 1px solid #eef2f7;
border-radius: 10px;
}
.dialog-meta {
color: #6b7280;
font-size: 12px;
}
</style> </style>
export const OrderListRoute = {
path: "/orders",
name: "OrderList",
component: () => import("./OrderList.vue"),
};
<script setup lang="ts">
import { ref, reactive } from "vue";
import { VButton, VDialog, VInput, VSelect, VTable } from "@vui/vue";
const selectOptions = {
"field-2": [
{
"label": "Option A",
"value": "option-a"
},
{
"label": "Option B",
"value": "option-b"
}
]
};
const dialogState = reactive({ visible: false, title: "", description: "", targetBlockId: "", targetKind: "", scope: "" });
const dialogTargetMap = {
"action-3": {
"title": "新增",
"targetBlockId": "mcp-list-semantics-test-toolbar-action-3-dialog",
"targetKind": "dialog",
"scope": "toolbar"
},
"action-5": {
"title": "编辑",
"targetBlockId": "mcp-list-semantics-test-row-action-5-dialog",
"targetKind": "dialog",
"scope": "row"
}
};
const filters = reactive({
"field-1": "",
"field-2": ""
});
const tableColumns = [
{
"key": "column1",
"label": "订单号"
},
{
"key": "column2",
"label": "客户名称"
}
];
const rows = ref([
{
"column1": "SO-001",
"column2": "张三"
}
]);
function handleFilterAction(actionId: string) {
if (dialogTargetMap[actionId]) {
dialogState.title = dialogTargetMap[actionId].title;
dialogState.description = `Generated ${dialogTargetMap[actionId].targetKind || "dialog"} placeholder for ${dialogTargetMap[actionId].title}.`;
dialogState.targetBlockId = dialogTargetMap[actionId].targetBlockId;
dialogState.targetKind = dialogTargetMap[actionId].targetKind;
dialogState.scope = dialogTargetMap[actionId].scope;
dialogState.visible = true;
return;
}
console.log("filter-action", actionId, filters);
}
function handleToolbarAction(actionId: string) {
if (dialogTargetMap[actionId]) {
dialogState.title = dialogTargetMap[actionId].title;
dialogState.description = `Generated ${dialogTargetMap[actionId].targetKind || "dialog"} placeholder for ${dialogTargetMap[actionId].title}.`;
dialogState.targetBlockId = dialogTargetMap[actionId].targetBlockId;
dialogState.targetKind = dialogTargetMap[actionId].targetKind;
dialogState.scope = dialogTargetMap[actionId].scope;
dialogState.visible = true;
return;
}
console.log("toolbar-action", actionId);
}
function handleRowAction(actionId: string, row: Record<string, unknown>) {
if (dialogTargetMap[actionId]) {
dialogState.title = dialogTargetMap[actionId].title;
dialogState.description = `Generated ${dialogTargetMap[actionId].targetKind || "dialog"} placeholder for ${dialogTargetMap[actionId].title}.`;
dialogState.targetBlockId = dialogTargetMap[actionId].targetBlockId;
dialogState.targetKind = dialogTargetMap[actionId].targetKind;
dialogState.scope = dialogTargetMap[actionId].scope;
dialogState.visible = true;
return;
}
console.log("row-action", actionId, row);
}
</script>
<template>
<div class="generated-page OrderList">
<header class="page-header">
<h1>订单列表</h1>
<p>Generated from page schema pilot.</p>
</header>
<section class="page-section">
<h2>筛选条件</h2>
<div class="filter-row">
<VInput v-model="filters.field-1" placeholder="关键字" />
<VSelect v-model="filters.field-2"
:options="selectOptions["field-2"]"
placeholder="状态" />
<VButton @click="handleFilterAction('action-1')">
查询
</VButton>
<VButton plain @click="handleFilterAction('action-2')">
重置
</VButton>
</div>
</section>
<section class="page-section">
<div class="section-header">
<h2>订单列表 Table</h2>
<VButton @click="handleToolbarAction('action-3')">
新增
</VButton>
</div>
<VTable :columns="tableColumns" :data="rows">
<template #actions="{ row }">
<VButton plain @click="handleRowAction('action-4', row)">
查看
</VButton>
<VButton plain @click="handleRowAction('action-5', row)">
编辑
</VButton>
</template>
</VTable>
</section>
<VDialog v-model="dialogState.visible"
:title="dialogState.title || 'Dialog'"
width="520px">
<p>{{ dialogState.description }}</p>
<p v-if="dialogState.targetBlockId" class="dialog-meta">
Target: {{ dialogState.targetKind }} / {{ dialogState.targetBlockId }}
</p>
<p v-if="dialogState.scope" class="dialog-meta">
Scope: {{ dialogState.scope }}
</p>
<template #footer>
<div class="action-row">
<VButton plain @click="dialogState.visible = false">
Cancel
</VButton>
<VButton @click="dialogState.visible = false">
Confirm
</VButton>
</div>
</template>
</VDialog>
</div>
</template>
<style scoped>
.generated-page {
display: grid;
gap: 16px;
padding: 16px;
}
.page-header {
display: grid;
gap: 8px;
}
.page-section {
padding: 16px;
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 12px;
}
.filter-row,
.section-header,
.action-row,
.field-switch {
display: flex;
gap: 12px;
align-items: center;
justify-content: space-between;
}
.field-group {
display: grid;
gap: 12px;
padding: 12px;
border: 1px solid #eef2f7;
border-radius: 10px;
}
.dialog-meta {
color: #6b7280;
font-size: 12px;
}
</style>
export const UserFormSemanticRoute = {
path: "/users/form",
name: "UserFormSemantic",
component: () => import("./UserFormSemantic.vue"),
};
<script setup lang="ts">
import { reactive } from "vue";
import { VButton, VInput, VSelect } from "@vui/vue";
const selectOptions = {
"field-4": [
{
"label": "Option A",
"value": "option-a"
},
{
"label": "Option B",
"value": "option-b"
}
]
};
const formModel = reactive({
"field-1": "",
"field-2": "",
"field-3": "",
"field-4": "",
"field-5": false,
"field-6": ""
});
function handleFormAction(actionId: string) {
console.log("form-action", actionId, formModel);
}
</script>
<template>
<div class="generated-page UserFormSemantic">
<header class="page-header">
<h1>用户表单</h1>
<p>Generated from page schema pilot.</p>
</header>
<section class="page-section">
<h2>用户表单</h2>
<el-form label-position="top">
<div class="field-group">
<h3>基础信息</h3>
<el-form-item label="姓名">
<VInput v-model="formModel.field-1" placeholder="姓名" />
</el-form-item>
</div>
<div class="field-group">
<h3>联系信息</h3>
<el-form-item label="邮箱">
<VInput v-model="formModel.field-2" placeholder="邮箱" />
</el-form-item>
<el-form-item label="电话">
<VInput v-model="formModel.field-3" placeholder="电话" />
</el-form-item>
</div>
<div class="field-group">
<h3>状态配置</h3>
<el-form-item label="角色">
<VSelect v-model="formModel.field-4"
:options="selectOptions["field-4"]"
placeholder="角色" />
</el-form-item>
<el-form-item label="启用">
<div class="field-switch">
<span>启用</span>
<el-switch v-model="formModel.field-5" />
</div>
</el-form-item>
</div>
<div class="field-group">
<h3>时间信息</h3>
<el-form-item label="开始日期">
<el-date-picker v-model="formModel.field-6" placeholder="开始日期" type="date" />
</el-form-item>
</div>
<div class="action-row">
<VButton @click="handleFormAction('action-1')">
提交
</VButton>
<VButton plain @click="handleFormAction('action-2')">
取消
</VButton>
</div>
</el-form>
</section>
</div>
</template>
<style scoped>
.generated-page {
display: grid;
gap: 16px;
padding: 16px;
}
.page-header {
display: grid;
gap: 8px;
}
.page-section {
padding: 16px;
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 12px;
}
.filter-row,
.section-header,
.action-row,
.field-switch {
display: flex;
gap: 12px;
align-items: center;
justify-content: space-between;
}
.field-group {
display: grid;
gap: 12px;
padding: 12px;
border: 1px solid #eef2f7;
border-radius: 10px;
}
.dialog-meta {
color: #6b7280;
font-size: 12px;
}
</style>
...@@ -14,6 +14,26 @@ ...@@ -14,6 +14,26 @@
"routePath": "/allocation/confirmation", "routePath": "/allocation/confirmation",
"routeName": "AllocationConfirmation" "routeName": "AllocationConfirmation"
}, },
"semanticContext": {
"filterContext": null,
"primaryTable": {
"id": "table-1-1592",
"role": "primary-table",
"columnCount": 6,
"hasRowActions": false
},
"toolbarActions": [],
"rowActions": [],
"dialogContext": null,
"actionClassification": {
"filterActions": [],
"toolbarActions": [],
"rowActions": [],
"dialogTriggers": [],
"navigateActions": [],
"requestActions": []
}
},
"routeRegistration": { "routeRegistration": {
"strategy": "static-routes-array", "strategy": "static-routes-array",
"routeFile": "src/router/index.ts", "routeFile": "src/router/index.ts",
...@@ -25,12 +45,7 @@ ...@@ -25,12 +45,7 @@
"insertionScope": "Layout.children", "insertionScope": "Layout.children",
"insertBeforeRoutePath": "/:pathMatch(.*)*", "insertBeforeRoutePath": "/:pathMatch(.*)*",
"insertionHint": "Insert the new route into Layout.children before the catch-all 404 route.", "insertionHint": "Insert the new route into Layout.children before the catch-all 404 route.",
"detectedSignals": [ "detectedSignals": ["routes-array", "layout-parent-route", "layout-children-array", "catch-all-route"],
"routes-array",
"layout-parent-route",
"layout-children-array",
"catch-all-route"
],
"menuConfigTarget": "src/config/menus.ts", "menuConfigTarget": "src/config/menus.ts",
"menuAnchorPath": "/allocation", "menuAnchorPath": "/allocation",
"menuAnchorConfidence": "high", "menuAnchorConfidence": "high",
...@@ -45,14 +60,8 @@ ...@@ -45,14 +60,8 @@
"exportName": "VTable", "exportName": "VTable",
"packageName": "@vui/vue", "packageName": "@vui/vue",
"sourceManifest": "packages/vui/vue/src/components/VTable/VTable.manifest.json", "sourceManifest": "packages/vui/vue/src/components/VTable/VTable.manifest.json",
"usedIn": [ "usedIn": ["block:table-1-1592"],
"block:table-1-1592" "recommendedScenarios": ["后台列表页", "带行操作的数据展示", "查询结果表格"]
],
"recommendedScenarios": [
"后台列表页",
"带行操作的数据展示",
"查询结果表格"
]
} }
], ],
"operations": [ "operations": [
...@@ -79,9 +88,7 @@ ...@@ -79,9 +88,7 @@
"description": "Register the generated route using the detected static-routes-array strategy.", "description": "Register the generated route using the detected static-routes-array strategy.",
"patchStrategy": "append-snippet", "patchStrategy": "append-snippet",
"snippet": "import { AllocationConfirmationRoute } from \"../views/AllocationConfirmation.route-snippet\";\n\n/*\nInsert into the static routes array:\nInsert before route: /:pathMatch(.*)*\nInsert the new route into Layout.children before the catch-all 404 route.\nAllocationConfirmationRoute,\n*/", "snippet": "import { AllocationConfirmationRoute } from \"../views/AllocationConfirmation.route-snippet\";\n\n/*\nInsert into the static routes array:\nInsert before route: /:pathMatch(.*)*\nInsert the new route into Layout.children before the catch-all 404 route.\nAllocationConfirmationRoute,\n*/",
"dependsOn": [ "dependsOn": ["create-route-snippet"],
"create-route-snippet"
],
"reason": "The project context indicates that route registration is required for new pages and the router file matches static-routes-array." "reason": "The project context indicates that route registration is required for new pages and the router file matches static-routes-array."
}, },
{ {
...@@ -102,10 +109,7 @@ ...@@ -102,10 +109,7 @@
} }
], ],
"validation": { "validation": {
"commands": [ "commands": ["pnpm lint", "pnpm run check:type"],
"pnpm lint",
"pnpm run check:type"
],
"notes": [ "notes": [
"Review the generated route snippet before patching the live router file.", "Review the generated route snippet before patching the live router file.",
"Prefer reusing the existing project UI library rather than introducing raw UI markup." "Prefer reusing the existing project UI library rather than introducing raw UI markup."
...@@ -115,6 +119,7 @@ ...@@ -115,6 +119,7 @@
"changes must respect workspace-level quality gates", "changes must respect workspace-level quality gates",
"new pages should include route registration planning", "new pages should include route registration planning",
"state additions should align with the current pinia store layout", "state additions should align with the current pinia store layout",
"component library manifest loaded from packages/vui/vue/meta/index.json" "component library manifest loaded from packages/vui/vue/meta/index.json",
"detected primary table: primary-table"
] ]
} }
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref } from "vue";
import { VButton, VTable } from "@vui/vue"; import { VTable } from "@vui/vue";
const tableColumns = [ const tableColumns = [
{ {
...@@ -27,11 +27,6 @@ const tableColumns = [ ...@@ -27,11 +27,6 @@ const tableColumns = [
{ {
"key": "column6", "key": "column6",
"label": "调入仓" "label": "调入仓"
},
{
"key": "actions",
"label": "Actions",
"width": 220
} }
]; ];
const rows = ref([ const rows = ref([
...@@ -44,14 +39,6 @@ const rows = ref([ ...@@ -44,14 +39,6 @@ const rows = ref([
"column6": "上海仓" "column6": "上海仓"
} }
]); ]);
function handleToolbarAction(actionId: string) {
console.log("toolbar-action", actionId);
}
function handleRowAction(actionId: string, row: Record<string, unknown>) {
console.log("row-action", actionId, row);
}
</script> </script>
<template> <template>
...@@ -63,16 +50,8 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) { ...@@ -63,16 +50,8 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) {
<section class="page-section"> <section class="page-section">
<div class="section-header"> <div class="section-header">
<h2>调拨明细表</h2> <h2>调拨明细表</h2>
<VButton @click="handleToolbarAction('default-action')">
Create
</VButton>
</div> </div>
<VTable :columns="tableColumns" :data="rows"> <VTable :columns="tableColumns" :data="rows">
<template #actions="{ row }">
<VButton @click="handleRowAction('default-action', row)">
View
</VButton>
</template>
</VTable> </VTable>
</section> </section>
</div> </div>
...@@ -106,4 +85,17 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) { ...@@ -106,4 +85,17 @@ function handleRowAction(actionId: string, row: Record<string, unknown>) {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.field-group {
display: grid;
gap: 12px;
padding: 12px;
border: 1px solid #eef2f7;
border-radius: 10px;
}
.dialog-meta {
color: #6b7280;
font-size: 12px;
}
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!