<%@ page import="com.lightinit.hsdataplatform.dictionary.DicPublishApiState" %>
<%@ page import="com.lightinit.hsdataplatform.dictionary.DicPublishChannel" %>
<%@ page import="com.lightinit.hsdataplatform.dictionary.DicBuyTimesLimit" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
    String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../../../common/admin/head.jsp"></jsp:include>
</head>
<body>
<jsp:include page="../../../common/admin/body_pre.jsp"></jsp:include>
<div class="row hidden-print">
    <div class="col-lg-12">
        <div class="ibox">
            <div class="ibox-title">
                <h2>详情</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="javascript:void(0);">资源管理</a>
                    </li>
                    <li>
                        <a href="">API发布</a>
                    </li>
                    <li class="active">
                        <strong>详情</strong>
                    </li>
                </ol>
            </div>
        </div>
    </div>
    <div class="col-md-12 column">
        <ul id="myTab" class="nav nav-tabs">
            <li class="active">
                <a href="#home" data-toggle="tab">基本信息</a>
            </li>
            <li>
                <a href="#ios" data-toggle="tab">发布渠道</a>
            </li>
        </ul>
        <form class="form-horizontal" id="settingFrom" role="form" method="post"
              action="<%=basePath%>/admin/api_publish/publishAPI_edit.action">
            <input type="hidden" name="resourceId" value="${resource.id}">
            <input type="hidden" id="publishInfoId" name="publishInfoId" value="${publishInfo.id}">
            <input type="hidden" id="publishState" name="publishState">
            <input type="hidden" id="z" name="z" value="0">
            <div id="myTabContent" class="tab-content">
                <input type="hidden" id="apiPublish_badge" name="apiPublish_badge" value="0">
                <div class="tab-pane fade in active" id="home">
                    <%--<form class="form-horizontal" role="form" id="resource_view">--%>
                    </br>
                    <div class="form-group">
                        <label for="resourceName" class="col-lg-2  text-right">服务名称</label>
                        <div id="resourceName">
                            ${resource.resourceName}
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="resourceIdentity" class="col-lg-2  text-right">服务标识</label>
                        <div id="resourceIdentity">
                            ${resource.resourceIdentity}
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="resourceSummary" class="col-lg-2  text-right">服务简介</label>
                        <div id="resourceSummary">
                            ${resource.resourceSummary}
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="registerDate" class="col-lg-2  text-right">注册日期</label>
                        <div id="registerDate">
                            <fmt:formatDate value="${resource.registerDate}" pattern="yyyy-MM-dd"/>
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="provider" class="col-lg-2  text-right">提供单位</label>
                        <div id="provider">
                            ${resource.providerName}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="catelogType" class="col-lg-2  text-right">目录分类</label>
                        <div id="catelogType">
                            ${resource.catelogType}
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="catelogBasic" class="col-lg-2  text-right">基础分类</label>
                        <div id="catelogBasic">
                            ${resource.catelogBasicName}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="catelogSector" class="col-lg-2  text-right">部门分类</label>
                        <div id="catelogSector">
                            ${resource.catelogSectorName}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="catelogTheme" class="col-lg-2  text-right">主题分类</label>
                        <div id="catelogTheme">
                            ${resource.catelogThemeName}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="dataTag" class="col-lg-2  text-right">服务标签</label>
                        <div id="dataTag" class="col-md-7 col-sm-2">
                            ${publishInfo.dataTag}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                        </br>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="catelogCustom" class="col-lg-2  text-right">自定义分类</label>
                        <div id="catelogCustom">
                            ${resource.catelogCustomName}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="allowDeal" class="col-lg-2  text-right">是否可交易</label>
                        <div id="allowDeal">
                            <c:if test="${resource.allowDeal==0}">否</c:if>
                            <c:if test="${resource.allowDeal==1}">是</c:if>
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="serviceType" class="col-lg-2  text-right">服务类型</label>
                        <div id="serviceType">
                            ${resource.serviceType}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="serviceTag" class="col-lg-2  text-right">服务标签</label>
                        <div id="serviceTag">
                            ${resource.serviceTag}
                        </div>
                    </div>
                    <span class="field-validation-valid help-block"></span>
                    </br>
                    <div class="form-group">
                        <label for="component" class="col-lg-2  text-right">组成接口</label>
                        <div id="component">
                            ${resource.component}
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <table id="testaaa" class="table table-hover  table-condensed table-bordered "
                               style="width: 70%;margin-left:10%" align="center">
                            <thead>
                            <tr>
                                <th>接口名称</th>
                                <th>接口标识</th>
                                <th>接口地址</th>
                                <th>操作</th>
                            </tr>
                            <c:if test="${resourceApiInterface.size()>0}">
                                <c:forEach items="${resourceApiInterface}" var="apiInterface">
                                    <tr>
                                        <td>${apiInterface.interfaceName}</td>
                                        <td>${apiInterface.interfaceIdentity}</td>
                                        <td>${apiInterface.url}</td>
                                        <td><a onclick='resourceviewById(${apiInterface.id});'>&nbsp;查看</a></td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            </thead>
                        </table>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="dataTag" class="col-lg-2  text-right">资源图片</label>
                        <div class="col-md-7 col-sm-7">
                            ${publishInfo.resourceImg}
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="publishState" class="col-lg-2  text-right">状态</label>
                        <div class="col-md-7 col-sm-7">
                            ${publishInfo.publishState}
                        </div>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="auditOpinion" class="col-lg-2  text-right">审核意见</label>
                        <div id="auditOpinion" class="col-md-7 col-sm-7">
                            ${publishInfo.auditOpinion}
                        </div>
                    </div>
                    <input type="hidden" id="resourceState" name="resourceState">
                </div>

                <div class="tab-pane fade" id="ios">
                    </br>
                    <div class="form-group">
                        <label for="publishChannel" class="col-sm-2 control-label text-right">发布渠道</label>
                        <div class="col-md-7 col-sm-7">
                            <input type="checkbox" id="publishChannel" name="publishChannel" <c:if test="${fn:contains(publishInfo.publishChannel,'开放平台')}">checked</c:if>
                                   value="<%=DicPublishChannel.OPEN%>"/><%=DicPublishChannel.OPEN%>
                            <input type="checkbox" name="publishChannel" <c:if test="${fn:contains(publishInfo.publishChannel,'共享平台')}">checked</c:if>
                                   value="<%=DicPublishChannel.SHARE%>" style="margin-left: 50px;"/><%=DicPublishChannel.SHARE%>
                        </div>
                        <span class="field-validation-valid help-block"></span>
                    </div>
                    </br>
                    <div class="form-group">
                        <label class="col-lg-2 control-label text-right">共享平台</label>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="shareType" class="col-sm-2 control-label text-right">共享类型</label>
                        <div class="col-md-7 col-sm-7">
                            <input type="text" id="shareType" name="shareType" class="form-control"
                                   value=" ${resource.shareType}" readonly/>
                        </div>
                        <span class="field-validation-valid help-block"></span>
                        </br>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="shareCondition" class="col-sm-2 control-label text-right">共享条件</label>
                        <div class="col-md-7 col-sm-7">
                            <input type="text" id="shareCondition" name="shareCondition" class="form-control"
                                   value="${publishInfo.shareCondition}" readonly/>
                        </div>
                        <span class="field-validation-valid help-block"></span>
                        </br>
                    </div>
                    </br>
                    <div class="form-group">
                        <label class="col-sm-2 control-label text-right">开放平台</label>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="openType" class="col-sm-2 control-label text-right">开放类型</label>
                        <div class="col-md-7 col-sm-7">
                            <input type="text" id="openType" name="openType" class="form-control"
                                   value="${resource.openType}" readonly/>
                        </div>
                        <span class="field-validation-valid help-block"></span>
                        </br>
                    </div>
                    </br>
                    <div class="form-group">
                        <label for="openCondition" class="col-sm-2 control-label text-right">开放条件</label>
                        <div class="col-md-7 col-sm-7">
                            <input type="text" id="openCondition" name="openCondition" class="form-control"
                                   value="${publishInfo.openCondition}" readonly/>
                        </div>
                        <span class="field-validation-valid help-block"></span>
                        </br>
                    </div>
                    </br>
                    <div class="form-group">
                        <table id="publishSettingTable" class="table table-hover  table-condensed table-bordered "
                               style="width: 70%;margin-left:10%" align="center">
                            <thead>
                            <tr>
                                <th>套餐名称</th>
                                <th>套餐价格</th>
                                <th>购买限制</th>
                                <th>使用限制</th>
                                <th>生效日期</th>
                                <th>失效日期</th>
                                <th>操作</th>
                            </tr>
                            <c:if test="${publishSettingList.size()>0}">
                                <c:forEach items="${publishSettingList}" var="publishSetting">
                                    <tr id="editPublishSetting_${publishSetting.id}">
                                        <td>${publishSetting.packageName}</td>
                                        <td>${publishSetting.packagePrice}元/${publishSetting.packagePrice}月</td>
                                        <c:if test="${publishSetting.buyTimesLimit eq 0}">
                                            <td><%=DicBuyTimesLimit.UNLIMITED%></td>
                                        </c:if>
                                        <c:if test="${publishSetting.buyTimesLimit eq 1}">
                                            <td><%=DicBuyTimesLimit.UNLIMITED_ONE%></td>
                                        </c:if>
                                        <c:if test="${empty publishSetting.buyTimesLimit}">
                                            <td></td>
                                        </c:if>
                                        <td>${publishSetting.useTimesLimit}次</td>
                                        <td>
                                            <fmt:formatDate value="${publishSetting.effectiveDate}"
                                                            pattern="yyyy-MM-dd"/>
                                        </td>
                                        <td>
                                            <fmt:formatDate value="${publishSetting.expiriedDate}"
                                                            pattern="yyyy-MM-dd"/>
                                        </td>
                                        <td><a onclick='viewPublishSetting(${publishSetting.id});'>&nbsp;查看</a>
                                            </td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                            </thead>
                        </table>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-7 text-center">
                        <button type="button" id="submitButton" class="btn btn-default"><i class="fa fa-close"></i>返回</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <jsp:include page="../../../common/admin/body_post.jsp"></jsp:include>
    <script type="text/javascript">
        $(".input-group.date").datetimepicker({
            format: "YYYY-MM-DD",
            locale: "zh-cn"
        });

        $("#submitButton").click(function () {
            window.location.href = "<%=basePath%>/admin/api_publish/index.htm";
        });

        function resourceviewById(id) {
            $.popBsPartial({url: "<%=basePath%>/admin/data_register_api/apiInterface_view.htm/" + id});
        }


        function viewPublishSetting(id) {
            $.popBsPartial({url: "<%=basePath%>/admin/api_publish/publishSettingView.htm/" + id});
        }
    </script>
</body>
</html>