category.Index.js
4.18 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
webpackJsonp([23],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/*
*@time: 2016/1/26
*@author: chenglong
*/
var $ = __webpack_require__(1);
var common=__webpack_require__(2);
//下拉框
new common.dropDown({
el: "#status"
});
var renderHd = false;
var g = new common.grid({
el: "#basicTable",
parms: function() {
return {
status: common.util.__input('status'), //$.trim($('#status').val()) || '',
};
},
columns: [{
display: '',
name: 'foler',
render: function(item) {
debugger;
var html = "", top = true;
if (!renderHd) {
html += $('#tableHdTemp').html();
init(item);
renderHd = true;
} else {init(item)}
return html;
function init(item){
if(top){
html += "<div id='category_id_"+ item.id +"' class='level-wrap clearfix'>";
top = false;
}else{
html += "<div id='category_id_"+ item.id +"' class='level-wrap clearfix' style='display: none'>"
}
html += common.util.__template2($('#tableTemp2').html(), item);
if(item.subList){
for(var i=0; i<item.subList.length; i++){
init(item.subList[i]);
}
}
html += "</div>";
}
}
}
]
});
g.init($("#gridurl").val());
//g.init("/erpproduct/sort/index");
$("#filter-btn").click(function() {
renderHd = false;
g.reload();
});
//打开层级类目
$(document).on('click', '.folder', function() {
var $wrap = $(this).parent();
if (!$(this).hasClass('open')) {
if ($wrap.find('> .level-wrap').size() > 0) {
var position = $(this).css("background-position");
var a = position.substring(0,position.indexOf("px"));
$wrap.find('> .level-wrap').show().find(".folder").css("background-position", (parseInt(a)+36) + "px");
$(this).addClass('open');
}
} else {
$(this).removeClass('open');
if ($wrap.find('.level-wrap').size() > 0) {
$wrap.find('.level-wrap').hide().find(".folder").removeClass('open').css("background-position", "12px center");
}
}
});
//删除物理类目
$(document).on('click', '.del-class-btn', function() {
var sortId = $(this).parent().data('id'),
sortName = $(this).parent().data('name');
common.dialog.confirm("温馨提示", "确定  <b><font color='#ff0000'>删除 </font>【" + sortName + "】</b> 分类吗?", function() {
common.util.__ajax2({
url: '/erpproduct/sorter/del',
data: {
param: sortId
}
}, function(res){
if (res.code == 200) {
// g.reload();
$("#filter-btn").click();
common.util.__tip("删除成功!","success");
}
})
});
event.preventDefault();
});
$(document).on('click', '.open-close-btn',function() {
var status;
var id = $(this).parent().data('id');
if ($(this).attr('data-status') === '1') {
status = 0;
} else if ($(this).attr('data-status') === '0') {
status = 1;
}
console.log(status);
$.ajax({
type: 'POST',
dataType: 'json',
url: status?"/erpproduct/sorter/open":"/erpproduct/sorter/close",
data: {
param: id
}
}).then(function (data) {
console.log(data);
if (data.code === 200) {
if ($(this).hasClass('btn-danger')) {
common.util.__tip("关闭成功!",'success');
} else {
common.util.__tip("开启成功!",'success');
}
// g.reload();
$("#filter-btn").click();
}
});
event.preventDefault();
}
);
/***/ }
]);