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.fccbd_c from api.fccbd import get_fccbd_list_api def render(*args, **kwargs): button_perms = kwargs.get('button_perms') fccbd_params = dict(page_num=1, page_size=10) table_info = get_fccbd_list_api(fccbd_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:fccbd:edit' in button_perms else {}, { 'content': '删除', 'type': 'link', 'icon': 'antd-delete' } if 'dataint:cypz:fccbd:remove' in button_perms else {}, ] return [ dcc.Store(id='fccbd-button-perms-container', data=button_perms), # 用于导出成功后重置dcc.Download的状态,防止多次下载文件 dcc.Store(id='fccbd-export-complete-judge-container'), # 绑定的导出组件 dcc.Download(id='fccbd-export-container'), # 岗位管理模块操作类型存储容器 dcc.Store(id='fccbd-operations-store'), dcc.Store(id='fccbd-operations-store-bk'), # 岗位管理模块修改操作行key存储容器 dcc.Store(id='fccbd-edit-id-store'), # 岗位管理模块删除操作行key存储容器 dcc.Store(id='fccbd-delete-ids-store'), fac.AntdRow( [ fac.AntdCol( [ fac.AntdRow( [ fac.AntdCol( html.Div( [ fac.AntdForm( [ fac.AntdSpace( [ fac.AntdFormItem( fac.AntdInput( id='fccbd-term-input', placeholder='请输入词语', autoComplete='off', allowClear=True, style={ 'width': 210 } ), label='词语' ), fac.AntdFormItem( fac.AntdInput( id='fccbd-pos-input', placeholder='请输入词性', autoComplete='off', allowClear=True, style={ 'width': 210 } ), label='词性' ), fac.AntdFormItem( fac.AntdInput( id='fccbd-pos_name-input', placeholder='请输入词性名称', autoComplete='off', allowClear=True, style={ 'width': 210 } ), label='词性名称' ), fac.AntdFormItem( fac.AntdSelect( id='fccbd-status-select', placeholder='状态', options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' } ], style={ 'width': 200 } ), label='状态' ), fac.AntdFormItem( fac.AntdButton( '搜索', id='fccbd-search', type='primary', icon=fac.AntdIcon( icon='antd-search' ) ) ), fac.AntdFormItem( fac.AntdButton( '重置', id='fccbd-reset', icon=fac.AntdIcon( icon='antd-sync' ) ) ) ], style={ 'paddingBottom': '10px' } ), ], layout='inline', ) ], id='fccbd-search-form-container', hidden=False ), ) ] ), fac.AntdRow( [ fac.AntdCol( fac.AntdSpace( [ fac.AntdButton( [ fac.AntdIcon( icon='antd-plus' ), '新增', ], id={ 'type': 'fccbd-operation-button', 'index': 'add' }, style={ 'color': '#1890ff', 'background': '#e8f4ff', 'border-color': '#a3d3ff' } ) if 'dataint:cypz:fccbd:add' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-edit' ), '修改', ], id={ 'type': 'fccbd-operation-button', 'index': 'edit' }, disabled=True, style={ 'color': '#71e2a3', 'background': '#e7faf0', 'border-color': '#d0f5e0' } ) if 'dataint:cypz:fccbd:edit' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-minus' ), '删除', ], id={ 'type': 'fccbd-operation-button', 'index': 'delete' }, disabled=True, style={ 'color': '#ff9292', 'background': '#ffeded', 'border-color': '#ffdbdb' } ) if 'dataint:cypz:fccbd:remove' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-arrow-up' ), '导入', ], id='fccbd-import', style={ 'color': '#909399', 'background': '#f4f4f5', 'border-color': '#d3d4d6' } ) if 'dataint:cypz:fccbd:export' in button_perms else [], fac.AntdButton( [ fac.AntdIcon( icon='antd-arrow-down' ), '导出', ], id='fccbd-export', style={ 'color': '#ffba00', 'background': '#fff8e6', 'border-color': '#ffe399' } ) if 'dataint:cypz:fccbd: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='fccbd-hidden', shape='circle' ), id='fccbd-hidden-tooltip', title='隐藏搜索' ) ), html.Div( fac.AntdTooltip( fac.AntdButton( [ fac.AntdIcon( icon='antd-sync' ), ], id='fccbd-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='fccbd-list-table', data=table_data, columns=[ { 'dataIndex': 'onum', 'title': '序号', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'term', 'title': '词语', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'freq', 'title': '频次', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'pos', 'title': '词性', 'renderOptions': { 'renderType': 'ellipsis' }, }, { 'dataIndex': 'pos_name', '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': 'fccbd-form-value', 'index': 'term' }, placeholder='请输入词语', allowClear=True, style={ 'width': 350 } ), label='词语', required=True, id={ 'type': 'fccbd-form-label', 'index': 'term', 'required': True } ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'fccbd-form-value', 'index': 'freq' }, placeholder='请输入频次', allowClear=True, style={ 'width': 350 } ), label='频次', required=True, id={ 'type': 'fccbd-form-label', 'index': 'freq', 'required': True } ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'fccbd-form-value', 'index': 'pos' }, placeholder='请输入词性', allowClear=True, style={ 'width': 350 } ), label='词性', required=True, id={ 'type': 'fccbd-form-label', 'index': 'pos', 'required': True } ), fac.AntdFormItem( fac.AntdInput( id={ 'type': 'fccbd-form-value', 'index': 'pos_name' }, placeholder='请输入词性名称', allowClear=True, style={ 'width': 350 } ), label='词性名称', required=True, id={ 'type': 'fccbd-form-label', 'index': 'pos_name', 'required': True } ), fac.AntdFormItem( fac.AntdRadioGroup( id={ 'type': 'fccbd-form-value', 'index': 'status' }, options=[ { 'label': '正常', 'value': '0' }, { 'label': '停用', 'value': '1' }, ], #defaultValue='0', style={ 'width': 350 } ), label='状态', required=True, id={ 'type': 'fccbd-form-label', 'index': 'status', 'required': False } ), ], labelCol={ 'span': 6 }, wrapperCol={ 'span': 18 } ) ], id='fccbd-modal', mask=False, width=580, renderFooter=True, okClickClose=False ), # 删除新词典配置表二次确认modal fac.AntdModal( fac.AntdText('是否确认删除?', id='fccbd-delete-text'), id='fccbd-delete-confirm-modal', visible=False, title='提示', renderFooter=True, centered=True ), # 词典配置表导入modal fac.AntdModal( [ html.Div( fac.AntdDraggerUpload( id='fccbd-upload-choose', apiUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/upload', apiUrlExtraParams={'taskPath': 'fccbdUpload'}, downloadUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/caches', downloadUrlExtraParams={'taskPath': 'fccbdUpload', '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='fccbd-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-fccbd-import-template', type='link' ) ], style={ 'textAlign': 'center', 'marginTop': '10px' } ) ], id='fccbd-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 ), ]