v24 第 2 轮:19 条清单收尾(附件预览/CalDAV/任务分类看板/全局选人/家谱/纪念日/财务)

用户 2026-10-02 提的 19 条需求,本轮完成剩下的 8 条 + CalDAV 服务端:

- ③ 附件:图片/视频给缩略图,PDF/Word/Excel 给**同尺寸**图标;可预览的在本页
     弹层里看(不再新开标签页),渲染不了的点了直接下载;预览层右上角恒有下载按钮。
- ⑦b CalDAV:把「我的日历本」按 RFC 4791 只读子集分享出去(OPTIONS/PROPFIND/
     REPORT/GET,写方法一律 403)。用**专用口令**(库里只存 sha256),不是登录口令。
- ⑨⑩ 任务:分类与看板都由用户自建;已完成的任务从看板消失,改在「已完成」页
     按分类查看/搜索;设置入口在「新建任务」旁的 ☰。
- ⑪ 全局人员选择器:一个片段铺到观影/旅程/资源/日历共享/任务共享/财务共享;
     修掉了老组件「名字和拼音都搜不动」的 bug —— .att-item 自己声明了 display:flex,
     压过了浏览器 [hidden]{display:none},过滤根本没生效。
- ⑫ 家谱:头像改方形不再裁切;姻亲不在图上的卡片给「⇄ 姻亲」入口,
     以 TA 为中心重画 + 「返回我的家谱」。
- ⑬ 纪念日:阴历/阳历都能设且按对应历法重复;名册里每个人的生日默认可见
     (实时派生,不复制一份);全部作为全天日程进日历。
- ⑮ 财务:账本可共享,双方都能记账、都能看全部账目,资产−负债=净资产;
     金额一律以「分」存,不用浮点。

验证:端到端 724 项通过 / 0 失败;几何 368、交互 97、移动端 516、家谱 24、
升级 123 全绿;SQL 列名静态校验 0 处可疑;部署 11 条线上探针全过。
This commit is contained in:
2026-10-03 08:18:05 +08:00
parent 72dc6c0006
commit 8f80f3e835
47 changed files with 5363 additions and 578 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
/**
* 任务模块的「设置」下拉(v24 用户第 10 条)
*
* 用户原话:「和观影一样,新建任务旁边,也是设置,对任务的设置。」
* 所以这里与观影的 _settings_menu.php 用**同一套外观**:只留图标(三条横线)、
* 排在最右侧(靠 CSS 的 margin-left:auto)、条目文字前都有图标。
*
* 用法(require 前 set 好):
* $setCurrent 当前页 key('board'|'settings'|'done'),用来高亮
*/
$setCurrent = (string)($setCurrent ?? '');
$setOn = static function (string $key) use ($setCurrent): string {
return $setCurrent === $key ? ' class="on"' : '';
};
$setIcon = static function (string $name): string {
$paths = [
// 看板设置:分栏
'board' => '<rect x="2" y="3" width="4" height="10" rx="1"/><rect x="7.5" y="3" width="4" height="6" rx="1"/>',
// 已完成:对勾
'done' => '<path d="M3 8.5l3 3 7-7"/>',
];
$d = $paths[$name] ?? '';
if ($d === '') {
return '';
}
return '<svg class="mi" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"'
. ' fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"'
. ' stroke-linejoin="round">' . $d . '</svg>';
};
?>
<details class="movie-set menu">
<summary class="btn btn-icon" title="任务设置" aria-label="任务设置"><svg viewBox="0 0 16 16" width="18" height="18" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/></svg></summary>
<div class="menu-list">
<a href="<?= e(url('tasks/settings')) ?>"<?= $setOn('settings') ?>><?= $setIcon('board') ?><span>分类与看板</span></a>
<a href="<?= e(url('tasks/done')) ?>"<?= $setOn('done') ?>><?= $setIcon('done') ?><span>已完成</span></a>
</div>
</details>
<?php
unset($setCurrent, $setOn, $setIcon);
+79
View File
@@ -0,0 +1,79 @@
<?php
/**
* 已完成的任务(v24 用户第 10 条)
*
* 用户原话:「还可以在这里查看已完成的任务,已完成的任务,
* 按照分类来进行展示和搜索就可以了。」
*
* 所以这一页是**只看已完成**的归档:按分类筛 + 按标题搜,不再分列、不拖拽。
*
* @param array $rows 已完成的任务
* @param array $categories 分类清单(做筛选条)
* @param int $cat 当前选中的分类(0=全部)
* @param string $kw 搜索词
*/
?>
<div class="page-head">
<h1>已完成</h1>
<span class="sub">共 <?= count($rows) ?> 项</span>
<div class="actions">
<a class="btn btn-ghost" href="<?= e(url('tasks')) ?>">返回看板</a>
<a class="btn btn-ghost" href="<?= e(url('tasks/settings')) ?>">任务设置</a>
</div>
</div>
<form class="card card-pad" method="get" action="index.php">
<input type="hidden" name="r" value="tasks/done">
<div class="form-grid">
<div class="field">
<label for="td-cat">分类</label>
<select class="select" id="td-cat" name="cat">
<option value="0">全部分类</option>
<?php foreach ($categories as $c): ?>
<option value="<?= (int)$c['id'] ?>" <?= $cat === (int)$c['id'] ? 'selected' : '' ?>>
<?= e((string)$c['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="field">
<label for="td-kw">搜索标题</label>
<input class="input" id="td-kw" name="kw" value="<?= e($kw) ?>" placeholder="输入关键字">
</div>
</div>
<div class="btn-row">
<button class="btn" type="submit">筛选</button>
<a class="btn btn-ghost" href="<?= e(url('tasks/done')) ?>">清空</a>
</div>
</form>
<div class="card card-pad">
<?php if (!$rows): ?>
<p class="empty-hint">
<?= ($cat > 0 || $kw !== '') ? '没有符合条件的已完成任务。' : '还没有已完成的任务。' ?>
</p>
<?php else: ?>
<ul class="done-list">
<?php foreach ($rows as $t): ?>
<li class="done-item">
<a class="done-title" href="<?= e(url('tasks/show', ['id' => (int)$t['id']])) ?>">
<?= e((string)$t['title']) ?>
</a>
<?php if (($t['category_name'] ?? '') !== ''): ?>
<span class="node-badge"><?= e((string)$t['category_name']) ?></span>
<?php endif; ?>
<?php if (($t['done_at'] ?? '') !== ''): ?>
<span class="small muted">完成于 <?= e(substr((string)$t['done_at'], 0, 10)) ?></span>
<?php endif; ?>
<?php if (!empty($t['assignee_name'])): ?>
<?= person_chip([
'id' => (int)$t['assignee_id'], 'name' => (string)$t['assignee_name'],
'my_nickname' => (string)($t['assignee_nick'] ?? ''),
'avatar' => $t['avatar'] ?? null, 'avatar_color' => $t['avatar_color'] ?? null,
]) ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
+60 -3
View File
@@ -12,20 +12,35 @@
* @param array $people 名册(选负责人 / 共享给别人)
*/
$canWrite = \App\Auth::canWrite();
$cols = [['todo', '待办'], ['doing', '进行中'], ['done', '已完成']];
// ⚠️ v24 第 10 条:看板上只有「待办 / 进行中」两列 —— 已完成的任务从看板消失,
// 要看去「任务设置 → 已完成」按分类看/搜。留着第三列就不是"直接消失"了。
$cols = [['todo', '待办'], ['doing', '进行中']];
$boards = $boards ?? [];
$categories = $categories ?? [];
$curBoard = (int)($curBoard ?? 0);
?>
<div class="page-head">
<h1>任务</h1>
<span class="sub">共 <?= (int)$total ?> 项</span>
<span class="sub">共 <?= (int)$total ?> 项未完成</span>
<div class="actions">
<?php if ($canWrite): ?>
<button class="btn" type="button" id="taskAddBtn">新建任务</button>
<?php else: ?>
<span class="link-quiet">只读账号</span>
<?php endif; ?>
<?php $setCurrent = 'board'; require __DIR__ . '/_settings_menu.php'; ?>
</div>
</div>
<?php if (count($boards) > 1): ?>
<div class="seg kb-boards">
<?php foreach ($boards as $b): ?>
<a class="seg-btn<?= (int)$b['id'] === $curBoard ? ' is-on' : '' ?>"
href="<?= e(url('tasks', ['board' => (int)$b['id']])) ?>"><?= e((string)$b['name']) ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($canWrite): ?>
<div class="card card-pad" id="taskAddCard" hidden>
<h2 class="cinema-h2">新建任务</h2>
@@ -36,9 +51,14 @@ $cols = [['todo', '待办'], ['doing', '进行中'], ['done', '已完成']];
<label for="tk-title">要做什么 *</label>
<input class="input" id="tk-title" name="title" required placeholder="如:周末大扫除">
</div>
<?php /* v24 第 5 条:截止时刻也走全局统一的「日期 + 时分秒」控件。
秒这一档保留(与其它模块同一口径),默认 23:59:59 —— "这天之前做完"
比"这天 00:00 之前"更符合直觉。 */ ?>
<div class="field">
<label for="tk-due">截止时间(有才会出现在日历里)</label>
<input class="input" type="date" id="tk-due" name="due_date">
<?php $dtName = 'due_at'; $dtId = 'tk-due'; $dtValue = null;
$dtRequired = false; $dtSeconds = true;
require __DIR__ . '/../_datetime.php'; ?>
</div>
<div class="field">
<label for="tk-assign">负责人</label>
@@ -57,6 +77,25 @@ $cols = [['todo', '待办'], ['doing', '进行中'], ['done', '已完成']];
<?php endforeach; ?>
</select>
</div>
<div class="field">
<label for="tk-cat">分类</label>
<select class="select" id="tk-cat" name="category_id">
<option value="0">未分类</option>
<?php foreach ($categories as $c): ?>
<option value="<?= (int)$c['id'] ?>"><?= e((string)$c['name']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="field">
<label for="tk-board">看板</label>
<select class="select" id="tk-board" name="board_id">
<?php foreach ($boards as $b): ?>
<option value="<?= (int)$b['id'] ?>" <?= (int)$b['id'] === $curBoard ? 'selected' : '' ?>>
<?= e((string)$b['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="field">
<label for="tk-share">共享给(可多选,任何人完成都算完成)</label>
<select class="select" id="tk-share" name="shares[]" multiple size="3">
@@ -123,6 +162,9 @@ $cols = [['todo', '待办'], ['doing', '进行中'], ['done', '已完成']];
<?php if ((int)($t['attach_count'] ?? 0) > 0): ?>
<span class="kb-ico" title="附件">📎 <?= (int)$t['attach_count'] ?></span>
<?php endif; ?>
<?php if (($t['category_name'] ?? '') !== ''): ?>
<span class="node-badge" title="分类"><?= e((string)$t['category_name']) ?></span>
<?php endif; ?>
</div>
<?php if ($total > 0): ?>
<div class="kb-sub">
@@ -194,21 +236,36 @@ $cols = [['todo', '待办'], ['doing', '进行中'], ['done', '已完成']];
});
/* ---- 拖动(渐进增强:拖不动还有上面的左右按钮)---- */
/* ⚠️ v24(用户 2026-10-02 第 8 条):拖完一张卡,松手那一下浏览器还会
补一个 click 给卡片里的标题链接 —— 于是"刚拖到位就立刻跳进详情页",
看板直接没法用了。
修法:拖结束就立个牌子 dragEnded,标题链接的 click 看到牌子就吞掉。
牌子在**下一次 mousedown** 时摘掉(真想点进去总得再按一次鼠标),
所以不会误伤正常点击 —— 比用 setTimeout 猜时间准得多。 */
var dragging = null;
var dragEnded = false;
document.addEventListener('mousedown', function () { dragEnded = false; }, true);
Array.prototype.forEach.call(document.querySelectorAll('.kb-card[draggable="true"]'), function (card) {
card.addEventListener('dragstart', function (ev) {
dragging = card;
dragEnded = false;
card.classList.add('is-dragging');
if (ev.dataTransfer) { ev.dataTransfer.effectAllowed = 'move'; }
});
card.addEventListener('dragend', function () {
card.classList.remove('is-dragging');
dragging = null;
dragEnded = true;
Array.prototype.forEach.call(document.querySelectorAll('.kb-body.is-over'), function (el) {
el.classList.remove('is-over');
});
});
});
Array.prototype.forEach.call(document.querySelectorAll('.kb-card .kb-title'), function (a) {
a.addEventListener('click', function (ev) {
if (dragEnded) { ev.preventDefault(); ev.stopPropagation(); }
});
});
Array.prototype.forEach.call(document.querySelectorAll('.kb-body'), function (body) {
body.addEventListener('dragover', function (ev) {
if (!dragging) return;
+95
View File
@@ -0,0 +1,95 @@
<?php
/**
* 任务设置(v24 用户第 9、10 条)
*
* 用户原话:「和观影一样,新建任务旁边,也是设置,对任务的设置。
* 用户可以设置任务分类、看板。还可以在这里查看已完成的任务,
* 已完成的任务,按照分类来进行展示和搜索就可以了。」
*
* 所以这一页两块:看板 / 分类,各有增删改;旁边给一个进「已完成」的入口。
*
* @param array $boards 看板(带 open_count:里面还有几件没做完)
* @param array $categories 分类(带 used_count:被几条任务用过)
*/
$canWrite = \App\Auth::canWrite();
?>
<div class="page-head">
<h1>任务设置</h1>
<span class="sub">看板与分类都由你自己定</span>
<div class="actions">
<a class="btn btn-ghost" href="<?= e(url('tasks')) ?>">返回任务</a>
<a class="btn" href="<?= e(url('tasks/done')) ?>">已完成的任务</a>
</div>
</div>
<?php if (!$canWrite): ?>
<div class="card card-pad"><p class="empty-hint">只读账号不能改设置。</p></div>
<?php else: ?>
<div class="card card-pad">
<h2 class="cinema-h2">看板</h2>
<p class="small muted" style="margin-top:0">
看板是「分开看几摊事」用的(家务 / 装修 / 旅行准备 …)。任务看板顶上可以切换。
删掉一个看板时,里面的任务不会被删,会挪到默认看板。
</p>
<div class="set-list">
<?php foreach ($boards as $b): ?>
<form class="inline-form set-row" method="post" action="<?= e(url('tasks/board_update')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int)$b['id'] ?>">
<input class="input" name="name" value="<?= e((string)$b['name']) ?>" required>
<span class="small muted"><?= (int)($b['open_count'] ?? 0) ?> 件未完成</span>
<button class="btn btn-sm" type="submit">改名</button>
</form>
<?php if (count($boards) > 1): ?>
<form class="inline-form" method="post" action="<?= e(url('tasks/board_del')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int)$b['id'] ?>">
<button class="btn btn-ghost btn-sm" type="submit"
onclick="return confirm('删掉这个看板?里面的任务会挪到默认看板,不会丢。')">删除</button>
</form>
<?php else: ?>
<span class="small muted set-tail">最后一个看板不能删</span>
<?php endif; ?>
<?php endforeach; ?>
</div>
<form class="inline-form" method="post" action="<?= e(url('tasks/board_add')) ?>" style="margin-top:10px">
<?= csrf_field() ?>
<input class="input" name="name" placeholder="新看板名,如:装修" required>
<button class="btn btn-sm" type="submit">添加看板</button>
</form>
</div>
<div class="card card-pad">
<h2 class="cinema-h2">分类</h2>
<p class="small muted" style="margin-top:0">
分类是给任务贴的标签(证件 / 报销 / 维修 …),用来在「已完成」里归类查看与搜索。
</p>
<div class="set-list">
<?php if (!$categories): ?>
<p class="empty-hint">还没有分类。</p>
<?php endif; ?>
<?php foreach ($categories as $c): ?>
<form class="inline-form set-row" method="post" action="<?= e(url('tasks/cat_update')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int)$c['id'] ?>">
<input class="input" name="name" value="<?= e((string)$c['name']) ?>" required>
<span class="small muted"><?= (int)($c['used_count'] ?? 0) ?> 条用过</span>
<button class="btn btn-sm" type="submit">改名</button>
</form>
<form class="inline-form" method="post" action="<?= e(url('tasks/cat_del')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int)$c['id'] ?>">
<button class="btn btn-ghost btn-sm" type="submit"
onclick="return confirm('删掉这个分类?用它标过的任务会变成「未分类」。')">删除</button>
</form>
<?php endforeach; ?>
</div>
<form class="inline-form" method="post" action="<?= e(url('tasks/cat_add')) ?>" style="margin-top:10px">
<?= csrf_field() ?>
<input class="input" name="name" placeholder="新分类名,如:证件" required>
<button class="btn btn-sm" type="submit">添加分类</button>
</form>
</div>
<?php endif; ?>
+46 -27
View File
@@ -88,8 +88,10 @@ $isChild = !empty($t['parent_id']);
<input class="input" name="title" required value="<?= e((string)$t['title']) ?>">
</div>
<div class="field">
<label>截止日期(留空=不上日历)</label>
<input class="input" type="date" name="due_date" value="<?= e(substr((string)($t['due_at'] ?? ''), 0, 10)) ?>">
<label>截止时间(留空=不上日历)</label>
<?php $dtName = 'due_at'; $dtValue = $t['due_at'] ?? null;
$dtRequired = false; $dtSeconds = true;
require __DIR__ . '/../_datetime.php'; ?>
</div>
<div class="field">
<label>负责人</label>
@@ -123,6 +125,28 @@ $isChild = !empty($t['parent_id']);
<?php endforeach; ?>
</select>
</div>
<?php /* v24 第 9、10 条:分类与看板(看板把任务放到哪一块,分类是标签) */ ?>
<div class="field">
<label>分类</label>
<select class="select" name="category_id">
<option value="0">未分类</option>
<?php foreach (($categories ?? []) as $c): ?>
<option value="<?= (int)$c['id'] ?>"<?= (int)($t['category_id'] ?? 0) === (int)$c['id'] ? ' selected' : '' ?>>
<?= e((string)$c['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="field">
<label>看板</label>
<select class="select" name="board_id">
<?php foreach (($boards ?? []) as $b): ?>
<option value="<?= (int)$b['id'] ?>"<?= (int)($t['board_id'] ?? 0) === (int)$b['id'] ? ' selected' : '' ?>>
<?= e((string)$b['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="field full">
<label>备注</label>
<textarea class="input" name="note" rows="2"><?= e((string)($t['note'] ?? '')) ?></textarea>
@@ -175,7 +199,8 @@ $isChild = !empty($t['parent_id']);
<?= csrf_field() ?>
<input type="hidden" name="parent_id" value="<?= (int)$t['id'] ?>">
<input class="input" name="title" required placeholder="如:擦玻璃">
<input class="input" type="date" name="due_date">
<?php $dtName = 'due_at'; $dtValue = null; $dtRequired = false; $dtSeconds = true;
require __DIR__ . '/../_datetime.php'; ?>
<button class="btn btn-sm" type="submit">加上</button>
</form>
</details>
@@ -189,24 +214,14 @@ $isChild = !empty($t['parent_id']);
<?php if (!$t['attachs']): ?>
<p class="empty-hint">还没有附件。</p>
<?php else: ?>
<div class="attach-row">
<?php foreach ($t['attachs'] as $a): ?>
<span class="attach-item">
<a href="<?= e(media_url((string)$a['key'])) ?>" target="_blank" rel="noopener">
<?= (int)$a['is_image'] === 1 ? '🖼' : '📄' ?> <?= e((string)($a['name'] ?: '附件')) ?>
</a>
<span class="res-size"><?= e(\App\Attachment::sizeWord($a['size'] ?? 0)) ?></span>
<a class="link-quiet" href="<?= e(media_url((string)$a['key'], ['dl' => 1])) ?>">下载</a>
<?php if ($canWrite): ?>
<form method="post" action="<?= e(url('tasks/attach_del')) ?>" class="res-inline">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int)$a['id'] ?>">
<button class="btn btn-ghost btn-sm" type="submit" onclick="return confirm('删掉这个附件?')">删除</button>
</form>
<?php endif; ?>
</span>
<?php endforeach; ?>
</div>
<?php
$attRows = $t['attachs'];
$attCanEdit = $canWrite;
$attDelUrl = 'tasks/attach_del';
$attDelField = 'id';
$attExtra = [];
require __DIR__ . '/../_attachments.php';
?>
<?php endif; ?>
<?php if ($canWrite): ?>
<form class="inline-form" method="post" enctype="multipart/form-data" action="<?= e(url('tasks/attach_add')) ?>">
@@ -243,12 +258,16 @@ $isChild = !empty($t['parent_id']);
<form class="inline-form" method="post" action="<?= e(url('tasks/share')) ?>">
<?= csrf_field() ?>
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
<select class="select" name="person_id">
<?php foreach ($people as $p): ?>
<?php if ((int)$p['id'] === $meId) { continue; } ?>
<option value="<?= (int)$p['id'] ?>"><?= e(person_name($p)) ?></option>
<?php endforeach; ?>
</select>
<?php
$ppName = 'person_id';
$ppPeople = array_values(array_filter($people, fn($p) => (int)$p['id'] !== $meId));
$ppSelected = [];
$ppMode = 'single';
$ppOpenBtn = '选择要共享给谁';
$ppTitle = '共享给谁';
$ppEmptyText = '未选择';
require __DIR__ . '/../_person_picker.php';
?>
<select class="select" name="perm">
<option value="write">可写</option>
<option value="read">只读</option>