按「any → 包时 / 按次 / 包赛季」规则检查后修复 3 处问题: 1) 包赛季套餐编辑时「按日」也被勾中 - 赛季套餐在库里 unit='day' + season=1,模板只判断了 unit,导致按日/赛季两个 radio 都带 checked - 修正为「unit=day 且非赛季」才勾中按日 2) 客户开通表单:选中包赛季时仍显示且必填「开始日」 - 赛季起止由套餐决定,开始日应隐藏 - 表单加 data-start-wrap,JS 在赛季模式隐藏并取消 required,切回其它模式恢复 3) 按次开通时没有带出套餐默认有效期 - 套餐选项新增 data-validity,选中按次且终止日为空时,自动按「开始日 + 默认有效期 - 1」带出到期日,仍可手改 现状(已逐项验证): - 包时:默认量单位「天」,无有效期/赛季字段 - 按次:默认量单位「次」,显示「按次默认有效期(天)」,开单自动带出到期日 - 包赛季:显示赛季开始日/结束日(必填),隐藏默认量有效期与开始日;过期套餐下拉置灰 测试: - 转换专项 10 项全过:三种模式的勾选状态、字段显示、按日→按次→赛季→按日 往返保存均正常 - 数据库未改动结构,往返保存后 unit/season/season_start/season_end 值正确 - 版本号 1.8.2
This commit is contained in:
@@ -69,20 +69,38 @@
|
||||
var daysWrap = form.querySelector('[data-days-wrap]');
|
||||
var countWrap = form.querySelector('[data-count-wrap]');
|
||||
var endWrap = form.querySelector('[data-end-wrap]');
|
||||
var startWrap = form.querySelector('[data-start-wrap]');
|
||||
var startInput = form.querySelector('input[name="start_date"]');
|
||||
if (!sel) return;
|
||||
|
||||
function sync() {
|
||||
var opt = sel.options[sel.selectedIndex];
|
||||
var unit = opt && opt.getAttribute('data-unit');
|
||||
var amount = opt && opt.getAttribute('data-amount');
|
||||
if (unit === 'count') {
|
||||
if (daysWrap) daysWrap.hidden = true;
|
||||
if (countWrap) { countWrap.hidden = false; if (amount) countWrap.querySelector('input').value = amount; }
|
||||
if (endWrap) endWrap.hidden = true;
|
||||
} else if (unit === 'season') {
|
||||
var validity = opt && parseInt(opt.getAttribute('data-validity') || '0', 10);
|
||||
var endInput = endWrap && endWrap.querySelector('input');
|
||||
|
||||
if (unit === 'season') {
|
||||
if (daysWrap) daysWrap.hidden = true;
|
||||
if (countWrap) countWrap.hidden = true;
|
||||
if (endWrap) endWrap.hidden = true;
|
||||
if (startWrap) startWrap.hidden = true;
|
||||
if (startInput) startInput.required = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (startWrap) startWrap.hidden = false;
|
||||
if (startInput) startInput.required = true;
|
||||
|
||||
if (unit === 'count') {
|
||||
if (daysWrap) daysWrap.hidden = true;
|
||||
if (countWrap) { countWrap.hidden = false; if (amount) countWrap.querySelector('input').value = amount; }
|
||||
if (endWrap) endWrap.hidden = false;
|
||||
if (validity > 0 && endInput && !endInput.value && startInput && startInput.value) {
|
||||
var d = new Date(startInput.value + 'T00:00:00');
|
||||
d.setDate(d.getDate() + validity - 1);
|
||||
endInput.value = d.toISOString().slice(0, 10);
|
||||
}
|
||||
} else if (unit === 'day') {
|
||||
if (daysWrap) { daysWrap.hidden = false; if (amount) daysWrap.querySelector('input').value = amount; }
|
||||
if (countWrap) countWrap.hidden = true;
|
||||
|
||||
@@ -89,12 +89,12 @@
|
||||
<select name="package_id" required data-pkg-select>
|
||||
<option value="">选择套餐…</option>
|
||||
{{range .D.Packages}}
|
||||
<option value="{{.ID}}" data-unit="{{if .Season}}season{{else}}{{.Unit}}{{end}}" data-amount="{{.DefaultAmount}}"{{if .Archived}} disabled{{end}}{{if .SeasonExpired $.TodayStr}} disabled{{end}}>
|
||||
<option value="{{.ID}}" data-unit="{{if .Season}}season{{else}}{{.Unit}}{{end}}" data-amount="{{.DefaultAmount}}" data-validity="{{.DefaultValidityDays}}"{{if .Archived}} disabled{{end}}{{if .SeasonExpired $.TodayStr}} disabled{{end}}>
|
||||
{{.Name}} · {{.UnitLabel}} {{if .Season}}{{.SeasonStart}}~{{.SeasonEnd}}{{else}}{{.DefaultAmount}}{{if eq .Unit "day"}}天{{else}}次{{end}}{{end}}{{if .SeasonExpired $.TodayStr}}(赛季已结束){{end}}{{if .Archived}}(已归档){{end}}
|
||||
</option>
|
||||
{{end}}
|
||||
</select>
|
||||
<label class="inline-field">开始日
|
||||
<label class="inline-field" data-start-wrap>开始日
|
||||
<input type="date" name="start_date" value="{{.TodayStr}}" required>
|
||||
</label>
|
||||
<label class="inline-field" data-days-wrap>{{/* 默认显示 */}}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<fieldset class="field">
|
||||
<span>计费方式 <i>*</i></span>
|
||||
<div class="radios">
|
||||
<label><input type="radio" name="unit" value="day"{{if eq .D.Package.Unit "day"}} checked{{end}}>
|
||||
<label><input type="radio" name="unit" value="day"{{if and (eq .D.Package.Unit "day") (not .D.Package.Season)}} checked{{end}}>
|
||||
<b>按日</b><small>有开始日与结束日,每天一条待打任务,可打卡</small></label>
|
||||
<label><input type="radio" name="unit" value="count"{{if and (eq .D.Package.Unit "count") (not .D.Package.Season)}} checked{{end}}>
|
||||
<b>按次</b><small>记录剩余次数,排期完成时自动扣 1 次,有效期可选</small></label>
|
||||
|
||||
Reference in New Issue
Block a user