From 5f5dc180c9a7820f00b60b56f71b3253e2825600 Mon Sep 17 00:00:00 2001 From: augushong Date: Sun, 3 May 2026 21:22:00 +0800 Subject: [PATCH] feat(phone-image): add history popup with load config support --- app/admin/controller/Post.php | 25 +++++++++ view/admin/post/phone_image.html | 94 ++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index 0cc80fa..ab113ec 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -489,6 +489,31 @@ class Post extends Common ]); } + /** + * 获取输出记录列表(JSON) + */ + public function getOutputListJson() + { + $id = $this->request->param('id', 0); + $list = \app\model\PostOutput::where('post_id', $id) + ->where('output_type', 'phone_image') + ->order('id', 'desc') + ->limit(20) + ->select(); + + $result = []; + foreach ($list as $item) { + $result[] = [ + 'id' => $item->id, + 'status' => $item->status, + 'page_count' => $item->page_count, + 'create_time' => $item->create_time, + ]; + } + + return json(['code' => 0, 'data' => $result]); + } + /** * 删除输出记录 */ diff --git a/view/admin/post/phone_image.html b/view/admin/post/phone_image.html index fc782e0..d55d4c4 100644 --- a/view/admin/post/phone_image.html +++ b/view/admin/post/phone_image.html @@ -139,6 +139,9 @@ + + +
'; + html += ''; + } + html += '
'; + + layer.open({ + type: 1, + title: '排版历史记录', + area: ['520px', '400px'], + content: html, + success: function (layero) { + layero.find('.btn-load-history').on('click', function () { + var outputId = $(this).data('id'); + loadFromHistory(outputId); + }); + } + }); + }).fail(function () { + layer.close(loadIdx); + layer.msg('获取历史记录失败'); + }); + }); + + function loadFromHistory(outputId) { + var loadIdx2 = layer.load(); + $.get(loadConfigUrl + '?id=' + outputId, function (res) { + layer.close(loadIdx2); + if (res.code !== 0 || !res.data) { + layer.msg('加载失败: ' + (res.msg || '未知错误')); + return; + } + + var cfg = res.data.config || {}; + // 更新表单控件 + if (cfg.size) { + $('[name="size"]').val(cfg.size); + form.render('select'); + } + if (cfg.fontSize) { + $('[name="fontSize"]').val(cfg.fontSize); + $('#fontSizeValue').text(cfg.fontSize + 'px'); + } + if (cfg.watermark !== undefined) { + $('[name="watermark"]').val(cfg.watermark); + } + + // 更新内容HTML(如果有保存) + if (res.data.content_html) { + postData.contentHtml = res.data.content_html; + $('#post-content-html').html(res.data.content_html); + } + + // 关闭历史弹窗 + layer.closeAll(); + + // 重新初始化引擎并渲染 + lastOutputId = outputId; + doRender(); + layer.msg('已加载历史配置'); + }).fail(function () { + layer.close(loadIdx2); + layer.msg('加载历史配置失败'); + }); + } + // 初始渲染 doRender(); });