Complete main UI #37

Merged
FatttSnake merged 192 commits from FatttSnake into dev 2024-02-23 16:31:17 +08:00
2 changed files with 71 additions and 65 deletions
Showing only changes of commit 50f7b99bbe - Show all commits

View File

@@ -136,7 +136,6 @@ const Base = () => {
)} )}
</> </>
), ),
dataIndex: 'enable',
width: '12em', width: '12em',
align: 'center', align: 'center',
render: (_, record) => ( render: (_, record) => (

View File

@@ -74,10 +74,6 @@ const Template = () => {
) )
const handleOnAddBtnClick = () => { const handleOnAddBtnClick = () => {
if (Object.keys(hasEdited).length) {
void message.warning('新增前请保存修改')
return
}
setIsDrawerEdit(false) setIsDrawerEdit(false)
setIsDrawerOpen(true) setIsDrawerOpen(true)
form.setFieldValue('id', undefined) form.setFieldValue('id', undefined)
@@ -105,21 +101,21 @@ const Template = () => {
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'createTime', dataIndex: 'createTime',
width: '20%', width: '0',
align: 'center', align: 'center',
render: (value: string) => utcToLocalTime(value) render: (value: string) => utcToLocalTime(value)
}, },
{ {
title: '修改时间', title: '修改时间',
dataIndex: 'updateTime', dataIndex: 'updateTime',
width: '20%', width: '0',
align: 'center', align: 'center',
render: (value: string) => utcToLocalTime(value) render: (value: string) => utcToLocalTime(value)
}, },
{ {
title: '状态', title: '状态',
dataIndex: 'enable', dataIndex: 'enable',
width: '5%', width: '0',
align: 'center', align: 'center',
render: (value) => render: (value) =>
value ? <AntdTag color={'success'}></AntdTag> : <AntdTag></AntdTag> value ? <AntdTag color={'success'}></AntdTag> : <AntdTag></AntdTag>
@@ -127,15 +123,20 @@ const Template = () => {
{ {
title: ( title: (
<> <>
(
{!Object.keys(hasEdited).length && (
<>
{' '}
(
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddBtnClick}> <a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddBtnClick}>
</a> </a>
) )
</> </>
)}
</>
), ),
dataIndex: 'enable', width: '8em',
width: '15em',
align: 'center', align: 'center',
render: (_, record) => ( render: (_, record) => (
<> <>
@@ -150,6 +151,7 @@ const Template = () => {
</a> </a>
</Permission> </Permission>
)} )}
{!Object.keys(hasEdited).length && (
<Permission operationCode={'system:tool:modify:base'}> <Permission operationCode={'system:tool:modify:base'}>
<a <a
style={{ color: COLOR_PRODUCTION }} style={{ color: COLOR_PRODUCTION }}
@@ -158,6 +160,7 @@ const Template = () => {
</a> </a>
</Permission> </Permission>
)}
<Permission operationCode={'system:tool:delete:base'}> <Permission operationCode={'system:tool:delete:base'}>
<a <a
style={{ color: COLOR_PRODUCTION }} style={{ color: COLOR_PRODUCTION }}
@@ -203,11 +206,6 @@ const Template = () => {
const handleOnEditBtnClick = (value: ToolTemplateVo) => { const handleOnEditBtnClick = (value: ToolTemplateVo) => {
return () => { return () => {
if (Object.keys(hasEdited).length) {
void message.warning('编辑前请保存修改')
return
}
setIsDrawerEdit(true) setIsDrawerEdit(true)
setIsDrawerOpen(true) setIsDrawerOpen(true)
form.setFieldValue('id', value.id) form.setFieldValue('id', value.id)
@@ -362,6 +360,16 @@ const Template = () => {
...templateDetailData, ...templateDetailData,
[record.id]: response.data! [record.id]: response.data!
}) })
setTemplateData(
templateData.map((value) =>
value.id === response.data!.id
? {
...response.data!,
source: { id: response.data!.source.id }
}
: value
)
)
break break
default: default:
void message.error(`获取模板 ${record.name} 文件内容失败,请稍后重试`) void message.error(`获取模板 ${record.name} 文件内容失败,请稍后重试`)
@@ -382,11 +390,6 @@ const Template = () => {
} }
const handleOnAddFile = () => { const handleOnAddFile = () => {
if (Object.keys(hasEdited).length) {
void message.warning('新建文件前请先保存更改')
return
}
void modal.confirm({ void modal.confirm({
title: '新建文件', title: '新建文件',
content: ( content: (
@@ -493,12 +496,18 @@ const Template = () => {
{ {
title: ( title: (
<> <>
(
{!Object.keys(hasEdited).length && (
<>
{' '}
(
<a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddFile}> <a style={{ color: COLOR_PRODUCTION }} onClick={handleOnAddFile}>
</a> </a>
) )
</> </>
)}
</>
), ),
dataIndex: 'enable', dataIndex: 'enable',
width: '12em', width: '12em',
@@ -514,6 +523,7 @@ const Template = () => {
</a> </a>
</Permission> </Permission>
{!Object.keys(hasEdited).length && (
<Permission operationCode={'system:tool:modify:category'}> <Permission operationCode={'system:tool:modify:category'}>
<a <a
onClick={handleOnRenameFile(record.name)} onClick={handleOnRenameFile(record.name)}
@@ -522,6 +532,8 @@ const Template = () => {
</a> </a>
</Permission> </Permission>
)}
{!Object.keys(hasEdited).length && (
<Permission operationCode={'system:tool:delete:category'}> <Permission operationCode={'system:tool:delete:category'}>
<a <a
onClick={handleOnDeleteFile(record.name)} onClick={handleOnDeleteFile(record.name)}
@@ -530,6 +542,7 @@ const Template = () => {
</a> </a>
</Permission> </Permission>
)}
</AntdSpace> </AntdSpace>
</> </>
) )
@@ -551,10 +564,6 @@ const Template = () => {
const handleOnRenameFile = (fileName: string) => { const handleOnRenameFile = (fileName: string) => {
return () => { return () => {
if (Object.keys(hasEdited).length) {
void message.warning('重命名文件前请先保存更改')
return
}
renameFileForm.setFieldValue('fileName', fileName) renameFileForm.setFieldValue('fileName', fileName)
void modal.confirm({ void modal.confirm({
title: '重命名文件', title: '重命名文件',
@@ -655,11 +664,6 @@ const Template = () => {
const handleOnDeleteFile = (fileName: string) => { const handleOnDeleteFile = (fileName: string) => {
return () => { return () => {
if (Object.keys(hasEdited).length) {
void message.warning('删除文件前请先保存更改')
return
}
modal modal
.confirm({ .confirm({
title: '确定删除', title: '确定删除',
@@ -726,8 +730,10 @@ const Template = () => {
const handleOnChangeFileContent = (_content: string, _fileName: string, files: IFiles) => { const handleOnChangeFileContent = (_content: string, _fileName: string, files: IFiles) => {
setEditingFiles({ ...editingFiles, [editingTemplateId]: files }) setEditingFiles({ ...editingFiles, [editingTemplateId]: files })
if (!hasEdited[editingTemplateId]) {
setHasEdited({ ...hasEdited, [editingTemplateId]: true }) setHasEdited({ ...hasEdited, [editingTemplateId]: true })
} }
}
const getBaseData = () => { const getBaseData = () => {
if (isLoadingBaseData) { if (isLoadingBaseData) {
@@ -859,6 +865,7 @@ const Template = () => {
onChangeFileContent={handleOnChangeFileContent} onChangeFileContent={handleOnChangeFileContent}
showFileSelector={false} showFileSelector={false}
tsconfig={tsconfig} tsconfig={tsconfig}
readonly={isLoading || templateDetailLoading[editingTemplateId]}
/> />
<div className={'close-editor-btn'} onClick={handleOnCloseBtnClick}> <div className={'close-editor-btn'} onClick={handleOnCloseBtnClick}>
<Icon component={IconOxygenClose} /> <Icon component={IconOxygenClose} />
@@ -868,7 +875,7 @@ const Template = () => {
</FlexBox> </FlexBox>
</HideScrollbar> </HideScrollbar>
<AntdDrawer <AntdDrawer
title={isDrawerEdit ? '编辑板' : '添加板'} title={isDrawerEdit ? '编辑板' : '添加板'}
onClose={handleOnDrawerClose} onClose={handleOnDrawerClose}
open={isDrawerOpen} open={isDrawerOpen}
closable={!isSubmitting} closable={!isSubmitting}