上传密码本

This commit is contained in:
liang.chao 2025-05-23 15:42:07 +08:00
parent df1106c151
commit ebdad1c997
1 changed files with 38 additions and 7 deletions

View File

@ -43,7 +43,7 @@
<div class="layui-container" style="width: 100%;height: 100%;padding: 10px"> <div class="layui-container" style="width: 100%;height: 100%;padding: 10px">
<form id="baseForm" class="layui-form" method="POST" onsubmit="return false;"> <form id="baseForm" class="layui-form" method="POST" onsubmit="return false;">
<div>人员密码本:</div> <div>人员密码本:</div>
<button class="layui-btn" title="上传" type="button" onclick="uploadBook(2)">上传</button> <button class="layui-btn" title="上传" type="button" id="upload-btn">上传</button>
<button class="layui-btn" title="查看" type="button" onclick="viewBook(2)">查看</button> <button class="layui-btn" title="查看" type="button" onclick="viewBook(2)">查看</button>
</form> </form>
@ -57,12 +57,43 @@
let layer, laydate, table; let layer, laydate, table;
let obj = {}; let obj = {};
$(function () { $(function () {
layui.use(['layer', 'laydate', 'table'], function () { // layui.use(['layer', 'laydate', 'table'], function () {
layer = layui.layer; // layer = layui.layer;
laydate = layui.laydate; // laydate = layui.laydate;
table = layui.table; // table = layui.table;
initTable(); // initTable();
}); // });
layui.use('upload', function () {
var upload = layui.upload;
// 执行上传功能
var uploadInst = upload.render({
elem: '#upload-btn',
url: ctxPath + '/upload/file',
accept: 'file',
multiple: false,
done: function (res) {
// 上传完毕回调
console.log(res,'上传成功')
debugger
if (res.code === 0) { // 假设返回数据中有code字段0表示成功
// 在"人员密码本"后面添加文件名
$("form#baseForm div:first").append(
'<span style="margin-left: 10px; color: #1761c1;">' +
res.message +
'</span>'
);
layer.msg('上传成功');
} else {
layer.msg(res.resMsg || '上传失败');
}
},
error: function () {
layer.msg('请求失败')
}
})
})
}); });