from dash import dcc, html import feffery_antd_components as fac import callbacks.system_c.dscatalog_c from api.dscatalog import get_dscatalog_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_dscatalog_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['dscatalog_id'])) item['key'] = str(item['dscatalog_id']) if item['dscatalog_parent_id'] == 0: item['operation'] = [ { 'content': '修改', 'type': 'link', 'icon': 'antd-edit' } if 'system:dscatalog:edit' in button_perms else {}, { 'content': '新增', 'type': 'link', 'icon': 'antd-plus' } if 'system:dscatalog:add' in button_perms else {}, ] elif item['status'] == '1': item['operation'] = [ { 'content': '修改', 'type': 'link', 'icon': 'antd-edit' } if 'system:dscatalog:edit' in button_perms else {}, { 'content': '删除', 'type': 'link', 'icon': 'antd-delete' } if 'system:dscatalog:remove' in button_perms else {}, ] else: item['operation'] = [ { 'content': '修改', 'type': 'link', 'icon': 'antd-edit' } if 'system:dscatalog:edit' in button_perms else {}, { 'content': '新增', 'type': 'link', 'icon': 'antd-plus' } if 'system:dscatalog:add' in button_perms else {}, { 'content': '删除', 'type': 'link', 'icon': 'antd-delete' } if 'system:dscatalog: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, 'dscatalog_id', 'dscatalog_parent_id') return [ dcc.Store(id='dscatalog-button-perms-container', data=button_perms), # 标准管理模块操作类型存储容器 dcc.Store(id='dscatalog-operations-store'), dcc.Store(id='dscatalog-operations-store-bk'), # 标准管理模块修改操作行key存储容器 dcc.Store(id='dscatalog-edit-id-store'), # 标准管理模块删除操作行key存储容器 dcc.Store(id='dscatalog-delete-ids-store'), fac.AntdRow( [ fac.AntdCol( [ fac.AntdRow( [ fac.AntdCol( html.Div( [ fac.AntdForm( [ fac.AntdSpace( [ fac.AntdFormItem( fac.AntdInput( id='dscatalog-dscatalog_name-input', placeholder='请输入标准目录名称', autoComplete='off', allowClear=True, style={ 'width': 240 } ), label='标准目录名称' ), fac.AntdFormItem( fac.AntdSelect( id='dscatalog-status-select', placeholder='标准目录状态', options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' } ], style={ 'width': 240 } ), label='标准目录状态' ), fac.AntdFormItem( fac.AntdButton( '搜索', id='dscatalog-search', type='primary', icon=fac.AntdIcon( icon='antd-search' ) ) ), fac.AntdFormItem( fac.AntdButton( '重置', id='dscatalog-reset', icon=fac.AntdIcon( icon='antd-sync' ) ) ) ], style={ 'paddingBottom': '10px' } ), ], layout='inline', ) ], hidden=False, id='dscatalog-search-form-container', ), ) ] ), fac.AntdRow( [ fac.AntdCol( fac.AntdSpace( [ fac.AntdButton( [ fac.AntdIcon( icon='antd-plus' ), '新增', ], id={ 'type': 'dscatalog-operation-button', 'index': 'add' }, style={ 'color': '#1890ff', 'background': '#e8f4ff', 'border-color': '#a3d3ff' } ) if 'system:dscatalog:add' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-swap' ), '展开/折叠', ], id='dscatalog-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='dscatalog-hidden', shape='circle' ), id='dscatalog-hidden-tooltip', title='隐藏搜索' ) ), html.Div( fac.AntdTooltip( fac.AntdButton( [ fac.AntdIcon( icon='antd-sync' ), ], id='dscatalog-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='dscatalog-list-table', data=table_data_new, columns=[ { 'dataIndex': 'dscatalog_id', 'title': '标准编号', 'renderOptions': { 'renderType': 'ellipsis' }, 'hidden': True }, { 'dataIndex': 'dscatalog_name', 'title': '标准目录名称', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'dscatalog_remark', 'title': '标准目录分类', #隐藏排序字段,此处改为标准说明 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'status', 'title': '标准目录状态', 'renderOptions': { 'renderType': 'switch' }, }, #dscatalog_order_num { 'dataIndex': 'dscatalog_area', #增加标准范围,控制动态添加树 'title': '标准目录层级', '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, 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': 'dscatalog-form-value', 'index': 'dscatalog_parent_id' }, placeholder='请选择上级标准', treeData=[], treeNodeFilterProp='title', style={ 'width': '100%' } ), label='上级标准', required=True, id={ 'type': 'dscatalog-form-label', 'index': 'dscatalog_parent_id', 'required': True }, labelCol={ 'span': 4 }, wrapperCol={ 'span': 20 } ), ], id='dscatalog-dscatalog_parent_id-div', hidden=False ), span=24 ), ] ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'dscatalog-form-value', 'index': 'dscatalog_name' }, placeholder='请输入标准目录名', allowClear=True, style={ 'width': '100%' } ), label='标准目录名', required=True, id={ 'type': 'dscatalog-form-label', 'index': 'dscatalog_name', 'required': True } ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'dscatalog-form-value', 'index': 'dscatalog_remark' }, placeholder='请输入标准目录分类', #min=0, style={ 'width': '100%' } ), label='标准目录分类', required=False, id={ 'type': 'dscatalog-form-label', 'index': 'dscatalog_remark', 'required': False } ), span=12 ) ], gutter=5 ), fac.AntdRow( [ # fac.AntdCol( # fac.AntdFormItem( # fac.AntdSelect( # id={ # 'type': 'dscatalog-form-value', # 'index': 'dscatalog_area' # }, # placeholder='请选择标准层级', # options=[ # { # 'label': '一级', # 'value': '一级' # }, # { # 'label': '二级', # 'value': '二级' # }, # { # 'label': '三级', # 'value': '三级' # }, # { # 'label': '四级', # 'value': '四级' # }, # { # 'label': '五级', # 'value': '五级' # } # ], # style={ # 'width': '100%' # } # ), # label='标准层级', # id={ # 'type': 'dscatalog-form-label', # 'index': 'dscatalog_area', # 'required': False # }, # ), # span=12 # ), 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 ) ], gutter=5 ) ], labelCol={ 'span': 8 }, wrapperCol={ 'span': 16 }, style={ 'marginRight': '15px' } ) ], id='dscatalog-modal', mask=False, width=650, renderFooter=True, okClickClose=False ), # 删除标准二次确认modal fac.AntdModal( fac.AntdText('是否确认删除?', id='dscatalog-delete-text'), id='dscatalog-delete-confirm-modal', visible=False, title='提示', renderFooter=True, centered=True ), ]