from dash import dcc, html
import feffery_antd_components as fac
from feffery_dash_utils.style_utils import style
import callbacks.dasset_c.nddict_c
from api.nddict import get_nddict_list_api
from flask import session
from config.global_config import ApiBaseUrlConfig
def render(*args, **kwargs):
button_perms = kwargs.get('button_perms')
nddict_params = dict(page_num=1, page_size=10)
table_info = get_nddict_list_api(nddict_params)
#print(table_info)
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 'dasset:nddict:edit' in button_perms else {},
{
'content': '删除',
'type': 'link',
'icon': 'antd-delete'
} if 'dasset:nddict:remove' in button_perms else {},
]
return [
dcc.Store(id='nddict-button-perms-container', data=button_perms),
# 用于导出成功后重置dcc.Download的状态,防止多次下载文件
dcc.Store(id='nddict-export-complete-judge-container'),
# 绑定的导出组件
dcc.Download(id='nddict-export-container'),
# 岗位管理模块操作类型存储容器
dcc.Store(id='nddict-operations-store'),
dcc.Store(id='nddict-operations-store-bk'),
# 岗位管理模块修改操作行key存储容器
dcc.Store(id='nddict-edit-id-store'),
# 岗位管理模块删除操作行key存储容器
dcc.Store(id='nddict-delete-ids-store'),
fac.AntdRow(
[
fac.AntdCol(
[
fac.AntdRow(
[
fac.AntdCol(
html.Div(
[
fac.AntdForm(
[
fac.AntdSpace(
[
fac.AntdFormItem(
fac.AntdInput(
id='nddict-data_dict_no-input',
placeholder='请输入字典编号',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='字典编号'
),
fac.AntdFormItem(
fac.AntdInput(
id='nddict-data_std_no-input',
placeholder='请输入数据标准编号',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='数据标准编号'
),
fac.AntdFormItem(
fac.AntdInput(
id='nddict-data_dict_cn_name-input',
placeholder='请输入字典中文名称',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='字典中文名称'
),
fac.AntdFormItem(
fac.AntdSelect(
id='nddict-status-select',
placeholder='字典状态',
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
}
],
style={
'width': 200
}
),
label='状态'
),
fac.AntdFormItem(
fac.AntdButton(
'搜索',
id='nddict-search',
type='primary',
icon=fac.AntdIcon(
icon='antd-search'
)
)
),
fac.AntdFormItem(
fac.AntdButton(
'重置',
id='nddict-reset',
icon=fac.AntdIcon(
icon='antd-sync'
)
)
)
],
style={
'paddingBottom': '10px'
}
),
],
layout='inline',
)
],
id='nddict-search-form-container',
hidden=False
),
)
]
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdSpace(
[
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-plus'
),
'新增',
],
id={
'type': 'nddict-operation-button',
'index': 'add'
},
style={
'color': '#1890ff',
'background': '#e8f4ff',
'border-color': '#a3d3ff'
}
) if 'dasset:nddict:add' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-edit'
),
'修改',
],
id={
'type': 'nddict-operation-button',
'index': 'edit'
},
disabled=True,
style={
'color': '#71e2a3',
'background': '#e7faf0',
'border-color': '#d0f5e0'
}
) if 'dasset:nddict:edit' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-minus'
),
'删除',
],
id={
'type': 'nddict-operation-button',
'index': 'delete'
},
disabled=True,
style={
'color': '#ff9292',
'background': '#ffeded',
'border-color': '#ffdbdb'
}
) if 'dasset:nddict:remove' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-arrow-up'
),
'导入',
],
id='nddict-import',
style={
'color': '#909399',
'background': '#f4f4f5',
'border-color': '#d3d4d6'
}
) if 'dasset:nddict:import' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-arrow-down'
),
'导出',
],
id='nddict-export',
style={
'color': '#ffba00',
'background': '#fff8e6',
'border-color': '#ffe399'
}
) if 'dasset:nddict: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='nddict-hidden',
shape='circle'
),
id='nddict-hidden-tooltip',
title='隐藏搜索'
)
),
html.Div(
fac.AntdTooltip(
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-sync'
),
],
id='nddict-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='nddict-list-table',
data=table_data,
columns=[
{
'dataIndex': 'onum',
'title': '序号',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'data_dict_no',
'title': '字典编号',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'data_std_no',
'title': '数据标准编号',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'data_dict_cn_name',
'title': '字典中文名称',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'data_dict_eng_name',
'title': '字典英文名称',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'dict_busi_mean',
'title': '字典业务含义',
'renderOptions': {
'renderType': 'ellipsis'
},
},
# {
# 'dataIndex': 'falias',
# #'title': '字典别名',
# #'AntdTooltip':'这里是字段别名的解释',
# 'titlePopoverInfo':'这里是字段别名的解释',
# 'renderOptions': {
# 'renderType': 'ellipsis'
# }
# },
{
"dataIndex": "falias",
"title": fac.AntdSpace(
[
fac.AntdText("字典别名"),
fac.AntdTooltip(
fac.AntdIcon(
icon="antd-question-circle",
style=style(color="#8c8c8c", cursor="help"),
),
title="这是字段别名的含义解释巴拉巴拉巴拉巴拉",
),
]
),
},
{
'dataIndex': 'fld_bype',
'title': '字段类型',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fld_dbype',
'title': '字段数据类型',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'status',
'title': '状态',
'renderOptions': {
'renderType': 'switch'
},
},
{
'dataIndex': 'update_by',
'title': '负责人员',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'create_time',
'title': '创建时间',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'title': '操作',
'dataIndex': 'operation',
'renderOptions': {
'renderType': 'button'
},
}
],
rowSelectionType='checkbox',
rowSelectionWidth=50,
bordered=True,
maxWidth=1800,
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'
# rowSelectionType='checkbox',
# rowSelectionWidth=50,
# bordered=True,
# pagination={
# 'pageSize': page_size,
# 'current': page_num,
# 'showSizeChanger': True,
# 'pageSizeOptions': [10, 30, 50, 100],
# 'showQuickJumper': True,
# 'total': total
# },
# mode='server-side',
# style={
# 'width': '100%',
# 'padding-right': '10px'
# }
),
text='数据加载中'
),
)
]
),
],
span=24
)
],
gutter=5
),
# 新增和编辑测试表单modal
fac.AntdModal(
[
fac.AntdForm(
[
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'data_dict_no'
},
placeholder='请输入字典编号',
allowClear=True,
style={
'width': '100%'
}
),
label='字典编号',
required=True,
id={
'type': 'nddict-form-label',
'index': 'data_dict_no',
'required': True
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'data_std_no'
},
placeholder='请输入数据标准编号',
allowClear=True,
style={
'width': '100%'
}
),
label='数据标准编号',
id={
'type': 'nddict-form-label',
'index': 'data_std_no',
'required': False
},
# labelCol={
# 'offset': 1
# },
),
span=12
)
],
gutter=5
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'data_dict_cn_name'
},
placeholder='请输入字典中文名称',
allowClear=True,
style={
'width': '100%'
}
),
label='字典中文名称',
required=True,
id={
'type': 'nddict-form-label',
'index': 'data_dict_cn_name',
'required': True
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'data_dict_eng_name'
},
placeholder='请输入字典英文名称',
allowClear=True,
style={
'width': '100%'
}
),
label='字典英文名称',
id={
'type': 'nddict-form-label',
'index': 'data_dict_eng_name',
'required': False
},
# labelCol={
# 'offset': 1
# },
),
span=12
)
],
gutter=5
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'dict_busi_mean'
},
placeholder='请输入字典业务含义',
allowClear=True,
style={
'width': '100%'
}
),
label='字典业务含义',
required=True,
id={
'type': 'nddict-form-label',
'index': 'dict_busi_mean',
'required': True
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'fld_bype'
},
placeholder='请输入字段类型',
allowClear=True,
style={
'width': '100%'
}
),
label='字段类型',
id={
'type': 'nddict-form-label',
'index': 'fld_bype',
'required': False
},
# labelCol={
# 'offset': 1
# },
),
span=12
)
],
gutter=5
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'fld_dbype'
},
placeholder='请输入字段数据类型',
allowClear=True,
style={
'width': '100%'
}
),
label='字段数据类型',
required=True,
id={
'type': 'nddict-form-label',
'index': 'fld_dbype',
'required': True
}
),
span=12
),
fac.AntdCol(
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'nddict-form-value',
'index': 'falias'
},
placeholder='请输入字典别名',
allowClear=True,
style={
'width': '100%'
}
),
label='字典别名',
id={
'type': 'nddict-form-label',
'index': 'falias',
'required': False
},
# labelCol={
# 'offset': 1
# },
),
span=12
)
],
gutter=5
)
],
labelCol={
'span': 8
},
wrapperCol={
'span': 16
},
style={
'marginRight': '10px'
}
)
],
id='nddict-modal',
mask=False,
width=680,
renderFooter=True,
okClickClose=False
),
# 代码表导入modal
fac.AntdModal(
[
html.Div(
fac.AntdDraggerUpload(
id='nddict-upload-choose',
apiUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/upload',
apiUrlExtraParams={'taskPath': 'nddictUpload'},
downloadUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/caches',
downloadUrlExtraParams={'taskPath': 'nddictUpload', '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='nddict-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-nddict-import-template',
type='link'
)
],
style={
'textAlign': 'center',
'marginTop': '10px'
}
)
],
id='nddict-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='nddict-delete-text'),
id='nddict-delete-confirm-modal',
visible=False,
title='提示',
renderFooter=True,
centered=True
),
]