@using PageAdmin.Utils;
@using PageAdmin.Common;
@{
    int isTabIframe = StringHelper.Format<int>(Request.QueryString["isTabIframe"]);
    int fieldId = ViewBag.FieldId;
    int parentId = ViewBag.ParentId;
    string parentGuid = ViewBag.parentGuid;
    string subTable = ViewBag.Table;
    CurrentUser currentUser = ViewBag.CurrentUser;
    string actionName = this.ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldDataList = Html.GetFieldList(subTable,"add", currentUser, (FromEnum)ViewBag.From, true);
    string guid = Html.Guid();
}
<script src="~/Incs/UEditor/ueditor.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-width="150px" label-position="left" size="medium">
        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("currentUser", currentUser);
            data.Add("guid", guid);
            data.Add("from", ViewBag.From);
            data.Add("detailId",ViewBag.DetailId);
            data.Add("fieldPrefix", "formData");
            data.Add("i", 0);
            int i = 0;
            foreach (var row in fieldDataList)
            {
                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" v-show="@isTabIframe==0">
        <el-button type="primary" v-on:click="postSubmit">提交保存</el-button>
        <el-button onclick="closeSelf()">关闭</el-button>
    </div>
</div>
<script type="text/javascript">
    var isTabIframe = @isTabIframe;
    var action="@actionName.ToLower()"
    var formData=@Html.RawModel((string)Model);
    formData.Guid = "@guid";
    formData.FieldId = "@fieldId";
    formData.ParentId = "@parentId";
    formData.ParentGuid = "@parentGuid";
    //提交前执行
    function beforeSubmitExecute() {
        @Html.Raw(beforeSubmitJs)
        return true;
    }
    var vue= new Vue({
          el: "#main",
          data: {
              formData: formData
          },
          methods:{
              validate: function () { //单独提出来信息表选项卡可能会用到
                 return this.validateForm({ beforeSubmit: function () { return beforeSubmitExecute() } });//表单验证
              },
              postSubmit:function (callback) {
                  if (this.validate())
                  {
                      this.submit({
                          url: "@Url.ActionUrl(actionName)",showSuccessMsg:(isTabIframe==0),data: formData,
                          success: function () {
                              callback();
                          },
                      });
                  }
              },
          },
    });

    //提交，从父页面触发
    function submit(callback) {
       vue.postSubmit(callback);
    }
</script>

