将数据导【入】【excel表】格式 前端页面

 

<html lang="en"><head>
    <meta charset="UTF-8">
    <title>PHPExcel表格测试</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8">
    <meta http-equiv="Cache-Control" content="no-siteapp">

<style>
    .w1{
        width: 30%;
    }
    .w2{
        width: 15%;
    }
</style>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>模板
            </label>
            <div class="layui-input-inline" style="width: auto;">
                <div class="layui-upload">
                    <button type="button" class="layui-btn exportTempBtn">下载模板</button>
                </div>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red"> * 导入的文件格式需严格按照模板整理</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>数据表
            </label>
            <div class="layui-input-inline" style="width: auto;">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="tableBtn">点击上传</button>
                </div>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <p id="pathVal">文件地址:新建XLS 工作表.xls</p>
                <input type="hidden" name="filepath" id="filepath" value="/Uploads/file/2019-05-11/5cd63ba8c2677.xls">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button class="layui-btn val_tijiao" type="button" lay-filter="add" data-type="on" lay-submit="">
                确认核算
            </button>
        </div>
    </form>
</div>

<script src="/Public/bl_zhaopin/js/jquery-1.10.2.js"></script>
<!--附件上传 js依赖-->
<script src="Public/static/plupload-2.1.9/plupload.full.min.js"></script>

<script src="/Public/bl_erpm/js/layer/layer.js"></script>
<script>
    /*单图片上传 js*/
    var uploader = new plupload.Uploader({
        "runtimes":"html5,flash,silverlight,html4",
        "flash_swf_url" : "/Public/static/plupload-2.1.9/Moxie.swf",
        "silverlight_xap_url" : "/Public/static/plupload-2.1.9/Moxie.xap",
        "browse_button":$("#tableBtn")[0],//点击触发事件
        "url":"{:U('Fileupload/xls_upload')}",//控制器地址
        "filters" : {
            max_file_size : '8M',
            mime_types: [
                {title : "Image files", extensions : "xls,xlsx"}
            ]
        },
        "multi_selection":false,// 多选
        "multipart_params":{"dir":"pic"},
        init:{
            FilesAdded: function(up, files) {
                this.start();
            },
            FileUploaded:function(up,files,res){

                var data = $.parseJSON(res.response);
                if(data.status == 1){
                    $('#pathVal').html('文件地址:' + data.name);
                    $('#filepath').val(data.data);
                }
            },
            Error:function(up,err){
                alert(err.message);

            }
        }
    });
    uploader.init();
</script>
<script>

    $('.val_tijiao').on('click',function(){
        layer.confirm('确认提交核算?', {
            btn: ['确认','取消'] //按钮
        }, function(){
            var f = $('.layui-form');
            $.post("{:U('User/together')}",f.serialize(),function(res){
                if(res.status){
                    //发异步,把数据提交给php
                    layer.alert(res.info, {icon: 6}, function (index) {
                        location.reload();
                    });
                }else{
                    layer.alert(res.info,{icon:5});
                }
            },'json');
        }, function(){
            // 取消
        });
    })

    $('.exportTempBtn').on('click',function(){
        location.href = "{:U('Kaoqin/temp_out')}";
    });

    //即时显示人员的职级信息
    function showname(){
        let bl_uid = $('input[name="uid"]').val();
        $.post("{:U('Money/getusermsg')}",{uid: bl_uid}, function(v){
            $('.unameBox').html(v.info);
        },'json');
    }
</script>
</body>

</html>

 

posted @ 2019-05-17 15:48  遇事稳坐钓鱼台  阅读(311)  评论(0编辑  收藏  举报