This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/admin/import_excel.htm
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

159 lines
4.7 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>导入excel-e订通后台</title>
<link rel="stylesheet" href="layuiadmin/layui/css/layui.css">
<link rel="stylesheet" href="index.css">
<script src="layuiadmin/layui/layui.js"></script>
<script src="js/function.js"></script>
</head>
<body>
<form class="layui-form">
<input type="hidden" id="m" name="m" value="">
<input type="hidden" id="cate" name="cate" value="">
<input type="hidden" id="tmp_file_name" name="tmp_file_name" value="">
<div style style="padding:4px;">
<div class="layui-form-item"></div>
<div class="layui-form-item">
<label class="layui-form-label">导入模板</label>
<div id="div_mb">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">信息提示</label>
<div class="layui-input-block" style="border:1px solid #e2e2e2;padding:8px;line-height:25px;">
<span id="div_path_priv"></span>
<span id="div_check"></span>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-inline">
<a class="layui-btn" id="up_file"><i class="layui-icon">&#xe67c;</i>选择文件</a>
</div>
</div>
</div>
</form>
<script>
layui.use(['form','layer','upload','jquery'],function(){
var form = layui.form,
layer = parent.layer === undefined ? layui.layer : top.layer,
laydate = layui.laydate,
$ = layui.jquery;
var m=get_url_param("m");
var cate=get_url_param("cate");
//初始化
var url="./?_m="+m+"&_a=import&cate="+cate;
$.ajax(
{
url:url,
contentType: "application/json",
method: 'POST',
success: function (res) {
var json_data=$.parseJSON(res);
//alert(JSON.stringify(json_data));
$("#m").val(m);
$("#cate").val(cate);
//加载模板
var html1='<a href="excel_mb/'+m+'.xls" target="_blank"><div class="layui-input-inline" style="width:30px;"><img src="images/excel.png" width="30" height="33"></div><div class="layui-input-inline" style="font-size:16px;font-weight:bold;line-height:33px;">admin/excel_mb/'+m+'.xls</div></a>';
$("#div_mb").html(html1);
//加载目录权限结果
var r1="";
if(json_data.path_priv[0].priv=="y")
r1='<span class="layui-badge-rim">可写</span><br>';
else
r1='<span class="layui-badge-rim">不可写</span><br>';
html1='目录权限检查: '+json_data.path_priv[0].title+' '+r1;
$("#div_path_priv").html(html1);
},
error: function () {
layui.layer.msg("与服务器通信失败!");
}
}
);
//上传组件
var upload = layui.upload;
upload.render({
elem: '#up_file',
field:'up_file',
accept:'file',
exts: 'xls|xlsx',
url: './?_m='+m+'&_a=import_check&cate='+cate,
before: function(obj){
layer.load();
},
done: function(res,index,upload){
//alert(JSON.stringify(res));
var json_data=res;
if(json_data.code==1){
//正确
//显示检查信息
var html1="";
for(var i=0;i<json_data.msg.length;i++){
html1+=json_data.msg[i].col1+" "+json_data.msg[i].col2+"<br>";
}
//加载表单元素
html1+=trans_html_input(json_data.input);
html1+='<div class="layui-form-item"><button id="form1_submit" lay-filter="form1_submit" lay-submit class="layui-btn layui-btn-sm layui-btn-normal"> 确认导入 </button></div>';
$("#div_check").html(html1);
//加载临时文件名称
$("#tmp_file_name").val(json_data.tmp_file_name);
form.render();
}else{
//错误
var html1=json_data.msg;
$("#div_check").html(html1);
}
layer.closeAll('loading');
},
error: function(index, upload){
layer.closeAll('loading');
}
});
//确认导入
form.on("submit(form1_submit)",function(data){
//alert(JSON.stringify(data.field));
//弹出loading
var index = top.layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
//提交
var url="./?_m="+m+"&cate="+cate+"&_a=import_do";
//alert(url);
var post_data=data.field;
$.ajax({
url:url,
contentType: "application/json",
method: 'GET',
data:post_data,
success: function (res) {
var json_data=$.parseJSON(res);
if(json_data.code==1){
//成功
top.layer.close(index);
top.layer.msg("导入成功!");
if(json_data.reload_type=="table"){
//刷新父页面的表格数据
parent.reload_table();
}else{
parent.location.reload();
}
//关闭窗口
layer.closeAll("iframe");
parent.layer.closeAll("iframe");
}else{
//失败
top.layer.close(index);
top.layer.alert(json_data.msg,{title:"导入失败"});
location.reload();
}
}
});
return false;
})
})
</script>
</body>
</html>