<%@ 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" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String basePath = request.getContextPath();
%>
<jsp:include page="../../../common/admin/modal_content_pre.jsp"><jsp:param name="modal_title" value="编辑"/></jsp:include>
<form id="formEdit" action="<%=basePath%>/admin/microapp_register/update.action"  enctype="multipart/form-data" method="post" class="form-horizontal">
    <input type="hidden" name="id" value="${busiModel.id}" />
    <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" value="${busiModel.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" value="${busiModel.resourceIdentity}" class="form-control" />
            <span class="field-validation-valid 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" value="${busiModel.resourceSummary}"class="form-control" />
            <span class="field-validation-valid 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" value='<fmt:formatDate value="${busiModel.registerDate}" pattern="yyyy-MM-dd"/>' 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="field-validation-valid 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" value="${busiModel.serviceMethod}"class="form-control" />
            <span class="field-validation-valid 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" value="${busiModel.serviceChannel}" class="form-control" />
            <span class="field-validation-valid 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" value="${busiModel.demoUrl}"  class="form-control" />
            <span class="field-validation-valid 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" value="${busiModel.url}"  class="form-control" />
            <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">
            <p class="form-control-static">${screenshot == null ? "" : screenshot}</p>
            <input type="file" name="imgFile" onchange="fileChange()" />
            <input  type="hidden" id="screenshot"  name="screenshot" value="${busiModel.screenshot}" />
            <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="checkbox" name="catelogType"   value="<%=DicResourceCatelogType.BASIC%>" <c:if test="${fn:contains(busiModel.catelogType,'基础分类')}">checked="checked"</c:if>/><%=DicResourceCatelogType.BASIC%>

            <input type="checkbox" name="catelogType"  value="<%=DicResourceCatelogType.SECTOR%>" <c:if test="${fn:contains(busiModel.catelogType,'部门分类')}">checked="checked"</c:if> style="margin-left: 50px;" /><%=DicResourceCatelogType.SECTOR%>
            <br />
            <input type="checkbox" name="catelogType"  value="<%=DicResourceCatelogType.THEME%>" <c:if test="${fn:contains(busiModel.catelogType,'主题分类')}">checked="checked"</c:if> /><%=DicResourceCatelogType.THEME%>
            <input type="checkbox"  name="catelogType" value="<%=DicResourceCatelogType.CUSTOM%>" <c:if test="${fn:contains(busiModel.catelogType,'自定义分类')}">checked="checked"</c:if>    style="margin-left: 50px;" /><%=DicResourceCatelogType.CUSTOM%>
            <span class="field-validation-valid 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" value="${busiModel.shareType}">
                <option></option>
                <c:forEach items="${dicResourceShareType}" var="item" >
                    <option value="${item.key}" ${item.key == busiModel.shareType ? "selected=\"selected\"" : ""}>${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" value="${busiModel.openType}">
                <option></option>
                <c:forEach items="${dicResourceOpenType}" var="item" >
                    <option value="${item.key}" ${item.key == busiModel.openType ? "selected=\"selected\"" : ""}>${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" ${busiModel.allowDeal == 0 ? "selected=\"selected\"" : ""}>否</option>
                <option value="1" ${busiModel.allowDeal == 1 ? "selected=\"selected\"" : ""}>是</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" value="${busiModel.serviceTag}" class="form-control" />
        </div>
        <span class="field-validation-valid help-block"></span>
    </div>

</form>
<jsp:include page="../../../common/admin/modal_content_post.jsp"></jsp:include>
<jsp:include page="../../../common/admin/modal_footer_pre.jsp"></jsp:include>
<c:if test="${busiModel.resourceState eq '待提交'}" >
    <button type="button" onclick="btnSubmit()" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-check"></i>提交</button>
</c:if>
    <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>
<jsp:include page="../../../common/admin/modal_footer_post.jsp"></jsp:include>
<script type="text/javascript">
    $("#btnSave").click(function() {
        $('#formEdit').ajaxSubmitCloseRefresh();
    });

    $(".input-group.date").datetimepicker({
        format: "YYYY-MM-DD",
        locale: "zh-cn"
    });
    // function fileChange() {
    //     $("#screenshot").val("111");
    // }
    function btnSubmit() {
        $('#formEdit').append('<input type="hidden" name="resourceState" value="待审核">')
        $('#formEdit').ajaxSubmitCloseRefresh();
        /*$.post(
            '/admin/microapp_register/doSubmit.action',
            $("#formEdit").serialize(),
            function () {
                var modal = $.getJqObj(wysharpDefaultModalContainerSelector);
                modal.modal('hide');

            }
        );*/

    }

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