Commit af3ac1fb by 施宇

商品批量删除

parent 04e37d8b
...@@ -178,20 +178,6 @@ ...@@ -178,20 +178,6 @@
{{# } }} {{# } }}
<div class="time fr ellipsis boxsiz">{{ layui.util.toDateString(item.update_time * 1000)}}</div> <div class="time fr ellipsis boxsiz">{{ layui.util.toDateString(item.update_time * 1000)}}</div>
</div> </div>
{{# if(item['status'] == 1){ }}
{{# if(item['audit_status'] == 1){ }}
<a class="xj xj_status fr xj_btn">下架</a>
{{# } else { }}
<a class="xj xj_status fr disabled xj_btn">下架</a>
{{# } }}
{{# } else { }}
{{# if(item['audit_status'] == 1){ }}
<a class="fb xj_status fr">发布</a>
{{# } else { }}
<a class="fb xj_status fr disabled">发布</a>
{{# } }}
{{# } }}
{{# if(item['audit_status'] == 1){ }} {{# if(item['audit_status'] == 1){ }}
<a class="edit fr" href="/uploadsingle?id={{item.goods_id}}">编辑</a> <a class="edit fr" href="/uploadsingle?id={{item.goods_id}}">编辑</a>
{{# } else { }} {{# } else { }}
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</div> </div>
</div> </div>
<div class="num input_div "> <div class="num input_div ">
<span class="input_title lineBlock">*库存:</span> <span class="input_title lineBlock">*需求数量:</span>
<div class="input_parent"> <div class="input_parent">
<input type="text" name="number" placeholder="请输入需求数量" class="input boxsiz" <input type="text" name="number" placeholder="请输入需求数量" class="input boxsiz"
lay-verify="required|number|limitStock"> lay-verify="required|number|limitStock">
......
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
position: absolute; position: absolute;
top: 0; top: 0;
left: 25px; left: 25px;
right: 140px; right: 60px;
bottom: 0; bottom: 0;
} }
.good_manage_content .good_data .data_list .data_item .data_detail > div { .good_manage_content .good_data .data_list .data_item .data_detail > div {
......
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
position: absolute; position: absolute;
top: 0; top: 0;
left: 25px; left: 25px;
right: 140px; right: 60px;
bottom: 0; bottom: 0;
& > div { & > div {
......
...@@ -191,9 +191,13 @@ ...@@ -191,9 +191,13 @@
*/ */
userMarkmsg: user_url + '/user/markmsg', userMarkmsg: user_url + '/user/markmsg',
/** /**
* 批量删除商品
*/
getVersion: user_url + '/get/version',
/**
* 获取最新版本信息 * 获取最新版本信息
*/ */
getVersion: user_url + '/get/version' goodsDelete: goods_url + '/goods/delete'
}; };
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
return apis; return apis;
......
!function () { ! function () {
window.GoodManageController = { window.GoodManageController = {
token: Util.getCookie('token') || '', token: Util.getCookie('token') || '',
deleteGoods:[], deleteGoods: [],
init: function () { init: function () {
this.created(this).mounted(this).render(this, { this.created(this).mounted(this).render(this, {
offset: 10, offset: 10,
...@@ -10,57 +10,57 @@ ...@@ -10,57 +10,57 @@
}, 1).handleBind(this); }, 1).handleBind(this);
}, },
created: function (opt) { created: function (opt) {
//日期控件初始化 //日期控件初始化
layui.laydate.render({ layui.laydate.render({
elem: '#start_time', elem: '#start_time',
theme: '#0D84D1' theme: '#0D84D1'
}); });
layui.laydate.render({ layui.laydate.render({
elem: '#end_time', elem: '#end_time',
theme: '#0D84D1' theme: '#0D84D1'
}); });
return this; return this;
}, },
mounted: function (opt) { mounted: function (opt) {
//商品数量获取 //商品数量获取
IcController.getData(apis.goodsCount, 'GET', { IcController.getData(apis.goodsCount, 'GET', {
token: opt.token token: opt.token
}, function (res) { }, function (res) {
if (res.errcode === 0) { if (res.errcode === 0) {
var getTpl = countHtml.innerHTML; var getTpl = countHtml.innerHTML;
layui.laytpl(getTpl).render(res.count, function (html) { layui.laytpl(getTpl).render(res.count, function (html) {
$(".good_total").empty().html(html); $(".good_total").empty().html(html);
}); });
} }
}); });
return this; return this;
}, },
render: function (opt, params, curr) { render: function (opt, params, curr) {
opt.deleteGoods = [];
$('.more-delete .gx-status').addClass('wxz').removeClass('xz')
//商品列表初始化 //商品列表初始化
IcController.getData(apis.goodsInfo, 'GET', params, function (res) { IcController.getData(apis.goodsInfo, 'GET', params, function (res) {
var getTpl = listHtml.innerHTML; var getTpl = listHtml.innerHTML;
if (res.errcode === 0) { if (res.errcode === 0) {
layui.laytpl(getTpl).render(res.goods_list, function (html) { layui.laytpl(getTpl).render(res.goods_list, function (html) {
$("#listData").empty().html(html); $("#listData").empty().html(html);
layui.laypage.render({ layui.laypage.render({
elem: 'pagination', elem: 'pagination',
theme: '#1080d0', theme: '#1080d0',
...@@ -69,35 +69,34 @@ ...@@ -69,35 +69,34 @@
curr: curr, curr: curr,
layout: ['prev', 'page', 'next', 'refresh'], layout: ['prev', 'page', 'next', 'refresh'],
jump: function (obj, first) { jump: function (obj, first) {
if (!first) { if (!first) {
//分页回调调用 //分页回调调用
var json = { var json = {
p: obj.curr p: obj.curr
} }
var param = $.extend({}, params, json); var param = $.extend({}, params, json);
GoodManageController.render(opt, param, obj.curr); GoodManageController.render(opt, param, obj.curr);
} }
} }
}); });
}); });
} else if (res.errcode === 110001 || res.errcode === 103001) { } else if (res.errcode === 110001 || res.errcode === 103001) {
layui.laytpl(getTpl).render([], function (html) { layui.laytpl(getTpl).render([], function (html) {
$("#listData").empty().html(html); $("#listData").empty().html(html);
}); });
} }
}); });
return this; return this;
}, },
sxj: function (id, type) { sxj: function (id, type) {
//上下架 1上架 2下架 //上下架 1上架 2下架
...@@ -116,128 +115,161 @@ ...@@ -116,128 +115,161 @@
}); });
} else { } else {
layer.msg('操作失败') layer.msg('操作失败')
}
})
},
//批量删除商品的接口
deleteGoodsAjax: function (opt) {
IcController.getData(apis.goodsDelete, 'GET', {
"token": Util.getCookie('token') || "",
"goods_id": JSON.stringify(opt.deleteGoods),
}, function (res) {
if (res.errcode === 0) {
opt.deleteGoods = [];
layer.msg('删除成功', {
time: 600
}, function () {
opt.mounted(opt)
$('.cx').click();
});
} else {
layer.msg('删除失败')
} }
}) })
}, },
handleBind: function (opt) { handleBind: function (opt) {
//搜索 //搜索
layui.form.on('submit(search)', function (data) { layui.form.on('submit(search)', function (data) {
var param = { var param = {
token: opt.token, token: opt.token,
offset: 10, offset: 10,
p: 1 p: 1
}; };
var params = $.extend({}, data.field, param); var params = $.extend({}, data.field, param);
opt.render(this, params, 1) opt.render(this, params, 1)
}); });
//上架 //上架
$('#listData').on('click', '.fb', function (e) { $('#listData').on('click', '.fb', function (e) {
e.stopPropagation(); e.stopPropagation();
var goodId = $(this).parent('.data_item').attr('goodid'); var goodId = $(this).parent('.data_item').attr('goodid');
if ($(this).hasClass('disabled')) { if ($(this).hasClass('disabled')) {
return; return;
} else { } else {
opt.sxj(goodId, 1); opt.sxj(goodId, 1);
} }
}); });
//下架 //下架
$('#listData').on('click', '.xj_btn', function (e) { $('#listData').on('click', '.xj_btn', function (e) {
e.stopPropagation(); e.stopPropagation();
var goodId = $(this).parent('.data_item').attr('goodid'); var goodId = $(this).parent('.data_item').attr('goodid');
if ($(this).hasClass('disabled')) { if ($(this).hasClass('disabled')) {
return; return;
} else { } else {
opt.sxj(goodId, 2) opt.sxj(goodId, 2)
} }
}); });
//进入详情 //进入详情
$(document).on('click', '#listData .data_item', function (e) { $(document).on('click', '#listData .data_item', function (e) {
e.stopPropagation(); e.stopPropagation();
var goodId = $(this).attr('goodid'); var goodId = $(this).attr('goodid');
window.location.href="/gooddetail?type=1&id="+goodId window.location.href = "/gooddetail?type=1&id=" + goodId
}); });
//阻止默认事件 //阻止默认事件
$(document).on('click','.data_list .disabled',function (e) { $(document).on('click', '.data_list .disabled', function (e) {
e.stopPropagation(); e.stopPropagation();
}); });
$(document).on('click','.gx-div',function (e) { $(document).on('click', '.gx-div', function (e) {
//单个商品勾选 //单个商品勾选
e.stopPropagation(); e.stopPropagation();
var goodid = $(this).find('.gx-status').attr('goodid') var goodid = $(this).find('.gx-status').attr('goodid')
if($(this).find('.gx-status').hasClass('wxz')){ if ($(this).find('.gx-status').hasClass('wxz')) {
//未勾选时变成勾选 //未勾选时变成勾选
$(this).find('.gx-status').removeClass('wxz').addClass('xz'); $(this).find('.gx-status').removeClass('wxz').addClass('xz');
opt.deleteGoods.push(goodid); opt.deleteGoods.push(goodid);
}else{ } else {
//勾选时变为未勾选 //勾选时变为未勾选
$(this).find('.gx-status').removeClass('xz').addClass('wxz'); $(this).find('.gx-status').removeClass('xz').addClass('wxz');
var index = opt.deleteGoods.indexOf(goodid); var index = opt.deleteGoods.indexOf(goodid);
if(index!=-1){ if (index != -1) {
opt.deleteGoods.splice(index,1) opt.deleteGoods.splice(index, 1)
} }
} }
if(opt.deleteGoods.length == 10){ if (opt.deleteGoods.length == 10) {
$('.more-delete .gx-status').removeClass('wxz').addClass('xz'); $('.more-delete .gx-status').removeClass('wxz').addClass('xz');
}else{ } else {
$('.more-delete .gx-status').removeClass('xz').addClass('wxz'); $('.more-delete .gx-status').removeClass('xz').addClass('wxz');
} }
}); });
$('.more-delete').on('click','.gx-status',function(){ $('.more-delete').on('click', '.gx-status', function () {
//全选 //全选
opt.deleteGoods = []; opt.deleteGoods = [];
if($(this).hasClass('wxz')){ if ($(this).hasClass('wxz')) {
//未勾选时变成勾选 //未勾选时变成勾选
$(this).removeClass('wxz').addClass('xz'); $(this).removeClass('wxz').addClass('xz');
$('#listData .gx-status').each(function(){ $('#listData .gx-status').each(function () {
var goodid = $(this).attr('goodid') var goodid = $(this).attr('goodid')
$(this).removeClass('wxz').addClass('xz'); $(this).removeClass('wxz').addClass('xz');
opt.deleteGoods.push(goodid) opt.deleteGoods.push(goodid)
}) })
}else{ } else {
//勾选时变为未勾选 //勾选时变为未勾选
$(this).removeClass('xz').addClass('wxz'); $(this).removeClass('xz').addClass('wxz');
$('#listData .gx-status').each(function(){ $('#listData .gx-status').each(function () {
$(this).removeClass('xz').addClass('wxz'); $(this).removeClass('xz').addClass('wxz');
}) })
} }
});
//批量删除
$('.plsc-text').on('click', function () {
if (opt.deleteGoods.length) {
layer.confirm('是否确认删除当前选中的商品?', {
icon: 3,
title: '提示',
move: false
}, function (index) {
opt.deleteGoodsAjax(opt)
layer.close(index);
})
}
}) })
return this; return this;
}, },
}, $(function () { }, $(function () {
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
}, },
limitStock:function(value, item){ limitStock:function(value, item){
if(value>10000000){ if(value>10000000){
return '库存最大为10000000(一千万)' return '需求数量最大为10000000(一千万)'
} }
}, },
limitLengthLgThree: function (value, item) { limitLengthLgThree: function (value, item) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment