<?php
use \common\libs\MyLib;
?>
<?php $this->beginBlock('header_css'); ?>
<link rel="stylesheet" type="text/css" href="/assets/css/plugins/webuploader/webuploader.css">
<?php $this->endBlock(); ?>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>批量导入</h5>
        </div>
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <form role="form" class="form-horizontal data-from" id="theFrm">
                        <div class="form-group">
                            <label class="control-label col-sm-1">文件</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input type="text" name="file" id="file" class="form-control" value="">
                                    <a href="javascript:void(0);" class="input-group-addon" id="upload">
                                        上传文件
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="row">
                                <div class="col-sm-5 col-sm-offset-5">
                                    <button class="btn btn-primary btn-save" type="button">
                                        <strong>提  交</strong>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->beginBlock('footer_js'); ?>
<script src="/assets/js/plugins/webuploader/webuploader.min.js"></script>
<script type="text/javascript" language="javascript">
    layui.use(['upload'], function(){
        var upload = layui.upload;
        var uploadInst = upload.render({
            elem: '#upload' //绑定元素
            ,url: '/common/upload' //上传接口
            ,accept: 'file'
            ,done: function(res){
                //上传完毕回调
                if(res.status == 'SUCCESS') {
                    $('#file').val(res.fileUrl);
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });
    $(function () {
        //提交按钮
        $(".btn-save").click(function(){
            parent.layer.confirm('是否确认提交？', {
                btn: ['确认','取消'], //按钮
                shade: false //不显示遮罩
            }, function(){
                var index = parent.layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var params = $("#theFrm").serialize();
                $.post('/finance/car-update-frame-info',params,function(obj){
                    parent.layer.close(index);
                    parent.layer.msg(obj.msg);
                    if(obj.success) {
                        window.location.reload();
                    }
                },'json');
            }, function(){
                //
            });
        });
    })
</script>
<?php $this->endBlock('footer_js'); ?>
