<%@ 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="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<jsp:include page="../../../common/admin/modal_content_pre.jsp">
    <jsp:param name="modal_title" value="详情"/>
</jsp:include>
<form  class="form-horizontal">
    <div>
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a href="#baseInfo" aria-controls="baseInfo" role="tab" data-toggle="tab">基本信息</a></li>
            <li role="presentation"><a href="#publish" aria-controls="publish" role="tab" data-toggle="tab">发布渠道</a></li>
        </ul>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="baseInfo">
                <input type="hidden" name="id" value="${busiModel.id}"/>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">数据名称：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px" style="padding-top: 7px">
                        ${busiModel.resourceName}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">数据摘要：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.resourceSummary}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">数据项：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.dataItem}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">发布日期：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        <fmt:formatDate value="${busiModel.registerDate}" pattern="yyyy-MM-dd"></fmt:formatDate>
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">所属单位：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.belongToString}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">主题分类：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.catelogType}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">数据标签：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.dataTag}
                    </div>

                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">数据文件：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        <label>${busiModel.dataFile}</label>
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">示例文件：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        <label>${busiModel.demoFile}</label>
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <%--<div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">文件格式：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        没有赋值，需求不明确
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>--%>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">资源图片：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                           <label name="resourceImg" ><a target="_blank" href="${busiModel.resourceImg}">查看图片</a></label>
                       <span class="help-block"></span>
                    </div>
                </div>
            </div>
            <%--/////////////////////发布渠道///////////////////////////--%>
            <div role="tabpanel" class="tab-pane" id="publish">
                <%--<div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">发布渠道：</label>
                    <input type="checkbox" name="publicChannel" value="共享平台"/>共享平台
                    <input type="checkbox" name="publicChannel" value="开放平台"/>开放平台
                </div>--%>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">共享平台：</label>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">共享类型：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.shareType}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">共享条件：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        <label>${busiModel.shareCondition}</label>
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">开放平台：</label>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">开放类型：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        ${busiModel.openType}
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div class="form-group">
                    <label class="col-md-3 col-sm-3 control-label">开放条件：</label>
                    <div class="col-md-7 col-sm-7" style="padding-top: 7px">
                        <label>${busiModel.openCondition}</label>
                    </div>
                    <span class="field-validation-valid help-block"></span>
                </div>
                <div>
                    <table id="fixedPriceTable" class="table table-hover  table-condensed table-bordered "
                           align="center">
                        <thead>
                        <tr>
                            <td>套餐名称</td>
                            <td>套餐价格</td>
                            <td>购买限制</td>
                            <td>使用限制</td>
                            <td>生效日期</td>
                            <td>失效日期</td>
                        </tr>
                        </thead>
                        <tbody>
                            <c:if test="${busiModel.publishSettingList !=null}" var="item">
                                <c:forEach items="${busiModel.publishSettingList}" var="item" varStatus="status">
                                    <tr id="fixedPriceTrId">
                                        <td>${item.packageName}</td>
                                        <td>${item.packagePrice}</td>
                                        <td>${item.buyTimesLimit==null?"无":item.buyTimesLimit}</td>
                                        <td>${item.useTimesLimit==null?"无":item.useTimesLimit}</td>
                                        <td><fmt:formatDate value="${item.effectiveDate}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                                        <td><fmt:formatDate value="${item.expiriedDate}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"></i>取消</button>
    </div>
</form>

<%--////////////////////////////////////--%>
<div id="fiexedPriceModal" style="display:none">
    <ul>
        <ol>计费方式：<input type="text" value="${item.chargeMethod}"></ol>
        <ol>套餐名称：<input type="text" value="${item.packageName}"></ol>
        <ol>套餐价格：<input type="text" value="${item.packagePrice}"></ol>
        <ol>购买次数限制：<input type="text" value="${item.buyTimesLimit}"></ol>
        <ol>使用限制：<input type="text" value="${item.useTimesLimit}"></ol>
        <ol>生效日期：<input type="text" value="${item.effectiveDate}"></ol>
        <ol>失效日期：<input type="text" value="${item.expiriedDate}"></ol>
        <ol>套餐说明：<input type="text"value="${item.description}"></ol>
       <%-- <input type="button" value="确定" onclick="hideFiexedPriceModal()"/>--%>
    </ul>
</div>
<script type="text/javascript">
    var updateId=0;   /*定义标识，用于存储“修改”的id*/
    var count=${fn:length(busiModel.publishSettingList)};/*用在对publishSettingList每次点击加一*/
    /*选择标签页*/
    $('#myTabs a').click(function (e) {
        $(this).tab('show')
    })

    function showFiexedPriceModal() {
        $('#fiexedPriceModal input').clearInputs();
        $('#fiexedPriceModal').show();
        $('#publisResourceDetailFormId').hide();
        $('#fiexedPriceTrId').remove();
    }

    function hideFiexedPriceModal() {
        $('#fiexedPriceModal').hide();
        $('#publisResourceDetailFormId').show();
        var fiexedPriceTr = "<tr id='fiexedPriceTrId-'>" +
            "<td>" + $('#fiexedPriceModal input:eq(1)').val() + "</td>" +
            "<td>" + $('#fiexedPriceModal input:eq(2)').val() + "</td>" +
            "<td>" + $('#fiexedPriceModal input:eq(3)').val() + "</td>" +
            "<td>" + $('#fiexedPriceModal input:eq(4)').val() + "</td>" +
            "<td>" + $('#fiexedPriceModal input:eq(5)').val() + "</td>" +
            "<td>" + $('#fiexedPriceModal input:eq(6)').val() + "</td>" +
            "<td><input type='hidden' name='publishSettingList["+count+"].chargeMethod' value='" + $('#fiexedPriceModal input:eq(0)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].packageName' value='" + $('#fiexedPriceModal input:eq(1)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].packagePrice' value='" + $('#fiexedPriceModal input:eq(2)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].buyTimesLimit' value='" + $('#fiexedPriceModal input:eq(3)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].useTimesLimit' value='" + $('#fiexedPriceModal input:eq(4)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].effectiveDate' value='" + $('#fiexedPriceModal input:eq(5)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].expiriedDate' value='" + $('#fiexedPriceModal input:eq(6)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].description' value='" + $('#fiexedPriceModal input:eq(7)').val() + "'/>" +
            "<input type='hidden' name='publishSettingList["+count+"].id' value='"+updateId+"'/>" +
            "<a onclick='toEdit(this)'>修改</a>|<a onclick='toDelete(this)'>删除</a></td>" +
            "</tr>"
        $('#fixedPriceTable').append(fiexedPriceTr);
        updateId=0;     //将标识变为0
        count++;
    }

    function toEdit(tr) {

        updateId=$(tr).parent().children('input:last').val();
        $(tr).parent().parent().remove();
        showFiexedPriceModal();
        for(var i=0;i<7;i++){
            $("#fiexedPriceModal ul ol:eq("+i+") input").val($(tr).parent().parent().children("td:last").children("input:eq("+i+")").val());
        }
        $("#fiexedPriceModal ul ol:eq(7) input").val($(tr).parent().parent().children("td:last").children("input:last").val());
    }

    function toDelete(tr) {
        $(tr).parent().parent().remove();
    }

    function fnSubmit(){
        $('#param').val(1);
        $('#publisResourceDetailFormId').ajaxSubmitCloseRefresh();
    }
    function fnStorage(){
        var serialize2 = $('#publisResourceDetailFormId').append("<input type='hidden' name='param' value='2'/>").serialize();
        $.post("/admin/datapublish_mgr/updatePublishDataDetial.action",serialize2,function(result){
            if(result.stateCode==200){
                alert("暂存操作成功");
                var modal = $.getJqObj(wysharpDefaultModalContainerSelector);
                modal.modal('hide');
                /*待加入需要对页面刷新*/
            }else{
                alert("暂存操作失败");
            }
        });
    }
</script>
<%--///////////////////////////////////////--%>
<jsp:include page="../../../common/admin/modal_content_post.jsp"></jsp:include>
<%--
<jsp:include page="../../../common/admin/modal_footer_pre.jsp"></jsp:include>
<jsp:include page="../../../common/admin/modal_footer_post.jsp"></jsp:include>--%>
