@{
    CurrentUser user = ViewBag.CurrentUser;
    string action = ViewContext.RouteData.Values["action"].ToString();
    IEnumerable<dynamic> fieldData = Html.GetFieldList((string)ViewBag.Table, action, user);
    string guid = Html.Guid();
}
<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="130px" label-position="left" style="width:830px">
        <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>
        <el-form-item label="备注">
            <el-input v-model="Remark"></el-input>
            <span class="help-block validate-tips-box"></span>
        </el-form-item>
        <el-form-item label="注册">
            <el-select v-model="CanReg" style="width:100%">
                <el-option label="开放注册" :key=1 :value=1></el-option>
                <el-option label="禁止注册" :key=0 :value=0></el-option>
            </el-select>
            <span class="help-block validate-tips-box"></span>
        </el-form-item>
        @{
            string beforeSubmitJs = "";
            var data = new ViewDataDictionary();
            data.Add("from", PageAdmin.Common.FromEnum.Admin);
            data.Add("guid", guid);
            data.Add("currentUser", ViewBag.CurrentUser);
            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-item label="等级" v-show="false">
            <el-input v-model="Rank" maxlength="3" style="width:200px;" v-validate="{data:Rank,dataType:'numeric',min:1,nullMsg:'请填写会员等级!',errorMsg:'只能填写大于等于1的数字！'}"></el-input>
            <span class="help-block validate-tips-box">等级不能重复</span>
        </el-form-item>
    </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 id = request("id");
    var formData =@Html.RawModel((string)Model ?? "{}");
    if (id == "") {
        formData.CanReg = 0;
        formData.IsDefault = 0;
        formData.Rank = parent.vue.dataList.length+1;
    }
    formData.Guid = "@guid";
    var vue = new Vue({
        el: "#main",
        data: formData,
        methods: {
            postSubmit: function () {
                var validated = this.validateForm({});//表单验证
                if (validated) {
                    this.submit({ url: "@Url.ActionUrl()", beforeExecute:"BeforeSubmit()", data: formData, success: "PostBack()" });
                }
            }
        }
    })
    function BeforeSubmit() {
        @Html.Raw(beforeSubmitJs)
        return true;
    }
    function PostBack() {
        if (id == "") {
            location.href = location.href
        }
        parent.loadData();
    }
</script>
