Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chatGLM
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘坚-丰林-DEV
chatGLM
Commits
3ee09474
Commit
3ee09474
authored
Apr 17, 2023
by
Ylg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
complete prompt word page
parent
5539db75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
107 deletions
+58
-107
index.tsx
src/components/EditAndAddPromptModal/index.tsx
+3
-3
index.tsx
src/components/deletePromptModal/index.tsx
+5
-3
index.tsx
src/pages/PromptWord/index.tsx
+50
-101
No files found.
src/components/EditAndAddPromptModal/index.tsx
View file @
3ee09474
...
@@ -31,16 +31,16 @@ const EditPromptModal = (props: IEditPromptModalProps) => {
...
@@ -31,16 +31,16 @@ const EditPromptModal = (props: IEditPromptModalProps) => {
}
}
},
[
open
])
},
[
open
])
const
handleSavePrompt
=
()
=>
{
const
handleSavePrompt
=
async
()
=>
{
if
(
modalType
===
'create'
)
{
if
(
modalType
===
'create'
)
{
handleCreatePrompt
({
await
handleCreatePrompt
({
type
:
currentSelectValue
,
type
:
currentSelectValue
,
content
:
textAreaValue
,
content
:
textAreaValue
,
});
});
}
}
if
(
modalType
===
'edit'
)
{
if
(
modalType
===
'edit'
)
{
handleEditPrompt
({
await
handleEditPrompt
({
type
:
currentSelectValue
,
type
:
currentSelectValue
,
content
:
textAreaValue
,
content
:
textAreaValue
,
})
})
...
...
src/components/deletePromptModal/index.tsx
View file @
3ee09474
...
@@ -19,10 +19,12 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => {
...
@@ -19,10 +19,12 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => {
tip
,
tip
,
content
,
content
,
loading
,
loading
,
handleDeletePrompt
,
}
=
props
;
}
=
props
;
const
handleDeletePrompt
=
()
=>
{
const
handleSavePrompt
=
async
()
=>
{
handleDeletePrompt
();
await
handleDeletePrompt
();
setOpen
(
false
);
}
}
return
(
return
(
...
@@ -30,7 +32,7 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => {
...
@@ -30,7 +32,7 @@ const DeletePromptModal = (props: IDeletePromptModalProps) => {
title=
{
title
}
title=
{
title
}
okText=
'确认'
okText=
'确认'
open=
{
open
}
open=
{
open
}
onOk=
{
handle
Delet
ePrompt
}
onOk=
{
handle
Sav
ePrompt
}
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
setOpen
(
false
);
setOpen
(
false
);
}
}
}
}
...
...
src/pages/PromptWord/index.tsx
View file @
3ee09474
import
{
DeleteOutlined
,
EditOutlined
,
PlusOutlined
}
from
'@ant-design/icons'
;
import
{
DeleteOutlined
,
EditOutlined
,
PlusOutlined
}
from
'@ant-design/icons'
;
import
type
{
ActionType
}
from
'@ant-design/pro-components'
;
import
{
ActionType
,
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
Button
,
Col
,
Divider
,
Form
,
Input
,
Modal
,
Radio
,
Row
,
Select
,
Switch
,
message
}
from
'antd'
;
import
{
Button
,
message
}
from
'antd'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
SetStateAction
,
useEffect
,
useRef
,
useState
}
from
'react'
;
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
styles
from
'./index.less'
;
import
styles
from
'./index.less'
;
import
EditPromptModal
from
'@/components/EditAndAddPromptModal'
;
import
EditPromptModal
from
'@/components/EditAndAddPromptModal'
;
import
DeletePromptModal
from
'@/components/DeletePromptModal'
;
import
DeletePromptModal
from
'@/components/DeletePromptModal'
;
...
@@ -32,6 +31,9 @@ interface ILoading {
...
@@ -32,6 +31,9 @@ interface ILoading {
}
}
const
PromptWord
=
()
=>
{
const
PromptWord
=
()
=>
{
const
actionRef
=
useRef
<
ActionType
>
();
const
[
allLoading
,
setAllLoading
]
=
useState
<
ILoading
>
({
const
[
allLoading
,
setAllLoading
]
=
useState
<
ILoading
>
({
editModalLoading
:
false
,
editModalLoading
:
false
,
createModalLoading
:
false
,
createModalLoading
:
false
,
...
@@ -47,16 +49,9 @@ const PromptWord = () => {
...
@@ -47,16 +49,9 @@ const PromptWord = () => {
const
[
currentRow
,
setCurrentRaw
]
=
useState
({}
as
IPromptList
);
const
[
currentRow
,
setCurrentRaw
]
=
useState
({}
as
IPromptList
);
const
columns
:
any
[]
=
[
const
columns
:
any
[]
=
[
{
title
:
'序号'
,
width
:
'10%'
,
key
:
'sequenceNumber'
,
dataIndex
:
'sequenceNumber'
,
search
:
false
,
},
{
{
title
:
'类型'
,
title
:
'类型'
,
width
:
'
15
%'
,
width
:
'
20
%'
,
key
:
'type'
,
key
:
'type'
,
dataIndex
:
'type'
,
dataIndex
:
'type'
,
valueType
:
'select'
,
valueType
:
'select'
,
...
@@ -72,7 +67,7 @@ const PromptWord = () => {
...
@@ -72,7 +67,7 @@ const PromptWord = () => {
},
},
{
{
title
:
'提示词语'
,
title
:
'提示词语'
,
width
:
'4
5
%'
,
width
:
'4
0
%'
,
key
:
'promptWord'
,
key
:
'promptWord'
,
dataIndex
:
'content'
,
dataIndex
:
'content'
,
ellipsis
:
true
,
ellipsis
:
true
,
...
@@ -81,7 +76,7 @@ const PromptWord = () => {
...
@@ -81,7 +76,7 @@ const PromptWord = () => {
},
},
{
{
title
:
'创建时间'
,
title
:
'创建时间'
,
width
:
'
1
5%'
,
width
:
'
2
5%'
,
key
:
'creationTime'
,
key
:
'creationTime'
,
dataIndex
:
'creationTime'
,
dataIndex
:
'creationTime'
,
search
:
false
,
search
:
false
,
...
@@ -120,116 +115,57 @@ const PromptWord = () => {
...
@@ -120,116 +115,57 @@ const PromptWord = () => {
},
},
];
];
const
fetchPromptList
=
async
()
=>
{
setAllLoading
({
...
allLoading
,
listLoading
:
true
,
})
try
{
const
response
=
await
pagePromptWords
({
filter
:
''
,
type
:
''
,
pageIndex
:
0
,
pageSize
:
10
})
setAllLoading
({
...
allLoading
,
listLoading
:
false
,
})
const
dataSource
:
IPromptList
[]
=
response
.
items
.
map
((
item
:
IPromptList
)
=>
{
return
{
...
item
,
}
})
setPromptList
(
dataSource
);
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
listLoading
:
false
,
})
message
.
error
(
'请求列表失败,请重试!'
)
}
};
const
fetchTypes
=
async
()
=>
{
const
fetchTypes
=
async
()
=>
{
const
data
=
await
typePromptWords
();
const
data
=
await
typePromptWords
();
setTypes
(
data
);
setTypes
(
data
);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
fetchPromptList
();
fetchTypes
();
fetchTypes
();
},
[]);
},
[]);
const
handleEditPrompt
=
async
(
editValue
:
IFormValue
)
=>
{
const
handleEditPrompt
=
async
(
editValue
:
IFormValue
)
=>
{
setAllLoading
({
setAllLoading
({
...
allLoading
,
editModalLoading
:
true
});
...
allLoading
,
editModalLoading
:
true
,
})
try
{
try
{
await
updatePromptWords
({
await
updatePromptWords
({
id
:
currentRow
.
id
,
id
:
currentRow
.
id
,
content
:
editValue
.
content
,
content
:
editValue
.
content
,
type
:
editValue
.
type
type
:
editValue
.
type
});
});
setAllLoading
({
setAllLoading
({
...
allLoading
,
editModalLoading
:
false
});
...
allLoading
,
actionRef
.
current
?.
reload
();
editModalLoading
:
false
,
})
fetchPromptList
();
}
catch
(
error
)
{
}
catch
(
error
)
{
setAllLoading
({
setAllLoading
({
...
allLoading
,
editModalLoading
:
false
});
...
allLoading
,
editModalLoading
:
false
,
})
message
.
error
(
'编辑提示用语失败,请重试!'
)
message
.
error
(
'编辑提示用语失败,请重试!'
)
}
}
};
};
const
handleCreatePrompt
=
async
(
createValue
:
IFormValue
)
=>
{
const
handleCreatePrompt
=
async
(
createValue
:
IFormValue
)
=>
{
setAllLoading
({
setAllLoading
({
...
allLoading
,
createModalLoading
:
true
});
...
allLoading
,
createModalLoading
:
true
,
})
try
{
try
{
await
createPromptWords
({
await
createPromptWords
({
content
:
createValue
.
content
,
content
:
createValue
.
content
,
type
:
createValue
.
type
type
:
createValue
.
type
})
})
setAllLoading
({
setAllLoading
({
...
allLoading
,
createModalLoading
:
false
});
...
allLoading
,
actionRef
.
current
?.
reload
();
createModalLoading
:
false
,
})
fetchPromptList
();
}
catch
(
error
)
{
}
catch
(
error
)
{
setAllLoading
({
setAllLoading
({
...
allLoading
,
createModalLoading
:
false
});
...
allLoading
,
createModalLoading
:
false
,
})
message
.
error
(
'新增提示用语失败,请重试!'
)
message
.
error
(
'新增提示用语失败,请重试!'
)
}
}
};
};
const
handleDeletePrompt
=
async
()
=>
{
const
handleDeletePrompt
=
async
()
=>
{
setAllLoading
({
setAllLoading
({
...
allLoading
,
deleteModalLoading
:
true
});
...
allLoading
,
deleteModalLoading
:
true
,
})
try
{
try
{
await
deletePromptWords
({
await
deletePromptWords
({
id
:
currentRow
.
id
id
:
currentRow
.
id
});
});
setAllLoading
({
setAllLoading
({
...
allLoading
,
deleteModalLoading
:
false
});
...
allLoading
,
actionRef
.
current
?.
reload
();
deleteModalLoading
:
false
,
})
fetchPromptList
();
}
catch
(
error
)
{
}
catch
(
error
)
{
setAllLoading
({
setAllLoading
({
...
allLoading
,
deleteModalLoading
:
false
});
...
allLoading
,
deleteModalLoading
:
false
,
})
message
.
error
(
'删除提示用语失败,请重试!'
)
message
.
error
(
'删除提示用语失败,请重试!'
)
}
}
};
};
...
@@ -256,25 +192,38 @@ const PromptWord = () => {
...
@@ -256,25 +192,38 @@ const PromptWord = () => {
loading=
{
modalType
===
'create'
?
allLoading
.
createModalLoading
:
allLoading
.
editModalLoading
}
loading=
{
modalType
===
'create'
?
allLoading
.
createModalLoading
:
allLoading
.
editModalLoading
}
/>
/>
<
ProTable
<
ProTable
dataSource=
{
promptList
}
request=
{
async
(
params
=
{
pageSize
:
10
,
current
:
0
})
=>
{
setAllLoading
({
...
allLoading
,
listLoading
:
true
});
const
promptListParams
=
{
filter
:
params
?.
promptWord
||
''
,
type
:
params
?.
type
||
''
,
pageIndex
:
params
?.
current
as
number
-
1
,
pageSize
:
params
?.
pageSize
,
}
try
{
const
response
=
await
pagePromptWords
(
promptListParams
);
setAllLoading
({
...
allLoading
,
listLoading
:
false
});
return
{
data
:
response
.
items
,
total
:
response
.
totalCount
,
success
:
!
isEmpty
(
response
),
}
}
catch
(
error
)
{
setAllLoading
({
...
allLoading
,
listLoading
:
false
});
message
.
error
(
'请求列表失败,请重试!'
);
return
{
data
:
[],
total
:
0
,
success
:
false
,
}
}
}
}
actionRef=
{
actionRef
}
columns=
{
columns
}
columns=
{
columns
}
cardBordered
cardBordered
rowKey=
"id"
rowKey=
"id"
pagination=
{
{
pagination=
{
{
pageSize
:
5
,
pageSize
:
10
,
onChange
:
(
page
)
=>
{
},
}
}
search=
{
{
labelWidth
:
'auto'
,
className
:
styles
.
search
,
optionRender
:
()
=>
{
return
[
<
Button
type=
'default'
key=
'2'
>
重置
</
Button
>,
<
Button
type=
'primary'
key=
'3'
>
查询
</
Button
>
]
}
}
}
}
}
options=
{
false
}
options=
{
false
}
dateFormatter=
"string"
dateFormatter=
"string"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment