Showing
5 changed files
with
135 additions
and
55 deletions
@@ -36,10 +36,13 @@ var grid = function(options) { | @@ -36,10 +36,13 @@ var grid = function(options) { | ||
36 | grid.prototype = { | 36 | grid.prototype = { |
37 | constructor: grid, | 37 | constructor: grid, |
38 | 38 | ||
39 | - init: function(url) { | 39 | + init: function(url, second) { |
40 | var g = this, | 40 | var g = this, |
41 | p = this.options; | 41 | p = this.options; |
42 | + | ||
43 | + | ||
42 | p.url = url; | 44 | p.url = url; |
45 | + p.second = second; | ||
43 | g.grid = $(p.el); | 46 | g.grid = $(p.el); |
44 | g.grid.html(p.innerHtml); | 47 | g.grid.html(p.innerHtml); |
45 | g.table = $("table", g.grid); | 48 | g.table = $("table", g.grid); |
@@ -76,7 +79,7 @@ grid.prototype = { | @@ -76,7 +79,7 @@ grid.prototype = { | ||
76 | if (typeof p.url == "string") { | 79 | if (typeof p.url == "string") { |
77 | g.ajax(_p); | 80 | g.ajax(_p); |
78 | } else { | 81 | } else { |
79 | - g.__bodyClomun(p.url); | 82 | + g.__bodyClomun(p.url, p.second); |
80 | } | 83 | } |
81 | 84 | ||
82 | } | 85 | } |
@@ -206,8 +209,7 @@ grid.prototype = { | @@ -206,8 +209,7 @@ grid.prototype = { | ||
206 | total: data.totalPage, | 209 | total: data.totalPage, |
207 | page: data.page | 210 | page: data.page |
208 | }); | 211 | }); |
209 | - g.__bodyClomun(data.list); | ||
210 | - // setpage(res); | 212 | + g.__bodyClomun(data.list, p.second); |
211 | }, | 213 | }, |
212 | complete: function(res) { | 214 | complete: function(res) { |
213 | console.log("complete~~"); | 215 | console.log("complete~~"); |
@@ -222,7 +224,7 @@ grid.prototype = { | @@ -222,7 +224,7 @@ grid.prototype = { | ||
222 | }; | 224 | }; |
223 | $.ajax(ajaxOptions); | 225 | $.ajax(ajaxOptions); |
224 | }, | 226 | }, |
225 | - __bodyClomun: function(rows) { | 227 | + __bodyClomun: function(rows, second) { |
226 | var g = this, | 228 | var g = this, |
227 | p = this.options; | 229 | p = this.options; |
228 | g.tbody.html(""); | 230 | g.tbody.html(""); |
@@ -236,31 +238,37 @@ grid.prototype = { | @@ -236,31 +238,37 @@ grid.prototype = { | ||
236 | return (p.page - 1) * parseInt(p.rp); | 238 | return (p.page - 1) * parseInt(p.rp); |
237 | } | 239 | } |
238 | 240 | ||
241 | + | ||
242 | + | ||
239 | if (rows.length > 0) { | 243 | if (rows.length > 0) { |
240 | for (var row in rows) { | 244 | for (var row in rows) { |
241 | - | ||
242 | var item = rows[row], | 245 | var item = rows[row], |
243 | _h = ""; | 246 | _h = ""; |
244 | var num = _r_num() + _count; | 247 | var num = _r_num() + _count; |
248 | + | ||
245 | item._num = _count; | 249 | item._num = _count; |
246 | item.rowid = "wqt_" + num + "_" + _count; | 250 | item.rowid = "wqt_" + num + "_" + _count; |
247 | if (!item) continue; | 251 | if (!item) continue; |
248 | - _h += ('<tr >'); | ||
249 | g.records.push(_count); | 252 | g.records.push(_count); |
250 | item.__index = _count; | 253 | item.__index = _count; |
251 | g.rows.push(item); | 254 | g.rows.push(item); |
252 | - $(p.columns).each(function(i, column) { | ||
253 | - if (!column.hidden) { | ||
254 | - //console.log(item, column); | ||
255 | - _h += ('<td>'); | ||
256 | - _h += (g.__bodyCell(item, column)); | ||
257 | - _h += ('</td>'); | ||
258 | - } | ||
259 | - }) | ||
260 | - _h += ('</tr>'); | 255 | + |
256 | + if (item[second] && item[second].length > 0) { | ||
257 | + _h += g.__bodySecondClomun(item, item[second]) | ||
258 | + } else { | ||
259 | + _h += ('<tr >'); | ||
260 | + $(p.columns).each(function(i, column) { | ||
261 | + if (!column.hidden) { | ||
262 | + _h += ('<td>'); | ||
263 | + _h += (g.__bodyCell(item, column)); | ||
264 | + _h += ('</td>'); | ||
265 | + } | ||
266 | + }) | ||
267 | + _h += ('</tr>'); | ||
268 | + _count++; | ||
269 | + } | ||
261 | 270 | ||
262 | _r.push(_h); | 271 | _r.push(_h); |
263 | - _count++; | ||
264 | g.tbody.html(_r.join('')); | 272 | g.tbody.html(_r.join('')); |
265 | } | 273 | } |
266 | } else { | 274 | } else { |
@@ -274,13 +282,40 @@ grid.prototype = { | @@ -274,13 +282,40 @@ grid.prototype = { | ||
274 | g.tbody.html(_r.join('')); | 282 | g.tbody.html(_r.join('')); |
275 | } | 283 | } |
276 | }, | 284 | }, |
285 | + __bodySecondClomun: function(row, second) { | ||
286 | + var g = this, | ||
287 | + p = this.options, | ||
288 | + index = this.options.secondIndex; | ||
289 | + var _r = '', | ||
290 | + count = 0; | ||
291 | + | ||
292 | + $.each(second, function(i, value) { | ||
293 | + _r += '<tr>'; | ||
294 | + $(p.columns).each(function(i, column) { | ||
295 | + if (!column.hidden && count < index) { | ||
296 | + _r += ('<td rowspan="' + second.length + '">'); | ||
297 | + _r += (g.__bodyCell(row, column)); | ||
298 | + _r += ('</td>'); | ||
299 | + count++; | ||
300 | + } else { | ||
301 | + if (i >= index) { | ||
302 | + _r += ('<td>'); | ||
303 | + _r += (g.__bodyCell(value, column)); | ||
304 | + _r += ('</td>'); | ||
305 | + } | ||
306 | + } | ||
307 | + }); | ||
308 | + _r += '</tr>'; | ||
309 | + }); | ||
310 | + | ||
311 | + return _r; | ||
312 | + }, | ||
277 | __bodyCell: function(row, col) { | 313 | __bodyCell: function(row, col) { |
278 | var g = this, | 314 | var g = this, |
279 | p = this.options; | 315 | p = this.options; |
280 | if (!row || !col) return ""; | 316 | if (!row || !col) return ""; |
281 | var value = col.name ? row[col.name] : null; | 317 | var value = col.name ? row[col.name] : null; |
282 | 318 | ||
283 | - | ||
284 | var content = ""; | 319 | var content = ""; |
285 | if (col.type) { | 320 | if (col.type) { |
286 | content = "<input type='" + col.type + "' name='" + col.name + "' class='wqt_checkbox' data-index='" + row.__index + "'>"; | 321 | content = "<input type='" + col.type + "' name='" + col.name + "' class='wqt_checkbox' data-index='" + row.__index + "'>"; |
@@ -290,6 +290,7 @@ $('#basicTable').on('click', '.shelve-btn', function() { | @@ -290,6 +290,7 @@ $('#basicTable').on('click', '.shelve-btn', function() { | ||
290 | 290 | ||
291 | var shelveTable = new common.grid({ | 291 | var shelveTable = new common.grid({ |
292 | el: "#shelve-table", | 292 | el: "#shelve-table", |
293 | + secondIndex: 2, | ||
293 | columns: [{ | 294 | columns: [{ |
294 | display: 'SKC(商品信息)', | 295 | display: 'SKC(商品信息)', |
295 | render: function(item) { | 296 | render: function(item) { |
@@ -301,57 +302,65 @@ $('#basicTable').on('click', '.shelve-btn', function() { | @@ -301,57 +302,65 @@ $('#basicTable').on('click', '.shelve-btn', function() { | ||
301 | display: 'SKC上架操作(状态)', | 302 | display: 'SKC上架操作(状态)', |
302 | render: function(item) { | 303 | render: function(item) { |
303 | if (item.status == 0) { | 304 | if (item.status == 0) { |
304 | - return '<a class="btn btn-success" href="javascript:;">点击上架</a>'; | 305 | + return '<a class="btn btn-success" data-type="1" data-skc="' + item.productSkc + '" href="javascript:;">点击上架</a>'; |
305 | } else { | 306 | } else { |
306 | - return '<a class="btn btn-danger" href="javascript:;">点击下架</a>'; | 307 | + return '<a class="btn btn-danger" data-type="0" data-skc="' + item.productSkc + '" href="javascript:;">点击下架</a>'; |
307 | } | 308 | } |
308 | } | 309 | } |
309 | }, { | 310 | }, { |
310 | display: 'SKU', | 311 | display: 'SKU', |
311 | - render: function(item) { | ||
312 | - //console.log(item.goodsSizeList); | ||
313 | - var html = ''; | ||
314 | - $.each(item.goodsSizeList, function(i, value) { | ||
315 | - html += value.productSku + '<br>'; | ||
316 | - }); | ||
317 | - return html; | ||
318 | - } | 312 | + name: 'productSku' |
319 | }, { | 313 | }, { |
320 | display: '尺码', | 314 | display: '尺码', |
321 | - render: function(item) { | ||
322 | - var html = ''; | ||
323 | - $.each(item.goodsSizeList, function(i, value) { | ||
324 | - html += value.sizeName + '<br>'; | ||
325 | - }); | ||
326 | - return html; | ||
327 | - } | 315 | + name: 'sizeName' |
328 | }, { | 316 | }, { |
329 | display: '库存', | 317 | display: '库存', |
330 | - render: function(item) { | ||
331 | - var html = ''; | ||
332 | - $.each(item.goodsSizeList, function(i, value) { | ||
333 | - html += value.stock + '<br>'; | ||
334 | - }); | ||
335 | - return html; | ||
336 | - } | 318 | + name: 'stock' |
337 | }, { | 319 | }, { |
338 | display: 'SKU上架操作', | 320 | display: 'SKU上架操作', |
339 | render: function(item) { | 321 | render: function(item) { |
340 | - var html = ''; | ||
341 | - /*$.each(item.goodsSizeList, function(i, value) { | ||
342 | - html += value.sizeName + '<br>'; | ||
343 | - });*/ | ||
344 | - return html; | 322 | + if (item.status == 0) { |
323 | + return '下架'; | ||
324 | + } else { | ||
325 | + return '上架'; | ||
326 | + } | ||
345 | } | 327 | } |
346 | }, { | 328 | }, { |
347 | - display: 'SKU上架状态', | ||
348 | - name: 'vip_discount_type', | 329 | + display: 'SKU上架操作', |
349 | render: function(item) { | 330 | render: function(item) { |
350 | - //return ENUM.ageLevel[item.ageLevel] + '/' + ENUM.gender[item.gender]; | 331 | + if (item.status == 0) { |
332 | + return '<a class="btn btn-success" data-type="1" data-sku="' + item.productSku + '" href="javascript:;">上架</a>'; | ||
333 | + } else { | ||
334 | + return '<a class="btn btn-danger" data-type="0" data-sku="' + item.productSku + '" href="javascript:;">下架</a>'; | ||
335 | + } | ||
351 | } | 336 | } |
352 | }] | 337 | }] |
353 | }); | 338 | }); |
354 | - shelveTable.init(res.data.goodsList); | 339 | + shelveTable.init(res.data.goodsList, 'goodsSizeList'); |
340 | + | ||
341 | + $('#shelve-table').on('click', '.btn', function() { | ||
342 | + var param = {}, | ||
343 | + reqUrl = ''; | ||
344 | + if ($(this).data('skc')) { | ||
345 | + param.productSkc = $(this).data('skc'); | ||
346 | + reqUrl = '/goods/product/updateGoodsStatus'; | ||
347 | + } else if ($(this).data('sku')) { | ||
348 | + param.productSku = $(this).data('sku'); | ||
349 | + reqUrl = '/goods/product/updateProductSkuStatus'; | ||
350 | + } | ||
351 | + | ||
352 | + param.targetStatus = $(this).data('type'); | ||
353 | + console.log(param); | ||
354 | + common.util.__ajax({ | ||
355 | + url: reqUrl, | ||
356 | + data: param | ||
357 | + }, function(res) { | ||
358 | + console.log(res); | ||
359 | + if (res.data.code == 200) { | ||
360 | + shelveModal.close(); | ||
361 | + } | ||
362 | + }) | ||
363 | + }) | ||
355 | }, true); | 364 | }, true); |
356 | 365 | ||
357 | }); | 366 | }); |
1 | -exports.domain = require('../config/common.js').domain; | ||
2 | -//exports.domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //变价 | 1 | +//exports.domain = require('../config/common.js').domain; |
2 | +exports.domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //变价 | ||
3 | //exports.domain = 'http://172.16.6.162:8088/platform'; //品牌合作 | 3 | //exports.domain = 'http://172.16.6.162:8088/platform'; //品牌合作 |
4 | 4 | ||
5 | //商品管理路由配置 | 5 | //商品管理路由配置 |
@@ -151,6 +151,30 @@ exports.res = [ | @@ -151,6 +151,30 @@ exports.res = [ | ||
151 | type: 'string' | 151 | type: 'string' |
152 | }] | 152 | }] |
153 | }, { | 153 | }, { |
154 | + //网销信息 -> skc上下架 | ||
155 | + route: '/goods/product/updateGoodsStatus', | ||
156 | + method: 'POST', | ||
157 | + url: '/product/updateGoodsStatus', | ||
158 | + params: [{ | ||
159 | + name: 'productSkc', | ||
160 | + type: 'number' | ||
161 | + }, { | ||
162 | + name: 'targetStatus', | ||
163 | + type: 'number' | ||
164 | + }] | ||
165 | + }, { | ||
166 | + //网销信息 -> sku上下架 | ||
167 | + route: '/goods/product/updateProductSkuStatus', | ||
168 | + method: 'POST', | ||
169 | + url: '/product/updateProductSkuStatus', | ||
170 | + params: [{ | ||
171 | + name: 'productSku', | ||
172 | + type: 'number' | ||
173 | + }, { | ||
174 | + name: 'targetStatus', | ||
175 | + type: 'number' | ||
176 | + }] | ||
177 | + }, { | ||
154 | //网销信息 -> 批量页面渲染 | 178 | //网销信息 -> 批量页面渲染 |
155 | route: '/goods/netsale/batch', | 179 | route: '/goods/netsale/batch', |
156 | method: 'GET', | 180 | method: 'GET', |
@@ -212,8 +212,8 @@ | @@ -212,8 +212,8 @@ | ||
212 | 212 | ||
213 | 213 | ||
214 | <script type="text/template" id="template"> | 214 | <script type="text/template" id="template"> |
215 | - <p>SKN:{productSkn} 品牌:{brandName}</p> | ||
216 | - <p>商品名称:{productName}</p> | 215 | + <p style="color: red;">SKN:{productSkn} 品牌:{brandName}</p> |
216 | + <p style="color: red;">商品名称:{productName}</p> | ||
217 | <div id="shelve-table" class="dataTables_wrapper no-footer"></div> | 217 | <div id="shelve-table" class="dataTables_wrapper no-footer"></div> |
218 | 218 | ||
219 | </script> | 219 | </script> |
1 | +<div class="panel panel-default"> | ||
2 | + <form action="" class="form-horizontal form-bordered"> | ||
3 | + <div class="panel-heading"> | ||
4 | + <div class="panel-btns" style="display: none;"> | ||
5 | + <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title=""><i class="fa fa-minus"></i></a> | ||
6 | + </div> | ||
7 | + <h2 class="panel-title">模特</h2> | ||
8 | + </div> | ||
9 | + <div class="panel-body nopadding"> | ||
10 | + </div> | ||
11 | + </form> | ||
12 | +</div> |
-
Please register or login to post a comment