Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
ypt_mgw_local
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
苏星豪
ypt_mgw_local
Commits
310b40b0
提交
310b40b0
authored
11月 21, 2024
作者:
李思鑫
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
产品系列下所有产品添加到授权产品
上级
b206ad1e
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
78 行增加
和
5 行删除
+78
-5
urls.py
datacenter/urls.py
+3
-0
views.py
listobj/views.py
+21
-0
user.html
templates/obj/user.html
+54
-5
没有找到文件。
datacenter/urls.py
浏览文件 @
310b40b0
...
...
@@ -119,6 +119,9 @@ urlpatterns = [
#2020-10-19
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
),
...
...
listobj/views.py
浏览文件 @
310b40b0
...
...
@@ -704,10 +704,14 @@ def edit_obj(request,obj_name,id=None):
if
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
)
else
:
s
=
"SELECT id,name,0"
+
\
"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
=
[]
if
id
:
s
=
"select id, name from product_product where id in (select UNNEST(product_ids) from company_user where id = "
+
id
+
") "
...
...
@@ -6394,3 +6398,20 @@ def agent_is_active_star(request,id=None):
"""
cur
.
execute
(
s
)
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
)
templates/obj/user.html
浏览文件 @
310b40b0
...
...
@@ -70,9 +70,15 @@
</div>
</div>
<style>
.fs-wrap
{
vertical-align
:
middle
;
}
</style>
<div
class=
"form-group"
>
<label
class=
"col-md-2 control-label"
>
产品系列授权
</label>
<div
class=
'col-sm-
4
'
>
<div
class=
'col-sm-
10
'
>
<select
id=
"ySelectSeries"
multiple=
"multiple"
>
{% for s in series %}
{% ifequal s.2 1 %}
...
...
@@ -82,6 +88,13 @@
{% endifequal %}
{% endfor %}
</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>
...
...
@@ -123,6 +136,44 @@
{% block js %}
{{ 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(){
$(this).hide();
var g_ids=[];
...
...
@@ -201,10 +252,7 @@
});
$('#obj_form .btn-showpassword').click(function(){
event.preventDefault();
$('#password').show();
});
//2024-05-31
$('#sel_is_active').val('{{form.instance.is_active}}');
...
...
@@ -249,6 +297,7 @@
);
$('#
product_label
').
autocomplete
({
source:
function
(
request
,
response
)
{
$.
ajax
({
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论