新增赋能中心一楼值班与请假
This commit is contained in:
Vendored
+40
@@ -614,6 +614,40 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s
|
||||
.center-tabs { max-width:500px; margin-bottom:24px; }
|
||||
.center-check-status { padding:18px 20px; background:var(--primary-soft); border:1px solid #d5e5da; border-radius:12px; margin-bottom:20px; }
|
||||
.center-subhead { margin-top:32px; }
|
||||
.center-duty-head { display:flex; align-items:flex-end; justify-content:space-between; flex-wrap:wrap; gap:18px; margin-bottom:18px; }
|
||||
.center-duty-head h3 { margin:4px 0 7px; font-size:24px; letter-spacing:-.4px; }
|
||||
.center-duty-head p { margin:0; }
|
||||
.center-duty-kicker { color:var(--primary); font-size:12px; font-weight:650; letter-spacing:1.4px; }
|
||||
.center-duty-nav { display:flex; flex-wrap:wrap; gap:8px; }
|
||||
.center-duty-nav .btn { min-height:38px; padding:7px 13px; }
|
||||
.center-duty-current { margin-bottom:12px; }
|
||||
.center-duty-live { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:18px 20px; background:linear-gradient(110deg,#e7f2eb,#f3f8f4); border:1px solid #cfe2d4; border-radius:14px; }
|
||||
.center-duty-live b { font-size:17px; }
|
||||
.center-duty-live p { margin:4px 0 0; color:var(--muted); }
|
||||
.center-duty-live > span { color:var(--primary); font-weight:600; font-variant-numeric:tabular-nums; }
|
||||
.center-duty-live-dot { display:inline-block; width:8px; height:8px; margin-right:8px; border-radius:50%; background:var(--ok); box-shadow:0 0 0 5px #12805c18; }
|
||||
.center-duty-idle { display:flex; align-items:center; flex-wrap:wrap; gap:8px 16px; padding:16px 20px; background:#f7f9f7; border:1px solid var(--line); border-radius:14px; }
|
||||
.center-duty-idle span { color:var(--muted); font-size:13px; }
|
||||
.center-duty-rule { display:flex; gap:8px 14px; align-items:baseline; flex-wrap:wrap; padding:12px 16px; border-left:3px solid #c49b65; background:#fbf8f2; color:var(--muted); font-size:13px; }
|
||||
.center-duty-rule strong { color:var(--ink); }
|
||||
.center-duty-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:18px; }
|
||||
.center-duty-day { min-width:0; overflow:hidden; background:var(--card); border:1px solid var(--line); border-radius:13px; box-shadow:var(--shadow); }
|
||||
.center-duty-day.is-today { border-color:#9abda8; box-shadow:0 0 0 2px #28664f12; }
|
||||
.center-duty-day > header { display:flex; align-items:baseline; gap:8px; padding:12px 15px; background:#f4f8f5; border-bottom:1px solid var(--line); }
|
||||
.center-duty-day > header b { font-size:16px; }
|
||||
.center-duty-day > header span { color:var(--muted); font-size:12px; }
|
||||
.center-duty-day > header em { margin-left:auto; padding:2px 7px; border-radius:999px; background:var(--primary); color:#fff; font-size:11px; font-style:normal; }
|
||||
.center-duty-slot { display:grid; grid-template-columns:96px minmax(0,1fr) auto; align-items:center; gap:12px; padding:13px 15px; border-bottom:1px solid #edf1ee; }
|
||||
.center-duty-slot:last-child { border-bottom:0; }
|
||||
.center-duty-slot.is-active { background:#edf7f0; }
|
||||
.center-duty-slot.is-past { opacity:.68; }
|
||||
.center-duty-slot > div:first-child b,.center-duty-slot > div:first-child span { display:block; }
|
||||
.center-duty-slot > div:first-child span { color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; }
|
||||
.center-duty-people { display:flex; flex-wrap:wrap; gap:6px; min-width:0; }
|
||||
.center-duty-name { display:inline-flex; align-items:center; gap:5px; padding:4px 8px; border-radius:7px; background:#edf3ef; color:var(--ink); font-size:13px; }
|
||||
.center-duty-name small { color:var(--warn); font-size:10px; }
|
||||
.center-duty-leave { flex:none; }
|
||||
.center-duty-slot .btn[disabled] { min-height:32px; }
|
||||
.timetable-mine { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; margin:24px 0; }
|
||||
.timetable-card { min-width:0; padding:22px; background:var(--card); border:1px solid var(--line); border-radius:12px; }
|
||||
.timetable-card h3 { margin:0 0 12px; }
|
||||
@@ -668,6 +702,12 @@ button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px s
|
||||
.timetable-warnings { padding:12px 14px; background:#fff7e7; border-radius:8px; font-size:13px; }
|
||||
.timetable-text { white-space:pre-wrap; overflow-wrap:anywhere; max-height:220px; overflow:auto; }
|
||||
@media (max-width:600px) { .timetable-mine { grid-template-columns:1fr; } .timetable-member { flex-wrap:wrap; } .timetable-member .acard-actions { width:100%; } }
|
||||
@media (max-width:760px) {
|
||||
.center-duty-grid { grid-template-columns:1fr; }
|
||||
.center-duty-slot { grid-template-columns:84px minmax(0,1fr); }
|
||||
.center-duty-slot > .btn { grid-column:2; justify-self:start; }
|
||||
.center-duty-live { align-items:flex-start; flex-direction:column; }
|
||||
}
|
||||
@media (max-width:600px) {
|
||||
.timetable-review-toolbar .muted { flex-basis:100%; margin-left:0; }
|
||||
.timetable-review-panel { width:calc(100% - 8px); padding:7px; }
|
||||
|
||||
Vendored
+23
-6
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>WorkLog · 活动记录</title>
|
||||
<meta name="theme-color" content="#f5f7f5" />
|
||||
<link rel="stylesheet" href="/assets/styles.css?v=27" />
|
||||
<link rel="stylesheet" href="/assets/styles.css?v=28" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
@@ -132,7 +132,7 @@
|
||||
</div>
|
||||
<section class="center-shortcuts" aria-label="赋能中心一楼快捷入口">
|
||||
<div><strong>赋能中心一楼</strong><p>上传活动照片,完成每日清点,申请物品借用</p></div>
|
||||
<div class="center-shortcut-actions"><a class="btn primary" href="#center-records">一楼活动记录</a><a class="btn" href="#center-assets">物品清点与借出</a><a class="btn" href="#timetables">课表收取</a></div>
|
||||
<div class="center-shortcut-actions"><a class="btn primary" href="#center-records">一楼活动记录</a><a class="btn" href="#center-duty">一楼值班</a><a class="btn" href="#center-assets">物品清点与借出</a><a class="btn" href="#timetables">课表收取</a></div>
|
||||
</section>
|
||||
<div class="filters">
|
||||
<input id="feed-q" aria-label="搜索活动或地点" placeholder="搜索活动 / 地点" type="search" />
|
||||
@@ -161,11 +161,11 @@
|
||||
<!-- 我的记录 -->
|
||||
<main id="center-view" class="view hidden">
|
||||
<div class="container">
|
||||
<div class="page-head"><div><h2>赋能中心一楼</h2><p class="muted">记录活动,管理物品流转,完成每日清点</p></div></div>
|
||||
<div class="page-head"><div><h2>赋能中心一楼</h2><p class="muted">查看单独的一楼值班表,记录活动,管理物品流转并完成每日清点</p></div></div>
|
||||
<details class="center-export"><summary>AI读取与数据导出</summary>
|
||||
<p class="muted">导出当前账号可见的数据,隐藏联系方式。照片与材料包以引用形式提供,全部CSV打包为ZIP。</p>
|
||||
<div class="filters center-toolbar">
|
||||
<label>数据范围<select id="center-export-dataset"><option value="all">全部一楼数据</option><option value="activities">一楼活动记录</option><option value="items">物品库存</option><option value="loans">借用记录</option><option value="checks">每日清点</option></select></label>
|
||||
<label>数据范围<select id="center-export-dataset"><option value="all">全部一楼数据</option><option value="activities">一楼活动记录</option><option value="items">物品库存</option><option value="loans">借用记录</option><option value="checks">每日清点</option><option value="duty_leaves">值班请假</option></select></label>
|
||||
<label>格式<select id="center-export-format"><option value="json">JSON(适合AI)</option><option value="csv">CSV(全部时为ZIP)</option></select></label>
|
||||
<label>关键词<input id="center-export-q" type="search" placeholder="主题、物品、申请理由" /></label>
|
||||
<label>从<input id="center-export-from" type="date" /></label><label>至<input id="center-export-to" type="date" /></label>
|
||||
@@ -175,11 +175,28 @@
|
||||
<p class="muted" id="center-export-status" role="status"></p>
|
||||
<p class="muted">程序读取:GET /api/center/data;字段说明:GET /api/center/schema。均需使用本人登录令牌。</p>
|
||||
</details>
|
||||
<div class="tabs center-tabs"><button class="tab active" data-center-tab="records">活动记录</button><button class="tab" data-center-tab="assets">物品清点与借出</button><button class="tab" data-center-tab="hall">展厅使用登记</button></div>
|
||||
<div class="tabs center-tabs"><button class="tab active" data-center-tab="records">活动记录</button><button class="tab" data-center-tab="duty">一楼值班</button><button class="tab" data-center-tab="assets">物品清点与借出</button><button class="tab" data-center-tab="hall">展厅使用登记</button></div>
|
||||
<section id="center-records">
|
||||
<div class="filters center-toolbar"><input id="center-q" type="search" aria-label="搜索活动主题" placeholder="搜索活动主题" /><input id="center-from" type="date" aria-label="活动起始日期" /><input id="center-to" type="date" aria-label="活动截止日期" /><button id="center-new" class="btn primary">+ 记录一楼活动</button></div>
|
||||
<div id="center-record-list" class="card-list"></div>
|
||||
</section>
|
||||
<section id="center-duty" class="hidden">
|
||||
<div class="center-duty-head">
|
||||
<div>
|
||||
<span class="center-duty-kicker">独立排班</span>
|
||||
<h3 id="center-duty-title">赋能中心一楼值班</h3>
|
||||
<p class="muted" id="center-duty-summary" role="status">正在读取值班表…</p>
|
||||
</div>
|
||||
<div class="center-duty-nav">
|
||||
<button class="btn" id="center-duty-prev" type="button">上一周</button>
|
||||
<button class="btn" id="center-duty-current" type="button">本周</button>
|
||||
<button class="btn" id="center-duty-next" type="button">下一周</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="center-duty-current" id="center-duty-current-card"></div>
|
||||
<div class="center-duty-rule"><strong>请假规则</strong><span>必须在值班日期开始前提交;请假不进入活动统计,也不记录缺勤。</span></div>
|
||||
<div class="center-duty-grid" id="center-duty-list"></div>
|
||||
</section>
|
||||
<section id="center-assets" class="hidden">
|
||||
<div class="center-check-status" id="center-check-status" role="status"></div>
|
||||
<div class="page-head center-subhead"><div><h3>物品库存</h3><p class="muted">这里维护清点用的库存清单,与下方借出登记互相独立。</p></div></div>
|
||||
@@ -341,7 +358,7 @@
|
||||
|
||||
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
||||
|
||||
<script src="/js/app.js?v=46"></script>
|
||||
<script src="/js/app.js?v=47"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Vendored
+83
-2
@@ -1538,10 +1538,11 @@
|
||||
let centerRecords = [];
|
||||
function openCenterFromHash() {
|
||||
if (state.me && location.hash === '#timetables') { show('timetables'); return true; }
|
||||
if (!state.me || !['#center', '#center-records', '#center-assets', '#center-hall'].includes(location.hash)) return false;
|
||||
centerTab = location.hash === '#center-assets' ? 'assets' : location.hash === '#center-hall' ? 'hall' : 'records';
|
||||
if (!state.me || !['#center', '#center-records', '#center-duty', '#center-assets', '#center-hall'].includes(location.hash)) return false;
|
||||
centerTab = location.hash === '#center-duty' ? 'duty' : location.hash === '#center-assets' ? 'assets' : location.hash === '#center-hall' ? 'hall' : 'records';
|
||||
$$('[data-center-tab]').forEach(button => button.classList.toggle('active', button.dataset.centerTab === centerTab));
|
||||
$('#center-records').classList.toggle('hidden', centerTab !== 'records');
|
||||
$('#center-duty').classList.toggle('hidden', centerTab !== 'duty');
|
||||
$('#center-assets').classList.toggle('hidden', centerTab !== 'assets');
|
||||
$('#center-hall').classList.toggle('hidden', centerTab !== 'hall');
|
||||
show('center');
|
||||
@@ -1562,6 +1563,8 @@
|
||||
const data = await api(`/activities?${p}`); centerRecords = data.items;
|
||||
$('#center-record-list').innerHTML = data.items.map(a => activityCard(a)).join('') || '<div class="empty">暂无匹配的一楼活动,记录活动时请上传照片。</div>';
|
||||
bindCardEvents($('#center-record-list'));
|
||||
} else if (centerTab === 'duty') {
|
||||
await loadCenterDuty();
|
||||
} else if (centerTab === 'hall') {
|
||||
$('#center-hall-status').textContent = '正在读取金山文档登记表…';
|
||||
const hall = await api('/center/hall-log');
|
||||
@@ -1612,6 +1615,7 @@
|
||||
history.replaceState(null, '', '#center-' + centerTab);
|
||||
$$('[data-center-tab]').forEach(b => b.classList.toggle('active', b === button));
|
||||
$('#center-records').classList.toggle('hidden', centerTab !== 'records');
|
||||
$('#center-duty').classList.toggle('hidden', centerTab !== 'duty');
|
||||
$('#center-assets').classList.toggle('hidden', centerTab !== 'assets');
|
||||
$('#center-hall').classList.toggle('hidden', centerTab !== 'hall');
|
||||
loadCenter();
|
||||
@@ -1652,6 +1656,83 @@
|
||||
if (!button || button.disabled) return;
|
||||
openLoanForm();
|
||||
});
|
||||
let centerDutyWeekStart = '';
|
||||
const centerDutyDate = (iso, withYear = true) => new Intl.DateTimeFormat('zh-CN', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
...(withYear ? { year: 'numeric' } : {}),
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}).format(new Date(iso + 'T00:00:00+08:00'));
|
||||
const centerDutyWeekText = data => `${centerDutyDate(data.week_start, false)}—${centerDutyDate(data.week_end)}`;
|
||||
function centerDutyAssignee(assignee) {
|
||||
return `<span class="center-duty-name">${esc(assignee.name)}${assignee.leave ? '<small>已请假</small>' : ''}</span>`;
|
||||
}
|
||||
async function loadCenterDuty() {
|
||||
const params = new URLSearchParams();
|
||||
if (centerDutyWeekStart) params.set('week_start', centerDutyWeekStart);
|
||||
const data = await api('/center/duty' + (params.size ? '?' + params : ''));
|
||||
centerDutyWeekStart = data.week_start;
|
||||
$('#center-duty-title').textContent = data.title;
|
||||
const currentText = data.current.length
|
||||
? `当前值班:${data.current.map(record => record.assignees.map(item => item.name).join('、')).join(';')}`
|
||||
: '当前没有正在进行的一楼值班';
|
||||
$('#center-duty-summary').textContent = `${data.week_type_label} · ${centerDutyWeekText(data)} · ${currentText}`;
|
||||
$('#center-duty-current-card').innerHTML = data.current.length
|
||||
? data.current.map(record => `<div class="center-duty-live"><div><span class="center-duty-live-dot"></span><b>${esc(record.weekday_label)} ${esc(record.slot.label)}</b><p>${record.assignees.map(centerDutyAssignee).join('、')}</p></div><span>${esc(record.slot.start)}—${esc(record.slot.end)}</span></div>`).join('')
|
||||
: '<div class="center-duty-idle"><b>当前时段空闲</b><span>可查看本周排班;请假须在值班日期开始前提交。</span></div>';
|
||||
const groups = new Map();
|
||||
for (const record of data.records) {
|
||||
if (!groups.has(record.date)) groups.set(record.date, []);
|
||||
groups.get(record.date).push(record);
|
||||
}
|
||||
$('#center-duty-list').innerHTML = [...groups.entries()].map(([day, records]) => {
|
||||
const first = records[0];
|
||||
const today = new Date().toLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' }) === day;
|
||||
return `<article class="center-duty-day ${today ? 'is-today' : ''}">
|
||||
<header><b>${esc(first.weekday_label)}</b><span>${esc(centerDutyDate(day))}</span>${today ? '<em>今天</em>' : ''}</header>
|
||||
${records.map(record => {
|
||||
const own = record.assignees.find(item => item.name.replace(/\s+/g, '') === data.viewer_name.replace(/\s+/g, ''));
|
||||
let leaveControl = '';
|
||||
if (own) {
|
||||
if (!own.leave && record.viewer_can_leave) {
|
||||
leaveControl = `<button class="btn small center-duty-leave" type="button" data-duty-date="${record.date}" data-duty-slot="${record.slot.id}" data-duty-label="${esc(record.weekday_label + ' ' + record.slot.label)}">申请请假</button>`;
|
||||
} else {
|
||||
const reason = own.leave ? '已请假' : (record.can_leave_reason || '当前不可请假');
|
||||
leaveControl = `<button class="btn small" type="button" disabled title="${esc(reason)}">${esc(own.leave ? '已请假' : '申请请假')}</button>`;
|
||||
}
|
||||
}
|
||||
return `<div class="center-duty-slot ${record.status === 'active' ? 'is-active' : ''} ${record.status === 'past' ? 'is-past' : ''}">
|
||||
<div><b>${esc(record.slot.label)}</b><span>${esc(record.slot.start)}—${esc(record.slot.end)}</span></div>
|
||||
<div class="center-duty-people">${record.assignees.map(centerDutyAssignee).join('')}</div>
|
||||
${leaveControl}
|
||||
</div>`;
|
||||
}).join('')}
|
||||
</article>`;
|
||||
}).join('');
|
||||
}
|
||||
$('#center-duty-prev').addEventListener('click', () => {
|
||||
const day = new Date(centerDutyWeekStart + 'T00:00:00+08:00'); day.setDate(day.getDate() - 7);
|
||||
centerDutyWeekStart = day.toLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' }); loadCenterDuty().catch(error => toast(error.message, true));
|
||||
});
|
||||
$('#center-duty-current').addEventListener('click', () => {
|
||||
centerDutyWeekStart = ''; loadCenterDuty().catch(error => toast(error.message, true));
|
||||
});
|
||||
$('#center-duty-next').addEventListener('click', () => {
|
||||
const day = new Date(centerDutyWeekStart + 'T00:00:00+08:00'); day.setDate(day.getDate() + 7);
|
||||
centerDutyWeekStart = day.toLocaleDateString('en-CA', { timeZone: 'Asia/Shanghai' }); loadCenterDuty().catch(error => toast(error.message, true));
|
||||
});
|
||||
$('#center-duty-list').addEventListener('click', event => {
|
||||
const button = event.target.closest('[data-duty-date][data-duty-slot]');
|
||||
if (!button || button.disabled) return;
|
||||
centerForm('申请赋能中心一楼值班请假',
|
||||
`<p class="muted">${esc(button.dataset.dutyLabel)}。请假必须在值班日期开始前提交,提交后立即显示在排班中,不进入活动统计,也不记录缺勤。</p>
|
||||
<label>请假原因<textarea name="reason" required minlength="2" maxlength="300" placeholder="请简要说明原因"></textarea></label>`,
|
||||
f => api('/center/duty/leave', { method: 'POST', body: {
|
||||
duty_date: button.dataset.dutyDate,
|
||||
slot: button.dataset.dutySlot,
|
||||
reason: f.reason.value.trim(),
|
||||
}}));
|
||||
});
|
||||
for (const id of ['center-q', 'center-item-q']) $('#' + id).addEventListener('input', debounce(loadCenter, 300));
|
||||
for (const id of ['center-from', 'center-to', 'center-loan-status']) $('#' + id).addEventListener('change', loadCenter);
|
||||
$('#center-refresh').addEventListener('click', loadCenter);
|
||||
|
||||
Reference in New Issue
Block a user