提交 90684c26 authored 作者: 张颂恩's avatar 张颂恩

Merge branch 'dev' of http://124.225.116.118:35236/tj_django/datacenter into dev

...@@ -390,6 +390,7 @@ class Activity_Lottery_Plan_Form(ModelForm): ...@@ -390,6 +390,7 @@ class Activity_Lottery_Plan_Form(ModelForm):
fields = '__all__' fields = '__all__'
widgets = { widgets = {
'company': forms.HiddenInput(), 'company': forms.HiddenInput(),
'win_scan_num': forms.Textarea(attrs={'placeholder': ('多个用户id请用英文,号隔开,不能超过20个')})
} }
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self._user = kwargs.pop('user') self._user = kwargs.pop('user')
......
...@@ -9851,6 +9851,7 @@ def activity_lottery_plan_list(request): ...@@ -9851,6 +9851,7 @@ def activity_lottery_plan_list(request):
# 单枚布奖 # 单枚布奖
@login_required @login_required
def activity_lottery_plan_edit(request, id=None): def activity_lottery_plan_edit(request, id=None):
e = ''
if id: if id:
obj = Activity_Lottery_Plan.objects.get(id=int(id)) obj = Activity_Lottery_Plan.objects.get(id=int(id))
else: else:
...@@ -9868,21 +9869,32 @@ def activity_lottery_plan_edit(request, id=None): ...@@ -9868,21 +9869,32 @@ def activity_lottery_plan_edit(request, id=None):
remark = request.POST.get('remark', '') remark = request.POST.get('remark', '')
batch_no = request.POST.get('batch_no', None) batch_no = request.POST.get('batch_no', None)
company_id = request.user.company.id company_id = request.user.company.id
if tm_start and tm_end and win_scan_num and activity and award: #lisin 修改成批量
if win_scan_num:
win_scan_num = [int(num) for num in win_scan_num.split(',')]
if(len(win_scan_num) > 2):
e = '设置数量不能超过20个'
return render(request, 'sales/activity_lottery_plan.html', {e : e})
obj = Activity_Lottery_Plan() if tm_start and tm_end and win_scan_num and activity and award:
obj.company_id = company_id # 创建对象列表
obj.activity_id = activity activity_lottery_plans = [
obj.tm_start = tm_start Activity_Lottery_Plan(
obj.tm_end = tm_end company_id=company_id,
obj.win_scan_num = win_scan_num activity_id=activity,
obj.award_id = award tm_start=tm_start,
obj.remark = remark tm_end=tm_end,
obj.batch_no = batch_no win_scan_num=num,
award_id=award,
obj.save() remark=remark,
batch_no=batch_no
)
for num in win_scan_num
]
# 使用 bulk_create 批量保存对象
Activity_Lottery_Plan.objects.bulk_create(activity_lottery_plans)
return render(request, 'sales/activity_lottery_plan.html', {'form': form}) return render(request, 'sales/activity_lottery_plan.html', {'form': form, e: e})
@login_required @login_required
def activity_lottery_plan_delete(request, id=None): def activity_lottery_plan_delete(request, id=None):
......
...@@ -29,6 +29,11 @@ ...@@ -29,6 +29,11 @@
border: none; border: none;
border-bottom: 1px solid gray; border-bottom: 1px solid gray;
} }
textarea {
width: 100%;
height: 100px;
}
</style> </style>
<div class="alert alert-success" role="alert" style="display: none">保存成功!</div> <div class="alert alert-success" role="alert" style="display: none">保存成功!</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论