import dash import time import uuid from dash import dcc from dash.dependencies import Input, Output, State, ALL from dash.exceptions import PreventUpdate import feffery_utils_components as fuc from server import app from utils.common import validate_data_not_empty from api.dasset import get_dasset_tree_api from api.vecset import get_vecset_list_api, get_vecset_detail_api, add_vecset_api, edit_vecset_api, delete_vecset_api,change_vecset_info_api, export_vecset_list_api,download_vecset_import_template_api,batch_import_vecset_api #树形搜索 app.clientside_callback( """(value) => value""", Output('vdasset-tree', 'searchKeyword'), Input('vdasset-input-search', 'value'), ) @app.callback( output=dict( vecset_table_data=Output('vecset-list-table', 'data', allow_duplicate=True), vecset_table_pagination=Output('vecset-list-table', 'pagination', allow_duplicate=True), vecset_table_key=Output('vecset-list-table', 'key'), vecset_table_selectedrowkeys=Output('vecset-list-table', 'selectedRowKeys'), api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True) ), inputs=dict( selected_dasset_tree=Input('vdasset-tree', 'selectedKeys'), search_click=Input('vecset-search', 'nClicks'), refresh_click=Input('vecset-refresh', 'nClicks'), pagination=Input('vecset-list-table', 'pagination'), operations=Input('vecset-operations-store', 'data') ), state=dict( stab_name=State('vecset-stab_name-input', 'value'), squery=State('vecset-squery-input', 'value'), sanal_plan=State('vecset-sanal_plan-input', 'value'), status_select=State('vecset-status-select', 'value'), #create_time_range=State('vecset-create_time-range', 'value'), button_perms=State('vecset-button-perms-container', 'data') ), prevent_initial_call=True ) #create_time_range, def get_vecset_table_data_by_dasset_tree(selected_dasset_tree, search_click, refresh_click, pagination, operations, stab_name,squery, sanal_plan,status_select, button_perms): """ 获取全句配置表格数据回调(进行表格相关增删查改操作后均会触发此回调) """ dasset_id = None # create_time_start = None # create_time_end = None query_params = None #print(55555,selected_dasset_tree,66666,create_time_range) if selected_dasset_tree is None: selected_dasset_tree = ['101'] # if create_time_range: # create_time_start = create_time_range[0] # create_time_end = create_time_range[1] if selected_dasset_tree: dasset_id = int(selected_dasset_tree[0]) query_params = dict( dasset_id=dasset_id, stab_name=stab_name, squery=squery, sanal_plan=sanal_plan, status=status_select, # create_time_start=create_time_start, # create_time_end=create_time_end, page_num=1, page_size=15 ) triggered_id = dash.ctx.triggered_id if triggered_id == 'vecset-list-table': query_params = dict( dasset_id=dasset_id, stab_name=stab_name, squery=squery, sanal_plan=sanal_plan, status=status_select, # create_time_start=create_time_start, # create_time_end=create_time_end, page_num=pagination['current'], page_size=pagination['pageSize'] ) if selected_dasset_tree or search_click or refresh_click or pagination or operations: table_info = get_vecset_list_api(query_params) try: if table_info['code'] == 200: table_data = table_info['data']['rows'] table_pagination = dict( pageSize=table_info['data']['page_size'], current=table_info['data']['page_num'], showSizeChanger=True, pageSizeOptions=[10, 30, 50, 100], showQuickJumper=True, total=table_info['data']['total'] ) for item in table_data: if item['status'] == '0': item['status'] = dict(checked=True) else: item['status'] = dict(checked=False) item['key'] = str(item['onum']) item['operation'] = [ { 'title': '修改', 'type': 'link', 'icon': 'antd-edit' } if 'dataint:vecset:edit' in button_perms else None, { 'title': '删除', 'type': 'link', 'icon': 'antd-delete' } if 'dataint:vecset:delete' in button_perms else None, ] return dict( vecset_table_data=table_data, vecset_table_pagination=table_pagination, vecset_table_key=str(uuid.uuid4()), vecset_table_selectedrowkeys=None, api_check_token_trigger={'timestamp': time.time()} ) except Exception as e: pass print('忽略,暂不做处理!') return dict( vecset_table_data=dash.no_update, vecset_table_pagination=dash.no_update, vecset_table_key=dash.no_update, vecset_table_selectedrowkeys=dash.no_update, api_check_token_trigger={'timestamp': time.time()} ) raise PreventUpdate # 重置用户搜索表单数据回调 app.clientside_callback( ''' (reset_click) => { if (reset_click) { return [null, null, null, null, null, null] } return window.dash_clientside.no_update; } ''', [Output('vdasset-tree', 'selectedKeys'), Output('vecset-stab_name-input', 'value'), Output('vecset-squery-input', 'value'), Output('vecset-sanal_plan-input', 'value'), Output('vecset-status-select', 'value'), #Output('vecset-create_time-range', 'value'), Output('vecset-operations-store', 'data')], Input('vecset-reset', 'nClicks'), prevent_initial_call=True ) # 隐藏/显示用户搜索表单回调 app.clientside_callback( ''' (hidden_click, hidden_status) => { if (hidden_click) { return [ !hidden_status, hidden_status ? '隐藏搜索' : '显示搜索' ] } return window.dash_clientside.no_update; } ''', [Output('vecset-search-form-container', 'hidden'), Output('vecset-hidden-tooltip', 'title')], Input('vecset-hidden', 'nClicks'), State('vecset-search-form-container', 'hidden'), prevent_initial_call=True ) @app.callback( Output({'type': 'vecset-operation-button', 'index': 'edit'}, 'disabled'), Input('vecset-list-table', 'selectedRowKeys'), prevent_initial_call=True ) def change_vecset_edit_button_status(table_rows_selected): """ 根据选择的表格数据行数控制编辑按钮状态回调 len(table_rows_selected) > 0 or """ outputs_list = dash.ctx.outputs_list if outputs_list: if table_rows_selected: if len(table_rows_selected) > 1 : return True return False return True raise PreventUpdate @app.callback( Output({'type': 'vecset-operation-button', 'index': 'delete'}, 'disabled'), Input('vecset-list-table', 'selectedRowKeys'), prevent_initial_call=True ) def change_vecset_delete_button_status(table_rows_selected): """ 根据选择的表格数据行数控制删除按钮状态回调 """ outputs_list = dash.ctx.outputs_list if outputs_list: if table_rows_selected: if '0' in table_rows_selected: return True return False return True raise PreventUpdate @app.callback( output=dict( modal_visible=Output('vecset-add-modal', 'visible', allow_duplicate=True), dasset_tree=Output({'type': 'vecset_add-form-value', 'index': 'dasset_id'}, 'treeData'), form_value=Output({'type': 'vecset_add-form-value', 'index': ALL}, 'value'), form_label_validate_status=Output({'type': 'vecset_add-form-label', 'index': ALL, 'required': True}, 'validateStatus', allow_duplicate=True), form_label_validate_info=Output({'type': 'vecset_add-form-label', 'index': ALL, 'required': True}, 'help', allow_duplicate=True), api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True) ), inputs=dict( add_click=Input('vecset-add', 'nClicks') ), prevent_initial_call=True ) def add_vecset_modal(add_click): """ 显示新增用户弹窗回调 """ if add_click: # 获取所有输出表单项对应value的index form_value_list = [x['id']['index'] for x in dash.ctx.outputs_list[2]] # 获取所有输出表单项对应label的index form_label_list = [x['id']['index'] for x in dash.ctx.outputs_list[3]] dasset_params = dict(dasset_name='') #过滤搜索框中的雨具配置,tree_info重新负值给treeinfo,2024/07/12,wangwentao tree_info = get_dasset_tree_api(dasset_params) #tile_value_to_remove = '全句配置' if tree_info['code'] == 200: tree_data = tree_info['data'] #tree_data = remove_statement_config(tree_data_temp) # 递归删除语句,2024/07/11 wangwentao vecset_info = dict(onum=None, dasset_id=None, squery=None, sanal_plan=None, sintnt_term=None, stab_name=None, ssql=None, sim_thrsh=None, status='0') return dict( modal_visible=True, dasset_tree=tree_data, form_value=[vecset_info.get(k) for k in form_value_list], form_label_validate_status=[None] * len(form_label_list), form_label_validate_info=[None] * len(form_label_list), api_check_token_trigger={'timestamp': time.time()} ) return dict( modal_visible=dash.no_update, dasset_tree=dash.no_update, form_value=[dash.no_update] * len(form_value_list), form_label_validate_status=[dash.no_update] * len(form_label_list), form_label_validate_info=[dash.no_update] * len(form_label_list), api_check_token_trigger={'timestamp': time.time()} ) raise PreventUpdate @app.callback( output=dict( form_label_validate_status=Output({'type': 'vecset_add-form-label', 'index': ALL, 'required': True}, 'validateStatus', allow_duplicate=True), form_label_validate_info=Output({'type': 'vecset_add-form-label', 'index': ALL, 'required': True}, 'help', allow_duplicate=True), modal_visible=Output('vecset-add-modal', 'visible', allow_duplicate=True), operations=Output('vecset-operations-store', 'data', allow_duplicate=True), api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True), global_message_container=Output('global-message-container', 'children', allow_duplicate=True) ), inputs=dict( add_confirm=Input('vecset-add-modal', 'okCounts') ), state=dict( form_value=State({'type': 'vecset_add-form-value', 'index': ALL}, 'value'), form_label=State({'type': 'vecset_add-form-label', 'index': ALL, 'required': True}, 'label') ), prevent_initial_call=True ) def vecset_add_confirm(add_confirm, form_value, form_label): if add_confirm: # 获取所有输出表单项对应label的index form_label_output_list = [x['id']['index'] for x in dash.ctx.outputs_list[0]] # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params = form_value_state add_button_result = add_vecset_api(params) if add_button_result['code'] == 200: return dict( form_label_validate_status=[None] * len(form_label_output_list), form_label_validate_info=[None] * len(form_label_output_list), modal_visible=False, operations={'type': 'add'}, api_check_token_trigger={'timestamp': time.time()}, global_message_container=fuc.FefferyFancyMessage('新增成功', type='success') ) return dict( form_label_validate_status=[None] * len(form_label_output_list), form_label_validate_info=[None] * len(form_label_output_list), modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger={'timestamp': time.time()}, global_message_container=fuc.FefferyFancyMessage('新增失败', type='error') ) return dict( form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, global_message_container=fuc.FefferyFancyMessage('新增失败', type='error') ) raise PreventUpdate @app.callback( output=dict( modal_visible=Output('vecset-edit-modal', 'visible', allow_duplicate=True), dasset_tree=Output({'type': 'vecset_edit-form-value', 'index': 'dasset_id'}, 'treeData'), form_value=Output({'type': 'vecset_edit-form-value', 'index': ALL}, 'value'), form_label_validate_status=Output({'type': 'vecset_edit-form-label', 'index': ALL, 'required': True}, 'validateStatus', allow_duplicate=True), form_label_validate_info=Output({'type': 'vecset_edit-form-label', 'index': ALL, 'required': True}, 'help', allow_duplicate=True), edit_row_info=Output('vecset-edit-id-store', 'data'), api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True) ), inputs=dict( operation_click=Input({'type': 'vecset-operation-button', 'index': ALL}, 'nClicks'), dropdown_click=Input('vecset-list-table', 'nClicksDropdownItem') ), state=dict( selected_row_keys=State('vecset-list-table', 'selectedRowKeys'), recently_clicked_dropdown_item_title=State('vecset-list-table', 'recentlyClickedDropdownItemTitle'), recently_dropdown_item_clicked_row=State('vecset-list-table', 'recentlyDropdownItemClickedRow') ), prevent_initial_call=True ) def vecset_edit_modal(operation_click, dropdown_click, selected_row_keys, recently_clicked_dropdown_item_title, recently_dropdown_item_clicked_row): """ 显示编辑字段弹窗回调 """ trigger_id = dash.ctx.triggered_id if trigger_id == {'index': 'edit', 'type': 'vecset-operation-button'} or (trigger_id == 'vecset-list-table' and recently_clicked_dropdown_item_title == '修改'): # 获取所有输出表单项对应value的index form_value_list = [x['id']['index'] for x in dash.ctx.outputs_list[2]] # 获取所有输出表单项对应label的index form_label_list = [x['id']['index'] for x in dash.ctx.outputs_list[3]] dasset_params = dict(dasset_name='') #tree_data = get_dasset_tree_api(dasset_params)['data'] #过滤搜索框中的雨具配置,tree_info重新负值给treeinfo,2024/07/12,wangwentao tree_info = get_dasset_tree_api(dasset_params) tree_data = tree_info['data'] #tree_data = remove_statement_config(tree_data_temp) # 递归删除语句,2024/07/11 wangwentao if trigger_id == {'index': 'edit', 'type': 'vecset-operation-button'}: onum = int(selected_row_keys[0]) else: if recently_clicked_dropdown_item_title == '修改': onum = int(recently_dropdown_item_clicked_row['key']) else: raise PreventUpdate edit_button_info = get_vecset_detail_api(onum) if edit_button_info['code'] == 200: edit_button_result = edit_button_info['data'] vecset = edit_button_result['vecset'] return dict( modal_visible=True, dasset_tree=tree_data, form_value=[vecset.get(k) for k in form_value_list], form_label_validate_status=[None] * len(form_label_list), form_label_validate_info=[None] * len(form_label_list), edit_row_info={'onum': onum}, api_check_token_trigger={'timestamp': time.time()} ) return dict( modal_visible=dash.no_update, dasset_tree=dash.no_update, form_value=[dash.no_update] * len(form_value_list), form_label_validate_status=[dash.no_update] * len(form_label_list), form_label_validate_info=[dash.no_update] * len(form_label_list), edit_row_info=dash.no_update, api_check_token_trigger={'timestamp': time.time()} ) raise PreventUpdate @app.callback( output=dict( form_label_validate_status=Output({'type': 'vecset_edit-form-label', 'index': ALL, 'required': True}, 'validateStatus', allow_duplicate=True), form_label_validate_info=Output({'type': 'vecset_edit-form-label', 'index': ALL, 'required': True}, 'help', allow_duplicate=True), modal_visible=Output('vecset-edit-modal', 'visible', allow_duplicate=True), operations=Output('vecset-operations-store', 'data', allow_duplicate=True), api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True), global_message_container=Output('global-message-container', 'children', allow_duplicate=True) ), inputs=dict( edit_confirm=Input('vecset-edit-modal', 'okCounts') ), state=dict( edit_row_info=State('vecset-edit-id-store', 'data'), form_value=State({'type': 'vecset_edit-form-value', 'index': ALL}, 'value'), form_label=State({'type': 'vecset_edit-form-label', 'index': ALL, 'required': True}, 'label') ), prevent_initial_call=True ) def vecset_edit_confirm(edit_confirm, edit_row_info, form_value, form_label): if edit_confirm: # 获取所有输出表单项对应label的index form_label_output_list = [x['id']['index'] for x in dash.ctx.outputs_list[0]] # 获取所有输入表单项对应的value及label form_value_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-2]} form_label_state = {x['id']['index']: x.get('value') for x in dash.ctx.states_list[-1]} if all(validate_data_not_empty(item) for item in [form_value_state.get(k) for k in form_label_output_list]): params = form_value_state params['onum'] = edit_row_info.get('onum') if edit_row_info else None edit_button_result = edit_vecset_api(params) if edit_button_result['code'] == 200: return dict( form_label_validate_status=[None] * len(form_label_output_list), form_label_validate_info=[None] * len(form_label_output_list), modal_visible=False, operations={'type': 'edit'}, api_check_token_trigger={'timestamp': time.time()}, global_message_container=fuc.FefferyFancyMessage('编辑成功', type='success') ) return dict( form_label_validate_status=[None] * len(form_label_output_list), form_label_validate_info=[None] * len(form_label_output_list), modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger={'timestamp': time.time()}, global_message_container=fuc.FefferyFancyMessage('编辑失败', type='error') ) return dict( form_label_validate_status=[None if validate_data_not_empty(form_value_state.get(k)) else 'error' for k in form_label_output_list], form_label_validate_info=[None if validate_data_not_empty(form_value_state.get(k)) else f'{form_label_state.get(k)}不能为空!' for k in form_label_output_list], modal_visible=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, global_message_container=fuc.FefferyFancyMessage('编辑失败', type='error') ) raise PreventUpdate @app.callback( [Output('vecset-operations-store', 'data', allow_duplicate=True), Output('api-check-token', 'data', allow_duplicate=True), Output('global-message-container', 'children', allow_duplicate=True)], [Input('vecset-list-table', 'recentlySwitchDataIndex'), Input('vecset-list-table', 'recentlySwitchStatus'), Input('vecset-list-table', 'recentlySwitchRow')], prevent_initial_call=True ) def table_switch_vecset_status(recently_switch_data_index, recently_switch_status, recently_switch_row): """ 表格内切换字段状态回调 """ if recently_switch_data_index: if recently_switch_status: params = dict(onum=int(recently_switch_row['key']), status='0', type='status') else: params = dict(onum=int(recently_switch_row['key']), status='1', type='status') edit_button_result = edit_vecset_api(params) if edit_button_result['code'] == 200: return [ {'type': 'switch-status'}, {'timestamp': time.time()}, fuc.FefferyFancyMessage('修改成功', type='success') ] return [ {'type': 'switch-status'}, {'timestamp': time.time()}, fuc.FefferyFancyMessage('修改失败', type='error') ] raise PreventUpdate #vecset-delete-confirm-modal @app.callback( [Output('vecset-delete-text', 'children'), Output('vecset-delete-confirm-modal', 'visible'), Output('vecset-delete-ids-store', 'data')], [Input({'type': 'vecset-operation-button', 'index': ALL}, 'nClicks'), Input('vecset-list-table', 'nClicksDropdownItem') ], [State('vecset-list-table', 'selectedRowKeys'), State('vecset-list-table', 'recentlyClickedDropdownItemTitle'), State('vecset-list-table', 'recentlyDropdownItemClickedRow')], prevent_initial_call=True ) def vecset_delete_modal(operation_click, dropdown_click, selected_row_keys, recently_clicked_dropdown_item_title, recently_dropdown_item_clicked_row): """ 显示删除字段二次确认弹窗回调 """ trigger_id = dash.ctx.triggered_id if trigger_id == {'index': 'delete', 'type': 'vecset-operation-button'} or (trigger_id == 'vecset-list-table' and recently_clicked_dropdown_item_title == '删除'): if trigger_id == {'index': 'delete', 'type': 'vecset-operation-button'}: onums = ','.join(selected_row_keys) else: if recently_clicked_dropdown_item_title == '删除': onums = recently_dropdown_item_clicked_row['key'] else: raise PreventUpdate return [ f'是否确认删除序号为{onums}的数据?', True, {'onums': onums} ] raise PreventUpdate @app.callback( [Output('vecset-operations-store', 'data', allow_duplicate=True), Output('api-check-token', 'data', allow_duplicate=True), Output('global-message-container', 'children', allow_duplicate=True)], Input('vecset-delete-confirm-modal', 'okCounts'), State('vecset-delete-ids-store', 'data'), prevent_initial_call=True ) def vecset_delete_confirm(delete_confirm, onums_data): """ 删除全句配置弹窗确认回调,实现删除操作 """ if delete_confirm: params = onums_data delete_button_info = delete_vecset_api(params) if delete_button_info['code'] == 200: return [ {'type': 'delete'}, {'timestamp': time.time()}, fuc.FefferyFancyMessage('删除成功', type='success') ] return [ dash.no_update, {'timestamp': time.time()}, fuc.FefferyFancyMessage('删除失败', type='error') ] raise PreventUpdate # 显示数据字典导入弹窗及重置上传弹窗组件状态回调 app.clientside_callback( ''' (nClicks) => { if (nClicks) { return [ true, [], [], false ]; } return [ false, window.dash_clientside.no_update, window.dash_clientside.no_update, window.dash_clientside.no_update ]; } ''', [Output('vecset-import-confirm-modal', 'visible'), Output('vecset-upload-choose', 'listUploadTaskRecord'), Output('vecset-upload-choose', 'defaultFileList'), Output('vecset-import-update-check', 'checked')], Input('vecset-import', 'nClicks'), prevent_initial_call=True ) @app.callback( output=dict( confirm_loading=Output('vecset-import-confirm-modal', 'confirmLoading'), modal_visible=Output('batch-result-modal', 'visible',allow_duplicate=True), #add batch_result=Output('batch-result-content', 'children',allow_duplicate=True), #add operations=Output('vecset-operations-store', 'data', allow_duplicate=True), api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True), global_message_container=Output('global-message-container', 'children', allow_duplicate=True) ), inputs=dict( import_confirm=Input('vecset-import-confirm-modal', 'okCounts') ), state=dict( list_upload_task_record=State('vecset-upload-choose', 'listUploadTaskRecord'), is_update=State('vecset-import-update-check', 'checked') ), prevent_initial_call=True ) def vecset_import_confirm(import_confirm, list_upload_task_record, is_update): """ 全句配置表导入弹窗确认回调,实现批量导入用户操作 """ if import_confirm: if list_upload_task_record: url = list_upload_task_record[-1].get('url') batch_param = dict(url=url, is_update=is_update) batch_import_result = batch_import_vecset_api(batch_param) if batch_import_result.get('code') == 200: return dict( confirm_loading=False, modal_visible=True if batch_import_result.get('message') else False, batch_result=batch_import_result.get('message'), operations={'type': 'batch-import'}, api_check_token_trigger={'timestamp': time.time()}, global_message_container=fuc.FefferyFancyMessage('导入成功', type='success') ) return dict( confirm_loading=False, modal_visible=True, batch_result=batch_import_result.get('message'), operations=dash.no_update, api_check_token_trigger={'timestamp': time.time()}, global_message_container=fuc.FefferyFancyMessage('导入失败', type='error') ) else: return dict( confirm_loading=False, modal_visible=dash.no_update, batch_result=dash.no_update, operations=dash.no_update, api_check_token_trigger=dash.no_update, global_message_container=fuc.FefferyFancyMessage('请上传需要导入的文件', type='error') ) raise PreventUpdate @app.callback( [Output('vecset-export-container', 'data', allow_duplicate=True), Output('vecset-export-complete-judge-container', 'data'), Output('api-check-token', 'data', allow_duplicate=True), Output('global-message-container', 'children', allow_duplicate=True)], [Input('vecset-export', 'nClicks'), Input('download-vecset-import-template', 'nClicks')], prevent_initial_call=True ) def export_vecset_list(export_click, download_click): """ 导出全句配置表信息回调 """ trigger_id = dash.ctx.triggered_id if export_click or download_click: if trigger_id == 'vecset-export': export_vecset_res = export_vecset_list_api({}) if export_vecset_res.status_code == 200: export_vecset = export_vecset_res.content return [ dcc.send_bytes(export_vecset, f'全句配置_{time.strftime("%Y%m%d%H%M%S", time.localtime())}.xlsx'), {'timestamp': time.time()}, {'timestamp': time.time()}, fuc.FefferyFancyMessage('导出成功', type='success') ] return [ dash.no_update, dash.no_update, {'timestamp': time.time()}, fuc.FefferyFancyMessage('导出失败', type='error') ] if trigger_id == 'download-vecset-import-template': download_template_res = download_vecset_import_template_api() if download_template_res.status_code == 200: download_template = download_template_res.content return [ dcc.send_bytes(download_template, f'全句配置导入模板_{time.strftime("%Y%m%d%H%M%S", time.localtime())}.xlsx'), {'timestamp': time.time()}, {'timestamp': time.time()}, fuc.FefferyFancyMessage('下载成功', type='success') ] return [ dash.no_update, dash.no_update, {'timestamp': time.time()}, fuc.FefferyFancyMessage('下载失败', type='error') ] raise PreventUpdate @app.callback( Output('vecset-export-container', 'data', allow_duplicate=True), Input('vecset-export-complete-judge-container', 'data'), prevent_initial_call=True ) def reset_vecset_export_status(data): """ 导出完成后重置下载组件数据回调,防止重复下载文件 """ time.sleep(0.5) if data: return None raise PreventUpdate