@{
    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 form-inline">
                        <select class="form-control form-control-sm" name="member_group_id" id="member_group_id">
                            <option value="1">默认会员组</option>
                        </select>
                        <span class="help-block">如果excle表包含member_group_id字段，则表中的数值优先。</span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">导入会员部门：</label>
                    <div class="controls form-inline">
                        <select class="form-control form-control-sm" name="department_id" id="department_id">
                            <option value="0">无部门</option>
                        </select>
                        <span class="help-block">如果excle表包含department_id字段，则表中的数值优先。</span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">导入默认状态：</label>
                    <div class="controls form-inline">
                        <select class="form-control form-control-sm" name="state" id="state">
                            <option value="1">已审核</option>
                            <option value="0">待审核</option>
                            <option value="-1">禁用</option>
                        </select>
                        <span class="help-block">如果excle表包含state字段，则表中的数值优先。</span>
                    </div>
                </div>


                <div class="control-group">
                    <label class="control-label">上传Excle文件</label>
                    <div class="controls form-inline">
                        <input type="text" name="filePath" id="filePath" readonly class="ui-uploadPanel form-control form-control-sm" data-validate="dataType:'*" nullMsg:'请先上传excle文件！" data-custom-params="url:'@Url.Action("Index","UploadPanel")',rename:1,fileSingleSizeLimit:'10240',fileNumLimit:1,extensions:'xls,xlsx',uploadRootPath:'/Upload/Temp/'" />
                        <span class="help-block">只能上传.xls或.xlsx格式的excle文件</span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">Excle表名</label>
                    <div class="controls form-inline">
                        <input type="text" name="sheetName" id="sheetName" value="Sheet1" class="form-control form-control-sm" data-validate="dataType:'str" nullMsg:'请填写表名！" errorMsg:'表名请用英文字符或数字！" />
                        <span class="help-block">Excle表名建议用英文字符加数字，不要用中文字符</span>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label">是否异步导入</label>
                    <div class="controls form-inline">
                        <input type="checkbox" name="isAsync" id="isAsync" value="1" />如果Excle数据较大建议采用异步导入。
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="postarea">
                    <div class="control-group">
                        <div class="controls">
                            @Html.AntiForgeryToken()
                            <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);

    function BeforeSubmit() {
        return true;
    }

    function CallBack(jsonData) {
        parent.Msg("数据导入中，请稍微刷新页面查看！")
        CloseDialog();
    }

</script>
