var NewTemplateForm = {
    template: '<div>\
    				<div class="title-name c-f16">\
	    				<span class="c-vam">模板未命名</span>\
	    			</div>\
	    			<div class="c-t-center" style="margin-top: 240px;">\
	    				<span class="c-vam c-f14 mr5">模板名称: </span>\
	    				<input v-model="name" placeholder="请输入新模板名称" class="c-vam temp-name-inpt"/>\
	    				<a @click="save" href="javascript: void(0);" class="ml10 save-temp-name-btn c-f14 c-vam">保存</a>\
	    			</div>\
    			</div>',
    props: [],
    data: function() {
        return {
        	name:''
        }
    },
    beforeRouteEnter: function (to, from, next) {
	    next(function(vm) {
	    	vm.name = ""
	    })
	},
    mounted: function() {
    	var vm = this

    },
    methods: {
    	save: function() {
    		var vm = this
    		
    		if(vm.name) {
    			rehaAPI.createTemplate({
	    			doctor: storage.docInfo.code,
	    			title: vm.name
	    		}).then(function(res) {
	    			if(res.status == 200) {
	    				vm.$router.push({
			    			path:'/template-items',
			    			query: {
			    				name: vm.name,
			    				isNew: true,
			    				templateId: res.data
			    			}
			    		})
	    			} else {
	    				toastr && toastr.error(res.msg)
	    			}
	    			
	    		}).catch(function(e) {
	    			console.error(e)
	    		})
    		}
    	}
    }
}