feat(training): 原型图
This commit is contained in:
1 parent
14e5af0c9c
commit
863e009b59
1 file changed
+38
-12
@@ -27,9 +27,11 @@
|
||||
.badge { display:inline-flex; padding:2px 8px; border-radius:99px; font-size:11px; font-weight:800; } .green { color:var(--green); background:#eafaf1; } .amber { color:var(--amber); background:#fff7e6; } .red { color:var(--red); background:#fff0ef; } .blue { color:#175cd3; background:var(--soft); } .gray { color:#475569; background:#edf1f6; }
|
||||
.link { border:0; padding:0; color:#175cd3; background:transparent; font-size:12px; font-weight:800; } .names { color:#334155; } .note { color:var(--muted); } .ops { display:flex; gap:10px; white-space:nowrap; } .chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; } .chip { padding:4px 8px; border-radius:99px; background:#f1f5f9; font-size:12px; }
|
||||
.mask { position:fixed; inset:0; display:none; background:rgba(15,23,42,.35); } .mask.show { display:block; }
|
||||
.drawer { position:fixed; top:0; right:0; width:min(460px,100%); height:100%; display:flex; flex-direction:column; background:#fff; box-shadow:-12px 0 40px rgba(15,23,42,.12); transform:translateX(100%); transition:.2s; } .mask.show .drawer { transform:none; }
|
||||
.drawer header,.drawer footer { padding:16px 18px; border-bottom:1px solid var(--line); } .drawer footer { border-bottom:0; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px; } .drawer h2 { margin:0; font-size:16px; } .drawer .body { padding:16px 18px 24px; overflow:auto; } .field { margin-bottom:12px; } .field textarea { min-height:64px; resize:vertical; } .readonly { padding:8px; border-radius:8px; color:#334155; background:#f8fafc; }
|
||||
.people { max-height:220px; overflow:auto; border:1px solid var(--line); border-radius:8px; } .person { display:flex; gap:8px; align-items:center; padding:8px 10px; border-bottom:1px solid var(--line); } .person:last-child { border-bottom:0; } .person small { color:var(--muted); }
|
||||
.drawer { position:fixed; top:0; right:0; width:min(460px,100%); height:100%; display:flex; flex-direction:column; background:#fff; box-shadow:-12px 0 40px rgba(15,23,42,.12); transform:translateX(100%); transition:.2s; } .drawer.monthly { width:min(560px,100%); } .mask.show .drawer { transform:none; }
|
||||
.drawer header,.drawer footer { padding:16px 18px; border-bottom:1px solid var(--line); } .drawer footer { border-bottom:0; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:8px; } .drawer h2 { margin:0; font-size:16px; } .drawer .body { padding:16px 18px 24px; overflow:auto; } .field { margin-bottom:12px; } .field input,.field select { width:100%; height:36px; } .field textarea { min-height:64px; resize:vertical; } .readonly { display:flex; align-items:center; min-height:36px; padding:8px 10px; border:1px solid #e7edf5; border-radius:8px; color:#334155; background:#f8fafc; }
|
||||
.sheet { display:flex; flex-direction:column; gap:16px; } .block { padding:12px; border:1px solid var(--line); border-radius:12px; background:#fbfcfe; } .block h3 { margin:0 0 10px; font-size:13px; } .sheet .field { margin:0; } .pair { display:grid; grid-template-columns:1fr 1fr; gap:10px 12px; } .pair .full { grid-column:1 / -1; } .triple { display:grid; grid-template-columns:1.2fr .8fr .8fr; gap:10px; }
|
||||
.file-add { display:grid; grid-template-columns:1fr 72px; gap:8px; margin-top:8px; } .chip .x { margin-left:6px; border:0; padding:0; color:#64748b; background:transparent; font-weight:700; }
|
||||
.people { max-height:220px; overflow:auto; border:1px solid var(--line); border-radius:8px; } .person { display:flex; gap:8px; align-items:center; padding:8px 10px; border-bottom:1px solid var(--line); } .person:last-child { border-bottom:0; } .person small { margin-left:auto; color:var(--muted); }
|
||||
.hint { margin:0 0 8px; color:var(--muted); font-size:12px; }
|
||||
.two { display:grid; grid-template-columns:1fr 360px; gap:14px; } .phone { width:100%; padding:16px; border-radius:24px; color:#fff; background:#172033; } .phone small { display:block; color:#aab9cc; text-align:center; } .notice { margin-top:12px; overflow:hidden; border-radius:12px; color:var(--ink); background:#fff; } .notice h3 { margin:0; padding:14px 14px 6px; font-size:15px; } .notice p { margin:0; padding:0 14px 14px; white-space:pre-line; color:#3d4b61; font-size:13px; } .notice button { width:100%; padding:11px; border:0; border-top:1px solid var(--line); color:var(--brand); background:#fff; font-weight:800; }
|
||||
.kv { display:grid; grid-template-columns:88px 1fr; gap:8px; padding:8px 0; border-bottom:1px solid var(--line); font-size:13px; } .kv b { color:var(--muted); font-weight:700; }
|
||||
@@ -462,8 +464,8 @@
|
||||
}).join('') || '<tr><td colspan="11" class="hint">这个范围还没有月度计划。</td></tr>';
|
||||
}
|
||||
|
||||
function openMask() { $('mask').classList.add('show'); }
|
||||
function closeMask() { $('mask').classList.remove('show'); drawerMode = ''; }
|
||||
function openMask(monthly) { document.querySelector('.drawer').classList.toggle('monthly', Boolean(monthly)); $('mask').classList.add('show'); }
|
||||
function closeMask() { $('mask').classList.remove('show'); document.querySelector('.drawer').classList.remove('monthly'); drawerMode = ''; }
|
||||
|
||||
/**
|
||||
* 打开计划行抽屉。分类从课程带出且只读,人员默认不勾选。
|
||||
@@ -501,7 +503,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开月度计划抽屉。从年度转入时带出课程、地点、内/外和参加人员。
|
||||
* 打开月度计划抽屉。日期和时间分开填写,避免系统日期控件挤在一列里。从年度转入时带出课程、地点和参加人员。
|
||||
* @param {object|null} record 已有月度计划,为空则新建
|
||||
* @param {object|null} annual 来源年度计划行
|
||||
*/
|
||||
@@ -521,8 +523,21 @@
|
||||
const courseOptions = courses.filter((item) => item[4] === 'enabled' || item[0] === courseName).map((item) => '<option' + (item[0] === courseName ? ' selected' : '') + '>' + item[0] + '</option>').join('');
|
||||
const annualOptions = '<option value="0">不关联,记为计划外</option>' + visiblePlans().map((item) => '<option value="' + item.no + '"' + (source && source.no === item.no ? ' selected' : '') + '>#' + item.no + ' ' + item.course + '(已排 ' + scheduledCount(item.no) + '/' + item.times + ')</option>').join('');
|
||||
const unitName = record ? record.unit : (source ? source.unit : (scopeUnit() || '财务部'));
|
||||
$('drawerBody').innerHTML = '<div class="field"><label>来源</label><select id="m-source"' + (record ? ' disabled' : '') + '>' + annualOptions + '</select></div><div class="field"><label>月份</label><input id="m-month" type="month" value="' + (record ? record.month : '2026-04') + '" /></div><div class="field"><label>课程</label>' + (source ? '<div class="readonly" id="m-course">' + courseName + '</div>' : '<select id="m-course">' + courseOptions + '</select>') + '</div><div class="field"><label>主办单位</label><div class="readonly" id="m-unit">' + unitName + '</div></div><div class="field"><label>开始</label><input id="m-start" type="datetime-local" value="' + (record ? record.start : '') + '" /></div><div class="field"><label>结束</label><input id="m-end" type="datetime-local" value="' + (record ? record.end : '') + '" /></div><div class="field"><label>时长(小时)</label><input id="m-hours" value="' + (record ? record.hours : '1') + '" /></div><div class="field"><label>地点</label><input id="m-place" value="' + (record ? record.place : (source ? source.place : '教育训练室')) + '" /></div><div class="field"><label>讲师</label><select id="m-instructor">' + instructors.map((name) => '<option' + ((record ? record.instructor : instructors[0]) === name ? ' selected' : '') + '>' + name + '</option>').join('') + '</select></div><div class="field"><label>课件 / 视频</label><div class="chips" id="m-files"></div><div class="ops" style="margin-top:8px"><input id="m-file" placeholder="文件名,如 课件.pdf" /><button class="btn" id="m-add-file" type="button">添加</button></div></div><div class="field"><label>参加人员</label><p class="hint">默认带出年度计划已选人员,可按这一场增删。</p><div class="people" id="m-people">' + people.map((item) => '<label class="person"><input type="checkbox" value="' + item.id + '"' + (selected.has(item.id) ? ' checked' : '') + ' />' + item.name + '<small>' + item.dept + '</small></label>').join('') + '</div></div>';
|
||||
const paintFiles = () => { $('m-files').innerHTML = draftFiles.map((name) => '<span class="chip">' + name + '</span>').join('') || '<span class="note">还没有资料</span>'; };
|
||||
const classDate = record && record.start ? record.start.slice(0, 10) : '';
|
||||
const startTime = record && record.start ? record.start.slice(11, 16) : '09:00';
|
||||
const endTime = record && record.end ? record.end.slice(11, 16) : '10:00';
|
||||
const courseField = source
|
||||
? '<div class="readonly" id="m-course">' + courseName + '</div>'
|
||||
: '<select id="m-course">' + courseOptions + '</select>';
|
||||
$('drawerBody').innerHTML = '<div class="sheet"><section class="block"><h3>课程</h3><div class="pair"><div class="field full"><label>来源</label><select id="m-source"' + (record ? ' disabled' : '') + '>' + annualOptions + '</select></div><div class="field full"><label>课程</label>' + courseField + '</div><div class="field"><label>主办单位</label><div class="readonly" id="m-unit">' + unitName + '</div></div><div class="field"><label>地点</label><input id="m-place" value="' + (record ? record.place : (source ? source.place : '教育训练室')) + '" /></div><div class="field full"><label>讲师</label><select id="m-instructor">' + instructors.map((name) => '<option' + ((record ? record.instructor : instructors[0]) === name ? ' selected' : '') + '>' + name + '</option>').join('') + '</select></div></div></section><section class="block"><h3>上课时间</h3><div class="triple"><div class="field"><label>日期</label><input id="m-date" placeholder="2026-04-09" value="' + classDate + '" /></div><div class="field"><label>开始</label><input id="m-start-time" placeholder="09:00" value="' + startTime + '" /></div><div class="field"><label>结束</label><input id="m-end-time" placeholder="10:00" value="' + endTime + '" /></div></div><div class="field" style="margin-top:10px"><label>时长(小时)</label><input id="m-hours" value="' + (record ? record.hours : '1') + '" /></div><p class="hint" style="margin-top:8px">日期用 2026-04-09,时间用 09:00。填完开始和结束会自动算时长,仍可手改。</p></section><section class="block"><h3>课件 / 视频</h3><div class="chips" id="m-files"></div><div class="file-add"><input id="m-file" placeholder="文件名,如 课件.pdf" /><button class="btn" id="m-add-file" type="button">添加</button></div></section><section class="block"><h3>参加人员</h3><p class="hint">默认带出年度计划已选人员,可按这一场增删。</p><div class="people" id="m-people">' + people.map((item) => '<label class="person"><input type="checkbox" value="' + item.id + '"' + (selected.has(item.id) ? ' checked' : '') + ' /><span>' + item.name + '</span><small>' + item.dept + '</small></label>').join('') + '</div></section></div>';
|
||||
const paintFiles = () => { $('m-files').innerHTML = draftFiles.length ? draftFiles.map((name, index) => '<span class="chip">' + name + '<button class="x" type="button" data-file="' + index + '">×</button></span>').join('') : '<span class="note">还没有资料</span>'; };
|
||||
const syncHours = () => {
|
||||
const start = ($('m-start-time').value || '').split(':');
|
||||
const end = ($('m-end-time').value || '').split(':');
|
||||
if (start.length < 2 || end.length < 2) return;
|
||||
const minutes = (Number(end[0]) * 60 + Number(end[1])) - (Number(start[0]) * 60 + Number(start[1]));
|
||||
if (minutes > 0) $('m-hours').value = String(Math.round(minutes / 6) / 10);
|
||||
};
|
||||
const applySource = () => {
|
||||
const no = Number($('m-source').value);
|
||||
const plan = plans.find((item) => item.no === no);
|
||||
@@ -539,6 +554,14 @@
|
||||
$('m-file').value = '';
|
||||
paintFiles();
|
||||
});
|
||||
$('m-files').addEventListener('click', (event) => {
|
||||
const button = event.target.closest('[data-file]');
|
||||
if (!button) return;
|
||||
draftFiles.splice(Number(button.dataset.file), 1);
|
||||
paintFiles();
|
||||
});
|
||||
$('m-start-time').addEventListener('change', syncHours);
|
||||
$('m-end-time').addEventListener('change', syncHours);
|
||||
if (!record) $('m-source').addEventListener('change', () => {
|
||||
const no = Number($('m-source').value);
|
||||
if (!no) {
|
||||
@@ -557,7 +580,7 @@
|
||||
}
|
||||
});
|
||||
paintFiles();
|
||||
openMask();
|
||||
openMask(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -567,17 +590,20 @@
|
||||
if (drawerMode === 'monthly') {
|
||||
const ids = [...document.querySelectorAll('#m-people input:checked')].map((item) => item.value);
|
||||
if (!ids.length) { toast('请至少选择 1 名参加人员'); return; }
|
||||
if (!$('m-start').value || !$('m-end').value) { toast('请填写开始和结束时间'); return; }
|
||||
const classDate = $('m-date').value.trim();
|
||||
const startTime = $('m-start-time').value.trim();
|
||||
const endTime = $('m-end-time').value.trim();
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(classDate) || !/^\d{2}:\d{2}$/.test(startTime) || !/^\d{2}:\d{2}$/.test(endTime)) { toast('日期填 2026-04-09,时间填 09:00'); return; }
|
||||
const annualNo = Number($('m-source').value || 0);
|
||||
const annual = plans.find((item) => item.no === annualNo);
|
||||
if (annual && scheduledCount(annual.no) >= annual.times && editingMonthly === 0) { toast('次数已排满'); return; }
|
||||
const courseEl = $('m-course');
|
||||
const payload = {
|
||||
annualNo, month:$('m-month').value, unit:$('m-unit').textContent,
|
||||
annualNo, month: classDate.slice(0, 7), unit:$('m-unit').textContent,
|
||||
plant: annual ? annual.plant : '1厂',
|
||||
course: courseEl.tagName === 'DIV' ? courseEl.textContent : courseEl.value,
|
||||
place:$('m-place').value.trim() || '教育训练室', side: annual ? annual.side : '内',
|
||||
start:$('m-start').value, end:$('m-end').value, hours:$('m-hours').value || '1',
|
||||
start: classDate + 'T' + startTime, end: classDate + 'T' + endTime, hours:$('m-hours').value || '1',
|
||||
instructor:$('m-instructor').value, files:draftFiles.slice(), ids, status:'scheduled'
|
||||
};
|
||||
if (editingMonthly) Object.assign(monthlies.find((item) => item.id === editingMonthly), payload);
|
||||
|
||||
Reference in new issue
Block a user