From 9cec8a7f66ba88df20c9b67659400205b9285783 Mon Sep 17 00:00:00 2001 From: kennethcheng Date: Sun, 13 Sep 2026 16:44:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E8=BD=A6=E8=BE=86=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5(=E5=88=97=E8=A1=A8=20+=20=E6=96=B0=E5=A2=9E/?= =?UTF-8?q?=E7=BC=96=E8=BE=91/=E5=88=A0=E9=99=A4/=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=88=87=E6=8D=A2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 把 Vehicles 页从空壳升级成真业务: - 卡片式列表,移动端单列、桌面端两列网格 - 每张卡片展示名称/默认标签/品牌+型号+车牌/能源类型/油箱/里程 - 操作:编辑 / 设为默认 / 删除(NPopconfirm 二次确认;走 NDialog.warning) - 顶部「+ 添加」按钮,弹 NModal 表单 - 表单:名称必填、5 个可选字段、NSwitch 切默认 - 提交走 vehiclesApi.create/update,刷新 store - 删除用 NDialog.warning(避免 Popconfirm 误触) - Loading / Empty / Error 状态完整 新增/改动: - src/components/VehicleFormModal.vue NModal + NForm + NInput/NInputNumber/NSwitch * watch props.show / editing 重置表单 * isEdit 复用同一份表单(create / update 双模式) * 内联 FuelSelect(简单 NSelect 包装) * useMessage 反馈成功/失败 - src/pages/Vehicles.vue 替换占位 Empty * onMounted 触发 store.loadList * openCreate / openEdit 控制 showForm + editing * onSaved 自动切到刚保存的车(UX:加完车立刻能进 Dashboard 看到统计) * setDefault -> store.setDefault * remove -> dialog.warning + store.remove - src/stores/vehicle.ts 暴露 setCurrentId(id) 给 UI 切换当前车 未做(留待后续): - 搜索 / 排序 / 分页:单车辆量 < 100,前两版没必要 - 列表项的「最近一次加油」摘要:留给 Dashboard 拿 验证: pnpm typecheck 0 errors pnpm build 12.5s,dist 重新生成,Dashboard / Vehicles 各自分 chunk --- .../src/components/VehicleFormModal.vue | 231 ++++++++++++++++++ fuellog-web/src/pages/Vehicles.vue | 133 +++++++++- fuellog-web/src/stores/vehicle.ts | 5 + 3 files changed, 363 insertions(+), 6 deletions(-) create mode 100644 fuellog-web/src/components/VehicleFormModal.vue diff --git a/fuellog-web/src/components/VehicleFormModal.vue b/fuellog-web/src/components/VehicleFormModal.vue new file mode 100644 index 0000000..9788fbe --- /dev/null +++ b/fuellog-web/src/components/VehicleFormModal.vue @@ -0,0 +1,231 @@ + + + + + diff --git a/fuellog-web/src/pages/Vehicles.vue b/fuellog-web/src/pages/Vehicles.vue index 90c57e1..3263ccc 100644 --- a/fuellog-web/src/pages/Vehicles.vue +++ b/fuellog-web/src/pages/Vehicles.vue @@ -1,13 +1,134 @@ diff --git a/fuellog-web/src/stores/vehicle.ts b/fuellog-web/src/stores/vehicle.ts index 57a6352..f303092 100644 --- a/fuellog-web/src/stores/vehicle.ts +++ b/fuellog-web/src/stores/vehicle.ts @@ -54,12 +54,17 @@ export const useVehicleStore = defineStore('vehicle', () => { await loadList() } + function setCurrentId(id: number | null) { + currentId.value = id + } + return { list, currentId, loading, loadList, getCurrent, + setCurrentId, create, update, remove,