operations.activitytemplate.Product.js
3.7 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
webpackJsonp([82],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/7/4.
* 模板商品管理
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var id = $("#basicForm").data("id");
/*下拉选择*/
new common.dropDown({
el: "#brandId",
ajax: "brand",
hash: true,
params:function(){
return {userLimitFlag:true};
}
});
var tabTree = new common.tabTree("#sort");
tabTree.init();
var g = new common.grid({
el: '#product-list',
parms: function () {
var select = tabTree.getAddress();
return {
templateId: id,
productSkn: common.util.__input("productSkn"),
brandId: common.util.__input("brandId"),
maxSortId: select[0] ? select[0].id : "",
middleSortId: select[1] ? select[1].id : "",
smallSortId: select[2] ? select[2].id : "",
sortId: select[3] ? select[3].id : ""
};
},
columns: [
{
display: "ID",
name: "id"
},
{
display: "SKN",
name: "productSkn"
},
{
display: '操作',
render: function (item) {
var HtmArr = [];
HtmArr.push(' 排序<input type="text" class="number" value="'+ item.orderBy +'" id="orderBy'+ item.__index +'"/>');
HtmArr.push(' <input type="checkbox" id="status'+ item.__index +'" '+ (item.status?"checked":"") +'>');
HtmArr.push('启用 ');
HtmArr.push('<a data-index="'+ item.__index +'" class="btn btn-primary btn-xs edit">修改</a>');
HtmArr.push('<a data-index="'+ item.__index +'" class="btn btn-danger btn-xs del">删除</a>');
return HtmArr.join('');
}
}
]
});
g.init("/activityTemplate/getProductListByCondition");
common.edit.ajaxfileupload("#uploadBox", {
params: {
type: "activityProduct",
__type: "batch-import",
args:id
},
valid_extensions: ['xls', 'xlsx'],
onComplete: function (response) {
if (response.status && response.code == 200) {
common.util.__tip(response.message, 'success');
g.reload();
}
else {
common.util.__tip(response.message, 'warning');
}
}
});
//编辑
$(document).on("click", ".edit", function () {
var index = $(this).data("index");
var item = g.rows[index];
var status = $("#status" + index).prop("checked") ? 1 : 0;
var isRecommend = item.isRecommend ? 1 : 0;
common.util.__ajax({
url: "/activityTemplate/updateProduct",
data: {
id:item.id,
isRecommend:isRecommend,
orderBy:$("#orderBy"+index).val(),
status: status
}
}, function () {
g.reload();
});
});
//删除
$(document).on("click", ".del", function () {
var index = $(this).data("index");
var item = g.rows[index];
common.dialog.confirm("温馨提示","你确定删除吗?",function() {
common.util.__ajax({
url: "/activityTemplate/delOneProduct",
data: {
id: item.id
}
}, function () {
g.reload();
});
});
});
$(document).on("click", "#filter-btn", function () {
g.reload(1);
});
//输入限制
$(document).on("keyup",".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});
$(document).on("click", "#chooseFile", function () {
$("#uploadBox").click();
});
/***/ }
]);