mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-07-10 05:12:48 +08:00
feat(phone-image): add history popup with load config support
This commit is contained in:
@@ -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]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除输出记录
|
* 删除输出记录
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -139,6 +139,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 历史记录 -->
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="btn-history" style="width:100%;margin-bottom:10px;"><i class="layui-icon layui-icon-list"></i> 历史记录</button>
|
||||||
|
|
||||||
<!-- 操作按钮 -->
|
<!-- 操作按钮 -->
|
||||||
<div class="action-btns">
|
<div class="action-btns">
|
||||||
<button type="button" class="layui-btn layui-btn-normal" id="btn-save"><i
|
<button type="button" class="layui-btn layui-btn-normal" id="btn-save"><i
|
||||||
@@ -177,6 +180,8 @@
|
|||||||
var lastOutputId = null;
|
var lastOutputId = null;
|
||||||
var downloadBaseUrl = '{:url("post/downloadPostOutputZip", ["id" => 0])}';
|
var downloadBaseUrl = '{:url("post/downloadPostOutputZip", ["id" => 0])}';
|
||||||
var saveConfigUrl = '{:url("post/savePostOutputConfig")}';
|
var saveConfigUrl = '{:url("post/savePostOutputConfig")}';
|
||||||
|
var historyListUrl = '{:url("post/getOutputListJson", ["id" => $post->id])}';
|
||||||
|
var loadConfigUrl = '{:url("post/loadPostOutputConfig")}';
|
||||||
|
|
||||||
var postData = {
|
var postData = {
|
||||||
postId: {$post.id},
|
postId: {$post.id},
|
||||||
@@ -303,6 +308,95 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 历史记录弹窗
|
||||||
|
$('#btn-history').click(function () {
|
||||||
|
var loadIdx = layer.load();
|
||||||
|
$.get(historyListUrl, function (res) {
|
||||||
|
layer.close(loadIdx);
|
||||||
|
if (res.code !== 0 || !res.data || res.data.length === 0) {
|
||||||
|
layer.msg('暂无历史记录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var statusMap = { 0: '草稿', 1: '已生成', 2: '失败' };
|
||||||
|
var html = '<div style="padding:15px;max-height:320px;overflow-y:auto;">';
|
||||||
|
html += '<table class="layui-table" lay-skin="line" style="margin:0;">';
|
||||||
|
html += '<colgroup><col width="150"><col width="70"><col width="70"><col width="80"></colgroup>';
|
||||||
|
html += '<thead><tr><th>时间</th><th>状态</th><th>页数</th><th>操作</th></tr></thead>';
|
||||||
|
html += '<tbody>';
|
||||||
|
for (var i = 0; i < res.data.length; i++) {
|
||||||
|
var item = res.data[i];
|
||||||
|
var timeStr = item.create_time ? new Date(item.create_time * 1000).toLocaleString('zh-CN') : '-';
|
||||||
|
var statusText = statusMap[item.status] || '未知';
|
||||||
|
html += '<tr>';
|
||||||
|
html += '<td style="font-size:12px;">' + timeStr + '</td>';
|
||||||
|
html += '<td>' + statusText + '</td>';
|
||||||
|
html += '<td>' + (item.page_count || '-') + '</td>';
|
||||||
|
html += '<td><button type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-load-history" data-id="' + item.id + '">加载</button></td>';
|
||||||
|
html += '</tr>';
|
||||||
|
}
|
||||||
|
html += '</tbody></table></div>';
|
||||||
|
|
||||||
|
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();
|
doRender();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user