<div class="main" id="main" v-cloak>
    <el-form ref="form" label-width="120px" label-position="left">
        <el-form-item label="分类备注">
            <el-input v-model="Remark" maxlength="50" v-validate="{data:Remark,dataType:'*',nullMsg:'请填写分类备注!'}"></el-input>
            <span class="help-block validate-tips-box">仅用于标识</span>
        </el-form-item>
                <el-form-item label="分类文件">
            <el-input v-model="Name" maxlength="50" v-validate="{data:Name,dataType:'routeFile',nullMsg:'请填写文件名称!',errorMsg:'文件必须包含Route.config!'}"></el-input>
            <span class="help-block validate-tips-box">每个分类将会在模板目录下创建一个*Route.config格式的文件</span>
        </el-form-item>
    </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 formData = { Name: "Route.config", Remark: "", FullName: "/Templates/@(ViewBag.CurrentTemplateDirectory)/" };
    if (request("formData")!="")
    {
        formData = JSON.parse(JSON.stringify(eval(request("formData"))));
    }
    var vue = new Vue({
        el: "#main",
        data: formData,
        methods: {
            postSubmit: function () {
                var validated = this.validateForm({tipsStyle: 1 });//jquery表单验证
                if (validated) {
                    this.submit({ url: "@Url.ActionUrl()", data: formData, success: "PostBack()" });
                }
            }
        },
    });
    function PostBack() {
        if (request("formData") == "") {
            location.href = location.href;
        }
        parent.loadData();
    }
    validateDataTypes.routeFile = function (gets, itemConfig) {
        if (gets.toLowerCase().indexOf("route.config")!=-1) {
            return true;
        }
        else {
            return false
        }
    }
</script>