@{
    string guid = Html.Guid();
}
<div class="main">
    <script src="/Incs/UEditor/ueditor.js" type="text/javascript"></script>
    <form method="post" id="_form" class="form-horizontal form form-group-sm" data-source="@Model">
        <div class="control-group">
            <label class="control-label">选择发送类型</label>
            <div class="controls form-inline">
                <span class="radio-inline">
                    <input type="radio" name="SendType" id="SendType" value="0" checked class="ui-show-hide ui-edit-readonly" hideObjs=".byDepartment,.byUids,.byMemberGroup" />所有用户
                </span>
                <span class="radio-inline">
                    <input type="radio" name="SendType" id="SendType" value="1" class="ui-show-hide ui-edit-readonly" showObjs=".byMemberGroup" hideObjs=".byDepartment,.byUids" />按用户组发送
                </span>
                <span class="radio-inline">
                    <input type="radio" name="SendType" id="SendType" value="2" class="ui-show-hide ui-edit-readonly" showObjs=".byDepartment" hideObjs=".byMemberGroup,.byUids" />按部门发送
                </span>
                <span class="radio-inline">
                    <input type="radio" name="SendType" id="SendType" value="3" class="ui-show-hide ui-edit-readonly" showObjs=".byUids" hideObjs=".byDepartment,.byMemberGroup" />选择指定用户
                </span>
                <span class="help-block"></span>
            </div>
        </div>

        <div class="control-group byMemberGroup">
            <label class="control-label">选择接收用户组*</label>
            <div class="controls">
                <select id="SendMemberGroupIds" name="SendMemberGroupIds" class="form-control ui-convertSelect" multiple data-validate="dataType:'select',ignoreHidden:true,nullMsg:'请选择用户组!'" data-custom-params="url:'@Url.Action("LoadListByIds","MemberGroup")',textField: 'Name'" style="height:150px;"></select>
                <div class="btn-group btn-group-sm"  id="select_user_box">
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-dialog  ui-edit-readonly" data-custom-params="title:'选择用户组',url:'@Url.Action("Select","MemberGroup")?objname=#SendMemberGroupIds',width:'800px',height:'90%',target:'_self'">选择用户组</a>
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-removeSelectedOptions  ui-edit-readonly" title="按住Ctrl键可实现多选" data-custom-params="obj:'#SendMemberGroupIds'">删除选中</a>
                </div>
                <span class="help-block"></span>
            </div>
        </div>

        <div class="control-group byDepartment">
            <label class="control-label">选择接收的部门*</label>
            <div class="controls">
                <select id="SendDepartmentIds" name="SendDepartmentIds" class="form-control ui-convertSelect" multiple data-validate="dataType:'select',ignoreHidden:true,nullMsg:'请选择部门!'" data-custom-params="url:'@Url.Action("LoadListByIds","DepartMent")',textField: 'Name',onlySelectFinal:true" style="height:150px;"></select>
                <div class="btn-group btn-group-sm"  id="select_user_box">
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-dialog  ui-edit-readonly" data-custom-params="title:'选择部门',url:'@Url.Action("Select","Department")?objname=#SendDepartmentIds',width:'800px',height:'90%',target:'_self'">选择部门</a>
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-removeSelectedOptions  ui-edit-readonly" title="按住Ctrl键可实现多选" data-custom-params="obj:'#SendDepartmentIds'">删除选中</a>
                </div>
                <span class="help-block"></span>
            </div>
        </div>

        <div class="control-group byUids">
            <label class="control-label">选择接收用户*</label>
            <div class="controls">
                <select id="SendUids" name="SendUids" class="form-control ui-convertSelect" multiple data-validate="dataType:'select',ignoreHidden:true,nullMsg:'请选择用户!'" data-custom-params="url:'@Url.Action("LoadListByIds","Member")',textField: 'Username'" style="height:150px;"></select>
                <div class="btn-group btn-group-sm"  id="select_user_box">
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-dialog  ui-edit-readonly" data-custom-params="title:'选择用户',url:'@Url.Action("Select","Member")?objname=#SendUids',width:'800px',height:'90%',target:'_self'">选择用户</a>
                    <a href="javascript:void(0)" class="btn btn-default btn-sm ui-removeSelectedOptions  ui-edit-readonly" title="按住Ctrl键可实现多选" data-custom-params="obj:'#SendUids'">删除选中</a>
                </div>
                <span class="help-block"></span>
            </div>
        </div>

        <div class="control-group rkmoney">
            <label class="control-label">信息分类</label>
            <div class="controls">
                <select name="CategoryId" id="CategoryId" class="form-control" data-source="">
                    <option value="0">无分类</option>
                </select>
                <span class="help-block">信息所属的分类</span>
            </div>
        </div>

        <div class="control-group rkmoney">
            <label class="control-label">信息标题</label>
            <div class="controls">
                <input type="text" name="Title" id="Title" data-validate="dataType:'*',nullMsg:'请填写信息标题!'" maxlength="150" class="form-control" />
                <input type="hidden" name="old_title" id="old_title" />
                <span class="help-block">当前操作涉及的金额,只能填写数字</span>
            </div>
        </div>
        <div class="control-group profit">
            <label class="control-label">信息内容</label>
            <div class="controls">
                <textarea id="Content" name="Content" data-validate="dataType:'editor',nullMsg:'内容不能为空!',errorMsg:'内容不能为空!'"></textarea>
                <script type="text/javascript">
                    var _ueditor_Content = UE.getEditor('Content',
                        {
                            initialFrameWidth: null,
                            initialFrameHeight: 300,  //初始化编辑器高度,默认320
                            toolbars: _UeditorZdyConfig.normal,
                        }
                    );
                    _ueditor_Content.ready(function () {
                        _ueditor_Content.execCommand("serverparam", {
                            "guid": "@guid",
                            "tableName": "pa_msg",
                            "fieldName": "Content",
                        });
                    });
                </script>
                <span class="help-block"></span>
            </div>
        </div>


        <div class="control-group">
            <label class="control-label"></label>
            <div class="controls">
                @Html.AntiForgeryToken()
                <input type="hidden" name="Guid" id="Guid" value="@guid" />
                <input type="hidden" name="Uid" id="Uid" value="@ViewBag.Uid" />
                <input type="hidden" name="Username" id="Username" value="@ViewBag.UserName" />
                <input type="hidden" id="Id" name="Id" value="0" />
                <input type="hidden" name="_AttachmentFields" value="Content" />
                <button type="button" class="btn btn-primary btn-sm ui-pagePost" data-custom-params="url:'@Url.Action()',callBack:'PostRefreshBack'">提交</button>
                <button type="button" class="btn btn-sm btn-default btn-back ui-closeDialog">关闭</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
                    var $categoryId = $("#CategoryId");
                    $categoryId.SelectBind({ url: "@Url.Action("ListData", "MsgCategory")", async: false })

                    var id = Request("id");
                    if (IsInt(id))
                    {
                        $(".current-location").hide();
                        $("#_form").FormBind({ dataSourceFrom: "attr" });
                        BindSelect();
                    }

                    function BindSelect() //编辑页绑定select数据
                    {
                        var data = $("#_form").attr("data-source");
                        data = JsonParse(data);
                        var sendIds = data.SendIds;
                        if (data.SendType == 3)
                        {
                            var data = { "SendUids": sendIds }
                            $(".byUids").FormBind({}, data)
                        }
                       else if (data.SendType == 2) {
                            var data = { "SendDepartmentIds": sendIds }
                            $(".byDepartment").FormBind({}, data)
                        }
                        else if (data.SendType ==1) {
                            var data = { "SendMemberGroupIds": sendIds }
                            $(".byMemberGroup").FormBind({}, data)
                        }
                    }

</script>