baserule.productParm.Index.js
8.91 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
webpackJsonp([15],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $ = __webpack_require__(1),
common = __webpack_require__(2);
$("#add-btn").hide();
$("#standardType-btn").hide();
window.batchOperateShelve = [];
var tabTree = new common.tabTree("#sortTree");
tabTree.init();
var g = new common.grid({
el: "#basicTable",
usepagesize:true,
parms: function () {
return {
sortId: tabTree.selected[2] ? tabTree.selected[2].id : "",
sortName: tabTree.selected[2] ? tabTree.selected[2].sortName : ""
};
},
columns: [ {
display: 'ID',
name: 'id',
}, {
display: '参数类别',
render: function(item) {
if(item!=null&&item.standardSort!=null){
return item.standardSort.standardSortName;
}
}
}, {
display: '参数名称',
name: 'standardName',
}, {
display: '参数值',
render: function(item) {
var parmList= item.parameterMakeList;
var parm=[];
if(parmList!=null){
for (var j = 0; j < parmList.length; j++) {
if(parmList[j].parameterValue!=null){
parm.push(parmList[j].parameterValue);
}
}
}
return parm.join('<br/>');
}
},{
display: '排序',
name: 'orderBy'
}, {
display: '操作',
render: function(items) {
var HtmArr = [];
HtmArr.push('<a data-index="'+ items.__index+ '" href="JavaScript:;" class="btn btn-info btn-xs edit-class-btn">编辑</a>');
HtmArr.push('<a data-index="'+ items.__index+ '" href="JavaScript:;" class="btn btn-info btn-xs param-val">参数值管理</a>');
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs del-standard">删除</a>');
return HtmArr.join('');
}
}]
});
g.init("/erpproduct/prodcutparm/list");
//筛选
$("#filter-btn").click(function () {
g.reload(1);
var smallSortId=tabTree.selected[2] ? tabTree.selected[2].id : "";
if(smallSortId>0){
$("#add-btn").show();
$("#standardType-btn").show();
}
});
$("#standardType-btn").click(function () {
var maxSortId = tabTree.selected[0] ? tabTree.selected[0].id : "";
var middleSortId = tabTree.selected[1] ? tabTree.selected[1].id : "";
var smallSortId = tabTree.selected[2] ? tabTree.selected[2].id : "";
var maxSortName = tabTree.selected[0] ? tabTree.selected[0].sortName : "";
var middleSortName = tabTree.selected[1] ? tabTree.selected[1].sortName : "";
var smallSortName = tabTree.selected[2] ? tabTree.selected[2].sortName : "";
window.location.href = "/erpproduct/standardSort/index?maxSortId="
+ maxSortId+"&middleSortId="+middleSortId+"&smallSortId="+smallSortId
+"&maxSortName="+encodeURIComponent(maxSortName)+"&middleSortName="+encodeURIComponent(middleSortName)+"&smallSortName="+encodeURIComponent(smallSortName);
});
//删除
$('tbody').on('click', '.del-standard', function() {
var item=g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示", "你确定要删除吗?", function () {
common.util.__ajax({
url:'/erpproduct/standard/del',
data:{id:item.id}
},function(){
g.reload();
});
});
});
/**参数值管理
**/
$('tbody').on('click', '.param-val', function() {
var item = g.rows[$(this).data("index")];
var standardId = item.id;
var standardName = item.standardName;
var url = "/erpproduct/standardVal/index"+"?"
+ "standardId=" + standardId
+"&" + "standardName=" + encodeURIComponent(standardName) ;
window.location.href= url;
});
$(document).on('click', '.edit-class-btn', function () {
var item = g.rows[$(this).data("index")];
var sortName="";
if(tabTree.selected[0]){
sortName=sortName+tabTree.selected[0].sortName+"/";
}
if(tabTree.selected[1]){
sortName=sortName+tabTree.selected[1].sortName+"/";
}
if(tabTree.selected[2]){
sortName=sortName+tabTree.selected[2].sortName;
}
var standardSortName="";
if(item.standardSort!=null){
standardSortName= item.standardSort.standardSortName;
}
var smallSortId =tabTree.selected[2] ? tabTree.selected[2].id : "";
common.dialog.confirm("修改参数",
common.util.__template2($("#template").html(),
{id: item.id, standardName: item.standardName,
orderBy:item.orderBy, sortTypeName:sortName,standardSortName:standardSortName
,standardSortId:item.standardSortId})
, function () {
var standardName = $('#standardName').val();
var check=true;
if (standardName === '' || $.trim(standardName) === '')
{
common.util.__tip("参数名称不能为空", "warning");
check=false;
}
var sortTypeId = $('#sortTypeId').val();
if (sortTypeId === '' || $.trim(sortTypeId) === ''||sortTypeId<1)
{
common.util.__tip("参数类别不能为空", "warning");
check= false;
}
if(check){
common.util.__ajax2({
url: '/erpproduct/standard/update',
data: (function () {
return {
id: item.id,
standardName: $("#standardName").val(),
orderBy: $("#orderBy").val(),
standardSortId:$("#sortTypeId").val()
};
})()
},function(rs){
if(rs.code == 200){
common.util.__tip("保存成功!", "success");
}else{
common.util.__tip(rs.message || rs.data.message);
}
g.reload();
},true)
}else {
return false;
}
});
new common.dropDown({
el: '#sortTypeId',
ajax: 'queryStortType',
hash: true,
params:function(){
return {sortId: smallSortId};
}
});
$('#sortTypeName').attr("disabled", true);
});
$(document).on('click', '#add-btn', function () {
var item = g.rows[$(this).data("index")];
var sortName="";
if(tabTree.selected[0]){
sortName=sortName+tabTree.selected[0].sortName+"/";
}
if(tabTree.selected[1]){
sortName=sortName+tabTree.selected[1].sortName+"/";
}
if(tabTree.selected[2]){
sortName=sortName+tabTree.selected[2].sortName;
}
var smallSortId=tabTree.selected[2] ? tabTree.selected[2].id : "";
common.dialog.confirm("新增参数",
common.util.__template2($("#template").html(),
{standardName: common.util.__input("standardName"),
orderBy: common.util.__input("orderBy"), stortId:smallSortId,sortTypeName:sortName
,standardSortId:common.util.__input("standardSortId")})
, function () {
var standardName = $('#standardName').val();
var check=true;
if (standardName === '' || $.trim(standardName) === '')
{
common.util.__tip("参数名称不能为空", "warning");
check=false;
}
var sortTypeId = $('#sortTypeId').val();
if (sortTypeId === '' || $.trim(sortTypeId) === ''||sortTypeId<1)
{
common.util.__tip("参数类别不能为空", "warning");
check= false;
}
if(check){
common.util.__ajax({
url: '/erpproduct/standard/add',
data: (function () {
return {
sortId:smallSortId,
standardName: $("#standardName").val(),
orderBy: $("#orderBy").val(),
standardSortId:$("#sortTypeId").val()
};
})()
}, function () {
g.reload();
});
}else {
return false;
}
});
new common.dropDown({
el: '#sortTypeId',
ajax: 'queryStortType',
hash: true,
params:function(){
return {sortId: smallSortId};
}
});
$('#sortTypeName').attr("disabled", true);
});
/***/ }
]);