<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<% String base = pageContext.getServletContext().getContextPath(); %>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript">
        window.UEDITOR_SERVER_URL = '<%=base%>';
    </script>
    <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,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]-->
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/html5shiv.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/respond.min.js"></script>
    <!--[endif]-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/h-ui.admin/css/page.css" />
    <link href="${pageContext.request.contextPath}/static/admin/css/page.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/layer/layer.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/laydate/laydate.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/index/layer/layer.js"></script>
    <!--[if IE 6]-->
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <title>后台管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>经典案例
    <span class="c-gray en">&gt;</span> 案例管理
    <span class="c-gray en">&gt;</span> 添加案例
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
        <form action="${pageContext.request.contextPath}/admin/submit_addProduct_en.html" method="post" class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>案例名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" name="name" >
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>一级分类名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select  name="cid" class="input-text" style="width:160px;" onchange="changeCategory()" id="first_s">
                        <option  selected  value="0">----请--选--择----</option>
                        <c:forEach items="${list01}" var="p">
                            <option  value="${p.id}">${p.name}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>

            <div class="row cl" style="display: none" id="dis_s">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>二级分类名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select  name="wid" class="input-text" style="width:160px;" id="second_s">
                        <option selected value="0">----请--选--择----</option>
                    </select>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>排序值：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="number" class="input-text" name="sort" value="0">&nbsp;&nbsp;&nbsp;&nbsp;<span class="c-red">*排序值越大,越先展示</span>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>添加时间：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input id="test1" class="input-text" name="time" style="width:160px;">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目地点：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" name="sites">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目规模：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" name="areas">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>项目进展：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" name="progress">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>设计日期：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input id="test2" class="input-text" name="times" style="width:160px;">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>竣工日期：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input id="test3" class="input-text" name="timess" style="width:160px;">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">建筑高度：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" name="heighs">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">建筑高度：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="text" class="input-text" name="heighs">
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">封面图：</label>
                <div class="formControls col-xs-8 col-sm-4">
                    <input type="file" class="input-text" name="filename" accept="image/*" id="geiBa">
                </div>
                <div class="formControls col-xs-8 col-sm-2">
                    <img alt="" src="" width="60" height="60" id="showIpt" style="display: none">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">案例详情：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <script id="introduction" name="context" type="text/plain" style="width:100%;height:400px;"></script>
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">案例描述：</label>
                <div class="formControls col-xs-8 col-sm-9">
                     <script id="introductions" name="detail" type="text/plain" style="width:100%;height:400px;"></script>
                </div>
            </div>

            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button class="btn btn-primary radius" type="submit" > <i class="Hui-iconfont">&#xe632;</i>提交</button>
                    <button  id="removeIframe" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </form>
</div>
<!-- 百度文本编辑器   引用文件 -->

<script src="<%=base%>/static/ue/ueditor.config.js" type="text/javascript"></script>
<script src="<%=base%>/static/ue/ueditor.all.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=base%>/static/ue/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/js/ajaxfileupload.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery.validation/1.14.0/messages_zh.js"></script>


<input type="hidden" value="${wid}" id="hidden_tid">
<script type="text/javascript">

    $("#removeIframe").click(function () {
        window.location.href='product_list_en.html?wid='+$("#hidden_tid").val();
    })

    //更改图片后显示
    $("#geiBa").change(function () {
        var num = URL.createObjectURL(this.files[0]);
        $("#showIpt").attr("src", num).show();
    });

    //验证表单不能为空
    $(function() {
        $("#form-article-add").validate({
            rules: {
                name: {
                    required: true,
                },
                sort: {
                    required: true,
                },
                cid: {
                    required: true,
                },
                wid: {
                    required: true,
                },
                time: {
                    required: true,
                },
                times: {
                    required: true,
                },
                sites: {
                    required: true,
                },
                areas: {
                    required: true,
                },
                progress: {
                    required: true,
                },
            },
            onkeyup: false,
            focusCleanup: true,
            success: "valid"
        });
    });

    //验证一二级分类不能为空
    $("#form-article-add").submit(function () {
        if($("#first_s").val()==0){
            alert("一级分类不能为空!");
            return false;
        }
    })

    laydate.render({
        elem: '#test1'
        ,type: 'datetime'
    });


    $("#test1").val(today());

    function today(){
        var today=new Date();
        var h=today.getFullYear();
        var m=today.getMonth()+1;
        var d=today.getDate();
        var hh=today.getHours();
        var mm=today.getMinutes();
        var ss=today.getSeconds();
        m= m<10?"0"+m:m;
        d= d<10?"0"+d:d;
        hh = hh < 10 ? "0" + hh:hh;
        mm = mm < 10 ? "0" +  mm:mm;
        ss = ss < 10 ? "0" + ss:ss;
        return h+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss;
    }

    $("#test2").val(today_s());

    function today_s(){
        var today=new Date();
        var h=today.getFullYear();
        return h;
    }

    function changeCategory() {
        var cid = $("#first_s").val();
        $.ajax({
            url : 'find_class02_en.html',
            type : 'POST',
            async: false,
            data : {'cid' : cid},
            dataType : 'text',
            success : function(data){
                var dataObj = eval("("+data+")");
                var dataList = dataObj.tasks;
                if(dataList!=null){
                    $("#dis_s").show();
                    $("#second_s").html('<option selected value="0">----请--选--择----</option>');
                    //解析json为数组

                    if (dataList != null) { //如果没有这一步，js会报length null之类的
                        for(var i=0;i<dataList.length;i++){
                            var categoryObj = dataList[i];
                            var id = categoryObj.id;
                            var name = categoryObj.name;
                            var str = '<option value="'+id+'">'+name+'</option>';
                            $("#second_s").html($("#second_s").html()+str);
                        }
                    }
                }else{
                    $("#second_s").html('<option selected value="0">----请--选--择----</option>');
                    $("#dis_s").hide();
                }

            },
            error : function(data) {
                console.log(data.msg);
            },
        });
    }

    $(function () {
        var ue = UE.getEditor('introduction', {
            //关闭字数统计
            wordCount: false,
            toolbars: [['fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion', 'insertvideo', 'attachment', 'map', 'template', 'background', '|',
                'horizontal', 'date', 'time', 'spechars', 'wordimage', '|',
                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                'print', 'preview', 'searchreplace', 'help'
            ]],
            //关闭elementPath
            elementPathEnabled: false,
        });
    });

    $(function () {
        var ue = UE.getEditor('introductions', {
            //关闭字数统计
            wordCount: false,
            toolbars: [['fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion', 'insertvideo', 'attachment', 'map', 'template', 'background', '|',
                'horizontal', 'date', 'time', 'spechars', 'wordimage', '|',
                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                'print', 'preview', 'searchreplace', 'help'
            ]],
            //关闭elementPath
            elementPathEnabled: false,
        });
    });



</script>

</body>
</html>
