frontend[紧急]: SeasonDrawer 删月份选择器 (后端 PR #2295 已上线 + 字典 product_season 有全局定义)
mmg: 之前合并 changelog 把这事埋在了 14_feat_season_month_auto_and_description_dynamic_cover.md B 部分, 没单独发, 你没注意到。本文件单独拎出来, 给精确文件:行号 + 改前/改后代码。 注: 字典 product_season 的 remark 字段已全局定义 spring=3-5月 / summer=6-8月 / autumn=9-11月 / winter=12-2月, 后端硬编码与字典一致, 前端展示可读字典 remark。 notify @mmg
这个提交包含在:
父节点
823d5e2629
当前提交
65f019ddb5
@ -0,0 +1,146 @@
|
||||
# [前端][紧急] SeasonDrawer 删月份选择器 (后端已自动赋值, 字典有全局定义)
|
||||
|
||||
> **服务**: 前端 hl-ui (管理端)
|
||||
> **后端 PR**: #2295 (Closes #2291) 已上线
|
||||
> **日期**: 2026-05-14
|
||||
> **影响范围**: 管理端 景区/游玩项目编辑页 SeasonDrawer 季节内容表单
|
||||
> **状态**: P1 — 后端已上线, 前端需删 monthStart/monthEnd 选择器
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ 关键变化
|
||||
|
||||
后端 PR #2295 (Closes #2291) 已上线测试服:
|
||||
- SaveRequest **删了 monthStart/monthEnd 字段**, 前端继续传会被忽略
|
||||
- 后端 SeasonMonthRangeUtil 按 seasonType 自动赋值: spring→3-5 / summer→6-8 / autumn→9-11 / winter→12-2 (跨年)
|
||||
- 字典 `product_season` 的 remark 字段全局定义了 "3-5月/6-8月/9-11月/12-2月", 跟硬编码一致
|
||||
|
||||
前端 SeasonDrawer.vue 的"时间范围"月份选择器**应删除**, 让用户不再操作月份。
|
||||
|
||||
---
|
||||
|
||||
## 精确改法
|
||||
|
||||
**文件**: `D:/work2/hl-ui/src/views/resource/scenic/SeasonDrawer.vue`
|
||||
|
||||
### 1. 删模板的月份选择器 (line 26 + line 48-60)
|
||||
|
||||
**删 line 26 `v-if="seasonContents[season.value]?.monthStart && seasonContents[season.value]?.monthEnd"`**:
|
||||
现在不依赖 monthStart/monthEnd 渲染, 改用 seasonType 是否存在配置内容判断, 或者直接显示。
|
||||
|
||||
**删 line 48-60 整个 `<n-form-item label="时间范围">` 块**:
|
||||
|
||||
```vue
|
||||
<!-- 删这整段 (line 48-60) -->
|
||||
<n-form-item label="时间范围">
|
||||
<n-input-group>
|
||||
<n-select
|
||||
v-model:value="seasonContents[season.value].monthStart"
|
||||
...
|
||||
/>
|
||||
<span>至</span>
|
||||
<n-select
|
||||
v-model:value="seasonContents[season.value].monthEnd"
|
||||
...
|
||||
/>
|
||||
</n-input-group>
|
||||
</n-form-item>
|
||||
```
|
||||
|
||||
可改为只读展示 (可选, 也可不显示):
|
||||
```vue
|
||||
<!-- 可选: 只读显示, 不让用户改 -->
|
||||
<n-form-item label="时间范围">
|
||||
<span>{{ seasonMonthRangeLabel(season.value) }}</span>
|
||||
</n-form-item>
|
||||
|
||||
<!-- helper -->
|
||||
const seasonMonthRangeLabel = (type) => ({
|
||||
spring: '3-5月',
|
||||
summer: '6-8月',
|
||||
autumn: '9-11月',
|
||||
winter: '12-2月 (跨年)',
|
||||
})[type] || '-'
|
||||
```
|
||||
|
||||
或者直接读字典 `product_season` 的 `remark` 字段 (推荐, 字典是真相):
|
||||
```js
|
||||
const dictStore = useDictStore()
|
||||
const seasonMonthRangeLabel = (type) =>
|
||||
dictStore.get('product_season')?.find(d => d.value === type)?.remark || '-'
|
||||
```
|
||||
|
||||
### 2. 删 form data 初始字段 (line 181-188)
|
||||
|
||||
```js
|
||||
// 删 line 181 那个 i+1 月份选项数组 (如果只用于月份选择器)
|
||||
// 删 line 188-189:
|
||||
monthStart: null,
|
||||
monthEnd: null,
|
||||
```
|
||||
|
||||
### 3. 删保存时的 month 字段提取 (line 247-248, 273-279)
|
||||
|
||||
`saveSeason` 函数里:
|
||||
```js
|
||||
// 删 line 247-248 不再从 item 读 month
|
||||
// 删 line 273-279 不再校验 + 提交 month
|
||||
|
||||
// 改为:
|
||||
const payload = {
|
||||
seasonName: form.seasonName,
|
||||
description: form.description,
|
||||
highlights: form.highlights,
|
||||
playGuide: form.playGuide,
|
||||
tips: form.tips,
|
||||
// ... 其他字段
|
||||
// 不传 monthStart/monthEnd
|
||||
}
|
||||
await updateScenicSeason(scenicId, seasonType, payload)
|
||||
```
|
||||
|
||||
### 4. 删 line 302 报错文案
|
||||
|
||||
```js
|
||||
// 删 message.info('未配置任何季节的时间范围,无需保存')
|
||||
// 改为基于其他字段是否有内容判断
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 游玩项目同款 (前端待补 SeasonDrawer 落地后)
|
||||
|
||||
`views/resource/playservice/SeasonDrawer.vue` (尚未创建, 见 [14_frontend_playservice_add_season_drawer.md](./14_frontend_playservice_add_season_drawer.md)) **直接照此规范实现, 不要复制旧 scenic SeasonDrawer 的月份选择器**。
|
||||
|
||||
---
|
||||
|
||||
## 验证
|
||||
|
||||
改完后:
|
||||
1. 景区/游玩项目季节内容编辑表单**不再显示**"时间范围 X月至X月"控件 (或只读显示)
|
||||
2. PUT 保存季节内容不传 monthStart/monthEnd
|
||||
3. GET 季节列表后端仍返 monthStart/monthEnd (后端自动赋值), 前端可只读展示
|
||||
|
||||
测试服 curl 验证 PASS (后端已部署):
|
||||
```
|
||||
PUT /admin/scenic/spot/{id}/season/spring (body 无 month) → 200
|
||||
GET /admin/scenic/spot/{id}/seasons → spring 这条 monthStart=3 monthEnd=5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 不影响范围
|
||||
|
||||
- 后端 VO 仍返 monthStart/monthEnd 字段, 前端可只读展示
|
||||
- DB 字段保留, 老数据兼容
|
||||
- 季节内容其他字段 (seasonName/description/highlights/playGuide/tips/封面/轮播/视频) 完全不动
|
||||
|
||||
---
|
||||
|
||||
## 相关 PR / Issue
|
||||
|
||||
- 后端 PR #2295: [wx/HL#2295](https://git.1814.love:8443/wx/HL/pulls/2295)
|
||||
- 后端 Issue #2291: [wx/HL#2291](https://git.1814.love:8443/wx/HL/issues/2291)
|
||||
- 字典 `product_season` 已有全局月份定义 (remark 字段)
|
||||
- 与游玩项目 SeasonDrawer 待新建任务关联: [14_frontend_playservice_add_season_drawer.md](./14_frontend_playservice_add_season_drawer.md)
|
||||
- 与合并 changelog: [14_feat_season_month_auto_and_description_dynamic_cover.md](./14_feat_season_month_auto_and_description_dynamic_cover.md) (B 部分)
|
||||
正在加载...
x
在新工单中引用
屏蔽一个用户