@{ 
    List<string> fieldList = ViewBag.FieldList;
}
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
            <form method="post" class="form-horizontal form  form-control-sm ui-validForm" action="@Url.Action()" data-custom-params="beforeSubmit:'BeforeSubmit'">
                <div class="control-group">
                    <label class="control-label">数据来源：</label>
                    <div class="controls">
                        <span class="radio-inline">
                            <input class="ui-show-hide" showObjs=".conditionBox" type="radio" id="dataSource" name="dataSource" value="0" checked/>自定义
                        </span>
                        <span class="radio-inline">
                            <input class="ui-show-hide" hideObjs=".conditionBox"  type="radio" id="dataSource" name="dataSource" value="1" />列表页选中数据
                        </span>
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="conditionBox">
                    <div class="control-group">
                        <label class="control-label">会员类别：</label>
                        <div class="controls form-inline">
                            <select class="form-control" name="member_group_id" id="member_group_id">
                                <option value="">所有会员组</option>
                            </select>
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">会员部门：</label>
                        <div class="controls form-inline">
                            <select class="form-control" name="department_id" id="department_id">
                                <option value="">所有部门</option>
                            </select>
                            <span class="help-block"></span>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">状态：</label>
                        <div class="controls form-inline">
                            <select class="form-control" name="state" id="state">
                                <option value="-100">所有状态</option>
                                <option value="1">已审核</option>
                                <option value="0">待审核</option>
                                <option value="-1">已禁用</option>
                            </select>
                            <span class="help-block"></span>
                        </div>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">选择导出字段</label>
                    <div class="controls">
                        <select id="fields" name="fields" multiple="multiple" class="form-control" style="height:200px">
                          @foreach(var field in fieldList)
                          {
                              <option value="@field">@field</option>
                          }
                        </select>
                        <span class="help-block">不选择则默认导出所有字段,按住Ctrl键可实现多选</span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">排序方式</label>
                    <div class="controls">
                        <select id="order" class="ui-queryString form-control">
                            <option value="id desc">按注册时间↓</option>
                            <option value="id asc">按注册时间↑</option>
                            <option value="last_date desc">按最后登录时间↓</option>
                            <option value="logins desc">按登录次数↓</option>
                            <option value="fnc_rkze desc">按入款金额↓</option>
                            <option value="fnc_xfze desc">按消费金额↓</option>
                            <option value="fnc_fkze desc">按返款金额↓</option>
                            <option value="point_rkze desc">按充值积分数↓</option>
                            <option value="point_xfze desc">按消费积分数↓</option>
                            <option value="point_fkze desc">按返点积分数↓</option>
                        </select>
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="postarea">
                    <div class="control-group">
                        <div class="controls">
                            @Html.AntiForgeryToken()
                            <input type="hidden" id="ids" name="ids" />
                            <button type="button" class="btn btn-primary btn-sm ui-pagePost" data-custom-params="url:'@Url.Action()',callBack:'CallBack'">确定</button>
                            <button type="button" class="btn btn-default btn-sm ui-closeDialog">关闭</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    //判断是否和父级页面域名一样


    if (parent.location == self.location) {
        $(".main").html("无效的请求！");
    }

    //判断域名是否匹配
    if (document.domain != parent.document.domain) {
        $(".main").html("非法请求！");
    }

    var params = { valueField: 'id', textField: 'name' };/*绑定类别*/
    var listJson = CallAjax("get", false, "@Url.Action("ListData", "MemberGroup")?_isload=1");
    $("#member_group_id").FillSelect(eval(listJson), params);

    var params = { valueField: 'id', textField: 'name', isTree: true, onlySelectFinal: true };/*绑定部门*/
    var listJson = CallAjax("get", false, "@Url.Action("ListData", "Department")?_isload=1");
    $("#department_id").FillSelect(eval(listJson), params);

    var $fields = $("#fields");
    var $ids = $("#ids");
    var $parentIds = parent.$("input[name='id']");
    var ids = GetChecked($parentIds);
    $ids.val(ids);

    function BeforeSubmit()
    {
        if ($("[name='dataSource']").eq(1).prop("checked"))
        {
            if(ids=="")
            {
                Alert("您还没有选择数据，请在父页面选择要导出的会员!");
                return false;
            }
        }
        var selected = GetSelected($fields);
        if (selected == "")
        {
            SetSelected("select-all",$fields);
        }
        return true;
    }

    function CallBack(jsonData)
    {
        jsonData = JsonParse(jsonData);
        location.href=jsonData.Description;
        CloseDialog();
    }

</script>
