<div class="main" id="main" v-cloak>
    <div class="breadcrumb-box">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item onclick="location.href=location.href"><i class="el-icon-s-home"></i>用户系统设置</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <el-tabs v-model="tabIndex" type="card">
        <el-tab-pane label="用户登录设置">
            <el-form ref="form" label-width="150px" label-position="left">
                <el-form-item label="登录功能">
                    <el-radio-group v-model="loginConfig.Open">
                        <el-radio :label="1">开启</el-radio>
                        <el-radio :label="0">关闭</el-radio>
                    </el-radio-group>
                    <span class="help-block validate-tips-box"></span>
                </el-form-item>
                <div v-if="loginConfig.Open=='1'">
                    <el-form-item label="登录方式">
                        <ui-checkbox v-model="loginConfig.LoginType" :options="loginTypeList"></ui-checkbox>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>

                    <el-form-item label="图片验证码">
                        <el-radio-group v-model="loginConfig.VerificationCode">
                            <el-radio :label="1">开启</el-radio>
                            <el-radio :label="0">关闭</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>
                    <el-form-item label="登录成功">
                        <el-checkbox v-model="loginConfig.SendEmail" :false-label="0" :true-label="1">发送邮件通知</el-checkbox>
                        <el-checkbox v-model="loginConfig.SendSms" :false-label="0" :true-label="1">发送短信通知</el-checkbox>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>
                    <el-form-item label="通知邮件设置" v-show="loginConfig.SendEmail==1">
                        <div>
                            <el-input v-model="loginConfig.EmailTitle" style="width:700px;"></el-input>
                            <span class="help-block validate-tips-box">通知邮件标题</span>
                        </div>
                        <div>
                            <el-input type="textarea" :rows="3" v-model="loginConfig.EmailContent" style="width:700px;"></el-input>
                            <span class="help-block validate-tips-box">通知邮件内容,占位符${username}表示当前用户名</span>
                        </div>
                    </el-form-item>
                    <el-form-item label="通知短信模板编号" v-show="loginConfig.SendSms==1">
                        <el-input v-model="loginConfig.SmsTemplateCode" style="width:700px;"></el-input>
                        <span class="help-block validate-tips-box">模板编号在接口提供商处设置并获取，模板占位符${username}表示当前用户名</span>
                    </el-form-item>
                    <el-form-item label="允许登录的用户组">
                        <ui-select v-model="loginConfig.MemberGroupIds" :multiple="true" style="width:700px;" v-bind:options="@Html.GetOptionsJson("pa_member_group","name","","Rank asc")"></ui-select>
                        <span class="help-block validate-tips-box">不选择则不进行用户组限制</span>
                    </el-form-item>
                    <el-form-item label="允许登录的部门">
                        <ui-cascader v-model="loginConfig.DepartmentIds" style="width:700px;" placeholder="请选择部门" :options="@Html.GetTreeOptionsJson("pa_department","name","","xuhao asc")" :props="{ expandTrigger: 'hover',multiple: true}"></ui-cascader>
                        <span class="help-block validate-tips-box">不选择则不进行部门限制</span>
                    </el-form-item>
                </div>

            </el-form>
        </el-tab-pane>
        <el-tab-pane label="用户注册设置">
            <el-form ref="form" label-width="150px" label-position="left">
                <el-form-item label="注册功能">
                    <el-radio-group v-model="regConfig.Open">
                        <el-radio :label="1">开启</el-radio>
                        <el-radio :label="0">关闭</el-radio>
                    </el-radio-group>
                    <span class="help-block validate-tips-box"></span>
                </el-form-item>
                <div v-if="regConfig.Open==1">

                    <el-form-item label="注册默认用户组">
                        <ui-select v-model="regConfig.DefaultMemberGroupId" placeholder="请选择默认注册用户组" style="width:700px;" v-bind:options="@Html.GetOptionsJson("pa_member_group","name","CanReg=1","Rank asc")"></ui-select>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>

                    <el-form-item label="手机注册设置">
                        <el-radio-group v-model="regConfig.MobileFieldSet">
                            <el-radio :label="0">不显示</el-radio>
                            <el-radio :label="1">必填项</el-radio>
                            <el-radio :label="2">必填项+手机验证码</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>

                    <el-form-item label="手机唯一性检测" v-show="regConfig.MobileFieldSet>0">
                        <el-radio-group v-model="regConfig.MobileOnlyOne">
                            <el-radio :label="1">是</el-radio>
                            <el-radio :label="0">否</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box">如果选择是，则一个手机只能注册一次</span>
                    </el-form-item>
                    <el-form-item label="邮箱注册设置">
                        <el-radio-group v-model="regConfig.EmailFieldSet">
                            <el-radio :label="0">不显示</el-radio>
                            <el-radio :label="1">必填项</el-radio>
                            <el-radio :label="2">必填项+邮件验证码</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>
                    <el-form-item label="邮箱唯一性检测" v-show="regConfig.EmailFieldSet>0">
                        <el-radio-group v-model="regConfig.EmailOnlyOne">
                            <el-radio :label=1>是</el-radio>
                            <el-radio :label=0>否</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box">如果选择是，则一个邮箱只能注册一次</span>
                    </el-form-item>
                    <el-form-item label="显示自定义字段">
                        <el-radio-group v-model="regConfig.ShowCustomField">
                            <el-radio :label="1">是</el-radio>
                            <el-radio :label="0">否</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box">自定义字段配置方法：系统管理>表>系统表>查找pa_member，进入字段管理中配置</span>
                    </el-form-item>
                    <el-form-item label="注册后状态">
                        <el-radio-group v-model="regConfig.DefaultState">
                            <el-radio :label="1">默认通过审核</el-radio>
                            <el-radio :label="0">需后台审核</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box">注册后的用户默认状态。</span>
                    </el-form-item>

                    <el-form-item label="注册成功登录状态">
                        <el-radio-group v-model="regConfig.RegSuccessLogin">
                            <el-radio :label="1">自动登录</el-radio>
                            <el-radio :label="0">跳转登录界面</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box">注：默认已审核的用户才能自动登录。</span>
                    </el-form-item>

                    <el-form-item label="OAuth2.0自动注册">
                        <el-radio-group v-model="regConfig.OAuth2AutoReg">
                            <el-radio :label="1">开启</el-radio>
                            <el-radio :label="0">关闭</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box">手机验证码、QQ、微信等第三方授权未绑定账号时，是否自动注册新账号</span>
                    </el-form-item>

                    <el-form-item label="图片验证码">
                        <el-radio-group v-model="regConfig.VerificationCode">
                            <el-radio :label="1">开启</el-radio>
                            <el-radio :label="0">关闭</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>

                    <el-form-item label="注册成功通知">
                        <el-checkbox v-model="regConfig.SendEmail" :false-label="0" :true-label="1">发送邮件通知</el-checkbox>
                        <el-checkbox v-model="regConfig.SendSms" :false-label="0" :true-label="1">发送短信通知</el-checkbox>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>

                    <el-form-item label="通知邮件设置" v-show="regConfig.SendEmail=='1'">
                        <div>
                            <el-input v-model="regConfig.EmailTitle" style="width:700px;"></el-input>
                            <span class="help-block validate-tips-box">通知邮件标题</span>
                        </div>
                        <div>
                            <el-input type="textarea" :rows="3" v-model="regConfig.EmailContent" style="width:700px;"></el-input>
                            <span class="help-block validate-tips-box">通知邮件内容，占位符${username}表示注册用户，${password}表示密码</span>
                        </div>
                    </el-form-item>
                    <el-form-item label="通知短信模板编号" v-show="regConfig.SendSms=='1'">
                        <el-input v-model="regConfig.SmsTemplateCode" style="width:700px;"></el-input>
                        <span class="help-block validate-tips-box">填写模板编号，模板占位符${username}表示注册用户，${password}表示密码。</span>
                    </el-form-item>
                </div>
                <el-form-item label="注册协议设置" id="Login_smsSet">
                    <el-button v-on:click="dialog({title:'注册协议设置', url:'@Url.ActionUrl("RegAgreement")',width:'100%',height:'100%'})" size="small">设置用户注册协议</el-button>
                </el-form-item>
            </el-form>
        </el-tab-pane>
        <el-tab-pane label="找回密码设置" name="2">
            <el-form ref="form" label-width="150px" label-position="left">
                <el-form-item label="找回密码功能">
                    <el-radio-group v-model="findPassConfig.Open">
                        <el-radio :label="1">开启</el-radio>
                        <el-radio :label="0">关闭</el-radio>
                    </el-radio-group>
                    <span class="help-block validate-tips-box"></span>
                </el-form-item>
                <div v-if="findPassConfig.Open==1">
                    <el-form-item label="密码找回方式">
                        <el-checkbox v-model="findPassConfig.FindByEmail" :false-label="0" :true-label="1">通过邮箱验证码找回</el-checkbox>
                        <el-checkbox v-model="findPassConfig.FindByMobile" :false-label="0" :true-label="1">通过手机验证码短信找回</el-checkbox>
                        <span class="help-block validate-tips-box">用户的邮箱或手机必须通过验证才能用于密码找回</span>
                    </el-form-item>
                    <el-form-item label="图片验证码">
                        <el-radio-group v-model="findPassConfig.VerificationCode">
                            <el-radio :label="1">开启</el-radio>
                            <el-radio :label="0">关闭</el-radio>
                        </el-radio-group>
                        <span class="help-block validate-tips-box"></span>
                    </el-form-item>
                </div>
            </el-form>
        </el-tab-pane>
        <el-tab-pane label="用户中心设置">
            <el-form ref="form" label-width="150px" label-position="left" >
                <el-form-item label="用户中心首页链接">
                    <el-input v-model="memberCenterConfig.HomeLink" style="width:700px;"></el-input>
                    <span class="help-block validate-tips-box">用户中心返回首页的链接地址，不设置则默认系统绑定的主域名</span>
                </el-form-item>

                <el-form-item label="登录是否完善资料">
                    <el-select v-model="memberCenterConfig.LoginedMustFillInformation" placeholder="请选择" style="width:400px;color:black;">
                        <el-option :value="1" label="是"></el-option>
                        <el-option :value="0" label="否"></el-option>
                    </el-select>
                    <span class="help-block validate-tips-box">设置为是后，用户登录后将强制到资料页面完善资料。</span>
                </el-form-item>
                <el-form-item label="用户中心公告栏目">
                    <ui-select-popup v-model="memberCenterConfig.MemberNoticeColumnId" url="@Url.ActionUrl("PopupDataList", "Column")" btn-title="选择" th-title="选择栏目" options-url="@Url.ActionUrl("GetColumnPathOptions", "Column")" source-list-type="tree-list" :multiple="false"></ui-select-popup>
                    <span class="help-block validate-tips-box">只能选择信息类栏目，非信息类栏目选择后不生效</span>
                </el-form-item>
                <el-form-item label="管理中心公告栏目">
                    <ui-select-popup v-model="memberCenterConfig.AdminNoticeColumnId" url="@Url.ActionUrl("PopupDataList", "Column")" btn-title="选择" th-title="选择栏目" options-url="@Url.ActionUrl("GetColumnPathOptions", "Column")" source-list-type="tree-list" :multiple="false"></ui-select-popup>
                    <span class="help-block validate-tips-box">只能选择信息类栏目，非信息类栏目选择后不生效</span>
                </el-form-item>
            </el-form>
        </el-tab-pane>
    </el-tabs>
    <div class="footer-submit-bar" style="padding-left:170px">
        <el-button type="primary" v-on:click="postSubmit">提交保存</el-button>
    </div>
</div>
<script type="text/javascript">
    var configData = {
        loginConfig:@Html.Raw(ViewBag.LoginConfig),
        regConfig:@Html.Raw(ViewBag.RegConfig),
        findPassConfig:@Html.Raw(ViewBag.FindPassConfig),
        memberCenterConfig:@Html.Raw(ViewBag.MemberCenterConfig),
    };

    var vue = new Vue({
        el: "#main",
        data: {
            tabIndex: 0,
            loginConfig: configData.loginConfig,
            regConfig: configData.regConfig,
            findPassConfig: configData.findPassConfig,
            memberCenterConfig: configData.memberCenterConfig,
            memberGroup: [],
            loginTypeList: [{ value: 'username', label: '账号+密码', disabled: true }, { value: 'mobile', label: '手机+手机验证码' }]
        },
        methods: {
            postSubmit: function () {
                var validated = this.validateForm({});//jquery表单验证
                if (validated) {
                    this.submit({ url: "@Url.ActionUrl("Update")", data: configData, contentType: "application/json" });
                }
            }
        }
    });
</script>


