moduleCard.js
2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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;
				}
			}
		});
	}
});