<div class="main" id="main" v-cloak>
    <el-form ref="form" label-width="100px" label-position="left" >
        <el-form-item   label="附件表" v-show="Id!=''">
            <el-input type="text" maxlength="20" v-model="Name" class="form-control" disabled></el-input>
            <span class="help-block"></span>
        </el-form-item>

        <el-form-item label="父级表">
            <el-input v-model="ParentTable" :disabled="Id!=''" maxlength="50" v-validate="{data:ParentTable,dataType:'table',nullMsg:'请填写父级表！',ignore:Id>0}"></el-input>
            <span class="help-block">请确保父级表存在和对应关系，添加后不可修改</span>
        </el-form-item>

        <el-form-item label="备注">
            <el-input placeholder="仅用于标识，如文章附件表，产品附件表" v-model="Remark" maxlength="50" v-validate="{data:Remark,dataType:'*',nullMsg:'请填写标识！'}"></el-input>
            <span class="help-block">仅用于识别</span>
        </el-form-item>

        <el-form-item label="状态" v-show="Id!=''">
            <el-radio-group v-model="State">
                <el-radio :label="1">启用</el-radio>
                <el-radio :label="0">弃用</el-radio>
            </el-radio-group>
            <span class="help-block"></span>
        </el-form-item>
    </el-form>

    <div class="footer-submit-bar" style="padding-left:120px">
        <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.QueryString["id"]";
    var formData = @Html.Raw(Model);
    formData.OldState = formData.State;
    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 () { callBack() } });
                }
            }
        },
    });

    function callBack()
    {
        parent.loadData();
        if (id == "")
        {
            closeSelf();
        }
    }
</script>