from dash import dcc, html import feffery_antd_components as fac from flask import session from config.global_config import ApiBaseUrlConfig import callbacks.dataint_c.cypz_c.tsmcb_c from api.tsmcb import get_tsmcb_list_api def render(*args, **kwargs): button_perms = kwargs.get('button_perms') tsmcb_params = dict(page_num=1, page_size=10) table_info = get_tsmcb_list_api(tsmcb_params) 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['operation'] = [ { 'content': '修改', 'type': 'link', 'icon': 'antd-edit' } if 'dataint:cypz:tsmcb:edit' in button_perms else {}, { 'content': '删除', 'type': 'link', 'icon': 'antd-delete' } if 'dataint:cypz:tsmcb:remove' in button_perms else {}, ] return [ dcc.Store(id='tsmcb-button-perms-container', data=button_perms), # 用于导出成功后重置dcc.Download的状态,防止多次下载文件 dcc.Store(id='tsmcb-export-complete-judge-container'), # 绑定的导出组件 dcc.Download(id='tsmcb-export-container'), # 岗位管理模块操作类型存储容器 dcc.Store(id='tsmcb-operations-store'), dcc.Store(id='tsmcb-operations-store-bk'), # 岗位管理模块修改操作行key存储容器 dcc.Store(id='tsmcb-edit-id-store'), # 岗位管理模块删除操作行key存储容器 dcc.Store(id='tsmcb-delete-ids-store'), fac.AntdRow( [ fac.AntdCol( [ fac.AntdRow( [ fac.AntdCol( html.Div( [ fac.AntdForm( [ fac.AntdSpace( [ fac.AntdFormItem( fac.AntdInput( id='tsmcb-pos-input', placeholder='请输入词性', autoComplete='off', allowClear=True, style={ 'width': 210 } ), label='词性' ), fac.AntdFormItem( fac.AntdInput( id='tsmcb-type-input', placeholder='请输入类型', autoComplete='off', allowClear=True, style={ 'width': 210 } ), label='类型' ), fac.AntdFormItem( fac.AntdInput( id='tsmcb-std_rpl_str-input', placeholder='请输入标准化替换字符', autoComplete='off', allowClear=True, style={ 'width': 210 } ), label='标准化替换字符' ), fac.AntdFormItem( fac.AntdSelect( id='tsmcb-status-select', placeholder='状态', options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' } ], style={ 'width': 200 } ), label='状态' ), fac.AntdFormItem( fac.AntdButton( '搜索', id='tsmcb-search', type='primary', icon=fac.AntdIcon( icon='antd-search' ) ) ), fac.AntdFormItem( fac.AntdButton( '重置', id='tsmcb-reset', icon=fac.AntdIcon( icon='antd-sync' ) ) ) ], style={ 'paddingBottom': '10px' } ), ], layout='inline', ) ], id='tsmcb-search-form-container', hidden=False ), ) ] ), fac.AntdRow( [ fac.AntdCol( fac.AntdSpace( [ fac.AntdButton( [ fac.AntdIcon( icon='antd-plus' ), '新增', ], id={ 'type': 'tsmcb-operation-button', 'index': 'add' }, style={ 'color': '#1890ff', 'background': '#e8f4ff', 'border-color': '#a3d3ff' } ) if 'dataint:cypz:tsmcb:add' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-edit' ), '修改', ], id={ 'type': 'tsmcb-operation-button', 'index': 'edit' }, disabled=True, style={ 'color': '#71e2a3', 'background': '#e7faf0', 'border-color': '#d0f5e0' } ) if 'dataint:cypz:tsmcb:edit' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-minus' ), '删除', ], id={ 'type': 'tsmcb-operation-button', 'index': 'delete' }, disabled=True, style={ 'color': '#ff9292', 'background': '#ffeded', 'border-color': '#ffdbdb' } ) if 'dataint:cypz:tsmcb:remove' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-arrow-up' ), '导入', ], id='tsmcb-import', style={ 'color': '#909399', 'background': '#f4f4f5', 'border-color': '#d3d4d6' } ) if 'dataint:cypz:tsmcb:export' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-arrow-down' ), '导出', ], id='tsmcb-export', style={ 'color': '#ffba00', 'background': '#fff8e6', 'border-color': '#ffe399' } ) if 'dataint:cypz:tsmcb: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='tsmcb-hidden', shape='circle' ), id='tsmcb-hidden-tooltip', title='隐藏搜索' ) ), html.Div( fac.AntdTooltip( fac.AntdButton( [ fac.AntdIcon( icon='antd-sync' ), ], id='tsmcb-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='tsmcb-list-table', data=table_data, columns=[ { 'dataIndex': 'onum', 'title': '序号', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'pos', 'title': '词性', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'type', 'title': '类型', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'std_rpl_str', 'title': '标准化替换字符', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'prefix_supp_str', 'title': '前缀补充字符', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'suffix_supp_str', 'title': '后缀补充字符', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'status', 'title': '状态', 'renderOptions': { 'renderType': 'switch' }, }, { 'dataIndex': 'update_by', 'title': '负责人员', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'update_time', 'title': '更新时间', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'title': '操作', 'dataIndex': 'operation', 'renderOptions': { 'renderType': 'button' }, } ], rowSelectionType='checkbox', rowSelectionWidth=50, bordered=True, maxWidth=2000, maxHeight=500, 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=24 ) ], gutter=5 ), # 新增和编辑代码表单modal fac.AntdModal( [ fac.AntdForm( [ fac.AntdFormItem( fac.AntdInput( id={ 'type': 'tsmcb-form-value', 'index': 'pos' }, placeholder='请输入词性', allowClear=True, style={ 'width': 350 } ), label='词性', required=True, id={ 'type': 'tsmcb-form-label', 'index': 'pos', 'required': True } ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'tsmcb-form-value', 'index': 'type' }, placeholder='请输入类型', allowClear=True, style={ 'width': 350 } ), label='类型', required=True, id={ 'type': 'tsmcb-form-label', 'index': 'type', 'required': True } ), # fac.AntdFormItem( # fac.AntdInput( # id={ # 'type': 'tsmcb-form-value', # 'index': 'std_rpl_str' # }, # placeholder='请输入标准化字符', # allowClear=True, # style={ # 'width': 350 # } # ), # label='标准化字符', # required=True, # id={ # 'type': 'tsmcb-form-label', # 'index': 'std_rpl_str', # 'required': True # } # ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'tsmcb-form-value', 'index': 'std_rpl_str' }, placeholder='请输入标准化替换字符', allowClear=True, style={ 'width': 350 } ), label='标准化替换字符', required=True, id={ 'type': 'tsmcb-form-label', 'index': 'std_rpl_str', 'required': True } ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'tsmcb-form-value', 'index': 'prefix_supp_str' }, placeholder='请输入前缀补充字符', allowClear=True, style={ 'width': 350 } ), label='前缀补充字符', required=True, id={ 'type': 'tsmcb-form-label', 'index': 'prefix_supp_str', 'required': True } ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'tsmcb-form-value', 'index': 'suffix_supp_str' }, placeholder='请输入后缀补充字符', allowClear=True, style={ 'width': 350 } ), label='后缀补充字符', required=True, id={ 'type': 'tsmcb-form-label', 'index': 'suffix_supp_str', 'required': True } ), fac.AntdFormItem( fac.AntdRadioGroup( id={ 'type': 'tsmcb-form-value', 'index': 'status' }, options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' }, ], #defaultValue='0', style={ 'width': 350 } ), label='状态', required=True, id={ 'type': 'tsmcb-form-label', 'index': 'status', 'required': False } ), ], labelCol={ 'span': 6 }, wrapperCol={ 'span': 18 } ) ], id='tsmcb-modal', mask=False, width=580, renderFooter=True, okClickClose=False ), # 删除新代码二次确认modal fac.AntdModal( fac.AntdText('是否确认删除?', id='tsmcb-delete-text'), id='tsmcb-delete-confirm-modal', visible=False, title='提示', renderFooter=True, centered=True ), # 代码表导入modal fac.AntdModal( [ html.Div( fac.AntdDraggerUpload( id='tsmcb-upload-choose', apiUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/upload', apiUrlExtraParams={'taskPath': 'tsmcbUpload'}, downloadUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/caches', downloadUrlExtraParams={'taskPath': 'tsmcbUpload', '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='tsmcb-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-tsmcb-import-template', type='link' ) ], style={ 'textAlign': 'center', 'marginTop': '10px' } ) ], id='tsmcb-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 ), ]