新建时只保留 每天/每周/每月; 历史遗留的 year 项在编辑时仍显示「每年」, 避免当前周期无选中项
This commit is contained in:
@@ -21,12 +21,15 @@ import {
|
|||||||
const GROUP_ORDER = ['day', 'week', 'month']
|
const GROUP_ORDER = ['day', 'week', 'month']
|
||||||
const GROUP_LABEL = { day: '每天', week: '每周', month: '每月' }
|
const GROUP_LABEL = { day: '每天', week: '每周', month: '每月' }
|
||||||
|
|
||||||
|
// 新建时只提供 每天 / 每周 / 每月 (「每年」已下线)
|
||||||
const PERIOD_OPTIONS = [
|
const PERIOD_OPTIONS = [
|
||||||
{ label: '每天', value: 'day' },
|
{ label: '每天', value: 'day' },
|
||||||
{ label: '每周', value: 'week' },
|
{ label: '每周', value: 'week' },
|
||||||
{ label: '每月', value: 'month' },
|
{ label: '每月', value: 'month' },
|
||||||
{ label: '每年', value: 'year' },
|
|
||||||
]
|
]
|
||||||
|
// 历史遗留的 year 项仍可编辑: 仅在编辑该周期时补回「每年」选项,
|
||||||
|
// 避免打开编辑弹窗时当前周期没有任何选中项
|
||||||
|
const YEAR_OPTION = { label: '每年', value: 'year' }
|
||||||
|
|
||||||
const COLORS = ['#1677ff', '#00b578', '#ff8f1f', '#ff3141', '#a855f7', '#14b8a6', '#f43f9e']
|
const COLORS = ['#1677ff', '#00b578', '#ff8f1f', '#ff3141', '#a855f7', '#14b8a6', '#f43f9e']
|
||||||
const EMPTY_FORM = { id: null, name: '', period: 'day', target: 1, color: COLORS[0], note: '' }
|
const EMPTY_FORM = { id: null, name: '', period: 'day', target: 1, color: COLORS[0], note: '' }
|
||||||
@@ -255,6 +258,11 @@ export default function MergedView({ date, onDateChange }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 渲染 ----------
|
// ---------- 渲染 ----------
|
||||||
|
// 只有编辑历史 year 项时才显示「每年」选项; 新建一律不给该周期
|
||||||
|
const periodOptions = form.period === 'year'
|
||||||
|
? [...PERIOD_OPTIONS, YEAR_OPTION]
|
||||||
|
: PERIOD_OPTIONS
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mv-view">
|
<div className="mv-view">
|
||||||
{/* 月历 */}
|
{/* 月历 */}
|
||||||
@@ -440,7 +448,7 @@ export default function MergedView({ date, onDateChange }) {
|
|||||||
<div className="form-field">
|
<div className="form-field">
|
||||||
<label>周期</label>
|
<label>周期</label>
|
||||||
<Selector
|
<Selector
|
||||||
options={PERIOD_OPTIONS}
|
options={periodOptions}
|
||||||
value={[form.period]}
|
value={[form.period]}
|
||||||
onChange={(v) => setForm((f) => ({ ...f, period: v[0] }))}
|
onChange={(v) => setForm((f) => ({ ...f, period: v[0] }))}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user