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.

497 lines
26 KiB

1 month ago
from dash import dcc, html
import feffery_antd_components as fac
import callbacks.system_c.newtest_c
from api.newtest import get_newtest_list_api
def render(*args, **kwargs):
button_perms = kwargs.get('button_perms')
newtest_params = dict(page_num=1, page_size=10)
table_info = get_newtest_list_api(newtest_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')
else:
item['status'] = dict(tag='停用', color='volcano')
item['key'] = str(item['newtest_id'])
item['operation'] = [
{
'content': '修改',
'type': 'link',
'icon': 'antd-edit'
} if 'system:newtest:edit' in button_perms else {},
{
'content': '删除',
'type': 'link',
'icon': 'antd-delete'
} if 'system:newtest:remove' in button_perms else {},
]
return [
dcc.Store(id='newtest-button-perms-container', data=button_perms),
# 用于导出成功后重置dcc.Download的状态,防止多次下载文件
dcc.Store(id='newtest-export-complete-judge-container'),
# 绑定的导出组件
dcc.Download(id='newtest-export-container'),
# 岗位管理模块操作类型存储容器
dcc.Store(id='newtest-operations-store'),
dcc.Store(id='newtest-operations-store-bk'),
# 岗位管理模块修改操作行key存储容器
dcc.Store(id='newtest-edit-id-store'),
# 岗位管理模块删除操作行key存储容器
dcc.Store(id='newtest-delete-ids-store'),
fac.AntdRow(
[
fac.AntdCol(
[
fac.AntdRow(
[
fac.AntdCol(
html.Div(
[
fac.AntdForm(
[
fac.AntdSpace(
[
fac.AntdFormItem(
fac.AntdInput(
id='newtest-newtest_code-input',
placeholder='请输入新测试编号',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='新测试编号'
),
fac.AntdFormItem(
fac.AntdInput(
id='newtest-newtest_name-input',
placeholder='请输入新测试名称',
autoComplete='off',
allowClear=True,
style={
'width': 210
}
),
label='新测试名称'
),
fac.AntdFormItem(
fac.AntdSelect(
id='newtest-status-select',
placeholder='新测试状态',
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
}
],
style={
'width': 200
}
),
label='新测试状态'
),
fac.AntdFormItem(
fac.AntdButton(
'搜索',
id='newtest-search',
type='primary',
icon=fac.AntdIcon(
icon='antd-search'
)
)
),
fac.AntdFormItem(
fac.AntdButton(
'重置',
id='newtest-reset',
icon=fac.AntdIcon(
icon='antd-sync'
)
)
)
],
style={
'paddingBottom': '10px'
}
),
],
layout='inline',
)
],
id='newtest-search-form-container',
hidden=False
),
)
]
),
fac.AntdRow(
[
fac.AntdCol(
fac.AntdSpace(
[
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-plus'
),
'新增',
],
id={
'type': 'newtest-operation-button',
'index': 'add'
},
style={
'color': '#1890ff',
'background': '#e8f4ff',
'border-color': '#a3d3ff'
}
) if 'system:newtest:add' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-edit'
),
'修改',
],
id={
'type': 'newtest-operation-button',
'index': 'edit'
},
disabled=True,
style={
'color': '#71e2a3',
'background': '#e7faf0',
'border-color': '#d0f5e0'
}
) if 'system:newtest:edit' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-minus'
),
'删除',
],
id={
'type': 'newtest-operation-button',
'index': 'delete'
},
disabled=True,
style={
'color': '#ff9292',
'background': '#ffeded',
'border-color': '#ffdbdb'
}
) if 'system:newtest:remove' in button_perms else [],
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-arrow-down'
),
'导出',
],
id='newtest-export',
style={
'color': '#ffba00',
'background': '#fff8e6',
'border-color': '#ffe399'
}
) if 'system:newtest: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='newtest-hidden',
shape='circle'
),
id='newtest-hidden-tooltip',
title='隐藏搜索'
)
),
html.Div(
fac.AntdTooltip(
fac.AntdButton(
[
fac.AntdIcon(
icon='antd-sync'
),
],
id='newtest-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='newtest-list-table',
data=table_data,
columns=[
{
'dataIndex': 'newtest_id',
'title': '测试编号',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'newtest_code',
'title': '测试编码',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'newtest_name',
'title': '测试名称',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'newtest_sort',
'title': '测试排序',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'dataIndex': 'status',
'title': '状态',
'renderOptions': {
'renderType': 'tags'
},
},
{
'dataIndex': 'create_time',
'title': '创建时间',
'renderOptions': {
'renderType': 'ellipsis'
},
},
{
'title': '操作',
'dataIndex': 'operation',
'renderOptions': {
'renderType': 'button'
},
}
],
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.AntdFormItem(
fac.AntdInput(
id={
'type': 'newtest-form-value',
'index': 'newtest_name'
},
placeholder='请输入测试名称',
allowClear=True,
style={
'width': 350
}
),
label='岗位名称',
required=True,
id={
'type': 'newtest-form-label',
'index': 'newtest_name',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'newtest-form-value',
'index': 'newtest_code'
},
placeholder='请输入测试编码',
allowClear=True,
style={
'width': 350
}
),
label='测试编码',
required=True,
id={
'type': 'newtest-form-label',
'index': 'newtest_code',
'required': True
}
),
fac.AntdFormItem(
fac.AntdInputNumber(
id={
'type': 'newtest-form-value',
'index': 'newtest_sort'
},
defaultValue=0,
min=0,
style={
'width': 350
}
),
label='测试顺序',
required=True,
id={
'type': 'newtest-form-label',
'index': 'newtest_sort',
'required': True
}
),
fac.AntdFormItem(
fac.AntdRadioGroup(
id={
'type': 'newtest-form-value',
'index': 'status'
},
options=[
{
'label': '正常',
'value': '0'
},
{
'label': '停用',
'value': '1'
},
],
defaultValue='0',
style={
'width': 350
}
),
label='测试状态',
id={
'type': 'newtest-form-label',
'index': 'status',
'required': False
}
),
fac.AntdFormItem(
fac.AntdInput(
id={
'type': 'newtest-form-value',
'index': 'remark'
},
placeholder='请输入内容',
allowClear=True,
mode='text-area',
style={
'width': 350
}
),
label='备注',
id={
'type': 'newtest-form-label',
'index': 'remark',
'required': False
}
),
],
labelCol={
'span': 6
},
wrapperCol={
'span': 18
}
)
],
id='newtest-modal',
mask=False,
width=580,
renderFooter=True,
okClickClose=False
),
# 删除新测试二次确认modal
fac.AntdModal(
fac.AntdText('是否确认删除?', id='newtest-delete-text'),
id='newtest-delete-confirm-modal',
visible=False,
title='提示',
renderFooter=True,
centered=True
),
]