category.Index.js
3.14 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
webpackJsonp([22],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/*
*@time: 2016/1/26
*@author: chenglong
*/
var $ = __webpack_require__(1);
var common=__webpack_require__(2);
//列表展示效果
var $toggleTd = $('.toggle-td');
$toggleTd.click(function () {
var $this = $(this),
$thisNext = $this.closest('tr').nextAll(),
thisVal = $(this).closest('tr').attr('data-val');
if ($this.closest('tr').attr('data-status') === 'close') {
$thisNext.filter(function (index) {
return $(this).attr('data-parent') === thisVal;
}).removeClass('hidden');
$this.closest('tr').attr('data-status', 'open').find('.toggle-td').find('span')
.removeClass('glyphicon-folder-close').addClass('glyphicon-folder-open');
} else {
$thisNext.filter(function (index) {
var thisR = $(this).attr('data-parent') === thisVal;
if (thisR && $(this).attr('data-status') === 'open') {
$(this).find('.toggle-td').trigger('click');
}
return thisR;
}).addClass('hidden');
$this.closest('tr').attr('data-status', 'close').find('.toggle-td').find('span')
.removeClass('glyphicon-folder-open').addClass('glyphicon-folder-close');
}
});
//列表编辑
var $table = $('.toggle-table');
$table.click(function (event) {
var $target = $(event.target),
id;
//编辑
if ($target.hasClass('edit-class-btn')) {
} else if ($target.hasClass('open-close-btn')) {
var status;
if ($target.attr('data-status') === '1') {
status = 0;
} else if ($target.attr('data-status') === '0') {
status = 1;
}
console.log(status);
$.ajax({
type: 'POST',
dataType: 'json',
url: status?"/erpproduct/sorter/open":"/erpproduct/sorter/close",
data: {
param: $target.closest('td').attr('data-id')
}
}).then(function (data) {
console.log(data);
if (data.code === 200) {
$target.attr('data-status', status);
if ($target.hasClass('btn-danger')) {
$target.text('开启');
$target.removeClass('btn-danger')
.addClass('btn-success').closest('td').prev('td').text('关闭');
common.util.__tip("关闭成功!",'success');
} else {
$target.text('关闭');
$target.removeClass('btn-success')
.addClass('btn-danger').closest('td').prev('td').text('开启');
common.util.__tip("开启成功!",'success');
}
}
});
event.preventDefault();
}
});
/***/ }
]);