交通字段 - 飞机只记航班号、火车只记车次,不再收座位号 / 线路 / 承运人 / 登机口 (多人同乘一趟时座位号本来就无意义) - trip_nodes 的历史列保留但不再写入也不再渲染,编辑一次即被显式清成 NULL - 节点表单按出行方式切换号码标签(航班号 / 车次 / 班次 / 线路 / 航次) 照片 - 一个节点可传多张照片,前端支持逐张裁剪(Cropper.js,只把裁过的走 base64) - MIME 由自建的 src/Mime.php 按内容识别:getimagesize → 魔数嗅探 → 扩展名映射, 刻意不依赖 fileinfo —— 线上同时装着 PHP 7.4(没装该扩展)与 8.1 - 单张体积上限、可传张数在设置页可调 双存储后端 - 本站 uploads/ 或阿里云 OSS,在「存储设置」页配 endpoint / 桶名 / 前缀 / 内网开关; OSS 配置不完整时静默回退本地,避免管理员填错就把上传整个弄挂 - OSS 鉴权支持 ECS 实例 RAM 角色换 STS 临时凭证(临时凭证缓存在 /tmp,不落 Web 目录), 也支持直接填 AccessKey - OSS V1 签名手写实现,不引 SDK(本项目无 composer / 无 autoload) 媒体代理 - 照片与活动封面一律经 media/show、media/cover 代理输出,先校验家庭归属再吐字节 - 页面里不出现 OSS 域名,也不出现本地真实路径;桶保持私有 - 响应带 nosniff,并关闭 display_errors,免得 PHP 报错混进图片正文把图弄坏 数据库 - 新增迁移机制(src/Migrate.php + tools/migrate.php,仅 CLI 可跑) - 建 app_settings 表;attachments 增加 storage / object_key / mime_type / size_bytes / width / height / is_image 与 idx_storage - MySQL 8 不支持「加列时带 IF NOT EXISTS」,迁移一律先查 information_schema 界面 - 顶栏只留品牌与「新建活动」,其余入口收进右上角下拉菜单(details/summary,零 JS 可开合) - 新增「存储设置」页:当前生效存储、数据库结构版本、是否 ECS 运行环境三张状态卡, 外加测试连接与角色探测 - 样式表整体重写 验证 - 模板渲染检查 234 项、SQL 列名静态检查、模板到 CSS 的类覆盖检查、内联 JS 语法检查全通过 - 已部署到 trip.yangyq.net 并完成线上验证:双 PHP(8.1 / 7.4)14 条路由渲染字节数完全一致、 26 项内容断言全部通过、照片代理取件与磁盘原件逐字节一致(69/69 字节)
128 lines
6.0 KiB
PHP
128 lines
6.0 KiB
PHP
<?php
|
||
/**
|
||
* 节点卡片(计划列 / 执行列共用)
|
||
* 依赖外部变量:$n(节点行)、$cardCategory(plan|reality)、$executedPlanIds
|
||
*/
|
||
$cardCategory = $cardCategory ?? 'plan';
|
||
$executedPlanIds = $executedPlanIds ?? [];
|
||
|
||
$statusLabels = [
|
||
'planned' => '待执行',
|
||
'ongoing' => '进行中',
|
||
'completed' => '已完成',
|
||
'cancelled' => '已取消',
|
||
];
|
||
$st = (string)($n['status'] ?? ($cardCategory === 'plan' ? 'planned' : 'completed'));
|
||
if (!isset($statusLabels[$st])) $st = $cardCategory === 'plan' ? 'planned' : 'completed';
|
||
|
||
$isExecuted = $cardCategory === 'plan' && in_array((int)$n['id'], $executedPlanIds, true);
|
||
|
||
$sLoc = json_decode_field($n['start_location'] ?? null);
|
||
$eLoc = json_decode_field($n['end_location'] ?? null);
|
||
|
||
// 交通只记一个号码(航班号 / 车次 / 班次)—— 航班号本身就隐含航空公司,
|
||
// 座位号对「多人同乘一趟」没有意义,所以这些字段都已不再收集
|
||
$transportParts = [];
|
||
if (!empty($n['trip_number'])) $transportParts[] = $n['trip_number'];
|
||
|
||
// 卡片上的状态快捷切换:计划节点在"待执行 / 已完成"之间来回,取消后可以恢复
|
||
$quickStatus = null;
|
||
$quickLabel = '';
|
||
if ($cardCategory === 'plan') {
|
||
if ($st === 'planned') { $quickStatus = 'completed'; $quickLabel = '✓ 标记完成'; }
|
||
elseif ($st === 'completed') { $quickStatus = 'planned'; $quickLabel = '↺ 撤销完成'; }
|
||
elseif ($st === 'cancelled') { $quickStatus = 'planned'; $quickLabel = '↺ 恢复'; }
|
||
} elseif ($st === 'cancelled') {
|
||
$quickStatus = 'completed';
|
||
$quickLabel = '↺ 恢复';
|
||
}
|
||
?>
|
||
<div class="node-card node-<?= e($cardCategory) ?><?= $st === 'cancelled' ? ' node-cancelled' : '' ?>">
|
||
<div class="node-head">
|
||
<span class="node-icon"><?= e($n['node_type_icon']) ?></span>
|
||
<span class="node-type"><?= e($n['node_type_name']) ?></span>
|
||
<?php if ($cardCategory === 'reality' && empty($n['original_plan_node_id'])): ?>
|
||
<span class="tag-temp">临时</span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<div class="node-time">
|
||
<?= date('m-d H:i', strtotime($n['start_time'])) ?> - <?= date('H:i', strtotime($n['end_time'])) ?>
|
||
</div>
|
||
<div class="node-title"><?= e($n['title'] ?: '(无标题)') ?></div>
|
||
|
||
<?php if (!empty($sLoc['name']) || !empty($eLoc['name'])): ?>
|
||
<div class="node-loc">
|
||
<?php if (!empty($sLoc['name'])): ?>
|
||
<span class="loc-start">📍 <?= e($sLoc['name']) ?></span>
|
||
<?php endif; ?>
|
||
<?php if (!empty($sLoc['name']) && !empty($eLoc['name'])): ?>
|
||
<span class="loc-arrow"> → </span>
|
||
<?php endif; ?>
|
||
<?php if (!empty($eLoc['name'])): ?>
|
||
<span class="loc-end">📍 <?= e($eLoc['name']) ?></span>
|
||
<?php endif; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if (!empty($transportParts)): ?>
|
||
<div class="node-transport">🚄 <?= e(implode(' · ', $transportParts)) ?></div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($st === 'cancelled' && !empty($n['cancel_reason'])): ?>
|
||
<div class="node-cancel-reason">取消原因:<?= e($n['cancel_reason']) ?></div>
|
||
<?php endif; ?>
|
||
|
||
<div class="node-actions">
|
||
<span class="status-tag status-<?= e($st) ?>"><?= e($statusLabels[$st]) ?></span>
|
||
|
||
<a href="<?= url('nodes/show', ['id' => $n['id']]) ?>" class="node-action-link node-action-strong">详情</a>
|
||
<a href="<?= url('attachments/node', ['id' => $n['id']]) ?>" class="node-action-link">
|
||
📷 照片 (<?= (int)($n['attachment_count'] ?? 0) ?>)
|
||
</a>
|
||
<?php if ((int)($n['member_count'] ?? 0) > 0): ?>
|
||
<a href="<?= url('nodes/show', ['id' => $n['id']]) ?>#members" class="node-action-link">
|
||
👥 <?= (int)$n['member_count'] ?>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php if ((int)($n['comment_count'] ?? 0) > 0): ?>
|
||
<a href="<?= url('nodes/show', ['id' => $n['id']]) ?>#comments" class="node-action-link">
|
||
💬 <?= (int)$n['comment_count'] ?>
|
||
</a>
|
||
<?php endif; ?>
|
||
<?php if ((int)($n['expense_count'] ?? 0) > 0): ?>
|
||
<a href="<?= url('nodes/show', ['id' => $n['id']]) ?>#expenses" class="node-action-link">
|
||
💰 <?= (int)$n['expense_count'] ?>
|
||
</a>
|
||
<?php endif; ?>
|
||
<a href="<?= url('nodes/edit', ['id' => $n['id']]) ?>" class="node-action-link">编辑</a>
|
||
|
||
<?php if ($quickStatus !== null): ?>
|
||
<form method="post" action="<?= url('nodes/status') ?>" class="node-action-form">
|
||
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
||
<input type="hidden" name="id" value="<?= (int)$n['id'] ?>">
|
||
<input type="hidden" name="status" value="<?= e($quickStatus) ?>">
|
||
<button type="submit" class="node-action-btn"><?= e($quickLabel) ?></button>
|
||
</form>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($cardCategory === 'plan'): ?>
|
||
<?php if ($isExecuted): ?>
|
||
<span class="node-action-note">✓ 已成行</span>
|
||
<?php else: ?>
|
||
<form method="post" action="<?= url('nodes/fromPlan') ?>" class="node-action-form">
|
||
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
||
<input type="hidden" name="plan_node_id" value="<?= (int)$n['id'] ?>">
|
||
<button type="submit" class="node-action-btn">→ 生成执行记录</button>
|
||
</form>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<form method="post" action="<?= url('nodes/destroy') ?>" class="node-action-form"
|
||
onsubmit="return confirm('确定删除这个节点?该节点的附件也会一并删除。');">
|
||
<input type="hidden" name="_csrf" value="<?= e(csrf_token()) ?>">
|
||
<input type="hidden" name="id" value="<?= (int)$n['id'] ?>">
|
||
<button type="submit" class="node-action-btn danger">删除</button>
|
||
</form>
|
||
</div>
|
||
</div>
|