product.productBatch.Index.js
4.66 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
webpackJsonp([143],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/*
*@time: 2016.10.10
*@author: LiQZ
*/
var $ = __webpack_require__(1), common = __webpack_require__(2);
var artTemplate = common.artTemplate;
new common.dropDown({el: "#brand-name", ajax: "brand"});
var tableGird = new common.grid({
el: "#table-box",
size: 30,
parms: function() {
return {
"productName": common.util.__input('productName'),
"productSkn": common.util.__input('productSkn'),
"minCount": $("#minCount").val(),
"brand": common.util.__input("brand-name")
};
},
columns: [
{ display: "SKN", render: function(items) {
return items.productSkn;
}},
{ display: "图片", render: function(items) {
if (items.defaultImg) {
return "<img src=\"" + items.defaultImg + "\" />";
}
return "";
}},
{ display: "商品信息", render: function(items) {
return "名称:" + t(items.productName) + "<br/>品牌:" + t(items.brand) + "<br/>品类:" + t(items.sort);
}},
{ display: "售价", render: function(items) {
return "吊牌价:" + t(items.retailPrice) + "<br/> 销售价:" + t(items.salesPrice);
}},
{ display: "量贩折扣", render: function(items) {
return items.discount;
}},
{ display: "起购件数", render: function(items) {
return items.minCount;
}},
{ display: "促销名称", render: function(items) {
return items.promotionPhrase;
}},
{ display: "状态", render: function(items) {
return items.status == 1 ? "开启" : "关闭";
}},
{ display: "操作信息", render: function(items) {
return items.operator + " " + common.util.__secondsFormat(items.updateTime);
}},
{ display: "操作", render: function(items) {
var HtmArr = [];
HtmArr.push('<a href="/product/batch/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
if (items.status == 1) {
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" data-status="2" class="btn btn-danger btn-xs delete">关闭</a>');
} else {
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" data-status="1" class="btn btn-danger btn-xs delete">开启</a>');
}
HtmArr.push('<a href="javascript:void(0);" data-index="' + items.__index + '" data-id="' + items.id + '" class="btn btn-xs btn-info history">操作记录</a>');
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-warning btn-xs sync">同步</a>');
return HtmArr.join('');
}
}]
});
tableGird.init('/product/batch/list');
$("#filter-btn").click(function() {
tableGird.reload(1);
});
/**
* 关闭--点击事件
*/
$(document).on('click', '.delete', function () {
var id = $(this).attr("data-id");
var status = $(this).attr("data-status");
var message = (status == 1 ? "开启": "关闭");
common.dialog.confirm("警告",
"确认" + message + "?",
function () {
common.util.__ajax({
url: '/product/batch/trigger',
data: { id: id, status: status }
}, function () {
tableGird.reload();
});
});
});
/**
* 查看操作记录
*/
$(document).on('click', '.history', function () {
var item = tableGird.rows[$(this).data("index")];
var row = {};
row.item = item;
var id = $(this).attr("data-id");
// 加载数据
$.post('/product/batch/history', { id: id }, function (resp, textStatus, jqXHR) {
row.data = resp.data;
// 渲染列表
var a = new common.dialog({
title: "<h4>操作纪录详情</h4>",
width: '50%',
content: artTemplate("history_template", row)
});
});
});
function t(obj) {
if (obj) { return obj; }
return "";
}
// 导出
$(document).on("click", "#exportsearch", function () {
var temp = $.extend(true, tableGird.__getparams(), {"size": 10000} );
window.open("/ajax/down?queryConf=" + JSON.stringify(temp) + "&type=productBatchServiceExport");
});
// 同步
$(document).on('click', '.sync', function () {
var id = $(this).attr("data-id");
common.util.__ajax({
url: '/product/batch/sync',
data: { id: id }
}, function (resp) {
// common.util.__tip(resp.message, resp.code == 200 ? 'success' : 'warning');
});
});
/***/ }
]);