<%@ page import="com.lightinit.hsdataplatform.dictionary.DicResourceCatelogType" %>
<%@ page import="com.lightinit.hsdataplatform.dictionary.DicResourceState" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
%>
<jsp:include page="../../../common/admin/modal_content_pre.jsp"><jsp:param name="modal_title" value="新增"/></jsp:include>
<form id="formAdd" action="<%=basePath%>/admin/microapp_register/shoreAdd.action" method="post" enctype="multipart/form-data" class="form-horizontal">
    <div class="form-group">
        <label for="resourceName" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>微应用名称：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="resourceName" name="resourceName" class="form-control" /><span class="field-validation-valid help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="resourceIdentity" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>微应用标示：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="resourceIdentity" name="resourceIdentity" class="form-control" />
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="resourceSummary" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>微应用简介：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="resourceSummary" name="resourceSummary" class="form-control" />
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="registerDate" class="col-md-3 col-sm-3 control-label">注册日期：</label>
        <div class="col-md-7 col-sm-7">
                <div class="input-group date">
                <input type="text" id="registerDate" name="registerDate" class="form-control" />
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>

    <div class="form-group">
        <label for="provider" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>所属单位：</label>
        <div class="col-md-7 col-sm-7">
            <input type="hidden" id="provider" name="provider" />
            <button type="button" class="btn btn-default dropdown-toggle" style="min-width: 120px; text-align: right;">
                <span class="caret" style="margin-left: 10px;"></span>
            </button>
            <div id="divAddSectorTree"></div>
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="serviceMethod" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>服务方式：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="serviceMethod" name="serviceMethod" class="form-control" />
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="serviceChannel" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>服务渠道：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="serviceChannel" name="serviceChannel" class="form-control" />
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="demoUrl" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>演示地址：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="demoUrl" name="demoUrl" class="form-control" />
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label for="url" class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>访问URL：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="url" name="url" class="form-control" />
            <span class="help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label  class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>页面截图：</label>
        <div class="col-md-7 col-sm-7">
            <%--<input type="text" id="screenshot" name="screenshot" class="form-control" />--%>
            <input type="hidden" id="screenshot" name="screenshot">
                <input type="file" name="imgFile" onchange="fileChange()" />
            <span class="field-validation-valid help-block"></span>
        </div>

    </div>
    <div class="form-group">
        <label  class="col-md-3 col-sm-3 control-label"><span style="color: red">*</span>目录分类：</label>
        <div class="col-md-7 col-sm-7">
            <input type="checkbox" name="catelogType"   value="<%=DicResourceCatelogType.BASIC%>" /><%=DicResourceCatelogType.BASIC%>
            <input type="checkbox" name="catelogType"  value="<%=DicResourceCatelogType.SECTOR%>" style="margin-left: 50px;" /><%=DicResourceCatelogType.SECTOR%>
            <br />
            <input type="checkbox" name="catelogType"  value="<%=DicResourceCatelogType.THEME%>" /><%=DicResourceCatelogType.THEME%>
            <input type="checkbox" name="catelogType"  value="<%=DicResourceCatelogType.CUSTOM%>" style="margin-left: 50px;" /><%=DicResourceCatelogType.CUSTOM%>
            <span class="help-block"></span>
        </div>
    </div>

    <div class="form-group">
        <label for="catelogBasic" class="col-md-3 col-sm-3 control-label text-right">基础分类</label>
        <div class="col-md-7 col-sm-7">
            <input type="hidden" id="catelogBasic" name="catelogBasic" />
            <button type="button" class="btn btn-default dropdown-toggle" style="min-width: 120px; text-align: right;">
                <span class="caret" style="margin-left: 10px;"></span>
            </button>
            <div id="divCatelogBasic"></div>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>
    <div class="form-group">
        <label for="catelogSector" class="col-md-3 col-sm-3 control-label">部门分类</label>
        <div class="col-md-7 col-sm-7">
            <input type="hidden" id="catelogSector" name="catelogSector" />
            <button type="button" class="btn btn-default dropdown-toggle" style="min-width: 120px; text-align: right;">
                <span class="caret" style="margin-left: 10px;"></span>
            </button>
            <div id="divCatelogSector"></div>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>
    <div class="form-group">
        <label for="catelogTheme" class="col-md-3 col-sm-3 control-label">主题分类</label>
        <div class="col-md-7 col-sm-7">
            <input type="hidden" id="catelogTheme" name="catelogTheme" />
            <button type="button" class="btn btn-default dropdown-toggle" style="min-width: 120px; text-align: right;">
                <span class="caret" style="margin-left: 10px;"></span>
            </button>
            <div id="divCatelogTheme"></div>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>
    <div class="form-group">
        <label for="catelogCustom" class="col-md-3 col-sm-3 control-label">自定义分类</label>
        <div class="col-md-7 col-sm-7">
            <input type="hidden" id="catelogCustom" name="catelogCustom" />
            <button type="button" class="btn btn-default dropdown-toggle" style="min-width: 120px; text-align: right;">
                <span class="caret" style="margin-left: 10px;"></span>
            </button>
            <div id="divCatelogCustom"></div>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>

    <div class="form-group">
        <label for="shareType" class="col-md-3 col-sm-3 control-label">共享类型：</label>
        <div class="col-md-7 col-sm-7">
            <select id="shareType" name="shareType" class="form-control">
                <option></option>
                <c:forEach items="${dicResourceShareType}" var="item" >
                    <option value="${item.key}">${item.value}</option>
                </c:forEach>
            </select>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>

    <div class="form-group">
        <label for="openType" class="col-md-3 col-sm-3 control-label">开放类型：</label>
        <div class="col-md-7 col-sm-7">
            <select id="openType" name="openType" class="form-control">
                <option></option>
                <c:forEach items="${dicResourceOpenType}" var="item" >
                    <option value="${item.key}">${item.value}</option>
                </c:forEach>
            </select>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>


    <div class="form-group">
        <label for="allowDeal" class="col-md-3 col-sm-3 control-label">是否可交易：</label>
        <div class="col-md-7 col-sm-7">
            <select id="allowDeal" name="allowDeal" class="form-control">
                <option value="0" selected="selected">否</option>
                <option value="1">是</option>
            </select>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>
    <div class="form-group">
        <label for="serviceTag" class="col-md-3 col-sm-3 control-label">服务标签：</label>
        <div class="col-md-7 col-sm-7">
            <input type="text" id="serviceTag" name="serviceTag" class="form-control" />
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>
<%--==============================================================================--%>
    <div class="form-group">
        <label for="shareType" class="col-md-3 col-sm-3 control-label">镜像列表：</label>
        <div class="col-md-7 col-sm-7">
            <select id="imageTags" name="imageTags" class="form-control">
                <option></option>
                <c:forEach items="${imagetags.data}" var="item" >
                    <option >${item}</option>
                </c:forEach>
            </select>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>


    <div class="form-group">
        <label for="developerId" class="col-sm-3 control-label">开发商</label>
        <div class="col-md-7 col-sm-7">
            <input id="developers" name="developers" type="hidden" value="">
            <select id="developerId" name="developerId" class="form-control" onchange="selectOnchang(this)">
                <option></option>
                <c:if test="${developes.data.size()>0}">
                    <c:forEach items="${developes.data}" var="item" >
                        <option value="${item.id}">${item.developer}</option>
                    </c:forEach>
                </c:if>
            </select>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>

    <div class="form-group">
        <input id="classIfcation" name="classIfcation" type="hidden" value="">
        <label for="appkinds" class="col-sm-3 control-label">分类</label>
        <div class="col-md-7 col-sm-7">
            <select id="appkinds" name="appkinds" class="form-control" onchange="selectOnchangKind(this)">
                <option></option>
                <c:if test="${appkinds.data.size()>0}">
                    <c:forEach items="${appkinds.data}" var="item" >
                        <option value="${item.id}">${item.kind}</option>
                    </c:forEach>
                </c:if>
            </select>
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>


    <div class="form-group">
        <label for="content" class="col-sm-3 control-label">详情说明</label>
        <div class="col-sm-7">
            <textarea type="text" id="content" name="content" class="form-control" value=""></textarea>
            <span class="field-validation-valid help-block"></span>
        </div>
    </div>


<%--=======================================================================--%>


</form>
<jsp:include page="../../../common/admin/modal_content_post.jsp"></jsp:include>
<jsp:include page="../../../common/admin/modal_footer_pre.jsp"></jsp:include>
<button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"></i>取消</button>
<button type="button" id="btnSave" class="btn btn-primary"><i class="fa fa-check"></i>保存</button>
<button type="button" onclick="btnSubmit()"class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-check"></i>提交</button>
<jsp:include page="../../../common/admin/modal_footer_post.jsp"></jsp:include>
<script type="text/javascript">
    $("#btnSave").click(function() {
        $('#formAdd').append('<input type="hidden" name="resourceState" value="<%=DicResourceState.DRAFT%>">')
        //$("#resourceState").val("<%=DicResourceState.DRAFT%>");
        $("#formAdd").ajaxSubmitCloseRefresh();
    });

    $(".input-group.date").datetimepicker({
        format: "YYYY-MM-DD",
        locale: "zh-cn"
    });
    $("#formAdd").validate({
        rules: {
            imgFile:"required"
        }
    });

    function fileChange() {
        $("#screenshot").val("111");
    }

    function btnSubmit() {
        $('#formAdd').append('<input type="hidden" name="resourceState" value="<%=DicResourceState.PENDING%>">')
        $('#formAdd').ajaxSubmitCloseRefresh();
    //     $.post(
    //         '/admin/microapp_register/doSubmit.action',
    //         $("formAdd").serialize(),
    //         function () {
    //             var modal = $.getJqObj(wysharpDefaultModalContainerSelector);
    //             modal.modal('hide');
    //         }
    // );

    }

    function selectOnchang(choose){
        //获取被选中的option标签选项
        $('#developers').val(choose.options[choose.selectedIndex].text) ;
    }

    function selectOnchangKind(choose){
        //获取被选中的option标签选项
        $('#classIfcation').val(choose.options[choose.selectedIndex].text) ;
    }


    $("#divAddSectorTree").selectTree({url: "<%=basePath%>/admin/common/sector_tree_data.action"});
    $("#divCatelogBasic").selectTree({url: "<%=basePath%>/admin/common/resource_catelog_tree_data.action?resourceCatelogType=<%=DicResourceCatelogType.BASIC%>"});
    $("#divCatelogSector").selectTree({url: "<%=basePath%>/admin/common/resource_catelog_tree_data.action?resourceCatelogType=<%=DicResourceCatelogType.SECTOR%>"});
    $("#divCatelogTheme").selectTree({url: "<%=basePath%>/admin/common/resource_catelog_tree_data.action?resourceCatelogType=<%=DicResourceCatelogType.THEME%>"});
    $("#divCatelogCustom").selectTree({url: "<%=basePath%>/admin/common/resource_catelog_tree_data.action?resourceCatelogType=<%=DicResourceCatelogType.CUSTOM%>"});
</script>