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