<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>确认交付</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <style>
        /*导入弹窗css*/
        .shuoiner {display: flex;width: 500px;margin-top: 10px;justify-content: center;margin-left: auto;margin-right: auto;}
        .choseBtn {border: none;background: transparent;cursor: pointer;margin-left: 10px;height: 30px;}
        .execlword {display: block;margin-left: 10px;margin-top: 5px;color: #ff3333;}
        .chosewrap {display: flex;justify-content: center;width: 500px;}
        .addskin .layui-layer-title, .addskin2 .layui-layer-title {height: 50px;line-height: 50px;position: relative;}
        .addskin .layui-layer-content, .addskin2 .layui-layer-content {padding-top: 68px;padding-bottom: 80px;}
        .redcolor {color: #ff3333;}
        .addskin, .addskin2 {width: 592px !important;background: #f0f2f6 !important;}
        .stari {color: #ff3333;font-size: 14px;margin-right: 5px;}
        .tcInput {width: 280px;height: 30px;background: #fff;border: 1px solid #ddd;padding-left: 10px; box-sizing: border-box; margin-left: 10px;}
        .webuploader-pick{padding: 0 10px;background-color: #D9B589;}
        html{
            background-color: #fff;
        }
        .choseBtn{
            display: inline-block;
            color: #fff;
            background: #D9B589;
            height: 20px;
            padding: 0 5px;
            position: absolute;
            top: 6px;
            right: 6px
        }
        .uploadBtn{
            position: absolute;
            right: 6px;
            width: 40px;
            height: 35px;
            top: 3px;
            opacity: 0;
        }
        /*导入弹窗css*/
    </style>
</head>
<body>
<div id="importCustomer">
    <form class="layui-form layui-form-pane" action="">
        <div class="shuoiner">
            <div>
                <p style="font-size: 15px;">确认已交付？</p>
            </div>
        </div>
     <%--   <div class="chosewrap tcMargin" style="margin-left: 30px; margin-top: 20px">
            <div><i class="stari">*</i><span>发电户号：</span></div>
            <div>
                <div style="position: relative">
                    <input type="text" class="tcInput" name="generatorNo" id="generatorNo">

                </div>
            </div>
        </div>--%>
        <div class="chosewrap tcMargin" style="margin-left: 30px; margin-top: 20px">
            <div><i class="stari">*</i><span>   交付签收表：</span></div>
            <div>
                <div style="position: relative">
                    <input type="text" class="tcInput" id="filename" readonly name="filename" >
                    <input type="hidden" id="uploadRet" name="uploadRet" >
                    <span class="choseBtn" id="filePicker">选择</span>
                    <input type="file" name="deliverFile" class="uploadBtn" id="deliverFile"/>
                </div>
            </div>
        </div>
    </form>
    <div class="operate-footer" >
        <div class="layui-form-item text-c" style="text-align: center;">
            <button type="button" class="layui-btn" id="sureDeliver">确认</button>
            <button type="button" onclick="closeSelf()" class="layui-btn layui-btn-primary ">取消</button>
        </div>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPlugin}/static/js/jquery-3.3.1.min.js"></script>
<script>
    var categorySelect;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();


        $(function () {

            var deliverFlag = true;
            $('#sureDeliver').click(function(){
                if(!deliverFlag){
                    return;
                }

               /* var generatorNo = $("#generatorNo").val();
                if(isBlank(generatorNo)){
                    layer.msg('请输入发电户号');
                    return;
                }*/
                var uploadRet = $('input[name=uploadRet]').val();
                if (isBlank(uploadRet)) {
                    layer.msg('请上传交付签收表');
                    return;
                }
                deliverFlag = false;
                $.ajax({
                    type: 'post',
                    url: '${ctx}/customerEntry/accept',
                    data: {
                        id: '${id}',
                        deliverFile: uploadRet,
                        generatorNo:12
                    },
                    success: function(data){
                        if (data.code == '200') {
                            parent.layer.msg('操作成功', {time: 1000});
                            closeSelf();
                            parent.searchOrder();
                        } else if (data.code == '501') {
                            layer.msg(data.errMsg, {time: 1000});
                        } else {
                            layer.msg('操作失败', {time: 1000});
                        }
                    },
                    complete: function(){
                        deliverFlag = true;
                    }
                });
            });

            $('#deliverFile').change(function () {
                var file = $(this)[0].files[0];
                if (isBlank(file)) {
                    return;
                }
                var suffix = file.name.split('.')[1].toLowerCase();
                var arr = ['jpg', 'gif', 'png', 'jpeg', 'bpm'];
                if (arr.indexOf(suffix) === -1) {
                    layer.msg('请上传图片');
                    return;
                }
                var formData = new FormData();
                formData.append("file", file);
                $.ajax({
                    url: "${ctx}/common/uploadFile",
                    type: 'POST',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function (data) {
                        $('#filename').val(file.name);
                        <%--$('#logo').attr('src', '${commonStaticImgPath}' + data.path);--%>
                        $('input[name=uploadRet]').val(data.path);
                    }
                });
            });
        })

        window.closeSelf = function() {
            var index = parent.layer.getFrameIndex(window.name);
            // window.parent.location.reload();//刷新父级页面
            parent.layer.close(index);//关闭当前页
        }

        function isBlank(val) {
            if (val == null || val == '' || val == undefined) {
                return true;
            }
            return false;
        }
    });
</script>
</body>
</html>