moduleCard.js 2.37 KB
define('module-card', ['vue','utils'], function (Vue,_u) {
	var template = '\
<li :data-tag = "tag" class="module-card" :class="{default: isdefault, checked: layoutInfo.exist, normal: layoutInfo.version > 1}" @click="toggleChecked">\n\
	<div class="icon"> <i class="iconfont" :class="layoutInfo.icon"></i></div>\n\
	<div class="title"> <p class="ellipsis" :title="layoutInfo.layoutname" v-text="layoutInfo.layoutname"></p>  <span v-text="layoutInfo.layouttype||layoutInfo.desc"></span> </div>\n\
</li>\
';

	return function() {
		Vue.component('module-card', {
			template: template,
			props: ['layout', "isdefault", "modelname", "type"],
			data: function() {
				return {
					layoutInfo: {}
				};
			},
			methods: {
				toggleChecked: function() {
					this.$emit("check");
				}
			},
			computed: {
				tag: function() {
					var tags = ["", "默认", "excel布局", "html布局"];

					if(this.isdefault) return tags[1];

					// 2 homepagelayout excel
					// 3 homepagelayout html
					return tags[this.layout.version];
				},
				layoutInfo: function() {
					var layout = this.layout,
						ltype = layout.type,
						type = this.type,
						modelname = this.modelname;
					
					if(ltype != undefined) {
						switch(ltype) {
							case 0: 
								this.layout.icon = "icon-display";break;
							case 1: 
								this.layout.icon = "icon-fileAdd";break;
							case 2: 
								this.layout.icon = "icon-edit";break;
							case 3:
								this.layout.icon = "icon-exception";break;
						}
						return this.layout;
					}

					switch(type) { //0显示 1新建 2编辑
						case 0:
							this.layout = {
								layoutname: _u.getHtmlNoteName(6082)+modelname,//显示
								icon: "icon-display",
								desc: _u.getHtmlNoteName(6079),//默认显示布局,
								exist: !!layout
							};
							break;
						case 1: 
							this.layout = {
								layoutname: _u.getHtmlNoteName(6081)+modelname,//新建
								icon: "icon-fileAdd",
								desc: _u.getHtmlNoteName(6078),//默认新建布局,
								exist: !!layout
							};
						break;
						case 2: 
							this.layout = {
								layoutname: _u.getHtmlNoteName(6083)+modelname,//编辑
								icon: "icon-edit",
								desc: _u.getHtmlNoteName(6080),//默认编辑布局,
								exist: !!layout
							};
						break;
						case 3:
							this.layout.icon = "icon-exception";break;
					}
					return this.layout;
				}
			}
		});
	}
});