<%@ Page Title="" Language="C#" MasterPageFile="~/Dialog/DialogMaster.Master" AutoEventWireup="true"
    CodeBehind="BaseAnnounceEdit.aspx.cs" Inherits="OAWeb.Announce.BaseAnnounceEdit" ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#aspnetForm").validate({
                /*验证规则*/
                rules: {
                    '<%=txtTitle.UniqueID %>': {
                        required: true
                    },
                    '<%=txtAnnounceContent.UniqueID %>': {
                        required: true
                    }
                },
                messages: {
                    '<%=txtTitle.UniqueID %>': {
                        required: "请输入标题"
                    },
                    '<%=txtAnnounceContent.UniqueID %>': {
                        required: "请输入公告内容"
                    }
                },
                /*重写错误显示消息方法,以alert方式弹出错误消息*/
                showErrors: function (errorMap, errorList) {
                    var msg = "";
                    $.each(errorList, function (i, v) {
                        msg += (v.message + "\r\n");
                    });
                    if (msg != "") alert(msg);
                },
                /* 失去焦点时不验证 */
                onkeyup: false,
                onfocusout: false
            });
        });
        // 传递给B页面
        function CloseCallbackFun() {
            var bText = art.dialog.data('departText');
            var bValue = art.dialog.data('departValue');
            if (bText != undefined) $('#<%=txtDepartmentList.ClientID %>').val(bText);
            if (bValue != undefined) $('#<%=hdfDepartmentList.ClientID %>').val(bValue);
        };

    </script>
    <script language="javascript" type="text/javascript" src='<%=ResolveUrl("~/ckeditor/ckeditor.js")%>'></script>
    <div class="form" style="width: 700px; height:450px; padding: 10px;">
        <table cellpadding="0" cellspacing="0" border="0" class="table_form">
            <tr>
                <td class="right">
                    公告类型：
                </td>
                <td>
                    <asp:DropDownList runat="server" ID="ddlAnnounceType">
                    <asp:ListItem Value="0">请选择</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="right">
                    面向部门：
                </td>
                <td>
                    <asp:TextBox ID="txtDepartmentList" runat="server" CssClass="text width400" Enabled="False"></asp:TextBox>
                    <asp:HiddenField ID="hdfDepartmentList" runat="server" />
                    <img class='ico03' src="/images/transparent.gif" onclick="return OpenDialog2('/Dialog/DepartmentSelectDialog.aspx','添加部门',CloseCallbackFun);" />
                </td>
            </tr>
            <tr>
                <td class="right" valign="top">
                    标题：
                </td>
                <td>
                    <asp:TextBox ID="txtTitle" runat="server" CssClass="text width400"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="right" valign="top">
                    关键字：
                </td>
                <td>
                    <asp:TextBox ID="txtKeyWord" runat="server" CssClass="text width400"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="right" valign="top">
                    公告内容：
                </td>
                <td style="vertical-align:top;">
                    <asp:TextBox ID="txtAnnounceContent" runat="server" TextMode="MultiLine"></asp:TextBox>
                    <script type="text/javascript">
                        CKEDITOR.replace('<%=txtAnnounceContent.ClientID %>',
                    {
                        skin: 'v2',
                        width: '600',
                        height: '200',
                        font_names: '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;',
                        toolbar: [
                        ['Bold', 'Italic', 'Underline', 'Strike', '-', 'NumberedList', 'BulletedList', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'Link', 'Unlink', 'Anchor', '-', 'Table', 'HorizontalRule', 'SpecialChar'],
                        ['Format', 'Font', 'FontSize', 'TextColor', 'BGColor']
                        ],
                        language: 'zh-cn'
                    })
                   
                    </script>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <input id="btnSave" type="button" value=" 保 存 " class="btn_77px" />
                    <input id="btnClose" type="button" value=" 返 回 " onclick="art.dialog.close();return false;"
                        class="btn_77px" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            rulesValue = { '<%=txtTitle.UniqueID %>': { required: true } };
            messagesValue = { '<%=txtTitle.UniqueID %>': { required: "请输入标题" }}
            var form = jQuery.validator.ValidateForm($("#aspnetForm"), rulesValue, messagesValue);
            $("#btnSave").click(function () {
                //把编辑值赋值到实际文本框，编辑器只在有post动作时才把值赋值给实际文本框。
                CKEDITOR.instances.<%=txtAnnounceContent.ClientID %>.updateElement(); 
                if (form.form()) {
                    $("#aspnetForm").ajaxSubmit({
                        url: "/Announce/BaseAnnounceEdit.aspx?op=Save&Id=<%=Id %>&r=" + Math.random(),
                        success: function (result) {
                            if (result == "ok") {
                                alert("保存成功");
                                CloseReload();
                            } else {
                                alert(result);
                            }
                        }
                    });
                }
                return false;
            })
        });
    </script>
</asp:Content>
