Merge pull request #586 from Calcium-Ion/channel-tag
fix: tag channel copy
This commit is contained in:
@@ -317,7 +317,7 @@ const ChannelsTable = () => {
|
|||||||
position={'left'}
|
position={'left'}
|
||||||
onConfirm={() => {
|
onConfirm={() => {
|
||||||
manageChannel(record.id, 'delete', record).then(() => {
|
manageChannel(record.id, 'delete', record).then(() => {
|
||||||
removeRecord(record.id);
|
removeRecord(record);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -365,7 +365,7 @@ const ChannelsTable = () => {
|
|||||||
okType={'danger'}
|
okType={'danger'}
|
||||||
position={'left'}
|
position={'left'}
|
||||||
onConfirm={async () => {
|
onConfirm={async () => {
|
||||||
copySelectedChannel(record.id);
|
copySelectedChannel(record);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button theme="light" type="primary" style={{ marginRight: 1 }}>
|
<Button theme="light" type="primary" style={{ marginRight: 1 }}>
|
||||||
@@ -441,10 +441,21 @@ const ChannelsTable = () => {
|
|||||||
const [showEditPriority, setShowEditPriority] = useState(false);
|
const [showEditPriority, setShowEditPriority] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
const removeRecord = (id) => {
|
const removeRecord = (record) => {
|
||||||
let newDataSource = [...channels];
|
let newDataSource = [...channels];
|
||||||
if (id != null) {
|
if (record.id != null) {
|
||||||
let idx = newDataSource.findIndex((data) => data.id === id);
|
let idx = newDataSource.findIndex((data) => {
|
||||||
|
if (data.children !== undefined) {
|
||||||
|
for (let i = 0; i < data.children.length; i++) {
|
||||||
|
if (data.children[i].id === record.id) {
|
||||||
|
data.children.splice(i, 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return data.id === record.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (idx > -1) {
|
if (idx > -1) {
|
||||||
newDataSource.splice(idx, 1);
|
newDataSource.splice(idx, 1);
|
||||||
@@ -566,11 +577,8 @@ const ChannelsTable = () => {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const copySelectedChannel = async (id) => {
|
const copySelectedChannel = async (record) => {
|
||||||
const channelToCopy = channels.find(
|
const channelToCopy = record
|
||||||
(channel) => String(channel.id) === String(id)
|
|
||||||
);
|
|
||||||
console.log(channelToCopy);
|
|
||||||
channelToCopy.name += '_复制';
|
channelToCopy.name += '_复制';
|
||||||
channelToCopy.created_time = null;
|
channelToCopy.created_time = null;
|
||||||
channelToCopy.balance = 0;
|
channelToCopy.balance = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user