提交 310b40b0 authored 作者: 李思鑫's avatar 李思鑫

产品系列下所有产品添加到授权产品

上级 b206ad1e
...@@ -119,6 +119,9 @@ urlpatterns = [ ...@@ -119,6 +119,9 @@ urlpatterns = [
#2020-10-19 #2020-10-19
url(r'^obj/ajax/subsaldiv/(?P<division_id>\w+)/$', list_views.ajax_subdiv), url(r'^obj/ajax/subsaldiv/(?P<division_id>\w+)/$', list_views.ajax_subdiv),
#2024-11-21 根据系列查产品
url(r'^obj/ajax/series_to_product/$', list_views.ajax_series_to_product),
......
...@@ -704,9 +704,13 @@ def edit_obj(request,obj_name,id=None): ...@@ -704,9 +704,13 @@ def edit_obj(request,obj_name,id=None):
if id: if id:
s = "SELECT id,name,(select count(id) from company_user where product_series @> Array[s.id] and id = "+id+") "+\ s = "SELECT id,name,(select count(id) from company_user where product_series @> Array[s.id] and id = "+id+") "+\
"FROM product_series s where company_id = "+str(c.ancestor_id) "FROM product_series s where company_id = "+str(c.ancestor_id)
cur.execute(s) else:
for r in cur.fetchall(): s = "SELECT id,name,0"+\
series.append([r[0], r[1],r[2]]) "FROM product_series s where company_id = "+str(c.ancestor_id)
cur.execute(s)
for r in cur.fetchall():
series.append([r[0], r[1],r[2]])
products = [] products = []
if id: if id:
...@@ -6394,3 +6398,20 @@ def agent_is_active_star(request,id=None): ...@@ -6394,3 +6398,20 @@ def agent_is_active_star(request,id=None):
""" """
cur.execute(s) cur.execute(s)
return JsonResponse(data) return JsonResponse(data)
def ajax_series_to_product(request):
cpid = request.GET.get('company_id', '')
series_ids = request.GET.get('series_ids', '')
s=f"""
select id,name from product_product where series_id in ({series_ids}) and company_id={cpid}
"""
cur = connection.cursor()
cur.execute(s)
data = []
for r in cur.fetchall():
data.append({
'id': r[0],
'name': r[1]
})
return JsonResponse(data, safe=False)
...@@ -69,10 +69,16 @@ ...@@ -69,10 +69,16 @@
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<style>
.fs-wrap{
vertical-align: middle;
}
</style>
<div class="form-group"> <div class="form-group">
<label class="col-md-2 control-label">产品系列授权</label> <label class="col-md-2 control-label">产品系列授权</label>
<div class='col-sm-4'> <div class='col-sm-10'>
<select id="ySelectSeries" multiple="multiple"> <select id="ySelectSeries" multiple="multiple">
{% for s in series %} {% for s in series %}
{% ifequal s.2 1 %} {% ifequal s.2 1 %}
...@@ -82,6 +88,13 @@ ...@@ -82,6 +88,13 @@
{% endifequal %} {% endifequal %}
{% endfor %} {% endfor %}
</select> </select>
{% ifequal request.user.company_id 255721 %}
<span id="series_to_product" style="display: inline-block; 'vertical-align':middle;" class="input-group-btn">
<button type="button" class="btn btn-success">
<span class='glyphicon glyphicon-arrow-down'>添加选取系列到产品授权</span>
</button>
</span>
{% endifequal%}
</div> </div>
</div> </div>
...@@ -123,6 +136,44 @@ ...@@ -123,6 +136,44 @@
{% block js %} {% block js %}
{{ block.super }} {{ block.super }}
//把授权系列产品添加到产品授权列表
$('#series_to_product').on('click',function(){
var series= $("#ySelectSeries").ySelectedValues(",");
if(!series) return;
if($("#ySelectSeries")){
$.ajax({
url: '/obj/ajax/series_to_product',
dataType: "json",
data: {
//term: $("#id_company_name").val() ,//搜索栏里的内容
company_id: {{ request.user.company_id }},//额外参数
series_ids : series
},
success: (data)=>{
console.log('data',data);
if(data.length==0) return;
for(var i=0;i<data.length;i++){
var e=false;
$("#sel-product option").each(function(){
if($(this).val() == data[i].id){
e=true;
}
});
if(e){
toastr.error(data[i].label+"已在列表中!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
console.log('已在列表中!',data[i].label);
}else{
$('#sel-product').append("<option value='"+data[i].id+"'>"+data[i].name+"</option>");
}
}
}
});
};
})
$('.btn-save').click(function(){ $('.btn-save').click(function(){
$(this).hide(); $(this).hide();
var g_ids=[]; var g_ids=[];
...@@ -201,10 +252,7 @@ ...@@ -201,10 +252,7 @@
}); });
$('#obj_form .btn-showpassword').click(function(){
event.preventDefault();
$('#password').show();
});
//2024-05-31 //2024-05-31
$('#sel_is_active').val('{{form.instance.is_active}}'); $('#sel_is_active').val('{{form.instance.is_active}}');
...@@ -248,6 +296,7 @@ ...@@ -248,6 +296,7 @@
} }
); );
$('#product_label').autocomplete({ $('#product_label').autocomplete({
source: function(request, response) { source: function(request, response) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论