@using GBLab.Common.Expand;
@model GBLab.Entities.T_CmsImg
@{
    Layout = null;
}
@*列表界面主体*@
<div id="Item_tabsContent" class="tabsContent" style="border-style: none;padding-top:3px;background-color:#E5EFEF;">
    <div id="layout">
        @*左侧导航收缩后效果*@
        <div id="Item_sidebar_sMids" class="sidebar_sMid" layouth="8" style="float: left;
            width: 24px; height: 100%; display: none; z-index: 21; border: 1px solid #B8D0D6;margin-right: 3px;">
            <div style="background: none repeat scroll 0 0 #EFF5F6;">
                <div id="Item_sidebar_sMid" class="toggleCollapse" style="background: none repeat scroll 0 0 transparent;
                    border: 0 none;">
                    <div style="background-position: -2px -147px; border: 0 none; width: 21px;">
                    </div>
                </div>
            </div>
        </div>
        @*左侧导航展开后效果*@
        @{
            if (Request.QueryString["IsLeftTree"].DefaultIsNullOrEmpty(true) == true) {
                <div id="Item_MidTree" layouth="8" style="float: left; display: block;overflow: auto; width: 227px; border: solid 1px #CCC; line-height: 21px; background: #fff;margin-right: 3px; ">
                    <div class="toggleCollapseForAction" id="Item_toggleCollapseMid" style="border-style: none;">
                        <h2>
                            栏目列表
                        </h2>
                        <div>
                            收缩
                        </div>
                    </div>
                    <ul id="Item_Tree" class="ztree"></ul>
                </div>
            }
        }
        <div id="jbsxBox" class="unitBox" style="display:block; overflow:auto;@(Request.QueryString["IsLeftTree"].DefaultIsNullOrEmpty(true)==true?"margin-left:29px;":"")">
            <div class="pageHeader" style="border: 1px #B8D0D6 solid; padding: 0px;margin-bottom: 1px;">
                <div class="searchBar">
                    <table class="searchContent">
                        <tr>
                            <td>
                                @Html.DropDownListFor(model => model.F_Name, ViewData["DroupInfo_SearchDataControl"] as List<SelectListItem>, new { @class = "combox", @id = "Item_F_SearchType", @Name = "Item_F_SearchType", @style = "width:150px;" })
                            </td>
                            <td>
                                @Html.Raw(Html.WebInput_CommonConfirmIdForListSearch("F_Name", "none", "", "true", "", "1", "80", "", ""))
                            </td>
                            <td>
                                @Html.DropDownListFor(model => model.F_Name, ViewData["DroupInfo_SearchDateControl"] as List<SelectListItem>, new { @class = "combox", @id = "Item_F_SearchDateType", @Name = "Item_F_SearchDateType", @style = "width:150px;" })
                            </td>
                            <td>
                                开始
                            </td>
                            <td>
                                @Html.Raw(Html.WebInput_DateForListSearch("F_DateBegin", "", "yyyy-MM-dd HH:mm:ss", "-30", "20", "true"))
                            </td>
                            <td>
                                结束
                            </td>
                            <td>
                                @Html.Raw(Html.WebInput_DateForListSearch("F_DateEnd", "", "yyyy-MM-dd HH:mm:ss", "-30", "20", "true"))
                            </td>
                            <td>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="button" onclick="Item_subSearch();">
                                            检索
                                        </button>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="pageContent" style="border-left: 1px #B8D0D6 solid; border-right: 1px #B8D0D6 solid">
                <div class="panelBar" style="margin: 0px; padding: 0px;">
                    <ul class="toolBar">
                        <div style="float:right;">
                            @if (Request.QueryString["back"] != null) {
                                <li>
                                    <a class="icon" onclick="Item_Select()" href='#this'>
                                        <span>选取记录带回父页面</span>
                                    </a>
                                </li>
                            }
                            @Html.Raw(Html.GetButtons("CmsImg", "Add,DeleteMore,BatchAction,ExportPage,ExportAll,PrintPage", ViewData["permit"] as string, ViewData["actions"] as Dictionary<string, string>))
                        </div>
                        <div style="float:left;">
                            <li>
                                <div id="Item_100" class="buttonDisabled">
                                    <div class="buttonContent">
                                        <button type="button" onclick="Item_SetMarkStatus(100, '100');">
                                            全部
                                        </button>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div id="Item_0" class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="button" onclick="Item_SetMarkStatus(0, '0');">
                                            正常
                                        </button>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div id="Item_10" class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="button" onclick="Item_SetMarkStatus(10, '10');">
                                            待审核
                                        </button>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div id="Item_1" class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="button" onclick="Item_SetMarkStatus(-1,'1');">
                                            删除
                                        </button>
                                    </div>
                                </div>
                            </li>
                        </div>
                    </ul>
                </div>
            </div>
            <div id="Item_TableInfo" style="border-width:0 1px;border-color:#D0D0D0;border-style:solid;"></div>
        </div>

        @*用于子标签引用的时候在高度上的处理*@
        <span id="Item_MidNumber" style="display: none;">@Html.ViewContext.HttpContext.Request.QueryString["Mid"]</span>

        @*查询条件存储*@
        <div style="display: none;">
            @*树形节点存储*@
            <div id="Item_TreeCode"></div>
            @*当前页面存储*@
            <div id="Item_currentPage">1</div>
            @*分页大小存储*@
            <div id="Item_pageSize">-1</div>
            @*分页数量存储*@
            <div id="Item_pageCount"></div>
            @*查询条件：排序*@
            <div id="Item_OrderInfo"></div>
            @*查询条件：名称*@
            <div id="Item_name"></div>
            @*查询条件：状态信息*@
            <div id="Item_markStatus">100</div>
            @*查询条件：字段搜索类型*@
            <div id="Item_searchType">name</div>
            @*查询条件：日期字段搜索类型*@
            <div id="Item_searchDateType"></div>
            @*查询条件：开始日期*@
            <div id="Item_dateBegin"></div>
            @*查询条件：结束日期*@
            <div id="Item_dateEnd"></div>
        </div>
    </div>
</div>

@*弹窗内容*@
<div class="pageFormContent" id="Item_BatchAction" style="display:none;">
    <fieldset style="margin:10px;height:530px;">
        <legend>批量操作</legend>

        <dl>
            <dt>修改状态：</dt>
            <dd>
                @Html.DropDownListFor(model => model.F_MarkStatus, ViewData["MarkStatus"] as List<SelectListItem>, new { @class = "combox", @id = "Item_F_MarkStatus", @Name= "Item_F_MarkStatus", @style = "width:150px;" })
                <div class="buttonActive"><div class="buttonContent"><button type="button" onclick="Item_Update_MarkStatus()">提交</button></div></div>
            </dd>
        </dl>

        @*推荐多选下拉树*@
        <dl style="display:none;">
            <dt>批量推荐：</dt>
            <dd>
                <input id="Item_F_RecommendTypeId" type="text" class="textInput">
            </dd>
        </dl>
        <dl>
            <dt>批量推荐：</dt>
            <dd>
                <input id="Item_F_RecommendTypeName" type="text" class="textInput" onclick="Item_F_RecommendTypeName_ShowMenu()">
                <div class="buttonActive"><div class="buttonContent"><button type="button" onclick="Item_Update_Recommend()">提交</button></div></div>
            </dd>
        </dl>


        @*类别下拉树*@
        <dl style="display:none;">
            <dt>迁移类别Id：</dt>
            <dd>
                <input id="Item_F_TypeId" type="text" class="textInput">
            </dd>
        </dl>
        <dl>
            <dt>迁移类别：</dt>
            <dd>
                <input id="Item_F_TypeName" type="text" class="textInput" onclick="Item_F_TypeName_ShowMenu()">
                <div id="testbutton" class="buttonActive"><div class="buttonContent"><button type="button" onclick="Item_Update_TypeId()">提交</button></div></div>
            </dd>
        </dl>


        @*相关类别多选下拉树*@
        <dl style="display:none;">
            <dt>迁移类别Ids：</dt>
            <dd>
                <input id="Item_F_TypeIds" type="text" class="textInput">
            </dd>
        </dl>
        <dl>
            <dt>修改相关类别：</dt>
            <dd>
                <input id="Item_F_TypeNames" type="text" class="textInput" onclick="Item_F_TypeNames_ShowMenu()">
                <div class="buttonActive"><div class="buttonContent"><button type="button" onclick="Item_Update_TypeIds()">提交</button></div></div>
            </dd>
        </dl>
    </fieldset>

    @*推荐多选下拉树*@
    <div id="Item_F_RecommendTypeName_Div" class="menuContent" style="display:none; position: absolute;">
        <ul id="Item_F_RecommendTypeName_Div_Tree" class="ztree" style="margin-top:0; width:180px; height: 300px;background-color:white;border:1px solid #efefef;"></ul>
    </div>

    @*单选树*@
    <div id="Item_F_TypeName_Div" class="menuContent" style="display:none; position: absolute;">
        <ul id="Item_TypeName_Div_Tree" class="ztree" style="margin-top:0; width:180px; height: 300px;background-color:white;border:1px solid #efefef;"></ul>
    </div>

    @*相关类别多选下拉树*@
    <div id="Item_F_TypeNames_Div" class="menuContent" style="display:none; position: absolute;">
        <ul id="Item_TypeNames_Div_Tree" class="ztree" style="margin-top:0; width:180px; height: 300px;background-color:white;border:1px solid #efefef;"></ul>
    </div>

</div>

@*列表功能脚本*@
<script type="text/javascript" language="javascript">
    var Item_TypeId =@ViewData["TypeId"].DefaultIsNullOrEmpty(10188);// 10188;
    var test = '@Html.ViewContext.RouteData.Values["id"]' + '_0';
    var isMidType=false;


    @*推荐ID*@
    var Item_F_RecommendTypeId = 11894;
    @*模块名称*@
    var Item_ModuleName='CmsImg';


    if (test != '_0') {
        test = test.replace('_0', '');
        Item_TypeId = test;
        isMidType = true;
    }

    var testMidId = '@Html.ViewContext.RouteData.Values["midId"]' + '_0';
    var isMidId = false;
    var testMidIdArg = '&F_CommonId=';
    var testSearchArg = "&strCommonId=";
    if (testMidId != '_0') {
        testMidIdArg += testMidId.replace('_0', '');
        testSearchArg += testMidId.replace('_0', '');
        isMidId = true;
    }

    //初始化获取列表信息
    function Item_GetList(TypeId, SearchInfo, OrderInfo, pageSize, currentPage, strName, strMarkStatus, strSearchType, strSearchDateType, strDateBegin, strDateEnd, isData, isAll) {

        if (isData == undefined) {
            isData = true;
        }

        if (isAll == undefined) {
            isAll = true;
        }

        url = "/Manage/CmsImg/List_Data";

        var isDataParam = "";

        if (isData == false) {
            isDataParam = "&isData=false";
        }

        params = "TypeId=" + TypeId + "&strName=" + strName +isDataParam + "&isAll=" + isAll + "&strSearchType=" + strSearchType + "&strDateBegin=" + strDateBegin + "&strDateEnd=" + strDateEnd + "&strSearchDateType=" + strSearchDateType + "&strMarkStatus=" + strMarkStatus + testSearchArg + "&strWhere=" + SearchInfo + "&strOrder=" + OrderInfo + "&pageSize=" + pageSize + "&currentPage=" + currentPage + "&num=" + Math.round(Math.random() * 10000);

        // 导出文件的处理
        if (isData == false) {
            window.open(url + "?" + params);
            return;
        }

        $.ajax({
            type: "GET",
            url: url,
            data: params,
            success: function (data) {
                if (Item_CheckLogin(data) == false) {
                    return;
                }

                $("#Item_TreeCode").html(TypeId);
                $("#Item_currentPage").html(currentPage);
                $("#Item_pageSize").html(pageSize);
                $("#Item_name").html(strName);
                $("#Item_markStatus").html(strMarkStatus);
                $("#Item_searchType").html(strSearchType);
                $("#Item_searchDateType").html(strSearchDateType);
                $("#Item_dateBegin").html(strDateBegin);
                $("#Item_dateEnd").html(strDateEnd);

                if(data.indexOf(',"statusCode":')>=0){
                    var info=eval('(' + data + ')');
                    if(info["statusCode"]=="300"){
                        alertMsg.error(info["message"])
                        return;
                    }
                }

                var aa = data[0].toString().replace(/Itemaa_/gi, 'Item_');

                // 用于子标签引用的使用在高度上的处理
                var MidNumber = $("#Item_MidNumber").html();
                if (MidNumber != '') {
                    aa = aa.replace('layouth="110"', 'layouth="' + MidNumber + '"');
                }

                $("#Item_TableInfo").html(aa);
                $("#Item_TableView").jTable();
                initUITwo();
                $(".gridTbody table tbody tr").css("cursor", "pointer");
                var pageCount = 0;
                if ($("#Item_TotalNum").html() % $("#Item_numPerPage").val() == 0) {
                    pageCount = $("#Item_TotalNum").html() / $("#Item_numPerPage").val();
                } else {
                    pageCount = $("#Item_TotalNum").html() / $("#Item_numPerPage").val() + 1;
                }
                $("#Item_pageCount").html(Math.floor(pageCount));
                initLayout();
                try {
                    var url = "/Manage/CmsImg/Edit?Action=Add&F_TypeId=" + TypeId;

                    url+="&AllTypeId="+@ViewData["TypeId"].DefaultIsNullOrEmpty(10188);

                    if (isMidId == true) {
                        url=url+testMidIdArg;
                    }

                    $("#Item_Add").attr("href",url);
                } catch (e) {
                }
                try{
                    var content = $(".dialogContent");
                    content.find("[layoutH]").layoutH(content);
                }catch(e){
                }
            }
        });
    }

    // 提交查询时处理
    function Item_subSearch() {
        $("#Item_currentPage").html(1);
        $("#Item_name").html($("#Item_F_Name").val());
        $("#Item_markStatus").html($("#Item_F_MarkStatus").val());
        $("#Item_searchType").html($("#Item_F_SearchType").val());
        $("#Item_searchDateType").html($("#Item_F_SearchDateType").val());
        $("#Item_dateBegin").html($("#Item_F_DateBegin").val());
        $("#Item_dateEnd").html($("#Item_F_DateEnd").val());
        Item_initData();
    }

    // 初始化数据
    function Item_initData(isData, isAll) {

        if (isData == undefined) {
            isData = true;
        }

        if (isAll == undefined) {
            isAll = true;
        }

        var currentPage = $("#Item_currentPage").html();
        if (currentPage == '') {
            currentPage = 1;
        }
        Item_GetList($("#Item_TreeCode").html(), '', $("#Item_OrderInfo").html(), $("#Item_pageSize").html(), currentPage, $("#Item_name").html(), $("#Item_markStatus").html(), $("#Item_searchType").html(), $("#Item_searchDateType").html(), $("#Item_dateBegin").html(), $("#Item_dateEnd").html(), isData, isAll);
    }

    // 当类别切换的时候数据的初始化，要清除必要的查询条件。
    function Item_firstinitData() {
        var currentPage = $("#Item_currentPage").html();
        if (currentPage == '') {
            currentPage = 1;
        }
        Item_GetList($("#Item_TreeCode").html(), '', '', $("#Item_pageSize").html(), currentPage, '', $("#Item_markStatus").html(), $("#Item_searchType").html(), $("#Item_searchDateType").html(), $("#Item_dateBegin").html(), $("#Item_dateEnd").html(),true,true);
    }
</script>

@Html.Partial("~/Areas/Manage/Views/Shared/PartialPage/Module/List/_Script_Function.cshtml")

@Html.Partial("~/Areas/Manage/Views/Shared/PartialPage/Module/List/_Script_Tree_Open.cshtml")
