@{
    string guid = Html.Guid();
    CurrentUser user = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
}
<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>
    <el-form label-position="left" label-width="150px" size="medium" >
        <el-tabs type="card">
            <el-tab-pane label="内容设置">
                <el-form-item label="seo标题">
                    <el-input type="text" maxlength="150" v-model="seoSet.Title"></el-input>
                    <span class="help-block"></span>
                </el-form-item>
                <el-form-item label="seo关键词">
                    <el-input maxlength="200" v-model="seoSet.Keywords" class="form-control"></el-input>
                    <span class="help-block"></span>
                </el-form-item>
                <el-form-item label="seo描述">
                    <div class="controls">
                        <el-input type="textarea" class="form-control" v-model="seoSet.Description" :autosize="{ minRows:3, maxRows:6}"></el-input>
                        <span class="help-block"></span>
                    </div>
                </el-form-item>
                @{
                    IEnumerable<dynamic> fieldData = Html.GetFieldList("pa_column", action, user);
                    string beforeSubmitJs = "";
                    fieldData = Html.GetFieldList("pa_column_content_set","edit",user);
                    var data = new ViewDataDictionary();
                    data.Add("from", PageAdmin.Common.FromEnum.Admin);
                    data.Add("guid", guid);
                    data.Add("currentUser", ViewBag.CurrentUser);
                    data.Add("fieldPrefix", "columnContent");
                    data.Add("detailId", ViewBag.ContentSetId ?? 0);
                    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-tab-pane>
        </el-tabs>
    </el-form>
    <div class="footer-submit-bar" style="padding-left:150px">
        <el-button type="primary" v-on:click="postSubmit">提交保存</el-button>
        <el-button onclick="closeSelf()">关闭</el-button>
    </div>
</div>
<script type="text/javascript">
    var action= "@action";
    var postUrl= "@Url.ActionUrl("ContentSet")";
    var vueData = {
        columnId: @ViewBag.ColumnId,
        columnContent:@Html.RawModel((string)ViewBag.ContentSet),
        seoSet:@Html.Raw(ViewBag.SeoSet ?? "{}")
    };
    vueData.columnContent.Guid = "@guid";
        //提交前执行
    function beforeSubmitExecute() {
        @Html.Raw(beforeSubmitJs)
        return true;
    }
    var vue= new Vue({
          el: "#main",
          data: vueData,
          methods: {
              postSubmit: function () {
                  var validated = this.validateForm({beforeSubmit: function () { return beforeSubmitExecute() } });//jquery表单验证
                  if (validated) {
                      this.submit({ url: postUrl,data:vueData,contentType:"application/json"});
                  }
              },
          },
    });
</script>
