<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AppMaster.Master"
    Inherits="System.Web.Mvc.ViewPage<QMAPP.Web.Models.Sys.NoticeBrowseModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    查看公告
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%=Html.QPEdit("查看公告", string.IsNullOrEmpty(Model.NOTICEID) ? QMFrameWork.WebUI.panelType.Add : QMFrameWork.WebUI.panelType.Update)%>
    <table id="editTable">
        <tr>
            <th align="right">
                <%=Html.QV(p => p.USETIME)%>
            </th>
            <td>
                <%=Html.QReadOnlyTextboxFor(p => p.USETIME)%>
            </td>
        </tr>        
        <tr>
            <th align="right" valign=top>
                <%=Html.QV(p => p.NOTICECONTEXT)%>
            </th>
            <td>
                <div class="validatebox-readonly" style="width: 600px; height: 200px; overflow: auto;">
                    <%=Model.NOTICECONTEXT%>
                </div> 
            </td>
        </tr>       
        <tr id="file">
            <th align="right" valign=top>
                <%=Html.QV(p => p.ATTACHFILE)%> 
            </th>
            <td>
               <a href="#" onclick="downAttach('<%=Model.ATTACHFILE%>','<%=Model.ATTACHFILE%>')"><%=Model.ATTACHFILE%></a>
            </td>  
        </tr>     
    </table>
    <table id="tblWorkMat" style="width: auto; height: 150px" iconcls="icon-edit">
        <thead>
            <tr>
                <th field="UserName" align="center" width="150">
                    浏览用户
                </th>
                <th field="REPLYCONTENT" align="center" width="300">
                    回复内容
                </th>
                <th field="REPLYTIMETXT" align="center" width="200">
                    回复时间
                </th> 
            </tr>
        </thead>
    </table> 
     <%=Html.HiddenFor(p=>p.INFOLIST) %> 
     <%=Html.HiddenFor(p => p.ATTACHFILE)%>
     <%=Html.HiddenFor(p => p.LogInUserName)%>
    <%=Html.QPEnd() %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ToolContent" runat="server">
     <table ><tr><td><%=Model.NOTICETITLE%></td></tr></table>
     
    <script type="text/javascript">
        $(function () {
            if (document.getElementById("ATTACHFILE").value == null || document.getElementById("ATTACHFILE").value == "") {
                var file = document.getElementById("file");
                file.style.display = "none";
            }

            var lastIndex;
            if (document.getElementById("INFOLIST") != null) {
                matData = JSON.parse(document.getElementById("INFOLIST").value);
            }

            if (matData != null) {

                $('#tblWorkMat').datagrid({});

                $('#tblWorkMat').datagrid("loadData", matData);
                $('#tblWorkMat').datagrid({
                    "loadData": matData,
                    onClickRow: function (rowIndex) {
                        $('#tblWorkMat').datagrid('endEdit', lastIndex);
                        $('#tblWorkMat').datagrid('beginEdit', rowIndex);

                        lastIndex = rowIndex;
                    }
                });

            }
        });

        //下载附件
        function downAttach(fileName, oldFileName) {
            $.ajax({
                type: "POST",
                url: "/Notice/ExistFile",
                dataType: "json",
                data: {
                    fileName: fileName,
                    oldFileName: oldFileName
                },
                success: function (data) {
                    if (data == "false") {
                        MSI("提示", "文件不存在!"); 
                        return false;
                    }
                    else {
                        submitByButton("/Notice/DownAttach?fileName=" + fileName + "&oldFileName=" + oldFileName);
                    }
                }
            });
        }
    </script>
</asp:Content>