feature: 面板

This commit is contained in:
zhuyu 2025-05-28 10:58:35 +08:00
parent 74ad433809
commit faa9d20ab8
4 changed files with 9 additions and 9 deletions

View File

@ -28,7 +28,7 @@
<div class="input-group-addon no-border no-padding"> <div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-path" class="btn btn-danger plupload" data-input-id="c-prove_file_path" data-mimetype="*" data-multiple="false" data-preview-id="p-path"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> <span><button type="button" id="plupload-path" class="btn btn-danger plupload" data-input-id="c-prove_file_path" data-mimetype="*" data-multiple="false" data-preview-id="p-path"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
{if $row->prove_file_path} {if $row->prove_file_path}
<span><button class="btn btn-primary btn-info btn-preview" data-type="{$row.filetype}" data-url="{$row.fileurl}">预览</button></span> <span><button class="btn btn-primary btn-info btn-preview" data-filetype="{$row.filetype}" data-fileurl="{$row.fileurl}">预览</button></span>
{/if} {/if}
</div> </div>
<span class="msg-box n-right" for="c-prove_file_path"></span> <span class="msg-box n-right" for="c-prove_file_path"></span>

View File

@ -26,7 +26,7 @@
<input id="c-path" data-rule="required" class="form-control" size="50" name="row[path]" type="text" value="{$row.path|htmlentities}"> <input id="c-path" data-rule="required" class="form-control" size="50" name="row[path]" type="text" value="{$row.path|htmlentities}">
<div class="input-group-addon no-border no-padding"> <div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-path" class="btn btn-danger plupload" data-input-id="c-path" data-mimetype="*" data-multiple="false" data-preview-id="p-path"><i class="fa fa-upload"></i> {:__('Upload')}</button></span> <span><button type="button" id="plupload-path" class="btn btn-danger plupload" data-input-id="c-path" data-mimetype="*" data-multiple="false" data-preview-id="p-path"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button class="btn btn-primary btn-info btn-preview" data-url="{$row.fileurl}" data-type="{$row.filetype}">预览</button></span> <span><button class="btn btn-primary btn-info btn-preview" data-fileurl="{$row.fileurl}" data-filetype="{$row.filetype}">预览</button></span>
</div> </div>
<span class="msg-box n-right" for="c-path"></span> <span class="msg-box n-right" for="c-path"></span>
</div> </div>

View File

@ -49,7 +49,7 @@
<input id="c-prove_file_path" class="form-control" size="50" readonly="readonly" name="row[prove_file_path]" type="text" value="{$row.prove_file_path}"> <input id="c-prove_file_path" class="form-control" size="50" readonly="readonly" name="row[prove_file_path]" type="text" value="{$row.prove_file_path}">
<div class="input-group-addon no-border no-padding"> <div class="input-group-addon no-border no-padding">
{if $row.prove_file_path} {if $row.prove_file_path}
<span><button class="btn btn-primary btn-info btn-preview" data-type="{$row.filetype}" data-url="{$row.fileurl}">预览</button></span> <span><button class="btn btn-primary btn-info btn-preview" data-filetype="{$row.filetype}" data-fileurl="{$row.fileurl}">预览</button></span>
{/if} {/if}
</div> </div>
<span class="msg-box n-right" for="c-prove_file_path"></span> <span class="msg-box n-right" for="c-prove_file_path"></span>

View File

@ -100,21 +100,21 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
$(document).on('click', '.btn-preview', function (e) { $(document).on('click', '.btn-preview', function (e) {
e.preventDefault(); e.preventDefault();
var fileType = $(this).data('type'); // 自动从 data-type 获取,比如 pdf, jpg, doc var fileType = $(this).data('filetype'); // 自动从 data-type 获取,比如 pdf, jpg, doc
var url = $(this).data('url'); var fileUrl = $(this).data('fileurl');
if (fileType === 'pdf') { if (fileType === 'pdf') {
Layer.open({ Layer.open({
type: 2, type: 2,
title: '预览PDF文件', title: '预览PDF文件',
area: ['80%', '80%'], area: ['80%', '80%'],
content: url content: fileUrl
}); });
} else if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileType)) { } else if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileType)) {
Layer.photos({ Layer.photos({
photos: { photos: {
"title": "图片预览", "title": "图片预览",
"data": [{"src": url}] "data": [{"src": fileUrl}]
}, },
anim: 5 anim: 5
}); });
@ -123,10 +123,10 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
type: 1, type: 1,
title: '视频预览', title: '视频预览',
area: ['800px', '500px'], area: ['800px', '500px'],
content: `<video src="${url}" width="100%" height="100%" controls autoplay></video>` content: `<video src="${fileUrl}" width="100%" height="100%" controls autoplay></video>`
}); });
} else { } else {
window.open(url, '_blank'); window.open(fileUrl, '_blank');
} }
}); });