from dash import dcc, html import feffery_antd_components as fac from flask import session from feffery_dash_utils.style_utils import style from config.global_config import ApiBaseUrlConfig import callbacks.dasset_c.ndstand_c from api.ndstand import get_ndstand_list_api from api.dscatalog import get_dscatalog_tree_api from . import nfddict_data def render(*args, **kwargs): button_perms = kwargs.get('button_perms') ndstand_params = dict(page_num=1, page_size=10) table_info = get_ndstand_list_api(ndstand_params) tree_data = get_dscatalog_tree_api(dict(title=''))['data'] for item in tree_data: #title更新value值 callbacks.dasset_c.ndstand_c.update_value_with_title(item) table_data = [] page_num = 1 page_size = 10 total = 0 if table_info['code'] == 200: table_data = table_info['data']['rows'] page_num = table_info['data']['page_num'] page_size = table_info['data']['page_size'] total = table_info['data']['total'] for item in table_data: 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) item['key'] = str(item['onum']) item['fddict_col_no'] = { 'content': item['fddict_col_no'], 'type': 'link', } #print(800000,item['fddict_col_no'] ,9999999) item['operation'] = [ { 'content': '修改', 'type': 'link', 'icon': 'antd-edit' } if 'dasset:ndstand:edit' in button_perms else {}, { 'content': '删除', 'type': 'link', 'icon': 'antd-delete' } if 'dasset:ndstand:remove' in button_perms else {}, ] return [ dcc.Store(id='ndstand-button-perms-container', data=button_perms), # 用于导出成功后重置dcc.Download的状态,防止多次下载文件 dcc.Store(id='ndstand-export-complete-judge-container'), # 绑定的导出组件 dcc.Download(id='ndstand-export-container'), # 岗位管理模块操作类型存储容器 dcc.Store(id='ndstand-operations-store'), dcc.Store(id='ndstand-operations-store-bk'), # 岗位管理模块修改操作行key存储容器 dcc.Store(id='ndstand-edit-id-store'), # 岗位管理模块删除操作行key存储容器 dcc.Store(id='ndstand-delete-ids-store'), fac.AntdRow( [ fac.AntdCol( [ fac.AntdInput( id='ndstand-input-search', placeholder='请输入标准分类名称', autoComplete='off', allowClear=True, prefix=fac.AntdIcon( icon='antd-search' ), style={ 'width': '85%' } ), fac.AntdTree( id='ndstand-tree', treeData=tree_data, defaultExpandAll=True, showLine=False, style={ 'margin-top': '10px', 'font-size': '14px', # 内联样式中设置字体大小 'color': 'black', # 内联样式中设置字体颜色 } ) ], span=4 ), fac.AntdCol( [ fac.AntdRow( [ fac.AntdCol( html.Div( [ fac.AntdForm( [ fac.AntdSpace( [ fac.AntdFormItem( fac.AntdInput( id='ndstand-data_std_no-input', placeholder='请输入数据标准编号', autoComplete='off', allowClear=True, style={ 'width': 200 } ), label='数据标准编号' ), fac.AntdFormItem( fac.AntdInput( id='ndstand-data_std_cn_name-input', placeholder='请输入数据标准中文名', autoComplete='off', allowClear=True, style={ 'width': 200 } ), label='数据标准中文名' ), fac.AntdFormItem( fac.AntdInput( id='ndstand-busi_defn-input', placeholder='请输入业务定义', autoComplete='off', allowClear=True, style={ 'width': 200 } ), label='业务定义' ), fac.AntdFormItem( fac.AntdSelect( id='ndstand-status-select', placeholder='状态', options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' } ], style={ 'width': 200 } ), label='状态' ), fac.AntdFormItem( fac.AntdButton( '搜索', id='ndstand-search', type='primary', icon=fac.AntdIcon( icon='antd-search' ) ) ), fac.AntdFormItem( fac.AntdButton( '重置', id='ndstand-reset', icon=fac.AntdIcon( icon='antd-sync' ) ) ) ], style={ 'paddingBottom': '10px' } ), ], layout='inline', ) ], id='ndstand-search-form-container', hidden=False ), ) ] ), fac.AntdRow( [ fac.AntdCol( fac.AntdSpace( [ fac.AntdButton( [ fac.AntdIcon( icon='antd-plus' ), '新增', ], id={ 'type': 'ndstand-operation-button', 'index': 'add' }, style={ 'color': '#1890ff', 'background': '#e8f4ff', 'border-color': '#a3d3ff' } ) if 'dasset:ndstand:add' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-edit' ), '修改', ], id={ 'type': 'ndstand-operation-button', 'index': 'edit' }, disabled=True, style={ 'color': '#71e2a3', 'background': '#e7faf0', 'border-color': '#d0f5e0' } ) if 'dasset:ndstand:edit' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-minus' ), '删除', ], id={ 'type': 'ndstand-operation-button', 'index': 'delete' }, disabled=True, style={ 'color': '#ff9292', 'background': '#ffeded', 'border-color': '#ffdbdb' } ) if 'dasset:ndstand:remove' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-arrow-up' ), '导入', ], id='ndstand-import', style={ 'color': '#909399', 'background': '#f4f4f5', 'border-color': '#d3d4d6' } ) if 'dasset:ndstand:import' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-arrow-down' ), '导出', ], id='ndstand-export', style={ 'color': '#ffba00', 'background': '#fff8e6', 'border-color': '#ffe399' } ) if 'dasset:ndstand:export' in button_perms else [], ], style={ 'paddingBottom': '10px', } ), span=16 ), fac.AntdCol( fac.AntdSpace( [ html.Div( fac.AntdTooltip( fac.AntdButton( [ fac.AntdIcon( icon='antd-search' ), ], id='ndstand-hidden', shape='circle' ), id='ndstand-hidden-tooltip', title='隐藏搜索' ) ), html.Div( fac.AntdTooltip( fac.AntdButton( [ fac.AntdIcon( icon='antd-sync' ), ], id='ndstand-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='ndstand-list-table', data=table_data, columns=[ { 'dataIndex': 'onum', 'title': '序号', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'data_std_no', 'title': '数据标准编号', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'data_std_cn_name', 'title': '数据标准中文名', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'data_std_eng_name', 'title': '数据标准英文', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'belt_scop', 'title': '所属范围', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'busi_defn', 'title': '业务定义', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'data_std_schm', 'title': '数据标准', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'std_pri_clas', 'title': '标准一级分类', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'std_scd_clas', 'title': '标准二级分类', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'std_thre_clas', 'title': '标准三级分类', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'data_sec_fifd', 'title': '数据安全分级', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'data_clas', 'title': '数据类别', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'val_scop', 'title': '取值范围', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'fddict_col_no', 'title': '代码编号', 'renderOptions': { 'renderType': 'button' }, }, # { # 'dataIndex': 'fddict_col_no', # 'title': '代码编号', # 'renderOptions': { # 'renderType': 'ellipsis' # }, # }, { 'dataIndex': 'update_by', 'title': '负责人', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'status', 'title': '状态', 'renderOptions': { 'renderType': 'switch' }, }, { 'dataIndex': 'create_time', 'title': '创建时间', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'title': '操作', 'dataIndex': 'operation', 'renderOptions': { 'renderType': 'button' }, } ], rowSelectionType='checkbox', rowSelectionWidth=50, bordered=True, maxWidth=2500, style={'width': '100%','text-align': 'center','paddingRight': '10px'}, pagination={ 'pageSize': page_size, 'current': page_num, 'showSizeChanger': True, 'pageSizeOptions': [15, 30, 50], 'showQuickJumper': True, 'total': total }, mode='server-side' ), text='数据加载中' ), ) ] ), ], span=20 ) ], gutter=5 ), # 新增和编辑测试表单modal fac.AntdModal( [ fac.AntdForm( [ fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'data_std_no' }, placeholder='请输入数据标准编号', allowClear=True, style={ 'width': '100%' } ), label='数据标准编号', required=True, id={ 'type': 'ndstand-form-label', 'index': 'data_std_no', 'required': True } ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'data_std_cn_name' }, placeholder='请输入数据标准中文名', allowClear=True, style={ 'width': '100%' } ), label='数据标准中文名', id={ 'type': 'ndstand-form-label', 'index': 'data_std_cn_name', 'required': False }, ), span=12 ) ], gutter=5 ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'data_std_eng_name' }, placeholder='请输入数据标准英文', allowClear=True, style={ 'width': '100%' } ), label='数据标准英文', required=True, id={ 'type': 'ndstand-form-label', 'index': 'data_std_eng_name', 'required': True } ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'belt_scop' }, placeholder='请输入所属范围', allowClear=True, style={ 'width': '100%' } ), label='所属范围', id={ 'type': 'ndstand-form-label', 'index': 'belt_scop', 'required': False }, ), span=12 ) ], gutter=5 ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'busi_defn' }, placeholder='请输入业务定义', allowClear=True, style={ 'width': '100%' } ), label='业务定义', required=True, id={ 'type': 'ndstand-form-label', 'index': 'busi_defn', 'required': True } ), span=12 ), # fac.AntdCol( # fac.AntdFormItem( # fac.AntdInput( # id={ # 'type': 'ndstand-form-value', # 'index': 'data_std_schm' # }, # placeholder='请输入数据标准', # allowClear=True, # style={ # 'width': '100%' # } # ), # label='数据标准', # id={ # 'type': 'ndstand-form-label', # 'index': 'data_std_schm', # 'required': False # }, # # labelCol={ # # 'offset': 1 # # }, # ), # span=12 # ) fac.AntdCol( fac.AntdFormItem( fac.AntdTreeSelect( id={ 'type': 'ndstand-form-value', 'index': 'data_std_schm' }, placeholder='请选择数据标准', allowClear=True, treeData=tree_data, treeNodeFilterProp='title', style={ 'width': '100%' #'width': '495px' } ), label='数据标准', id={ 'type': 'ndstand-form-label', 'index': 'data_std_schm', 'required': False } # , # labelCol={ # 'offset': 1 # } ), span=12 ) ], gutter=5 ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdTreeSelect( id={ 'type': 'ndstand-form-value', 'index': 'std_pri_clas' }, placeholder='请输入标准一级分类', allowClear=True, treeData=tree_data, treeNodeFilterProp='title', style={ 'width': '100%' } ), label='标准一级分类', #required=True, id={ 'type': 'ndstand-form-label', 'index': 'std_pri_clas', 'required': False } ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdTreeSelect( id={ 'type': 'ndstand-form-value', 'index': 'std_scd_clas' }, placeholder='标准二级分类', allowClear=True, treeData=tree_data, treeNodeFilterProp='title', style={ 'width': '100%', 'required': False } ), label='标准二级分类', id={ 'type': 'ndstand-form-label', 'index': 'std_scd_clas', 'required': False }, # labelCol={ # 'offset': 1 # }, ), span=12 ) ], gutter=5 ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdTreeSelect( id={ 'type': 'ndstand-form-value', 'index': 'std_thre_clas' }, placeholder='请输入标准三级分类', allowClear=True, treeData=tree_data, treeNodeFilterProp='title', style={ 'width': '100%' } ), label='标准三级分类', # required=True, id={ 'type': 'ndstand-form-label', 'index': 'std_thre_clas', 'required': False } ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'data_sec_fifd' }, placeholder='请输入数据安全分级', allowClear=True, style={ 'width': '100%' } ), label='数据安全分级', id={ 'type': 'ndstand-form-label', 'index': 'data_sec_fifd', 'required': False }, # labelCol={ # 'offset': 1 # }, ), span=12 ) ], gutter=5 ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'data_clas' }, placeholder='请输入数据类别', allowClear=True, style={ 'width': '100%' } ), label='数据类别', required=True, id={ 'type': 'ndstand-form-label', 'index': 'data_clas', 'required': True } ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'val_scop' }, placeholder='请输入取值范围', allowClear=True, style={ 'width': '100%' } ), label='取值范围', id={ 'type': 'ndstand-form-label', 'index': 'val_scop', 'required': False }, # labelCol={ # 'offset': 1 # }, ), span=12 ) ], gutter=5 ), fac.AntdRow( [ fac.AntdCol( fac.AntdFormItem( fac.AntdRadioGroup( id={ 'type': 'ndstand-form-value', 'index': 'status' }, options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' }, ], #defaultValue='0', style={ 'width': 350 } ), label='状态', id={ 'type': 'ndstand-form-label', 'index': 'status', 'required': False } ), # fac.AntdFormItem( # fac.AntdRadioGroup( # id={ # 'type': 'ndstand-form-value', # 'index': 'status' # }, # placeholder='请输入状态', # options=[ # { # 'label': '正常', # 'value': '0' # }, # { # 'label': '停用', # 'value': '1' # }, # ], # style={ # 'width': '100%' # } # ), # label='状态', # #required=True, # id={ # 'type': 'ndstand-form-label', # 'index': 'std_pri_clas', # 'required': False # } # ), span=12 ), fac.AntdCol( fac.AntdFormItem( fac.AntdInput( id={ 'type': 'ndstand-form-value', 'index': 'update_by' }, placeholder='请输入更新者', allowClear=True, style={ 'width': '100%' } ), label='更新者', id={ 'type': 'ndstand-form-label', 'index': 'update_by', 'required': False }, # labelCol={ # 'offset': 1 # }, ), span=12 ) ], gutter=5 ) ], labelCol={ 'span': 8 }, wrapperCol={ 'span': 16 }, style={ 'marginRight': '10px' } ) ], id='ndstand-modal', mask=False, width=680, renderFooter=True, okClickClose=False ), # 数据标准导入modal fac.AntdModal( [ html.Div( fac.AntdDraggerUpload( id='ndstand-upload-choose', apiUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/upload', apiUrlExtraParams={'taskPath': 'ndstandUpload'}, downloadUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/caches', downloadUrlExtraParams={'taskPath': 'ndstandUpload', 'token': session.get('Authorization')}, headers={'Authorization': 'Bearer ' + session.get('Authorization')}, fileTypes=['xls', 'xlsx'], fileListMaxLength=1, text='数据标准导入', hint='点击或拖拽文件至此处进行上传' ), style={ 'marginTop': '10px' } ), html.Div( [ fac.AntdCheckbox( id='ndstand-import-update-check', checked=False ), fac.AntdText( '是否更新已经存在的用户数据', style={ 'marginLeft': '5px' } ) ], style={ 'textAlign': 'center', 'marginTop': '10px' } ), html.Div( [ fac.AntdText('仅允许导入xls、xlsx格式文件。'), fac.AntdButton( '下载模板', id='download-ndstand-import-template', type='link' ) ], style={ 'textAlign': 'center', 'marginTop': '10px' } ) ], id='ndstand-import-confirm-modal', visible=False, title='数据标准导入', width=600, renderFooter=True, centered=True, okText='导入', confirmAutoSpin=True, loadingOkText='导入中', okClickClose=False ), fac.AntdModal( fac.AntdText( id='batch-result-content', className={ 'whiteSpace': 'break-spaces' } ), id='batch-result-modal', visible=False, title='数据标准导入结果', renderFooter=False, centered=True ), # 删除新测试二次确认modal fac.AntdModal( fac.AntdText('是否确认删除?', id='ndstand-delete-text'), id='ndstand-delete-confirm-modal', visible=False, title='提示', renderFooter=True, centered=True ), # 代码表数据modal fac.AntdModal( nfddict_data.render(button_perms), id='ndstand_to_nfddict_data-modal', mask=False, maskClosable=False, width=1000, renderFooter=False, okClickClose=False, visible=False, ) ]