product.productBundle.Index.js
7.96 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
webpackJsonp([142],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/*
*@time: 2016.10.10
*@author: LiQZ
*/
var $ = __webpack_require__(1), common = __webpack_require__(2);
__webpack_require__(9);
//new common.dropDown({el: "#shop-name", ajax: "queryShopPass"});
new common.dropDown({ el: "#time_status" });
/*下拉选择*/
new common.dropDown({
el: "#shop-name",
ajax: "queryShopPass",
hash: true
});
var tableGird = new common.grid({
el: "#table-box",
size: 30,
parms: function() {
return {
// "id": common.util.__input('id'),
"bundleName": common.util.__input('bundleName'),
"productSkn": common.util.__input('productSkn'),
"status": $("#time_status").val(),
"shopId": common.util.__input("shop-name")
};
},
columns: [
{ display: "组合套餐号", name: "id" },
{ display: "套餐名称", name: "bundleName" },
{ display: "SKN", render: function(items) {
var imgHtml = "<table><tr>" ;
$.each(items.productInfoList,function(index,item){
imgHtml += "<td style='padding:4px;'><img data-productName='" + item.productName + "' data-skn='" + item.productSkn + "' data-bundlePrice='" + items.bundlePrice + "' data-salePrice='" + item.salePrice + "' data-sknStatus='" + item.sknStatus + "' data-storageNum='" + item.storageNum + "' class=\"viewSknImg\" src=\""+item.productPicImg+"\"/></td>";
})
imgHtml += "</tr></table>"
return imgHtml;
}},
{ display: "店铺", render: function(items) {
return items.shopName;
}},
{ display: "有效期", render: function(items) {
// return common.util.__secondsFormat(items.startTime)
// + " ~ "
// + common.util.__secondsFormat(items.endTime);
return toDate(items.startTime) + " ~ " + toDate(items.endTime);
}},
{ display: "折扣", render: function(items) {
return items.discount;
}},
{ display: "状态", width : 100, render: function(items) {
if (items.auditStatus === 0) {
return "待审核";
}
else if (items.auditStatus === 1) {
return "驳回 <font color='red'>(" + items.rejectReason + ")</font>";
}
if (items.status != 1) {
return "已终止";
}
var now = Date.parse(new Date())/1000;
// 未开始
if (items.startTime > now) {
return "未开始" + (items.productValidFlag == 1 ? " <font color='red'>(异常)</font>" : "");
}
// 进行中
if (items.startTime <= now && items.endTime >= now) {
return "进行中" + (items.productValidFlag == 1 ? " <font color='red'>(异常)</font>" : "");
}
// 已结束
if (items.endTime < now) {
return "已结束";
}
return "时间设置错误";
}},
{ display: "操作信息", render: function(items) {
return items.operator + "<br/> " + common.util.__secondsFormat(items.updateTime);
}},
{ display: "操作", render: function(items) {
var now = Date.parse(new Date())/1000;
var HtmArr = [];
if (items.auditStatus == 1) { // `audit_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态 0 待审核 1代表审核驳回 2 审核通过',
HtmArr.push('<a href="/product/bundle/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
} else if (items.auditStatus == 2) {
if (items.status == 1 && items.endTime >= now) {
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-danger btn-xs delete">终止</a>');
}
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-warning btn-xs sync">同步</a>');
if (items.status != 2 && items.endTime >= now) { // 终止了或已结束就不用编辑
HtmArr.push('<a href="/product/bundle/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
}
}
return HtmArr.join('');
}
}]
});
tableGird.init('/product/bundle/list');
$("#filter-btn").click(function() {
tableGird.reload(1);
});
function toSeconds(strDate) {
var seconds = new Date(strDate).getTime() / 1000;
return seconds;
}
function toDate(seconds) {
if (!$.isNumeric(seconds) || seconds <= 0) { return ''; }
var date = new Date(seconds * 1000);
return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate()) + ' ' + fixTwo(date.getHours()) + ':' + fixTwo(date.getMinutes()) + ':' + fixTwo(date.getSeconds());
}
function fixTwo(number) {
return number < 10? "0" + number: number;
}
//获取鼠标坐标
function mousePosition(ev){
ev = ev || window.event;
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
/**
* 悬浮事件
*/
$(document).on('mouseover', '.viewSknImg', function (e) {
var productName = $(this).attr("data-productName");
var salePrice = $(this).attr("data-salePrice");
var sknStatus = $(this).attr("data-sknStatus");
var storageNum = $(this).attr("data-storageNum");
var bundlePrice = $(this).attr("data-bundlePrice");
var skn = $(this).attr("data-skn");
var mousePos = mousePosition(e);
var xOffset = 1;
var yOffset = 21;
$("#tooltip").css("display","block").css("position","absolute").css("top",(mousePos.y - yOffset) + "px").css("left",(mousePos.x + xOffset) + "px");
var html = "";
html += "<span><strong>商品名:</strong>"+productName+"</span><br>";
html += "<span><strong>SKN :</strong>"+skn+"</span><br>";
html += "<span><strong>销售价:</strong>"+salePrice+"</span><br>";
html += "<span><strong>上下架状态:</strong>"+sknStatus+"</span><br>";
html += "<span><strong>库存:</strong>"+storageNum+"</span><br>";
html += "<span><strong>套餐价:</strong>" + bundlePrice + "</span><br>";
$("#tooltip").append(html);
});
/**
* 悬浮事件
*/
$(document).on('mouseout', '.viewSknImg', function (e) {
$("#tooltip").css("display","none");
$("#tooltip").html("");
});
/**
* 删除--点击事件
*/
$(document).on('click', '.delete', function () {
var id = $(this).attr("data-id");
common.dialog.confirm("警告",
"确认终止?",
function () {
common.util.__ajax({
url: '/product/bundle/stop',
data: { id: id }
}, function () {
tableGird.reload();
});
});
});
// 导出
$(document).on("click", "#exportsearch", function () {
var temp = $.extend(true, tableGird.__getparams(), {"size": 10000} );
window.open("/ajax/down?queryConf=" + JSON.stringify(temp) + "&type=productBundleServiceExport");
});
// 同步
$(document).on('click', '.sync', function () {
var id = $(this).attr("data-id");
common.util.__ajax({
url: '/product/bundle/sync',
data: { id: id }
}, function (resp) {
// common.util.__tip(resp.message, resp.code == 200 ? 'success' : 'warning');
});
});
function toDate(seconds) {
if (!seconds || seconds <= 0) { return ''; }
var date = new Date(seconds * 1000);
return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate());
}
function fixTwo(number) {
return number < 10? "0" + number: number;
}
/***/ }
]);