fixed: 新闻编辑无法删除
This commit is contained in:
parent
800c14a4f8
commit
6abc6ab3d1
@ -1,19 +1,17 @@
|
||||
import {App} from "antd";
|
||||
import {showToast} from "@/components/message.ts";
|
||||
import {useState} from "react";
|
||||
import {push2article} from "@/service/api/news.ts";
|
||||
import {IconDelete} from "@/components/icons";
|
||||
import {useNavigate} from "react-router-dom";
|
||||
import {deleteByIds} from "@/service/api/article.ts";
|
||||
|
||||
export default function ButtonDeleteBatch(props: { ids: Id[];onSuccess?: () => void; }) {
|
||||
const {modal} = App.useApp();
|
||||
const [loading, setLoading] = useState(false)
|
||||
const navigate = useNavigate();
|
||||
const handlePush = () => {
|
||||
setLoading(true)
|
||||
push2article(props.ids).then(() => {
|
||||
deleteByIds(props.ids).then(() => {
|
||||
props.onSuccess?.();
|
||||
showToast('删除成功', 'success')
|
||||
navigate('/edit')
|
||||
}).catch(() => {
|
||||
showToast('删除失败', 'error')
|
||||
}).finally(() => {
|
||||
@ -27,8 +25,8 @@ export default function ButtonDeleteBatch(props: { ids: Id[];onSuccess?: () => v
|
||||
return
|
||||
}
|
||||
modal.confirm({
|
||||
title: '操作提示',
|
||||
content: '是否确定删除选中的新闻?',
|
||||
title: `你确定要删除选择的 ${props.ids.length} 条新闻吗?`,
|
||||
content: '删除后需从新闻素材中重新选择',
|
||||
onOk: handlePush,
|
||||
centered: true
|
||||
})
|
||||
|
@ -1,10 +1,10 @@
|
||||
import {Checkbox, Space} from "antd";
|
||||
import {Checkbox, Popconfirm, Space} from "antd";
|
||||
|
||||
import React, {useRef, useState} from "react";
|
||||
import {useRequest} from "ahooks";
|
||||
import {formatTime} from "@/util/strings.ts";
|
||||
import ArticleEditModal from "@/components/article/edit-modal.tsx";
|
||||
import {getList} from "@/service/api/article.ts";
|
||||
import {deleteByIds, getList} from "@/service/api/article.ts";
|
||||
import EditSearchForm from "@/pages/news/components/edit-search-form.tsx";
|
||||
import ButtonPush2Video from "@/pages/news/components/button-push2video.tsx";
|
||||
|
||||
@ -14,6 +14,7 @@ import {IconDelete, IconEdit} from "@/components/icons";
|
||||
import {clsx} from "clsx";
|
||||
import ButtonToTop from "@/components/scoller/button-to-top.tsx";
|
||||
import ButtonDeleteBatch from "@/pages/news/components/button-delete-batch.tsx";
|
||||
import {showErrorToast, showToast} from "@/components/message.ts";
|
||||
|
||||
|
||||
export default function NewEdit() {
|
||||
@ -58,7 +59,12 @@ export default function NewEdit() {
|
||||
}
|
||||
}
|
||||
const scrollerRef = useRef<InfiniteScrollerRef|null>(null)
|
||||
|
||||
const handleDelete = (id)=>{
|
||||
deleteByIds([id]).then(()=>{
|
||||
refresh()
|
||||
showToast('删除成功','success')
|
||||
}).catch(showErrorToast)
|
||||
}
|
||||
|
||||
return (<div className="container pb-5 news-edit">
|
||||
<div className="search-panel-container my-5">
|
||||
@ -109,13 +115,13 @@ export default function NewEdit() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="col source">
|
||||
<div className="text-sm">{item.media_name}</div>
|
||||
<div className="text-sm">{item.data_source_name}</div>
|
||||
</div>
|
||||
<div className="col count-picture">
|
||||
<div className="text-sm">{item.picture_count||'-'}</div>
|
||||
<div className="text-sm">{item.img_num}</div>
|
||||
</div>
|
||||
<div className="col count-words">
|
||||
<div className="text-sm">{item.words_count||'-'}</div>
|
||||
<div className="text-sm">{item.content_word_count}</div>
|
||||
</div>
|
||||
<div className="col time">
|
||||
<div
|
||||
@ -123,7 +129,11 @@ export default function NewEdit() {
|
||||
</div>
|
||||
<div className="col operations">
|
||||
<span className="icon-btn" onClick={() => setEditId(item.id)}><IconEdit/></span>
|
||||
<Popconfirm title={'确认删除此新闻吗?'} description={'删除后需从新闻素材中重新选择'} onConfirm={()=>{
|
||||
handleDelete(item.id)
|
||||
}}>
|
||||
<span className="icon-btn"><IconDelete/></span>
|
||||
</Popconfirm>
|
||||
<Checkbox checked={checked}
|
||||
onChange={e => handleItemChecked(e.target.checked, item)}/>
|
||||
</div>
|
||||
|
@ -164,8 +164,8 @@ export default function NewsIndex() {
|
||||
<div className="line-clamp-1">来源: <span>{item.data_source_name}</span></div>
|
||||
<div className="extras flex items-center justify-between gap-3">
|
||||
<div><span>{formatTime(item.publish_time,'min')}</span></div>
|
||||
<div><span>图片数: {item.picture_count || '-'}</span></div>
|
||||
<div><span>字数: {item.words_count || '-'}</span></div>
|
||||
<div><span>图片数: {item.img_num}</span></div>
|
||||
<div><span>字数: {item.content_word_count}</span></div>
|
||||
<div
|
||||
className={`checkbox mt-1`}>
|
||||
{item.internal_article_id > 0 ?
|
||||
|
@ -12,9 +12,8 @@ export function getList(data: ApiArticleSearchParams) {
|
||||
* 删除 【本期不做】
|
||||
* @param id
|
||||
*/
|
||||
export function deleteById(id: Id) {
|
||||
throw new Error('Not implement')
|
||||
return post<{ article: any }>({url: '/article/delete/' + id})
|
||||
export function deleteByIds(article_ids: Id[]) {
|
||||
return post('/article/remove',{article_ids})
|
||||
}
|
||||
|
||||
export function getById(id: Id) {
|
||||
|
5
src/types/api.d.ts
vendored
5
src/types/api.d.ts
vendored
@ -60,8 +60,9 @@ interface BasicArticleInfo {
|
||||
summary: string;
|
||||
publish_time: string;
|
||||
media_name: string;
|
||||
picture_count?: number;
|
||||
words_count?: number;
|
||||
data_source_name?: string;
|
||||
img_num?: number;
|
||||
content_word_count?: number;
|
||||
media_id: number;
|
||||
fanwen_column_id: number;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user