@{
    ViewBag.Title = "上传图片(最多可上传三张图片)";
    Layout = "~/Views/Shared/_LayoutUploadImages.cshtml";
}
<style type="text/css">
</style>
<html>
<body>
    <table class="table table-bordered table-striped table-hover">
        <tr>
            <td>
                <input id="file-zh" type="file" multiple>
            </td>
        </tr>
    </table>
    <table id="wew" class="table table-bordered table-striped table-hover">
        <tbody>
            <tr style="height:200px">
                <td id="manypic">
                    <div style="float:left;">
                        @{
                            if (ViewBag.dt != null && ViewBag.dt.Rows.Count != 0)
                            {
                                for (int i = 0; i < ViewBag.dt.Rows.Count; i++)
                                {
                                    <div id="show" style="float:left;">
                        <img  alt="" id="@(i+1)" style="width:160px; height:160px; margin-left:10px;" src="../Handler1.ashx?typeid=@ViewBag.dt.Rows[i]["ptypeid_"].ToString()&nubconunt=@(i+1)&pagetype=ptypeimages&DBName=@ViewBag.DBName&EditionName=@ViewBag.EditionName" layer-src="../Handler1.ashx?typeid=@ViewBag.dt.Rows[i]["ptypeid_"].ToString()&nubconunt=@(i+1)&pagetype=ptypeimages&DBName=@ViewBag.DBName&EditionName=@ViewBag.EditionName" />
                        </div>
                        <a onclick="Del('@ViewBag.dt.Rows[i]["ptypeid_"].ToString()',@(i + 1))">
                        <div id="del@(i)" style="float:left;height:30px;width:30px;margin-left:-30px;background-image:url(../../icon/删除.png);background-size:30px 30px;background-repeat:no-repeat;">
                            </div>
                        </a>
                                }
                            }
                        }
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    <a id="refesh" href="~/WLTManage/UpLoadImages?ptypeid=@ViewBag.ptypeid" hidden="hidden"></a>
    <script type="text/javascript">
        function Del(id,count) {
            layer.confirm("确认删除？", function (index) {//删除前提示
                if (index) {
                    $.ajax({
                        url: "../WLTManage/DeletePhotes",
                        dataType: "text",
                        data: { ptypeid: id,count:count },
                        type: "post",
                        success: function (data) {//删除成功后刷新table
                            parent.layer.msg(data, { time: 2000 });
                            //document.getElementById(""+count+"").style.display="none";
                            //document.getElementById("del"+(count-1)+"").style.display="none";
                            document.getElementById("refesh").click();
                            layer.close(index);
                        },
                        error: function (data) {
                            layer.msg(data, { time: 2000 });
                        }
                    })
                }
            })
        }
        layer.ready(function () { //为了layer.ext.js加载完毕再执行
            layer.photos({
                photos: '#manypic',
                shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
            });
        });

        $('#file-zh').fileinput({
            language: 'zh',
            maxFileSize: 300,//上传文件最大的尺寸
            uploadUrl: '../Uploader/ImagesUploader?ptypeid=' + '@ViewBag.ptypeid' + '&operation=commodities',
            browseClass: "btn btn-default", //按钮样式
            allowedFileExtensions: ['jpg', 'png', 'gif'],
            previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
            maxFileCount: 3,
            validateInitialCount: true
        });
        var count = 0;
        //导入文件上传完成之后的事件
        $("#file-zh").on("fileuploaded", function (event, data, previewId, index) {
            count++;
            if (count == document.getElementById("file-zh").files.length) {
                document.getElementById("refesh").click();
                parent.layer.msg("上传成功！", { time: 2000 });
            }
        });
    </script>
</body>
</html>