141 lines
6.4 KiB
PHP
141 lines
6.4 KiB
PHP
<?php
|
||||
|
|
/**
|
|||
|
|
* 节点参与人面板
|
|||
|
|
* 依赖外部变量:$node、$members、$familyUsers、$roleTags(id=>name)、$emotions(emoji=>中文)
|
|||
|
|
*/
|
|||
|
|
$members = $members ?? [];
|
|||
|
|
$familyUsers = $familyUsers ?? [];
|
|||
|
|
$roleTags = $roleTags ?? [];
|
|||
|
|
$emotions = $emotions ?? [];
|
|||
|
|
|
|||
|
|
$joinedIds = [];
|
|||
|
|
foreach ($members as $m) {
|
|||
|
|
$joinedIds[(int)$m['user_id']] = true;
|
|||
|
|
}
|
|||
|
|
$notJoined = [];
|
|||
|
|
foreach ($familyUsers as $u) {
|
|||
|
|
if (!isset($joinedIds[(int)$u['id']])) $notJoined[] = $u;
|
|||
|
|
}
|
|||
|
|
?>
|
|||
|
|
<section class="panel" id="members">
|
|||
|
|
<h2 class="section-title">👥 参与人 (<?= count($members) ?>)</h2>
|
|||
|
|
|
|||
|
|
<?php if (empty($members)): ?>
|
|||
|
|
<p class="muted">还没有添加参与人</p>
|
|||
|
|
<?php else: ?>
|
|||
|
|
<div class="member-list">
|
|||
|
|
<?php foreach ($members as $m):
|
|||
|
|
$mName = (string)($m['name'] ?? '');
|
|||
|
|
if ($mName === '') $mName = '已注销用户';
|
|||
|
|
?>
|
|||
|
|
<div class="member-row">
|
|||
|
|
<?php if (!empty($m['avatar'])): ?>
|
|||
|
|
<img src="<?= e($m['avatar']) ?>" alt="" class="avatar-sm">
|
|||
|
|
<?php else: ?>
|
|||
|
|
<span class="avatar-sm avatar-placeholder"><?= e(mb_substr($mName, 0, 1)) ?></span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
<span class="member-name"><?= e($mName) ?></span>
|
|||
|
|
|
|||
|
|
<?php foreach ($m['role_tag_names'] as $tagName): ?>
|
|||
|
|
<span class="member-role"><?= e($tagName) ?></span>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
|
|||
|
|
<?php if (!empty($m['emotion'])): ?>
|
|||
|
|
<span class="member-emotion" title="<?= e($emotions[$m['emotion']] ?? '') ?>">
|
|||
|
|
<?= e($m['emotion']) ?><?= e($emotions[$m['emotion']] ?? '') ?>
|
|||
|
|
</span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
|
|||
|
|
<?php if (!empty($m['check_in_time'])): ?>
|
|||
|
|
<span class="member-checkin">✓ 签到 <?= date('m-d H:i', strtotime((string)$m['check_in_time'])) ?></span>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
|
|||
|
|
<form method="post" action="<?= url('members/destroy') ?>" class="member-del-form"
|
|||
|
|
onsubmit="return confirm('把 <?= e($mName) ?> 从本节点移出?');">
|
|||
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|||
|
|
<input type="hidden" name="node_id" value="<?= (int)$node['id'] ?>">
|
|||
|
|
<input type="hidden" name="user_id" value="<?= (int)$m['user_id'] ?>">
|
|||
|
|
<button type="submit" class="comment-del">移出</button>
|
|||
|
|
</form>
|
|||
|
|
</div>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
|
|||
|
|
<?php if (!empty($notJoined)): ?>
|
|||
|
|
<form method="post" action="<?= url('members/addAll') ?>" style="display:inline"
|
|||
|
|
onsubmit="return confirm('把家庭里的 <?= count($familyUsers) ?> 位成员全部加入这个节点?');">
|
|||
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|||
|
|
<input type="hidden" name="node_id" value="<?= (int)$node['id'] ?>">
|
|||
|
|
<button type="submit" class="btn-sm">+ 一键加入全家(<?= count($notJoined) ?> 人待加入)</button>
|
|||
|
|
</form>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
|
|||
|
|
<details class="inline-panel">
|
|||
|
|
<summary>+ 添加 / 修改参与人</summary>
|
|||
|
|
<form method="post" action="<?= url('members/store') ?>" class="form form-plain">
|
|||
|
|
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
|||
|
|
<input type="hidden" name="node_id" value="<?= (int)$node['id'] ?>">
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>成员 *</label>
|
|||
|
|
<select name="user_id" required>
|
|||
|
|
<option value="">— 请选择 —</option>
|
|||
|
|
<?php foreach ($familyUsers as $u): ?>
|
|||
|
|
<option value="<?= (int)$u['id'] ?>">
|
|||
|
|
<?= e($u['name']) ?><?= isset($joinedIds[(int)$u['id']]) ? '(已加入,保存将覆盖)' : '' ?>
|
|||
|
|
</option>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<?php if (!empty($roleTags)): ?>
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>角色标签(可多选)</label>
|
|||
|
|
<div class="check-grid">
|
|||
|
|
<?php foreach ($roleTags as $tagId => $tagName): ?>
|
|||
|
|
<label class="checkbox-label">
|
|||
|
|
<input type="checkbox" name="role_tag_ids[]" value="<?= (int)$tagId ?>">
|
|||
|
|
<span><?= e($tagName) ?></span>
|
|||
|
|
</label>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<?php else: ?>
|
|||
|
|
<p class="muted" style="font-size:12px;">
|
|||
|
|
还没有角色标签,去
|
|||
|
|
<a href="<?= url('role_tags/index') ?>">角色标签管理</a>
|
|||
|
|
先建几个(例如:司机 / 摄影师 / 记账员)
|
|||
|
|
</p>
|
|||
|
|
<?php endif; ?>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>心情(可选)</label>
|
|||
|
|
<div class="emotion-grid">
|
|||
|
|
<label class="emotion-option">
|
|||
|
|
<input type="radio" name="emotion" value="" checked>
|
|||
|
|
<span class="emotion-face">🚫</span>
|
|||
|
|
<span class="emotion-text">不记录</span>
|
|||
|
|
</label>
|
|||
|
|
<?php foreach ($emotions as $emoji => $label): ?>
|
|||
|
|
<label class="emotion-option" title="<?= e($label) ?>">
|
|||
|
|
<input type="radio" name="emotion" value="<?= e($emoji) ?>">
|
|||
|
|
<span class="emotion-face"><?= e($emoji) ?></span>
|
|||
|
|
<span class="emotion-text"><?= e($label) ?></span>
|
|||
|
|
</label>
|
|||
|
|
<?php endforeach; ?>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-row">
|
|||
|
|
<label>签到时间(可选,留空表示未签到)</label>
|
|||
|
|
<input type="datetime-local" name="check_in_time">
|
|||
|
|
</div>
|
|||
|
|
|
|||
|
|
<div class="form-actions">
|
|||
|
|
<button type="submit" class="btn-primary">保存</button>
|
|||
|
|
</div>
|
|||
|
|
</form>
|
|||
|
|
</details>
|
|||
|
|
</section>
|