名册每人一份 · 分组两层 · 拖动排序 · 表单合一 · 裁剪可缩放
按用户十点反馈逐条落地(v5,Schema::VERSION = 5): - 名册改成每人一份:新表 person_roster(owner_id, person_id, group_id, sort_order, source)。默认只看「我添加的 + 别人分享给我的」; source='seeded' 是升级时从老 persons.group_id 播进来的(先播数据再删列)。 - 排序不再手填:名册页直接拖动卡片(整版提交,一次 applyLayout 落库), 无 JS 时卡片上的「调整分组」表单照旧可用。 - 分组分两层:管理员在「系统设置」维护公共分组(owner_id=0), 用户在「个人设置」加自己的分组;显示顺序各人各定、互不影响。 - 名册可共享:把名片分享给别的用户(people/share);添加成员时若系统里 已有这个人,可直接复用(people/pick),不必重复录入。 - 「编辑成员」与「改我自己的资料」合并为同一张表(templates/people/form.php), 两个入口 href 完全相同,h1 按改谁切换文案;个人设置页只留 资料入口 + 称呼 + 我的分组三块,删除 templates/settings/_profile.php。 - 系统设置收进头像下拉,顶栏只剩 首页/家谱/名册。 - 裁剪器加缩放(滑块 1-4x、Ctrl+滚轮、还原):缩放只改视图大小, 落库的归一化矩形保持不变。 - 权限:管理员可以改任何人的权限(含自己),只拦「最后一位管理员」被降级。 - 去掉首页「我的一句话」后的链接、家谱说明段、以及「还没归到任何分组」提示。 迁移安全:数据回填(PersonRoster::seedFromPersons)先于删列执行、且不进 tryStep 容错;失败步骤记入 settings.schema_upgrade_warning 并在系统设置页提示。 线上已验证:schema_upgrade_warning 为空,person_roster/person_groups.owner_id 就位,persons.group_id / sort_order 已删。 验证:php -l 48 文件;本地 e2e 277/0、老库升级 81/0、桌面几何 108/0、 移动端几何 180/0、交互 96/0;反向验证 38 条注入 + 2 条缩放注入全部命中; 部署静态断言 53/0,站点自检 7/7(--resolve 锁本机走 443,探针真的进 PHP)。
This commit is contained in:
+32
-26
@@ -13,6 +13,11 @@
|
||||
*/
|
||||
$isEdit = !empty($person['id']);
|
||||
$avatarUrl = avatar_url($person['avatar'] ?? null);
|
||||
// 这张表单有**两个入口**(名册/详情页的「编辑资料」、个人设置里的「编辑我的资料」),
|
||||
// 但只有一套字段。改自己、且不是能写的人(访客)时,只给属于他自己的那些 ——
|
||||
// 见 index.php 的 people/update(那条分支调 Person::updateSelf)。
|
||||
$canEditAll = $canEditAll ?? \App\Auth::canWrite();
|
||||
$isSelf = $isSelf ?? false;
|
||||
|
||||
$bdSource = old('birthday_source', 'solar');
|
||||
// 库里这列叫 birthday、表单叫 birthday_solar,一律走 solarOf() 取,别直接下标
|
||||
@@ -27,7 +32,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
?>
|
||||
|
||||
<div class="page-head">
|
||||
<h1><?= $isEdit ? '编辑成员' : '添加成员' ?></h1>
|
||||
<h1><?= $isEdit ? ($isSelf ? '我的资料' : '编辑成员') : '添加成员' ?></h1>
|
||||
<span class="sub"><?= $isEdit ? e($person['name']) : '填姓名就行,其他都可以以后再补' ?></span>
|
||||
</div>
|
||||
|
||||
@@ -57,6 +62,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field">
|
||||
<label for="birth_rank">家中排行</label>
|
||||
<input class="input" id="birth_rank" name="birth_rank" type="number" min="1" max="99"
|
||||
@@ -64,31 +70,15 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<span class="tip">用来认兄弟姐妹的长幼:长子、次女、三弟…</span>
|
||||
<?php if (!empty($errors['birth_rank'])): ?><span class="err"><?= e($errors['birth_rank']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field">
|
||||
<label for="sort_order">排序号</label>
|
||||
<input class="input" id="sort_order" name="sort_order" type="number"
|
||||
value="<?= e(old('sort_order', $person['sort_order'] ?? 1000)) ?>">
|
||||
<span class="tip">小的排前面。</span>
|
||||
</div>
|
||||
|
||||
<?php /* 一个人只属于一个关系分组;分组是全家共用的一套(名册按它分栏显示),
|
||||
但「哪一组排前面」是各人自己的习惯,在「个人设置」里调。 */ ?>
|
||||
<div class="field">
|
||||
<label for="group_id">关系分组</label>
|
||||
<select class="select" id="group_id" name="group_id">
|
||||
<option value="">未分类</option>
|
||||
<?php foreach (($groups ?? []) as $g): $gid = (int)$g['id']; ?>
|
||||
<option value="<?= $gid ?>"
|
||||
<?= (int)old('group_id', $person['group_id'] ?? 0) === $gid ? 'selected' : '' ?>>
|
||||
<?= e((string)$g['name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span class="tip">
|
||||
名册会按这个分组分栏显示。分组不够用就自己在「<a href="<?= e(url('settings/me')) ?>">个人设置</a>」里加。
|
||||
</span>
|
||||
</div>
|
||||
<?php /* ⚠️ 这里**没有**「排序号」,也**没有**「关系分组」:
|
||||
① 排序号已经彻底取消(用户原话:「排序号,不要让用户填写」),
|
||||
名册里的先后靠**拖动卡片**调,存在我自己的 person_roster.sort_order 上;
|
||||
② 分组是「我和他的关系」,写在我自己的名册条目上 ——
|
||||
只能在名册里拖到那一栏,或在那张卡片的「调整分组」里改。
|
||||
写进这张(全家人共用的)资料表单里是错的:我把他归成"同事"
|
||||
不该把妈妈那边的归类也改掉。 */ ?>
|
||||
|
||||
<!-- ==================== 三个生日 ==================== -->
|
||||
<div class="field full">
|
||||
@@ -153,6 +143,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<?php if (!empty($errors['slogan'])): ?><span class="err"><?= e($errors['slogan']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field">
|
||||
<label for="phone">手机号</label>
|
||||
<input class="input" id="phone" name="phone" inputmode="numeric"
|
||||
@@ -160,6 +151,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<span class="tip">开通登录后用它登录;加密存储,列表里只显示部分。</span>
|
||||
<?php if (!empty($errors['phone'])): ?><span class="err"><?= e($errors['phone']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field">
|
||||
<label for="email">邮箱</label>
|
||||
@@ -168,6 +160,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
<?php if (!empty($errors['email'])): ?><span class="err"><?= e($errors['email']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field full">
|
||||
<label for="id_card">身份证号</label>
|
||||
<input class="input mono" id="id_card" name="id_card"
|
||||
@@ -179,6 +172,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
</span>
|
||||
<?php if (!empty($errors['id_card'])): ?><span class="err"><?= e($errors['id_card']) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="field full">
|
||||
<label for="address">住址</label>
|
||||
@@ -215,6 +209,7 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
style="width:88px;height:88px;border-radius:12px;object-fit:cover;border:1px solid var(--line)">
|
||||
</div>
|
||||
|
||||
<?php if ($canEditAll): ?>
|
||||
<div class="field full">
|
||||
<label class="check-item">
|
||||
<input type="checkbox" name="is_placeholder" value="1"
|
||||
@@ -228,12 +223,23 @@ $idBd = trim((string)($person['birthday_id_card'] ?? ''));
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="btn-row">
|
||||
<button class="btn" type="submit"><?= $isEdit ? '保存' : '加入名册' ?></button>
|
||||
<a class="btn btn-ghost" href="<?= e($isEdit ? url('people/show', ['id' => (int)$person['id']]) : url('people')) ?>">取消</a>
|
||||
<?php
|
||||
// 取消:改自己的话回「个人设置」更顺手(那是他来的地方),
|
||||
// 改别人 / 新增则回他的详情页 / 名册。
|
||||
$cancelUrl = $isEdit
|
||||
? ($isSelf ? url('settings/me') : url('people/show', ['id' => (int)$person['id']]))
|
||||
: url('people');
|
||||
?>
|
||||
<a class="btn btn-ghost" href="<?= e($cancelUrl) ?>">取消</a>
|
||||
<?php if ($isSelf): ?>
|
||||
<a class="btn btn-ghost" href="<?= e(url('people/show', ['id' => (int)$person['id']])) ?>">看我的详情页</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user