<%@ 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>

<div >


            <jsp:include page="../../../common/admin/search_pre.jsp"></jsp:include>
            <input type="hidden" name="formSerializeResourceList"/>
            <input type="hidden" id="pageNoResourceList" name="pageNo" value="1"/>

            <form id="formSearchResourceList" action="<%=basePath%>/admin/MicroappRecommendation/addList.htm" method="get" class="form-inline">

                <div class="form-group">
                    <label for="resourceName">资源名称</label>
                    <input type="text" id="resourceName" name="resourceName" class="form-control"/>
                </div>

                <div class="form-group">
                    <label for="resourceType">资源类型</label>
                    <select id="resourceType" name="resourceType" class="form-control">
                        <option></option>
                        <c:forEach items="${resourceType}" var="item">
                            <option value="${item.key}">${item.value}</option>
                        </c:forEach>
                    </select>
                </div>
                <div class="form-group">
                    <button id="btnSearchResourceList" type="button" class="btn btn-sm btn-primary"><i class="fa fa-search"></i>查询</button>
                </div>
            </form>
            <jsp:include page="../../../common/admin/search_post.jsp"></jsp:include>
            <div id="divGridResourceList">

            </div>

</div>
<form id="callerForm" action="<%=basePath%>/admin/MicroappRecommendation/doAdd.action" method="post" class="form-inline">
    <input type="hidden" id="resourceId" name="resourceId" />
    <input type="hidden"  name="sortCategory" value="${type}"  />
    <div class="form-group">
        <label for="sortValue">排序值</label>
        <input type="text" id="sortValue" name="sortValue" class="form-control"/>
    </div>
    <div class="form-group">
        <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>
    </div>
</form>
<jsp:include page="../../../common/admin/modal_content_post.jsp"></jsp:include>
<jsp:include page="../../../common/admin/modal_footer_pre.jsp"></jsp:include>

<script type="text/javascript">
    function searchResourceList() {
        var formSerialize = $("input[type='hidden'][name='formSerializeResourceList']").val();
        var pageNo = $("input[type='hidden'][id='pageNoResourceList']").val();

        var formData = formSerialize + "&pageNo=" + pageNo;


        $("#divGridResourceList").renderPartial({url: "<%=basePath%>/admin/MicroappRecommendation/addList.htm", data: formData,onFinished: function(t){
            }});
    }

    $("#btnSearchResourceList").click(function () {
        $("input[type='hidden'][id='pageNoResourceList']").val(1);
        $("input[type='hidden'][name='formSerializeResourceList']").val($("#formSearchResourceList").serialize());
        searchResourceList();
    });


    searchResourceList();
    $("#btnSave").click(function() {
        // var ids = document.getElementsByName("resourceId");
        // var str="";
        // if(!(ids.length>0)) {
        // alert("请选择调用资源");
        // }else{
        //     for(var i=0;i<ids.length;i++){
        //         if(ids[i].checked){
        //             str+=ids[i].value+",";
        //         }
        //     }
        //     //去掉字符串末尾的‘,'
        //     str=str.substring(0, str.length-1);
        // }
        // $("#calle").val(str);
            var val = $("input[type='radio']:checked").val();
            $("#resourceId").val(val)
        var reg=/^[0-9]+$/;
        var result= reg.test($("#sortValue").val());
        if(result) {
            $('#callerForm').ajaxSubmitCloseRefresh();
        }else{
            alert("排序值：请输入数字！");
            reurn;
        }
    });

    $(".input-group.date").datetimepicker({
        format: "YYYY-MM-DD",
        locale: "zh-cn"
    });


</script>
<jsp:include page="../../../common/admin/modal_footer_post.jsp"></jsp:include>