提交 7a064fcf authored 作者: 蒋代伟's avatar 蒋代伟

步奖批量删除

上级 cd526fec
...@@ -1031,6 +1031,7 @@ urlpatterns = [ ...@@ -1031,6 +1031,7 @@ urlpatterns = [
url(r'^sales/lotteryseeds/$', sal_views.lotteryseeds), url(r'^sales/lotteryseeds/$', sal_views.lotteryseeds),
url(r'^sales/lottery/$', sal_views.lottery), url(r'^sales/lottery/$', sal_views.lottery),
url(r'^sales/lotteryseeds/delete/(?P<id>\d+)/$', sal_views.lotteryseeds_delete), url(r'^sales/lotteryseeds/delete/(?P<id>\d+)/$', sal_views.lotteryseeds_delete),
url(r'^sales/lotteryseeds/batch_delete/$', sal_views.lotteryseeds_batch_delete),
#奖品指定 #奖品指定
url(r'^sales/lotterywinnerseeds/$', sal_views.lotterywinnerseeds), url(r'^sales/lotterywinnerseeds/$', sal_views.lotterywinnerseeds),
url(r'^sales/winner_lottery/$', sal_views.winner_lottery), url(r'^sales/winner_lottery/$', sal_views.winner_lottery),
......
...@@ -4669,7 +4669,7 @@ def lotteryseeds(request): ...@@ -4669,7 +4669,7 @@ def lotteryseeds(request):
data = {'data': [], 'clmns': [], 'e': [], data = {'data': [], 'clmns': [], 'e': [],
'subtt': ['营销活动', '奖池布奖'], 'murl': '', 'dt': True, 'add': True, 'clmns2': [], 'cnts': [], 'subtt': ['营销活动', '奖池布奖'], 'murl': '', 'dt': True, 'add': True, 'clmns2': [], 'cnts': [],
'clmns3': [], 'cnts2': []} 'clmns3': [], 'cnts2': []}
data['clmns'] = ['标签序号', '活动', '奖品', '第二奖品', '产品', '批次', '经销商', '状态', '备注', '时间', '是否终端返利' ,'操作'] data['clmns'] = []
data['show_add'] = True data['show_add'] = True
data['murl'] = '/sales/lottery/' data['murl'] = '/sales/lottery/'
dt = datetime.datetime.now().strftime('%Y-%m-%d') dt = datetime.datetime.now().strftime('%Y-%m-%d')
...@@ -4699,8 +4699,8 @@ def lotteryseeds(request): ...@@ -4699,8 +4699,8 @@ def lotteryseeds(request):
is_terminal='是' is_terminal='是'
else: else:
is_terminal='否' is_terminal='否'
check_box = '<input class="checkchild" value="' + str(r[10]) + '" type="checkbox">'
data['data'].append([ data['data'].append([check_box,
r[0], r[0],
r[1], r[1],
r[2], r[2],
...@@ -4816,6 +4816,22 @@ def lotteryseeds_delete(request, id=None): ...@@ -4816,6 +4816,22 @@ def lotteryseeds_delete(request, id=None):
return redirect('/sales/lotteryseeds/') return redirect('/sales/lotteryseeds/')
# 布奖批量删除
@login_required
def lotteryseeds_batch_delete(request):
if request.method == 'POST':
otteryseeds_ids = request.POST.get('otteryseeds_ids','')
if otteryseeds_ids:
otteryseeds = otteryseeds_ids.split(',')
print(otteryseeds)
for os_id in otteryseeds:
obj = LotterySeeds.objects.get(id=int(os_id), company_id=request.user.company.id)
if obj:
obj.delete()
return redirect('/sales/lotteryseeds/')
# return JsonResponse(data={})
@login_required @login_required
def lotterywinnerseeds_delete(request, id=None): def lotterywinnerseeds_delete(request, id=None):
if id: if id:
......
...@@ -74,4 +74,4 @@ ...@@ -74,4 +74,4 @@
</table> </table>
</div> </div>
</div> </div>
</div </div>
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
var page_length=10; var page_length=10;
var value = []
var table=$('#tb').DataTable({ var table=$('#tb').DataTable({
dom: 'Bfrtip', dom: 'Bfrtip',
autoWidth: true, autoWidth: true,
...@@ -83,9 +84,93 @@ ...@@ -83,9 +84,93 @@
} }
}); });
{% endif %} {% endif %}
$(".checkall").on('click',function () {
var list_before = $('.checkchild')
for (var i = 0; i < list_before.length; i++) {
if (list_before[i].checked) {
console.log(1)
$(".checkchild").prop("checked", false);
break;
}else {
console.log(0)
$(".checkchild").prop("checked", true);
break;
}
}
var list = $('.checkchild')
for (var i = 0; i < list.length; i++) {
if (list[i].checked) {
if (value.indexOf(parseInt(list[i].value)) !=-1) {
{#value.push(parseInt(list[i].value))#}
}else{
value.push(parseInt(list[i].value))
}
}else {
if ($.inArray(parseInt(list[i].value), value) == -1) {
//$.inArray(元素, 数组) == -1 表示要删除的元素不在原数组中
} else {
value.splice($.inArray(parseInt(list[i].value), value), 1);
}
$(".checkchild").prop("checked", false);
}
}
}); });
$("#tb").on('click','.checkchild',function (e){
var check = $(this).prop("checked");
console.log(check)
if (check){
console.log(this.value)
if (value.indexOf(parseInt(this.value))){
value.push(parseInt(this.value))
}
}else{
if($.inArray(parseInt(this.value), value) == -1){
//$.inArray(元素, 数组) == -1 表示要删除的元素不在原数组中
}else{
value.splice($.inArray(parseInt(this.value), value), 1);
}
}
})
var url = 'sales/lotteryseeds/batch_delete/';
$('.btn-delete-all').click(function () {
if (value.length > 0) {
var r = confirm('您确定要删除吗?');
if (r) {
console.log(value)
$.ajax({
type: 'post',
url: url,
data: {
otteryseeds_ids: value.join(','),
delflag: 1
},
success: function (html) {
table.draw();
$.RefreshContent('sales/lotteryseeds/')
{#$('#bg-modal .modal-body').html(html);#}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('连接服务器失败');
}
})
}
} else {
alert('请勾选需要删除的内容!')
}
})
});
function deleteItem(id){ function deleteItem(id){
var r = confirm('您确定要删除吗?'); var r = confirm('您确定要删除吗?');
if(r){ if(r){
...@@ -151,15 +236,42 @@ ...@@ -151,15 +236,42 @@
<h4>明细</h4> <h4>明细</h4>
<table id='tb' class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"> <table id='tb' class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead> <thead>
{% for c in clmns %} {# {% for c in clmns %}#}
<th>{{c}}</th> {# <th>{{c}}</th>#}
{% endfor %} {# {% endfor %}#}
<tr>
<th>
<input type="checkbox" class ="checkall" id="group_checkbox" style="display: none;"/><label for="group_checkbox">全选/反选</label>
</th>
<th>标签序号</th>
<th>活动</th>
<th>奖品</th>
<th>第二奖品</th>
<th>产品</th>
<th>批次</th>
<th>经销商</th>
<th>状态</th>
<th>备注</th>
<th>时间</th>
<th>是否终端返利</th>
<th>操作</th>
</tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
<tfoot> <tfoot>
{% for c in clmns %} <th> <span class="btn btn-sm btn-danger btn-delete-all" >批量删除</span> </th>
<th><input type="text" placeholder="{{c}}"></th> <th><input type="text" placeholder="标签序号"></th>
{% endfor %} <th><input type="text" placeholder="活动"></th>
<th><input type="text" placeholder="奖品"></th>
<th><input type="text" placeholder="第二奖品"></th>
<th><input type="text" placeholder="产品"></th>
<th><input type="text" placeholder="批次"></th>
<th><input type="text" placeholder="经销商"></th>
<th><input type="text" placeholder="状态"></th>
<th><input type="text" placeholder="备注"></th>
<th><input type="text" placeholder="时间"></th>
<th><input type="text" placeholder="是否终端返利"></th>
<th><input type="text" placeholder="操作"></th>
</tfoot> </tfoot>
</table> </table>
</div> </div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论