用户 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 条线上探针全过。
327 lines
14 KiB
PHP
327 lines
14 KiB
PHP
<?php
|
||
/**
|
||
* 任务详情(v12):正文 + 子任务 + 评论(@人)+ 附件 + 共享。
|
||
*
|
||
* @人:评论里写「@老杨」会高亮(Task::commentHtml),**不会**真的发通知 ——
|
||
* 家庭场景下"点名"主要是让人一眼看到在说谁,做通知要先解决推送渠道,先不做。
|
||
*
|
||
* @param array $t 任务(带 children / comments / attachs / shares)
|
||
* @param array $people 名册(负责人 / 共享 / @人 提示)
|
||
* @param array $parents 可选的父任务候选(把当前任务挂到别的父任务下)
|
||
*/
|
||
$canWrite = \App\Auth::canWrite() && \App\Task::canWrite($t, (int)\App\Auth::personId());
|
||
$meId = (int)\App\Auth::personId();
|
||
$names = [];
|
||
foreach ($people as $p) {
|
||
$names[] = person_name($p);
|
||
$nm = trim((string)($p['name'] ?? ''));
|
||
if ($nm !== '') {
|
||
$names[] = $nm;
|
||
}
|
||
}
|
||
$names = array_values(array_unique(array_filter($names)));
|
||
$isChild = !empty($t['parent_id']);
|
||
?>
|
||
<div class="page-head">
|
||
<h1><?= e((string)$t['title']) ?></h1>
|
||
<span class="sub"><?= e(\App\Task::statusWord((string)$t['status'])) ?></span>
|
||
<div class="actions">
|
||
<?php if ($canWrite): ?>
|
||
<form method="post" action="<?= e(url('tasks/move')) ?>" class="res-inline">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<?php if ($t['status'] !== 'done'): ?>
|
||
<input type="hidden" name="status" value="done">
|
||
<button class="btn" type="submit">标记完成</button>
|
||
<?php else: ?>
|
||
<input type="hidden" name="status" value="doing">
|
||
<button class="btn btn-ghost" type="submit">重新打开</button>
|
||
<?php endif; ?>
|
||
</form>
|
||
<?php endif; ?>
|
||
<a class="btn btn-ghost" href="<?= e(url('tasks')) ?>">返回任务</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card card-pad">
|
||
<dl class="kv">
|
||
<div class="kv-row"><dt>状态</dt><dd><?= e(\App\Task::statusWord((string)$t['status'])) ?></dd></div>
|
||
<?php if (($t['due_at'] ?? '') !== ''): ?>
|
||
<div class="kv-row"><dt>截止</dt>
|
||
<dd class="<?= \App\Task::isOverdue($t['due_at'] ?? null) && $t['status'] !== 'done' ? 'kb-late' : '' ?>">
|
||
<?= e((string)$t['due_at']) ?><?= \App\Task::dueWord($t['due_at'] ?? null) !== '' ? '(' . e(\App\Task::dueWord($t['due_at'] ?? null)) . ')' : '' ?>
|
||
</dd>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php if (!empty($t['repeat_rule'])): ?>
|
||
<div class="kv-row"><dt>循环</dt><dd><?= e(\App\Task::repeatWord($t['repeat_rule'])) ?></dd></div>
|
||
<?php endif; ?>
|
||
<?php if (!empty($t['assignee_name'])): ?>
|
||
<div class="kv-row"><dt>负责人</dt>
|
||
<dd><?= e(person_name(['name' => $t['assignee_name'], 'my_nickname' => $t['assignee_nick'] ?? ''])) ?></dd>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php if (!empty($t['creator_name'])): ?>
|
||
<div class="kv-row"><dt>谁建的</dt>
|
||
<dd><?= e(person_name(['name' => $t['creator_name'], 'my_nickname' => $t['creator_nick'] ?? ''])) ?></dd>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php if ($isChild && !empty($t['parent_title'])): ?>
|
||
<div class="kv-row"><dt>属于</dt>
|
||
<dd><a href="<?= e(url('tasks/show', ['id' => (int)$t['parent_id']])) ?>"><?= e((string)$t['parent_title']) ?></a></dd>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php if (!empty($t['note'])): ?>
|
||
<div class="kv-row"><dt>备注</dt><dd><?= nl2br(e((string)$t['note'])) ?></dd></div>
|
||
<?php endif; ?>
|
||
</dl>
|
||
|
||
<?php if ($canWrite): ?>
|
||
<details class="node-add">
|
||
<summary class="link-quiet">编辑这项任务</summary>
|
||
<form method="post" action="<?= e(url('tasks/update')) ?>" class="node-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<div class="nf-grid">
|
||
<div class="field full">
|
||
<label>标题</label>
|
||
<input class="input" name="title" required value="<?= e((string)$t['title']) ?>">
|
||
</div>
|
||
<div class="field">
|
||
<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>
|
||
<select class="select" name="assignee_id">
|
||
<option value="0">不指定</option>
|
||
<?php foreach ($people as $p): ?>
|
||
<option value="<?= (int)$p['id'] ?>"<?= (int)($t['assignee_id'] ?? 0) === (int)$p['id'] ? ' selected' : '' ?>>
|
||
<?= e(person_name($p)) ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label>循环</label>
|
||
<select class="select" name="repeat_rule">
|
||
<?php foreach (\App\Task::REPEAT as $rk => $rv): ?>
|
||
<option value="<?= e($rk) ?>"<?= (string)($t['repeat_rule'] ?? '') === (string)$rk ? ' selected' : '' ?>>
|
||
<?= e($rv) ?>
|
||
</option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label>挂到哪个父任务下</label>
|
||
<select class="select" name="parent_id">
|
||
<option value="0">(这是一项独立的任务)</option>
|
||
<?php foreach ($parents as $p): ?>
|
||
<option value="<?= (int)$p['id'] ?>"<?= (int)($t['parent_id'] ?? 0) === (int)$p['id'] ? ' selected' : '' ?>>
|
||
<?= e((string)$p['title']) ?>
|
||
</option>
|
||
<?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>
|
||
</div>
|
||
</div>
|
||
<div class="btn-row"><button class="btn btn-sm" type="submit">保存</button></div>
|
||
</form>
|
||
</details>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<?php /* ---- 子任务 ---- */ ?>
|
||
<?php if (!$isChild): ?>
|
||
<div class="card card-pad">
|
||
<h2 class="cinema-h2">子任务 <span class="group-n"><?= count($t['children']) ?> 项</span></h2>
|
||
<?php if (!$t['children']): ?>
|
||
<p class="empty-hint">还没有子任务。把一件大事拆成几件小事,进度才看得见。</p>
|
||
<?php else: ?>
|
||
<ul class="sub-list">
|
||
<?php foreach ($t['children'] as $c): ?>
|
||
<li class="sub-row<?= $c['status'] === 'done' ? ' is-done' : '' ?>">
|
||
<?php if ($canWrite): ?>
|
||
<form method="post" action="<?= e(url('tasks/move')) ?>" class="res-inline">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$c['id'] ?>">
|
||
<input type="hidden" name="status" value="<?= $c['status'] === 'done' ? 'todo' : 'done' ?>">
|
||
<button class="sub-check" type="submit" title="<?= $c['status'] === 'done' ? '取消完成' : '标记完成' ?>">
|
||
<?= $c['status'] === 'done' ? '☑' : '☐' ?>
|
||
</button>
|
||
</form>
|
||
<?php else: ?>
|
||
<span class="sub-check is-static"><?= $c['status'] === 'done' ? '☑' : '☐' ?></span>
|
||
<?php endif; ?>
|
||
<a class="sub-title" href="<?= e(url('tasks/show', ['id' => (int)$c['id']])) ?>">
|
||
<?= e((string)$c['title']) ?>
|
||
</a>
|
||
<?php if (($c['due_at'] ?? '') !== ''): ?>
|
||
<span class="node-time<?= \App\Task::isOverdue($c['due_at'] ?? null) && $c['status'] !== 'done' ? ' kb-late' : '' ?>">
|
||
<?= e(\App\Task::dueWord($c['due_at'] ?? null)) ?>
|
||
</span>
|
||
<?php endif; ?>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
<?php endif; ?>
|
||
<?php if ($canWrite): ?>
|
||
<details class="node-add">
|
||
<summary class="link-quiet">+ 加一项子任务</summary>
|
||
<form method="post" action="<?= e(url('tasks/create')) ?>" class="inline-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="parent_id" value="<?= (int)$t['id'] ?>">
|
||
<input class="input" name="title" required placeholder="如:擦玻璃">
|
||
<?php $dtName = 'due_at'; $dtValue = null; $dtRequired = false; $dtSeconds = true;
|
||
require __DIR__ . '/../_datetime.php'; ?>
|
||
<button class="btn btn-sm" type="submit">加上</button>
|
||
</form>
|
||
</details>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php /* ---- 附件 ---- */ ?>
|
||
<div class="card card-pad">
|
||
<h2 class="cinema-h2">附件</h2>
|
||
<?php if (!$t['attachs']): ?>
|
||
<p class="empty-hint">还没有附件。</p>
|
||
<?php else: ?>
|
||
<?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')) ?>">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<input type="file" name="attach[]" multiple required>
|
||
<button class="btn btn-sm" type="submit">上传附件</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<?php /* ---- 共享 ---- */ ?>
|
||
<div class="card card-pad">
|
||
<h2 class="cinema-h2">共享</h2>
|
||
<?php if (!$t['shares']): ?>
|
||
<p class="empty-hint">还没共享给别人。共享之后,任何一个人完成都算完成。</p>
|
||
<?php else: ?>
|
||
<div class="res-shares">
|
||
<?php foreach ($t['shares'] as $s): ?>
|
||
<?= person_chip($s) ?>
|
||
<span class="node-badge"><?= ($s['perm'] ?? '') === 'write' ? '可写' : '只读' ?></span>
|
||
<?php if ($canWrite): ?>
|
||
<form method="post" action="<?= e(url('tasks/unshare')) ?>" class="res-inline">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<input type="hidden" name="person_id" value="<?= (int)$s['person_id'] ?>">
|
||
<button class="btn btn-ghost btn-sm" type="submit">取消</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
<?php if ($canWrite): ?>
|
||
<form class="inline-form" method="post" action="<?= e(url('tasks/share')) ?>">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<?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>
|
||
</select>
|
||
<button class="btn btn-sm" type="submit">共享</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<?php /* ---- 评论 ---- */ ?>
|
||
<div class="card card-pad">
|
||
<h2 class="cinema-h2">讨论 <span class="group-n"><?= count($t['comments']) ?> 条</span></h2>
|
||
<?php if (!$t['comments']): ?>
|
||
<p class="empty-hint">还没有留言。写 @名字 可以点名。</p>
|
||
<?php else: ?>
|
||
<ul class="cmt-list">
|
||
<?php foreach ($t['comments'] as $c): ?>
|
||
<li class="cmt-row">
|
||
<div class="cmt-who">
|
||
<?= person_chip($c) ?>
|
||
<span class="cmt-time"><?= e((string)$c['created_at']) ?></span>
|
||
</div>
|
||
<div class="cmt-body"><?= \App\Task::commentHtml((string)$c['content'], $names) ?></div>
|
||
<?php if ((int)$c['person_id'] === $meId): ?>
|
||
<form method="post" action="<?= e(url('tasks/comment_del')) ?>" class="res-inline">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$c['id'] ?>">
|
||
<input type="hidden" name="task_id" value="<?= (int)$t['id'] ?>">
|
||
<button class="btn btn-ghost btn-sm" type="submit" onclick="return confirm('删掉这条留言?')">删除</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
<?php endif; ?>
|
||
<?php if ($canWrite): ?>
|
||
<form method="post" action="<?= e(url('tasks/comment_add')) ?>" class="cmt-form">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<textarea class="input" name="content" rows="2" required
|
||
placeholder="说点什么… 写 @名字 可以点名"><?= e(old('content', '')) ?></textarea>
|
||
<div class="btn-row"><button class="btn btn-sm" type="submit">发表</button></div>
|
||
</form>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<?php if ($canWrite): ?>
|
||
<div class="task-danger">
|
||
<form method="post" action="<?= e(url('tasks/destroy')) ?>"
|
||
onsubmit="return confirm('删除「<?= e((string)$t['title']) ?>」?子任务、附件与留言会一起删掉。')">
|
||
<?= csrf_field() ?>
|
||
<input type="hidden" name="id" value="<?= (int)$t['id'] ?>">
|
||
<button class="btn btn-danger btn-sm" type="submit">删除这项任务</button>
|
||
</form>
|
||
</div>
|
||
<?php endif; ?>
|