Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
08456378
authored
Apr 10, 2024
by
iszcz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增渠道复制
parent
366adc01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
web/src/components/ChannelsTable.js
+38
-0
No files found.
web/src/components/ChannelsTable.js
View file @
08456378
...
@@ -254,6 +254,19 @@ const ChannelsTable = () => {
...
@@ -254,6 +254,19 @@ const ChannelsTable = () => {
>
>
编辑
编辑
<
/Button
>
<
/Button
>
<
Popconfirm
title
=
'确定是否要复制此渠道?'
content
=
'复制渠道的所有信息'
okType
=
{
'danger'
}
position
=
{
'left'
}
onConfirm
=
{
async
()
=>
{
copySelectedChannel
(
record
.
id
);
}}
>
<
Button
theme
=
'light'
type
=
'primary'
style
=
{{
marginRight
:
1
}}
>
复制
<
/Button
>
<
/Popconfirm
>
<
/div
>
<
/div
>
),
),
},
},
...
@@ -340,6 +353,31 @@ const ChannelsTable = () => {
...
@@ -340,6 +353,31 @@ const ChannelsTable = () => {
setLoading
(
false
);
setLoading
(
false
);
};
};
const
copySelectedChannel
=
async
(
id
)
=>
{
const
channelToCopy
=
channels
.
find
(
channel
=>
String
(
channel
.
id
)
===
String
(
id
));
console
.
log
(
channelToCopy
)
channelToCopy
.
name
+=
'_复制'
;
channelToCopy
.
created_time
=
null
;
channelToCopy
.
balance
=
0
;
channelToCopy
.
used_quota
=
0
;
if
(
!
channelToCopy
)
{
showError
(
"渠道未找到,请刷新页面后重试。"
);
return
;
}
try
{
const
newChannel
=
{...
channelToCopy
,
id
:
undefined
};
const
response
=
await
API
.
post
(
'/api/channel/'
,
newChannel
);
if
(
response
.
data
.
success
)
{
showSuccess
(
"渠道复制成功"
);
await
refresh
();
}
else
{
showError
(
response
.
data
.
message
);
}
}
catch
(
error
)
{
showError
(
"渠道复制失败: "
+
error
.
message
);
}
};
const
refresh
=
async
()
=>
{
const
refresh
=
async
()
=>
{
await
loadChannels
(
activePage
-
1
,
pageSize
,
idSort
);
await
loadChannels
(
activePage
-
1
,
pageSize
,
idSort
);
};
};
...
...
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