|
@@ -3,197 +3,204 @@ var $ = require('jquery'), |
|
@@ -3,197 +3,204 @@ var $ = require('jquery'), |
3
|
util = require('../common/util');
|
3
|
util = require('../common/util');
|
4
|
|
4
|
|
5
|
|
5
|
|
6
|
- new common.dropDown({el: "#subject-type"});
|
|
|
7
|
- new common.dropDown({el: "#subject-paltform"});
|
|
|
8
|
- new common.dropDown({el: "#subject-status"});
|
|
|
9
|
-
|
|
|
10
|
- var g = new common.grid({
|
|
|
11
|
- el: "#subject-manage",
|
|
|
12
|
- parms: function () {
|
|
|
13
|
- return {
|
|
|
14
|
- sort: common.util.__input('subject-type'),
|
|
|
15
|
- plateform: common.util.__input('subject-paltform'),
|
|
|
16
|
- status: common.util.__input('subject-status')
|
|
|
17
|
- };
|
|
|
18
|
- },
|
|
|
19
|
- columns: [
|
|
|
20
|
- {display: "ID", name: "id"},
|
|
|
21
|
- {display: "分类", name: "sort", render: function (item) {
|
|
|
22
|
- if(item.sort == "1") return "奥莱";
|
|
|
23
|
- else if(item.sort == "2") return "SALE";
|
|
|
24
|
- }},
|
|
|
25
|
- {display: "排序", name: "orderNum"},
|
|
|
26
|
- {display: "标题", name: "title"},
|
|
|
27
|
- {display: "封面图", name: "coverUrl", render: function (item) {
|
|
|
28
|
- return '<img src="'+item.coverUrl+'" height="100px" />';
|
|
|
29
|
- }},
|
|
|
30
|
- {display: "促销形式", name: "promotionName"},
|
|
|
31
|
- {display: "平台", name: "plateform", render: function (item) {
|
|
|
32
|
-
|
|
|
33
|
- if(item.plateform != null && item.plateform.trim() != "") {
|
|
|
34
|
- var paltform = item.plateform;
|
|
|
35
|
- var temp = paltform.replace("1", "WEB").replace("2", "APP").replace("3", "WAP").replace("4", "IPAD");
|
|
|
36
|
- return temp;
|
|
|
37
|
- }
|
|
|
38
|
- }},
|
|
|
39
|
- {display: "状态", name: "status", render: function (item) {
|
|
|
40
|
- if(item.status == 1) return "未定时";
|
|
|
41
|
- else if(item.status == 2) return "未发布";
|
|
|
42
|
- else if(item.status == 3) return "已发布";
|
|
|
43
|
- else if(item.status == 4) return "已结束";
|
|
|
44
|
- }},
|
|
|
45
|
- {display: "创建时间", name: "createTime", render: function (item) {
|
|
|
46
|
- if(!item.createTime) return "";
|
|
|
47
|
- return Bll.getLocalTime(item.createTime);
|
|
|
48
|
- }},
|
|
|
49
|
- {display: "活动时间", name: "", render: function (item) {
|
|
|
50
|
- // return new Date(item.startTime).toStri34ng() + "~" + new Date(item.endTime).tostring();
|
|
|
51
|
- if(!item.startTime || !item.endTime) return "";
|
|
|
52
|
- return Bll.getLocalTime(item.startTime) + "~" + Bll.getLocalTime(item.endTime);
|
|
|
53
|
- }},
|
|
|
54
|
- {
|
|
|
55
|
- display: "操作", name: "", render: function (item) {
|
|
|
56
|
- var arr = [];
|
|
|
57
|
- arr.push('<a class="btn btn-info add2" data-index="' + item.__index + '">编辑</a>');
|
|
|
58
|
- arr.push('<a class="btn btn-info delbtn" data-index="' + item.__index + '">删除</a>');
|
|
|
59
|
- return arr.join("");
|
|
|
60
|
- }
|
6
|
+new common.dropDown({el: "#subject-type"});
|
|
|
7
|
+new common.dropDown({el: "#subject-paltform"});
|
|
|
8
|
+new common.dropDown({el: "#subject-status"});
|
|
|
9
|
+
|
|
|
10
|
+var yhChannelArr = ["男生", "女生", "儿童", "创意生活"];
|
|
|
11
|
+
|
|
|
12
|
+var g = new common.grid({
|
|
|
13
|
+ el: "#subject-manage",
|
|
|
14
|
+ parms: function () {
|
|
|
15
|
+ return {
|
|
|
16
|
+ sort: common.util.__input('subject-type'),
|
|
|
17
|
+ plateform: common.util.__input('subject-paltform'),
|
|
|
18
|
+ status: common.util.__input('subject-status')
|
|
|
19
|
+ };
|
|
|
20
|
+ },
|
|
|
21
|
+ columns: [
|
|
|
22
|
+ {display: "ID", name: "id"},
|
|
|
23
|
+ {display: "分类", name: "sort", render: function (item) {
|
|
|
24
|
+ if(item.sort == "1") return "奥莱";
|
|
|
25
|
+ else if(item.sort == "2") return "SALE";
|
|
|
26
|
+ }},
|
|
|
27
|
+ {display: "排序", name: "orderNum"},
|
|
|
28
|
+ {display: "标题", name: "title"},
|
|
|
29
|
+ {display: "封面图", name: "coverUrl", render: function (item) {
|
|
|
30
|
+ return '<img src="'+item.coverUrl+'" height="100px" />';
|
|
|
31
|
+ }},
|
|
|
32
|
+ {display: "促销形式", name: "promotionName"},
|
|
|
33
|
+ {display: "平台", name: "plateform", render: function (item) {
|
|
|
34
|
+
|
|
|
35
|
+ if(item.plateform != null && item.plateform.trim() != "") {
|
|
|
36
|
+ var paltform = item.plateform;
|
|
|
37
|
+ var temp = paltform.replace("1", "WEB").replace("2", "APP").replace("3", "WAP").replace("4", "IPAD");
|
|
|
38
|
+ return temp;
|
61
|
}
|
39
|
}
|
|
|
40
|
+ }},
|
|
|
41
|
+ {display:"频道", name:"yhChannel", render: function (item) {
|
|
|
42
|
+ if(item.yhChannel) {
|
|
|
43
|
+ return yhChannelArr[item.yhChannel-1];
|
|
|
44
|
+ }
|
|
|
45
|
+ }},
|
|
|
46
|
+ {display: "状态", name: "status", render: function (item) {
|
|
|
47
|
+ if(item.status == 1) return "未定时";
|
|
|
48
|
+ else if(item.status == 2) return "未发布";
|
|
|
49
|
+ else if(item.status == 3) return "已发布";
|
|
|
50
|
+ else if(item.status == 4) return "已结束";
|
|
|
51
|
+ }},
|
|
|
52
|
+ {display: "创建时间", name: "createTime", render: function (item) {
|
|
|
53
|
+ if(!item.createTime) return "";
|
|
|
54
|
+ return Bll.getLocalTime(item.createTime);
|
|
|
55
|
+ }},
|
|
|
56
|
+ {display: "活动时间", name: "", render: function (item) {
|
|
|
57
|
+ // return new Date(item.startTime).toStri34ng() + "~" + new Date(item.endTime).tostring();
|
|
|
58
|
+ if(!item.startTime || !item.endTime) return "";
|
|
|
59
|
+ return Bll.getLocalTime(item.startTime) + "~" + Bll.getLocalTime(item.endTime);
|
|
|
60
|
+ }},
|
|
|
61
|
+ {
|
|
|
62
|
+ display: "操作", name: "", render: function (item) {
|
|
|
63
|
+ var arr = [];
|
|
|
64
|
+ arr.push('<a class="btn btn-info add2" data-index="' + item.__index + '">编辑</a>');
|
|
|
65
|
+ arr.push('<a class="btn btn-info delbtn" data-index="' + item.__index + '">删除</a>');
|
|
|
66
|
+ return arr.join("");
|
|
|
67
|
+ }
|
|
|
68
|
+ }
|
62
|
|
69
|
|
63
|
- ]
|
|
|
64
|
- });
|
|
|
65
|
-
|
|
|
66
|
- g.init('/runManage/subjectManage/subjectList');
|
|
|
67
|
-
|
|
|
68
|
- var Bll = {
|
|
|
69
|
- getLocalTime:function(nS) {
|
|
|
70
|
- var date = new Date(parseInt(nS) * 1000);
|
|
|
71
|
- var mm = date.getMonth() + 1;
|
|
|
72
|
- var dd = date.getDate();
|
|
|
73
|
- return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd);
|
|
|
74
|
- },
|
|
|
75
|
- toast:function(url, item, hint) {
|
|
|
76
|
- var e = new common.edit("#baseform", {bucket:"activity"});
|
|
|
77
|
-
|
|
|
78
|
- e.on("validate",function() {
|
|
|
79
|
- var startTime=$("#startTime").val();
|
|
|
80
|
- var endTime=$("#endTime").val();
|
|
|
81
|
- if((startTime==""&&endTime=="") || (startTime!=""&&endTime!="")){}else{
|
|
|
82
|
- return "开始时间和结束时间必须同时存在";
|
|
|
83
|
- }
|
|
|
84
|
- });
|
|
|
85
|
- e.on("validate", function() {
|
|
|
86
|
- var temp = $("#productPoolId").val();
|
|
|
87
|
- if(!temp || temp == -1) {
|
|
|
88
|
- return "请填写商品池";
|
|
|
89
|
- }
|
|
|
90
|
- });
|
70
|
+ ]
|
|
|
71
|
+});
|
|
|
72
|
+
|
|
|
73
|
+g.init('/runManage/subjectManage/subjectList');
|
|
|
74
|
+
|
|
|
75
|
+var Bll = {
|
|
|
76
|
+ getLocalTime:function(nS) {
|
|
|
77
|
+ var date = new Date(parseInt(nS) * 1000);
|
|
|
78
|
+ var mm = date.getMonth() + 1;
|
|
|
79
|
+ var dd = date.getDate();
|
|
|
80
|
+ return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd);
|
|
|
81
|
+ },
|
|
|
82
|
+ toast:function(url, item, hint) {
|
|
|
83
|
+ var e = new common.edit("#baseform", {bucket:"activity"});
|
|
|
84
|
+
|
|
|
85
|
+ e.on("validate",function() {
|
|
|
86
|
+ var startTime=$("#startTime").val();
|
|
|
87
|
+ var endTime=$("#endTime").val();
|
|
|
88
|
+ if((startTime==""&&endTime=="") || (startTime!=""&&endTime!="")){}else{
|
|
|
89
|
+ return "开始时间和结束时间必须同时存在";
|
|
|
90
|
+ }
|
|
|
91
|
+ });
|
|
|
92
|
+ e.on("validate", function() {
|
|
|
93
|
+ var temp = $("#productPoolId").val();
|
|
|
94
|
+ if(!temp || temp == -1) {
|
|
|
95
|
+ return "请填写商品池";
|
|
|
96
|
+ }
|
|
|
97
|
+ });
|
91
|
|
98
|
|
92
|
- e.on("validate", function() {
|
|
|
93
|
- if(($("#promotion1").is(":checked") && !$("#promotionName1").val())
|
99
|
+ e.on("validate", function() {
|
|
|
100
|
+ if(($("#promotion1").is(":checked") && !$("#promotionName1").val())
|
94
|
|| ($("#promotion2").is(":checked") && (!$("#promotionName2").val() || !$("#promotionName3").val()))
|
101
|
|| ($("#promotion2").is(":checked") && (!$("#promotionName2").val() || !$("#promotionName3").val()))
|
95
|
|| ($("#promotion4").is(":checked") && !$("#promotionName4").val())
|
102
|
|| ($("#promotion4").is(":checked") && !$("#promotionName4").val())
|
96
|
|| ($("#promotion5").is(":checked") && !$("#promotionName5").val())) {
|
103
|
|| ($("#promotion5").is(":checked") && !$("#promotionName5").val())) {
|
97
|
- return "请将折扣形式填写完整";
|
|
|
98
|
- }
|
|
|
99
|
- });
|
|
|
100
|
-
|
|
|
101
|
- var dialog=common.dialog.confirm(hint,
|
|
|
102
|
- common.util.__template($("#template").html(), item),
|
|
|
103
|
- function() {
|
|
|
104
|
- e.submit(url,function(option){
|
|
|
105
|
- //option.data;
|
|
|
106
|
- if(typeof option.data.startTime == "string") {
|
|
|
107
|
- option.data.startTime=new Date(option.data.startTime).getTime() / 1000;
|
|
|
108
|
- option.data.endTime=new Date(option.data.endTime).getTime() / 1000;
|
|
|
109
|
- }
|
|
|
110
|
-
|
|
|
111
|
- var val=$('input:radio[name="promotionName"]:checked').val();
|
|
|
112
|
- if(val == 1) {
|
|
|
113
|
- option.data.promotionName = $("#promotionName1").val() + "折起";
|
|
|
114
|
- }else if(val == 2) {
|
|
|
115
|
- option.data.promotionName = $("#promotionName2").val() + "~" + $("#promotionName3").val() + "折";
|
|
|
116
|
- }else if(val == 4) {
|
|
|
117
|
- option.data.promotionName = $("#promotionName4").val() + "元起";
|
|
|
118
|
- }else if(val == 5) {
|
|
|
119
|
- option.data.promotionName = $("#promotionName5").val() + "%Off";
|
|
|
120
|
- }
|
|
|
121
|
-
|
|
|
122
|
- option.success=function(res){
|
|
|
123
|
- dialog.close();
|
|
|
124
|
- util.__tip(res.data.message, 'success');
|
|
|
125
|
- g.reload();
|
|
|
126
|
- };
|
|
|
127
|
- option.error=function(res){
|
|
|
128
|
- dialog.close();
|
|
|
129
|
- util.__tip(res.data.message);
|
|
|
130
|
- }
|
|
|
131
|
- });
|
|
|
132
|
- return false;
|
104
|
+ return "请将折扣形式填写完整";
|
|
|
105
|
+ }
|
|
|
106
|
+ });
|
|
|
107
|
+
|
|
|
108
|
+ var dialog=common.dialog.confirm(hint,
|
|
|
109
|
+ common.util.__template($("#template").html(), item),
|
|
|
110
|
+ function() {
|
|
|
111
|
+ e.submit(url,function(option){
|
|
|
112
|
+ //option.data;
|
|
|
113
|
+ if(typeof option.data.startTime == "string") {
|
|
|
114
|
+ option.data.startTime=new Date(option.data.startTime).getTime() / 1000;
|
|
|
115
|
+ option.data.endTime=new Date(option.data.endTime).getTime() / 1000;
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+ var val=$('input:radio[name="promotionName"]:checked').val();
|
|
|
119
|
+ if(val == 1) {
|
|
|
120
|
+ option.data.promotionName = $("#promotionName1").val() + "折起";
|
|
|
121
|
+ }else if(val == 2) {
|
|
|
122
|
+ option.data.promotionName = $("#promotionName2").val() + "~" + $("#promotionName3").val() + "折";
|
|
|
123
|
+ }else if(val == 4) {
|
|
|
124
|
+ option.data.promotionName = $("#promotionName4").val() + "元起";
|
|
|
125
|
+ }else if(val == 5) {
|
|
|
126
|
+ option.data.promotionName = $("#promotionName5").val() + "%Off";
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ option.success=function(res){
|
|
|
130
|
+ dialog.close();
|
|
|
131
|
+ util.__tip(res.data.message, 'success');
|
|
|
132
|
+ g.reload();
|
|
|
133
|
+ };
|
|
|
134
|
+ option.error=function(res){
|
|
|
135
|
+ dialog.close();
|
|
|
136
|
+ util.__tip(res.data.message);
|
|
|
137
|
+ }
|
133
|
});
|
138
|
});
|
134
|
- //提取折扣信息
|
|
|
135
|
- if(item.promotionName) {
|
|
|
136
|
- if(item.promotionName.indexOf("折起") != -1) {
|
|
|
137
|
- $('#promotionName1').val(item.promotionName.replace("折起", ""));
|
|
|
138
|
- $("#promotion1").attr("checked","checked");
|
|
|
139
|
- } else if(item.promotionName.indexOf("折") != -1) {
|
|
|
140
|
- $('#promotionName2').val(item.promotionName.split("~")[0]);
|
|
|
141
|
- $('#promotionName3').val(item.promotionName.split("~")[1]);
|
|
|
142
|
- $("#promotion2").attr("checked","checked");
|
|
|
143
|
- } else if(item.promotionName.indexOf("元起") != -1) {
|
|
|
144
|
- $('#promotionName4').val(item.promotionName.replace("元起", ""));
|
|
|
145
|
- $("#promotion4").attr("checked","checked");
|
|
|
146
|
- } else if(item.promotionName.indexOf("%") != -1) {
|
|
|
147
|
- var promotionName5 = $("#promotionName5");
|
|
|
148
|
- var temp = item.promotionName.replace("%", "");
|
|
|
149
|
- temp = temp.replace(/off/i, "");
|
|
|
150
|
- promotionName5.val(temp);
|
|
|
151
|
- $("#promotion5").attr("checked","checked");
|
|
|
152
|
- }
|
139
|
+ return false;
|
|
|
140
|
+ });
|
|
|
141
|
+ //提取折扣信息
|
|
|
142
|
+ if(item.promotionName) {
|
|
|
143
|
+ if(item.promotionName.indexOf("折起") != -1) {
|
|
|
144
|
+ $('#promotionName1').val(item.promotionName.replace("折起", ""));
|
|
|
145
|
+ $("#promotion1").attr("checked","checked");
|
|
|
146
|
+ } else if(item.promotionName.indexOf("折") != -1) {
|
|
|
147
|
+ $('#promotionName2').val(item.promotionName.split("~")[0]);
|
|
|
148
|
+ $('#promotionName3').val(item.promotionName.split("~")[1]);
|
|
|
149
|
+ $("#promotion2").attr("checked","checked");
|
|
|
150
|
+ } else if(item.promotionName.indexOf("元起") != -1) {
|
|
|
151
|
+ $('#promotionName4').val(item.promotionName.replace("元起", ""));
|
|
|
152
|
+ $("#promotion4").attr("checked","checked");
|
|
|
153
|
+ } else if(item.promotionName.indexOf("%") != -1) {
|
|
|
154
|
+ var promotionName5 = $("#promotionName5");
|
|
|
155
|
+ var temp = item.promotionName.replace("%", "");
|
|
|
156
|
+ temp = temp.replace(/off/i, "");
|
|
|
157
|
+ promotionName5.val(temp);
|
|
|
158
|
+ $("#promotion5").attr("checked","checked");
|
153
|
}
|
159
|
}
|
|
|
160
|
+ }
|
154
|
|
161
|
|
155
|
- e.init();
|
|
|
156
|
- new common.dropDown({el: "#productPoolId","ajax":"productPool"});
|
162
|
+ e.init();
|
|
|
163
|
+ new common.dropDown({el: "#productPoolId","ajax":"productPool"});
|
157
|
|
164
|
|
158
|
- if(hint == "专题编辑") {
|
|
|
159
|
- common.util.__ajax({
|
|
|
160
|
- url:'/runManage/subjectManage/queryBaseProductPoolListById',
|
|
|
161
|
- data:{id:item.productPoolId}
|
|
|
162
|
- },function(res) {
|
|
|
163
|
- $("#select2-productPoolId-container").html(res.data[0].text);
|
|
|
164
|
- },true);
|
|
|
165
|
- }
|
165
|
+ if(hint == "专题编辑") {
|
|
|
166
|
+ common.util.__ajax({
|
|
|
167
|
+ url:'/runManage/subjectManage/queryBaseProductPoolListById',
|
|
|
168
|
+ data:{id:item.productPoolId}
|
|
|
169
|
+ },function(res) {
|
|
|
170
|
+ $("#select2-productPoolId-container").html(res.data[0].text);
|
|
|
171
|
+ },true);
|
166
|
}
|
172
|
}
|
|
|
173
|
+ }
|
167
|
};
|
174
|
};
|
168
|
|
175
|
|
169
|
- $('#add-subject').on('click', function() {
|
|
|
170
|
- var item = {};
|
|
|
171
|
- Bll.toast('/runManage/subjectManage/addSubject', item, "专题添加");
|
|
|
172
|
- });
|
176
|
+$('#add-subject').on('click', function() {
|
|
|
177
|
+ var item = {};
|
|
|
178
|
+ Bll.toast('/runManage/subjectManage/addSubject', item, "专题添加");
|
|
|
179
|
+});
|
|
|
180
|
+
|
|
|
181
|
+$(document).on('click', '.add2', function() {
|
|
|
182
|
+ var item = g.rows[$(this).data("index")];
|
|
|
183
|
+ if(typeof item.startTime == "number") {
|
|
|
184
|
+ item.startTime = Bll.getLocalTime(item.startTime);
|
|
|
185
|
+ item.endTime = Bll.getLocalTime(item.endTime);
|
|
|
186
|
+ }
|
|
|
187
|
+ Bll.toast('/runManage/subjectManage/modify', item, "专题编辑");
|
|
|
188
|
+});
|
|
|
189
|
+
|
|
|
190
|
+$(document).on('click', '.delbtn', function() {
|
|
|
191
|
+ var item=g.rows[$(this).data("index")];
|
|
|
192
|
+ common.dialog.confirm("警告",
|
|
|
193
|
+ "确认删除?",
|
|
|
194
|
+ function() {
|
|
|
195
|
+ common.util.__ajax({
|
|
|
196
|
+ url:'/runManage/subjectManage/delSubject',
|
|
|
197
|
+ data:{id:item.id}
|
|
|
198
|
+ },function() {
|
|
|
199
|
+ g.reload();
|
|
|
200
|
+ });
|
|
|
201
|
+ });
|
|
|
202
|
+});
|
173
|
|
203
|
|
174
|
- $(document).on('click', '.add2', function() {
|
|
|
175
|
- var item = g.rows[$(this).data("index")];
|
|
|
176
|
- if(typeof item.startTime == "number") {
|
|
|
177
|
- item.startTime = Bll.getLocalTime(item.startTime);
|
|
|
178
|
- item.endTime = Bll.getLocalTime(item.endTime);
|
|
|
179
|
- }
|
|
|
180
|
- Bll.toast('/runManage/subjectManage/modify', item, "专题编辑");
|
|
|
181
|
- });
|
|
|
182
|
-
|
|
|
183
|
- $(document).on('click', '.delbtn', function() {
|
|
|
184
|
- var item=g.rows[$(this).data("index")];
|
|
|
185
|
- common.dialog.confirm("警告",
|
|
|
186
|
- "确认删除?",
|
|
|
187
|
- function() {
|
|
|
188
|
- common.util.__ajax({
|
|
|
189
|
- url:'/runManage/subjectManage/delSubject',
|
|
|
190
|
- data:{id:item.id}
|
|
|
191
|
- },function() {
|
|
|
192
|
- g.reload();
|
|
|
193
|
- });
|
|
|
194
|
- });
|
|
|
195
|
- });
|
|
|
196
|
-
|
|
|
197
|
- $(document).on("click","#filter-btn",function () {
|
|
|
198
|
- g.reload(1);
|
|
|
199
|
- }); |
|
|
|
|
204
|
+$(document).on("click","#filter-btn",function () {
|
|
|
205
|
+ g.reload(1);
|
|
|
206
|
+}); |