@{
    string guid = Html.Guid();
    CurrentUser user = ViewBag.CurrentUser;
}
<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 ref="form" label-width="120px" label-position="left" data-source="@Model">
        <el-form-item label="标签">
            <el-input v-model="Name" v-validate="{data:Name,dataType:'*',nullMsg:'请填写标签!'}"></el-input>
            <span class="help-block validate-tips-box"></span>
        </el-form-item>
        @{
            string beforeSubmitJs = "";
            var fieldData = Html.GetFieldList("pa_tag", "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("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:140px">
        <el-button type="primary" v-on:click="postSubmit">提交保存</el-button>
        <el-button onclick="closeSelf()">关闭</el-button>
    </div>
</div>
<script type="text/javascript">
    var id = request("id");
    var formData =@Html.RawModel((string)Model);
    formData.Guid = "@guid";
    if (formData.TableId == 0)
    {
        formData.TableId = "@ViewBag.TableId";
    }
    function beforeSubmit()
    {
        @Html.Raw(beforeSubmitJs)
        return true;
    }
    var vue = new Vue({
        el: "#main",
        data: formData,
        methods: {
            postSubmit: function () {
                var validated = this.validateForm();//jquery表单验证
                if (validated) {
                    this.submit({ url: "@Url.ActionUrl()", data: formData, success: function () { PostBack() } });
                }
            },
        },
    });
    function PostBack() {
        if (id == "") {
            location.href = location.href
        }
        parent.loadData();
    }
</script>
