修复赋能中心一楼记录表单:隐藏记录类型选项,保留照片与ZIP附件上传
This commit is contained in:
Vendored
+15
-18
@@ -1053,7 +1053,6 @@
|
||||
<h3>${isEdit ? "编辑工作" : "记录一项工作"}</h3>
|
||||
<p class="modal-sub muted">提交后立即生效,所有人可见。</p>
|
||||
<form id="act-form">
|
||||
<label>记录类型<select name="record_type"><option value="normal">普通工作记录</option></select></label>
|
||||
<label>工作名称 *<input name="title" required maxlength="120" value="${esc(existing?.title || "")}" placeholder="例如:周三晚例会" /></label>
|
||||
<div class="form-row">
|
||||
<label>开始时间 *<input name="start_at" type="datetime-local" required value="${existing ? toLocalInput(existing.start_at) : ""}" /></label>
|
||||
@@ -1061,7 +1060,7 @@
|
||||
</div>
|
||||
<label>人数上限 <span class="hint-inline">(选填,留空不限人数)</span><input name="capacity" type="number" min="1" max="500" step="1" value="${existing?.capacity ?? ""}" placeholder="不限人数" /></label>
|
||||
<label>备注 <span class="hint-inline">(选填)</span><textarea name="description" rows="3" maxlength="2000" placeholder="做什么、带什么、注意事项…">${esc(existing?.description || "")}</textarea></label>
|
||||
<div id="act-photo-fields" class="hidden">${centerUploadFields('act')}<p class="muted">照片和ZIP至少选择一种。编辑时会保留原照片和附件,所选内容追加保存。</p><div id="act-photo-preview">${photoGallery(existing?.photo_ids, '已有活动照片')}</div></div>
|
||||
<div id="act-photo-fields">${centerUploadFields('act')}<p class="muted">照片和ZIP至少选择一种。编辑时会保留原照片和附件,所选内容追加保存。</p><div id="act-photo-preview">${photoGallery(existing?.photo_ids, '已有活动照片')}</div></div>
|
||||
<label class="checkline" id="act-visibility"><input type="checkbox" name="visibility" ${!existing || existing.visibility === "public" ? "checked" : ""} /> 公开活动(所有人可见;不勾选则仅参加者可见)</label>
|
||||
<p id="act-center-policy" class="muted hidden">全员可见,仅作活动记录,无需参加,也不计入参加统计。</p>
|
||||
<div id="act-upload-progress" class="upload-progress hidden">
|
||||
@@ -1075,22 +1074,23 @@
|
||||
</div>
|
||||
</form>`);
|
||||
const activityForm = $('#act-form');
|
||||
const recordType = existing?.record_type || defaultType;
|
||||
const isCenterRecord = recordType === 'center';
|
||||
if (!isCenterRecord) {
|
||||
$('#act-photo-fields').classList.add('hidden');
|
||||
$('#act-center-policy').classList.add('hidden');
|
||||
}
|
||||
const progressBox = $('#act-upload-progress');
|
||||
const progressLabel = $('#act-upload-status');
|
||||
const progressMeter = $('#act-upload-meter');
|
||||
const errorBox = $('#act-error');
|
||||
const collectUploads = bindCenterUploads(activityForm, progressBox, progressLabel, progressMeter, 'act');
|
||||
activityForm.record_type.value = existing?.record_type || defaultType;
|
||||
activityForm.record_type.disabled = state.view === 'center';
|
||||
const togglePhotos = () => {
|
||||
const isCenter = activityForm.record_type.value === 'center';
|
||||
$('#act-photo-fields').classList.toggle('hidden', !isCenter);
|
||||
$('#act-visibility').classList.toggle('hidden', isCenter);
|
||||
$('#act-center-policy').classList.toggle('hidden', !isCenter);
|
||||
activityForm.visibility.disabled = isCenter;
|
||||
if (isCenter && !activityForm.location.value.trim()) activityForm.location.value = '赋能中心一楼';
|
||||
};
|
||||
activityForm.record_type.addEventListener('change', togglePhotos); togglePhotos();
|
||||
if (isCenterRecord) {
|
||||
$('#act-visibility').classList.add('hidden');
|
||||
$('#act-center-policy').classList.remove('hidden');
|
||||
activityForm.visibility.disabled = true;
|
||||
if (!activityForm.location.value.trim()) activityForm.location.value = '赋能中心一楼';
|
||||
}
|
||||
bindPhotoPreviews(activityForm);
|
||||
|
||||
$("#act-cancel").addEventListener("click", closeModal);
|
||||
@@ -1107,13 +1107,11 @@
|
||||
start_at: startMs,
|
||||
location: f.location.value.trim(),
|
||||
description: f.description.value.trim(),
|
||||
visibility: f.record_type.value === 'center' || f.visibility.checked ? "public" : "private",
|
||||
record_type: f.record_type.value,
|
||||
visibility: isCenterRecord || f.visibility.checked ? "public" : "private",
|
||||
record_type: recordType,
|
||||
capacity: f.capacity.value ? Number(f.capacity.value) : null,
|
||||
};
|
||||
btn.disabled = true;
|
||||
const typeWasDisabled = f.record_type.disabled;
|
||||
f.record_type.disabled = true;
|
||||
f.materials.disabled = true;
|
||||
f.photos.disabled = true;
|
||||
try {
|
||||
@@ -1140,7 +1138,6 @@
|
||||
progressMeter.value = 0;
|
||||
if (!progressBox.classList.contains('hidden')) progressLabel.textContent = '提交未完成,可重试;已上传成功的照片会复用。';
|
||||
btn.disabled = false;
|
||||
f.record_type.disabled = typeWasDisabled;
|
||||
f.materials.disabled = false;
|
||||
f.photos.disabled = false;
|
||||
btn.textContent = isEdit ? '保存修改' : '提交记录';
|
||||
|
||||
Reference in New Issue
Block a user