@{
    string guid = Html.Guid();
    CurrentUser user = ViewBag.CurrentUser;
    int id = ViewBag.CurrentSiteId;
    int blockSet = StringHelper.Format<int>(Request.QueryString["blockset"]);//可视化区块
}
<script src="~/Incs/UEditor/ueditor.forAdmin.config.js" type="text/javascript"></script>
<script src="~/Incs/UEditor/ueditor.all.min.js" type="text/javascript"></script>
<div class="main" id="main" v-cloak>
    <div class="breadcrumb-box" v-show="@blockSet==0">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item><i class="el-icon-s-home"></i>@ViewBag.CurrentSiteName</el-breadcrumb-item>
            <el-breadcrumb-item>站点设置</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="form-box">
        <el-form label-position="left" label-width="150px" size="medium" >
            <el-form-item label="站点标识">
                <el-input v-model.trim="Remark" maxlength="50" v-validate="{data:Remark,dataType:'*',nullMsg:'请填写站点标识!'}"></el-input>
                <span class="help-block validate-tips-box">仅用于后台识别</span>
            </el-form-item>
            <el-form-item label="站点名称" prop="name">
                <el-input v-model.trim="Name" id="Name" name="Name" maxlength="50" v-validate="{data:Name,dataType:'*',nullMsg:'请填写站点名称!'}"></el-input>
                <span class="help-block validate-tips-box">默认作为前台页面的标题后缀</span>
            </el-form-item>
            <el-form-item label="默认缓存方案" style="width:600px">
                <el-input-convert placeholder="选择缓存方案" :clearable="true" v-model="HttpcacheSolutionId" :convert-url="'@Url.ActionUrl("getName","HttpCacheSolution")?id='+HttpcacheSolutionId">
                    <el-button type="button" v-on:click="dialog({title:'选择站点缓存方案',url:'@Url.ActionUrl("Select","HttpCacheSolution")?setData=parent.vue.HttpcacheSolutionId',width:'660px',height:'95%',target:'_self'})">选择</el-button>
                </el-input-convert>
                <span class="help-block" id="_ValidateTips_HttpcacheSolutionId">设置后会作用于站点的所有栏目，也可以在栏目管理中独立设置设置。</span>
            </el-form-item>
            <el-form-item label="访问目录">
                <el-input v-model.trim="Directory" id="Directory" name="Directory" v-validate="{data:Directory,dataType:'string',nullMsg:'请填写访问目录！'}" maxlength="20" v-on:change="NeedRestart=1"></el-input>
                <span class="help-block">如果网站未绑定域名，则用主域名+访问目录形式访问，<span class="text-danger">修改后必须重启进程才生效！</span></span>
            </el-form-item>
            <el-form-item label="绑定域名">
                <el-input v-model.trim="Domain" maxlength="500" v-on:change="NeedRestart=1"></el-input>
                <span class="help-block">如果网站未绑定域名，则用主域名+访问目录形式访问，<span class="text-danger">修改后必须重启进程才生效！</span></span>
            </el-form-item>

            <el-form-item label="模板目录">
                <ui-select v-model="TemplateDirectory" :options="TemplateDirectoryList" :clearable="false" :multiple="false" style="width:100%;" maxlength="100" v-validate="{data:TemplateDirectory,dataType:'*',nullMsg:'请选择模板目录!'}" v-on:change="NeedRestart=1"></ui-select>
                <span class="help-block" id="_ValidateTips_TemplateDirectory">模板目录在/Templates目录下，填写或修改时请确认目录是否存在，<span class="text-danger">修改后必须重启进程才生效！</span></span>
            </el-form-item>
            <el-form-item label="Gzip压缩">
                <el-switch v-model="Compression" active-text="开启" :active-value="1" :inactive-value="0"></el-switch>
                <span class="help-block">压缩可减少带宽消耗和提升访问速度，如果服务器的IIS中已开启了Gzip压缩，网站中就不需要再开启。</span>
            </el-form-item>
            @{
                string beforeSubmitJs = "";
                var fieldData = Html.GetFieldList("pa_site", "Add", user);
                var data = new ViewDataDictionary();
                data = new ViewDataDictionary();
                data.Add("from", PageAdmin.Common.FromEnum.Admin);
                data.Add("guid", guid);
                data.Add("currentUser", user);
                data.Add("detailId", id);
                data.Add("i", 0);
                int i = 0;
                if (fieldData != null)
                {
                    foreach (var row in fieldData)
                    {
                        data["i"] = i;
                        beforeSubmitJs += row.BeforeSubmitJs;
                        Html.RenderPartial("~/Areas/E/Views/CustomForm/FormPartial.cshtml", (object)row, data);
                        i++;
                    }
                }
            }
        </el-form>
        <div class="footer-submit-bar" style="padding-left:170px">
            <el-button type="primary" v-on:click="postSubmit">提交保存</el-button>
            <el-button onclick="closeSelf()" v-show="@blockSet==1">关闭</el-button>
        </div>
    </div>
</div>
<script type="text/javascript">
   var formData =@Html.RawModel((string)Model);
    formData.Guid = "@guid";
    formData.TemplateDirectoryList = [];
    formData.NeedRestart=0;
    //提交前执行
    function beforeSubmit() {
        var domainVal = formData.Domain
        vue.Domain = (domainVal.toLocaleLowerCase());
        return true;
    }

    var vue = new Vue({
        el: "#main",
        data: formData,
        methods: {
            postSubmit: function () {
                var _this = this;
                var validated = this.validateForm({ beforeSubmit: 'beforeSubmit' });//jquery表单验证
                if (validated) {
                    this.submit({
                        url: "@Url.ActionUrl("Edit")", data: formData, success: function () {}
                    });
                }
            },
        }
    });

    //加载数据
    function loadData()
    {
        vue.ajax({
            url: "@Url.ActionUrl("TemplatesDirectoryList", "TemplateManager")",
            data: {},
            success: function (responseData) {
                if (Array.isArray(responseData))
                {
                    var templateDirectoryList = [];
                    responseData.forEach(function (item, index) {
                        templateDirectoryList.push({ value: item.Name, label: item.Name });
                    })
                    formData.TemplateDirectoryList = templateDirectoryList;
                }
            }
        });
    }
    loadData();

</script>


