You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

652 lines
35 KiB

from dash import dcc, html
import feffery_antd_components as fac
import callbacks.system_c.dasset_c
from api.dasset import get_dasset_list_api
from utils.tree_tool import list_to_tree
def render(*args, **kwargs):
button_perms = kwargs.get('button_perms')
table_data_new = []
default_expanded_row_keys = []
table_info = get_dasset_list_api({})
if table_info['code'] == 200:
table_data = table_info['data']['rows']
for item in table_data:
default_expanded_row_keys.append(str(item['dasset_id']))
item['key'] = str(item['dasset_id'])
if item['dasset_parent_id'] == 0:
item['operation'] = [
{
'content': '修改',
'type': 'link',
'icon': 'antd-edit'
} if 'system:dasset:edit' in button_perms else {},
{
'content': '新增',
'type': 'link',
'icon': 'antd-plus'
} if 'system:dasset:add' in button_perms else {},
]
elif item['status'] == '1':
item['operation'] = [
{
'content': '修改',
'type': 'link',
'icon': 'antd-edit'
} if 'system:dasset:edit' in button_perms else {},
{
'content': '删除',
'type': 'link',
'icon': 'antd-delete'
} if 'system:dasset:remove' in button_perms else {},
]
else:
item['operation'] = [
{
'content': '修改',
'type': 'link',
'icon': 'antd-edit'
} if 'system:dasset:edit' in button_perms else {},
{
'content': '新增',
'type': 'link',
'icon': 'antd-plus'
} if 'system:dasset:add' in button_perms else {},
{
'content': '删除',
'type': 'link',
'icon': 'antd-delete'
} if 'system:dasset:remove' in button_perms else {},
]
if item['status'] == '0':
#item['status'] = dict(tag='正常', color='blue')
item['status'] = dict(checked=True)
else:
#item['status'] = dict(tag='停用', color='volcano')
item['status'] = dict(checked=False)
table_data_new = list_to_tree(table_data, 'dasset_id', 'dasset_parent_id')
return [
dcc.Store(id='dasset-button-perms-container', data=button_perms),
# 资产管理模块操作类型存储容器
dcc.Store(id='dasset-operations-store'),
dcc.Store(id='dasset-operations-store-bk'),
# 资产管理模块修改操作行key存储容器
dcc.Store(id='dasset-edit-id-store'),
# 资产管理模块删除操作行key存储容器
dcc.Store(id='dasset-delete-ids-store'),
fac.AntdRow(
[
fac.AntdCol(
[
fac.AntdRow(
[
fac.AntdCol(
html.Div(
[
fac.AntdForm(
[
fac.AntdSpace(
[
fac.AntdFormItem(
fac.AntdInput(
id='dasset-dasset_name-input',
placeholder='请输入资产名称',
autoComplete='off',
allowClear=True,
style={
'width': 240
}
),
label='资产名称'
),
fac.AntdFormItem(
fac.AntdSelect(
id='dasset-status-select',
placeholder='资产状态',
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
}
],
style={
'width': 240
}
),
label='资产状态'
),
fac.AntdFormItem(
fac.AntdButton(
'搜索',
id='dasset-search',
type='primary',
icon=fac.AntdIcon(
icon='antd-search'
)
)
),
fac.AntdFormItem(
fac.AntdButton(
'重置',
id='dasset-reset',
icon=fac.AntdIcon(
icon='antd-sync'
)
)
)
],
style={
'paddingBottom': '10px'
}
),
],
layout='inline',
)
],
hidden=False,
id='dasset-search-form-container',
),
)
]
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdSpace(
[
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-plus'
),
'新增',
],
id={
'type': 'dasset-operation-button',
'index': 'add'
},
style={
'color': '#1890ff',
'background': '#e8f4ff',
'border-color': '#a3d3ff'
}
) if 'system:dasset:add' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-swap'
),
'展开/折叠',
],
id='dasset-fold',
style={
'color': '#909399',
'background': '#f4f4f5',
'border-color': '#d3d4d6'
}
),
],
style={
'paddingBottom': '10px'
}
),
span=16
),
fac.AntdCol(
fac.AntdSpace(
[
html.Div(
fac.AntdTooltip(
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-search'
),
],
id='dasset-hidden',
shape='circle'
),
id='dasset-hidden-tooltip',
title='隐藏搜索'
)
),
html.Div(
fac.AntdTooltip(
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-sync'
),
],
id='dasset-refresh',
shape='circle'
),
title='刷新'
)
),
],
style={
'float': 'right',
'paddingBottom': '10px'
}
),
span=8,
style={
'paddingRight': '10px'
}
)
],
gutter=5
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdSpin(
fac.AntdTable(
id='dasset-list-table',
data=table_data_new,
columns=[
{
'dataIndex': 'dasset_id',
'title': '资产编号',
'renderOptions': {
'renderType': 'ellipsis'
},
'hidden': True
},
{
'dataIndex': 'dasset_name',
'title': '资产名称',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'dasset_remark',
'title': '资产英文名', #隐藏排序字段,此处改为资产说明
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'status',
'title': '状态',
'renderOptions': {
'renderType': 'switch'
},
},
# {
# 'dataIndex': 'dasset_area', #增加资产范围,控制动态添加树
# 'title': '资产范围',
# 'renderOptions': {
# 'renderType': 'ellipsis'
# },
# },
{
'dataIndex': 'clas',
'title': '标签',
'width': 100,
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'usages',
'title': '用法',
'width': 100,
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'data_sec_cifd',
'title': '数据安全分级',
'width': 120,
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'update_by',
'title': '维护人员',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'create_time',
'title': '创建时间',
#'width': '180px',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'title': '操作',
'dataIndex': 'operation',
'renderOptions': {
'renderType': 'button'
},
}
],
bordered=True,
maxWidth=1000,
maxHeight=500,
#maxHeight=500,
pagination={
'hideOnSinglePage': True
},
defaultExpandedRowKeys=default_expanded_row_keys[0],
#defaultExpandedRowKeys=default_expanded_row_keys,
style={
'width': '100%',
'padding-right': '10px',
'padding-bottom': '20px'
}
),
text='数据加载中'
),
)
]
),
],
span=24
)
],
gutter=5
),
# 新增和编辑资产表单modal
fac.AntdModal(
[
fac.AntdForm(
[
fac.AntdRow(
[
fac.AntdCol(
html.Div(
[
fac.AntdFormItem(
fac.AntdTreeSelect(
id={
'type': 'dasset-form-value',
'index': 'dasset_parent_id'
},
placeholder='请选择上级资产',
treeData=[],
treeNodeFilterProp='title',
style={
'width': '100%'
}
),
label='上级资产',
required=True,
id={
'type': 'dasset-form-label',
'index': 'dasset_parent_id',
'required': True
},
labelCol={
'span': 4
},
wrapperCol={
'span': 20
}
),
],
id='dasset-dasset_parent_id-div',
hidden=False
),
span=24
),
]
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'dasset-form-value',
'index': 'dasset_name'
},
placeholder='请输入资产名称',
allowClear=True,
style={
'width': '100%'
}
),
label='资产名称',
required=True,
id={
'type': 'dasset-form-label',
'index': 'dasset_name',
'required': True
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'dasset-form-value',
'index': 'dasset_remark'
},
placeholder='请输入资产英文名',
#min=0,
style={
'width': '100%'
}
),
label='资产英文名',
required=True,
id={
'type': 'dasset-form-label',
'index': 'dasset_remark',
'required': True
}
),
span=12
)
],
gutter=5
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'dasset-form-value',
'index': 'clas'
},
placeholder='请输入标签',
allowClear=True,
style={
'width': '100%'
}
),
label='标签',
required=False,
id={
'type': 'dasset-form-label',
'index': 'clas',
'required': False
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'dasset-form-value',
'index': 'usages'
},
placeholder='请输入用法',
#min=0,
style={
'width': '100%'
}
),
label='用法',
required=False,
id={
'type': 'dasset-form-label',
'index': 'usages',
'required': False
}
),
span=12
)
],
gutter=5
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdRadioGroup(
id={
'type': 'dasset-form-value',
'index': 'status'
},
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
},
],
#defaultValue='0',
style={
'width': 350
}
),
label='状态',
id={
'type': 'dasset-form-label',
'index': 'status',
'required': False
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'dasset-form-value',
'index': 'data_sec_cifd'
},
placeholder='请输入数据安全分级',
allowClear=False,
style={
'width': '100%'
}
),
label='数据安全分级',
required=False,
id={
'type': 'dasset-form-label',
'index': 'data_sec_cifd',
'required': False
}
),
span=12
)
],
gutter=5
)
# fac.AntdRow(
# [
# fac.AntdCol(
# fac.AntdFormItem(
# fac.AntdInputNumber(
# id={
# 'type': 'dasset-form-value',
# 'index': 'dasset_order_num'
# },
# min=0,
# style={
# 'width': '100%'
# }
# ),
# label='显示顺序',
# required=True, #小红星星,必填
# id={
# 'type': 'dasset-form-label',
# 'index': 'dasset_order_num',
# 'required': True
# }
# ),
# span=12
# ),
# fac.AntdCol(
# fac.AntdFormItem(
# fac.AntdInput(
# id={
# 'type': 'dasset-form-value',
# 'index': 'update_by'
# },
# placeholder='请输入维护人员',
# allowClear=True,
# style={
# 'width': '100%'
# }
# ),
# label='维护人员',
# required=True,
# id={
# 'type': 'dasset-form-label',
# 'index': 'update_by',
# 'required': True
# }
# ),
# span=12
# )
# ],
# gutter=5
# )
],
labelCol={
'span': 8
},
wrapperCol={
'span': 16
},
style={
'marginRight': '15px'
}
)
],
id='dasset-modal',
mask=False,
width=650,
renderFooter=True,
okClickClose=False
),
# 删除资产二次确认modal
fac.AntdModal(
fac.AntdText('是否确认删除?', id='dasset-delete-text'),
id='dasset-delete-confirm-modal',
visible=False,
title='提示',
renderFooter=True,
centered=True
),
]