You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

706 lines
36 KiB

1 month ago
from dash import dcc, html
import feffery_antd_components as fac
from flask import session
from config.global_config import ApiBaseUrlConfig
import callbacks.dasset_c.fddict_c
from api.fddict import get_fddict_list_api
def render(*args, **kwargs):
button_perms = kwargs.get('button_perms')
fddict_params = dict(page_num=1, page_size=10)
table_info = get_fddict_list_api(fddict_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['fddict_id'])
item['operation'] = [
{
'content': '修改',
'type': 'link',
'icon': 'antd-edit'
} if 'dasset:fddict:edit' in button_perms else {},
{
'content': '删除',
'type': 'link',
'icon': 'antd-delete'
} if 'dasset:fddict:remove' in button_perms else {},
]
return [
dcc.Store(id='fddict-button-perms-container', data=button_perms),
# 用于导出成功后重置dcc.Download的状态,防止多次下载文件
dcc.Store(id='fddict-export-complete-judge-container'),
# 绑定的导出组件
dcc.Download(id='fddict-export-container'),
# 岗位管理模块操作类型存储容器
dcc.Store(id='fddict-operations-store'),
dcc.Store(id='fddict-operations-store-bk'),
# 岗位管理模块修改操作行key存储容器
dcc.Store(id='fddict-edit-id-store'),
# 岗位管理模块删除操作行key存储容器
dcc.Store(id='fddict-delete-ids-store'),
fac.AntdRow(
[
fac.AntdCol(
[
fac.AntdRow(
[
fac.AntdCol(
html.Div(
[
fac.AntdForm(
[
fac.AntdSpace(
[
fac.AntdFormItem(
fac.AntdInput(
id='fddict-fddict_code-input',
placeholder='请输入代码码值',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='代码码值'
),
fac.AntdFormItem(
fac.AntdInput(
id='fddict-fddict_name-input',
placeholder='请输入码值说明',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='码值说明'
),
fac.AntdFormItem(
fac.AntdInput(
id='fddict-remark-input',
placeholder='请输入业务描述',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='业务描述'
),
fac.AntdFormItem(
fac.AntdSelect(
id='fddict-status-select',
placeholder='状态',
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
}
],
style={
'width': 200
}
),
label='状态'
),
fac.AntdFormItem(
fac.AntdButton(
'搜索',
id='fddict-search',
type='primary',
icon=fac.AntdIcon(
icon='antd-search'
)
)
),
fac.AntdFormItem(
fac.AntdButton(
'重置',
id='fddict-reset',
icon=fac.AntdIcon(
icon='antd-sync'
)
)
)
],
style={
'paddingBottom': '10px'
}
),
],
layout='inline',
)
],
id='fddict-search-form-container',
hidden=False
),
)
]
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdSpace(
[
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-plus'
),
'新增',
],
id={
'type': 'fddict-operation-button',
'index': 'add'
},
style={
'color': '#1890ff',
'background': '#e8f4ff',
'border-color': '#a3d3ff'
}
) if 'dasset:fddict:add' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-edit'
),
'修改',
],
id={
'type': 'fddict-operation-button',
'index': 'edit'
},
disabled=True,
style={
'color': '#71e2a3',
'background': '#e7faf0',
'border-color': '#d0f5e0'
}
) if 'dasset:fddict:edit' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-minus'
),
'删除',
],
id={
'type': 'fddict-operation-button',
'index': 'delete'
},
disabled=True,
style={
'color': '#ff9292',
'background': '#ffeded',
'border-color': '#ffdbdb'
}
) if 'dasset:fddict:remove' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-arrow-up'
),
'导入',
],
id='fddict-import',
style={
'color': '#909399',
'background': '#f4f4f5',
'border-color': '#d3d4d6'
}
) if 'dasset:fddict:export' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-arrow-down'
),
'导出',
],
id='fddict-export',
style={
'color': '#ffba00',
'background': '#fff8e6',
'border-color': '#ffe399'
}
) if 'dasset:fddict: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='fddict-hidden',
shape='circle'
),
id='fddict-hidden-tooltip',
title='隐藏搜索'
)
),
html.Div(
fac.AntdTooltip(
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-sync'
),
],
id='fddict-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='fddict-list-table',
data=table_data,
columns=[
{
'dataIndex': 'fddict_id',
'title': '代码序号',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fddict_col_no',
'title': '代码编号',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fddict_col_cn',
'title': '代码中文名称',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fddict_code',
'title': '代码码值',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fddict_name',
'title': '码值说明',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fddict_col_en',
'title': '代码别名',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'fddict_sort',
'title': '码值排序',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'remark',
'title': '业务描述',
'width': 280,
'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': 'fddict-form-value',
'index': 'fddict_col_no'
},
placeholder='请输入代码编号',
allowClear=True,
style={
'width': 350
}
),
label='代码编号',
required=True,
id={
'type': 'fddict-form-label',
'index': 'fddict_col_no',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'fddict-form-value',
'index': 'fddict_col_cn'
},
placeholder='请输入代码中文名称',
allowClear=True,
style={
'width': 350
}
),
label='代码中文名称',
required=True,
id={
'type': 'fddict-form-label',
'index': 'fddict_col_cn',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'fddict-form-value',
'index': 'fddict_code'
},
placeholder='请输入代码码值',
allowClear=True,
style={
'width': 350
}
),
label='代码码值',
required=True,
id={
'type': 'fddict-form-label',
'index': 'fddict_code',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'fddict-form-value',
'index': 'fddict_name'
},
placeholder='请输入码值说明',
allowClear=True,
style={
'width': 350
}
),
label='码值说明',
required=True,
id={
'type': 'fddict-form-label',
'index': 'fddict_name',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'fddict-form-value',
'index': 'fddict_col_en'
},
placeholder='请输入代码别名',
allowClear=True,
style={
'width': 350
}
),
label='代码别名',
required=True,
id={
'type': 'fddict-form-label',
'index': 'fddict_col_en',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInputNumber(
id={
'type': 'fddict-form-value',
'index': 'fddict_sort'
},
defaultValue=0,
min=0,
style={
'width': 350
}
),
label='码值排序',
required=True,
id={
'type': 'fddict-form-label',
'index': 'fddict_sort',
'required': True
}
),
fac.AntdFormItem(
fac.AntdRadioGroup(
id={
'type': 'fddict-form-value',
'index': 'status'
},
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
},
],
#defaultValue='0',
style={
'width': 350
}
),
label='状态',
id={
'type': 'fddict-form-label',
'index': 'status',
'required': False
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'fddict-form-value',
'index': 'remark'
},
placeholder='请输入内容',
allowClear=True,
mode='text-area',
style={
'width': 350
}
),
label='码值业务描述',
id={
'type': 'fddict-form-label',
'index': 'remark',
'required': False
}
),
],
labelCol={
'span': 6
},
wrapperCol={
'span': 18
}
)
],
id='fddict-modal',
mask=False,
width=580,
renderFooter=True,
okClickClose=False
),
# 删除新代码二次确认modal
fac.AntdModal(
fac.AntdText('是否确认删除?', id='fddict-delete-text'),
id='fddict-delete-confirm-modal',
visible=False,
title='提示',
renderFooter=True,
centered=True
),
# 代码表导入modal
fac.AntdModal(
[
html.Div(
fac.AntdDraggerUpload(
id='fddict-upload-choose',
apiUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/upload',
apiUrlExtraParams={'taskPath': 'fddictUpload'},
downloadUrl=f'{ApiBaseUrlConfig.BaseUrl}/common/caches',
downloadUrlExtraParams={'taskPath': 'fddictUpload', '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='fddict-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-fddict-import-template',
type='link'
)
],
style={
'textAlign': 'center',
'marginTop': '10px'
}
)
],
id='fddict-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
),
]