|
@@ -1,157 +1,68 @@
|
1
|
|
-import { getPostsList, deletePosts, updatePosts } from "@/services/posts";
|
|
1
|
+import { getPostsFilesList, deletePostsFiles } from "@/services/posts";
|
2
|
2
|
import { queryTable } from "@/utils/request";
|
3
|
3
|
import { PageContainer, ProTable, ProList } from "@ant-design/pro-components";
|
4
|
4
|
import { useNavigate } from "react-router-dom";
|
5
|
5
|
import { Button, message, Popconfirm } from "antd";
|
6
|
6
|
import { useRef, useState, useEffect } from "react";
|
7
|
7
|
import { floatMultiply, floatDivide } from "@/utils";
|
8
|
|
-import AddFiles from './addFiles'
|
|
8
|
+import AddFiles from "./addFiles";
|
9
|
9
|
|
10
|
10
|
const FilesList = (props) => {
|
11
|
|
-
|
12
|
11
|
const [showDetail, setShowDetail] = useState(false);
|
13
|
12
|
const [activeKey, setActiveKey] = useState("");
|
14
|
13
|
const actionRef = useRef();
|
15
|
14
|
const navigate = useNavigate();
|
16
|
15
|
|
17
|
|
-
|
18
|
|
- const updata = (row) => {
|
19
|
|
- if (row.id) {
|
20
|
|
- updatePosts(row.id, { status: row.status === 1 ? 0 : 1 }).then((res) => {
|
21
|
|
- actionRef.current.reload();
|
22
|
|
- });
|
23
|
|
- }
|
24
|
|
- };
|
25
|
|
-
|
26
|
16
|
const handleDelete = (id) => {
|
27
|
17
|
if (id) {
|
28
|
|
- deletePosts(id).then((res) => {
|
|
18
|
+ deletePostsFiles(id).then((res) => {
|
29
|
19
|
actionRef.current.reload();
|
30
|
20
|
});
|
31
|
21
|
}
|
32
|
22
|
};
|
33
|
23
|
|
34
|
|
- const columns = [
|
35
|
|
- {
|
36
|
|
- title: "内容名称",
|
37
|
|
- dataIndex: "title",
|
38
|
|
- },
|
39
|
|
-
|
40
|
|
- {
|
41
|
|
- title: "状态",
|
42
|
|
- dataIndex: "status",
|
43
|
|
- valueType: "select",
|
44
|
|
- valueEnum: {
|
45
|
|
- 0: { text: "未发布", status: "Error" },
|
46
|
|
- 1: { text: "已发布", status: "Processing" },
|
47
|
|
- },
|
48
|
|
- },
|
49
|
|
- {
|
50
|
|
- title: "发布人",
|
51
|
|
- dataIndex: "createPerson",
|
52
|
|
- search: false,
|
53
|
|
- },
|
54
|
|
- {
|
55
|
|
- title: "操作",
|
56
|
|
- valueType: "option",
|
57
|
|
- width: 200,
|
58
|
|
- render: (_, record) => [
|
59
|
|
- <Button
|
60
|
|
- key={3}
|
61
|
|
- style={{ padding: 0 }}
|
62
|
|
- type="link"
|
63
|
|
- onClick={() => {
|
64
|
|
- updata(record);
|
65
|
|
- }}
|
66
|
|
- >
|
67
|
|
- {record.status === 1 ? "下架" : "发布"}
|
68
|
|
- </Button>,
|
69
|
|
- <Button
|
70
|
|
- key={1}
|
71
|
|
- style={{ padding: 0 }}
|
72
|
|
- type="link"
|
73
|
|
- onClick={() => {
|
74
|
|
- navigate(`/cms/emergency-plan/detail?id=${record.id}`);
|
75
|
|
- }}
|
76
|
|
- >
|
77
|
|
- 详情
|
78
|
|
- </Button>,
|
79
|
|
- <Button
|
80
|
|
- key={2}
|
81
|
|
- style={{ padding: 0 }}
|
82
|
|
- type="link"
|
83
|
|
- onClick={() => {
|
84
|
|
- navigate(`/cms/emergency-plan/edit?id=${record.id}`);
|
85
|
|
- }}
|
86
|
|
- >
|
87
|
|
- 修改
|
88
|
|
- </Button>,
|
89
|
|
- <Popconfirm
|
90
|
|
- key={3}
|
91
|
|
- title="您是否确认删除 ?"
|
92
|
|
- onConfirm={() => handleDelete(record.id)}
|
93
|
|
- okText="确定"
|
94
|
|
- cancelText="取消"
|
95
|
|
- >
|
96
|
|
- {/* manualPush */}
|
97
|
|
- <Button style={{ padding: 0 }} type="link">
|
98
|
|
- 删除
|
99
|
|
- </Button>
|
100
|
|
- </Popconfirm>,
|
101
|
|
- ],
|
102
|
|
- },
|
103
|
|
- ];
|
104
|
|
-
|
105
|
24
|
return (
|
106
|
25
|
<PageContainer>
|
107
|
26
|
<ProList
|
108
|
27
|
toolBarRender={() => {
|
109
|
28
|
return [
|
110
|
|
- <AddFiles />,
|
|
29
|
+ <AddFiles
|
|
30
|
+ onsuccess={() => {
|
|
31
|
+ actionRef.current.reload();
|
|
32
|
+ }}
|
|
33
|
+ />,
|
111
|
34
|
];
|
112
|
35
|
}}
|
|
36
|
+ actionRef={actionRef}
|
|
37
|
+ request={queryTable(getPostsFilesList)}
|
113
|
38
|
search={{}}
|
114
|
39
|
rowKey="id"
|
115
|
40
|
// headerTitle="基础列表"
|
116
|
|
- pagination={{
|
117
|
|
- pageSize: 5,
|
118
|
|
- }}
|
119
|
|
- showActions="hover"
|
|
41
|
+ pagination={true}
|
|
42
|
+ // showActions="hover"
|
120
|
43
|
metas={{
|
121
|
44
|
title: {
|
122
|
45
|
dataIndex: "fileName",
|
123
|
46
|
title: "文件名称",
|
124
|
47
|
},
|
125
|
|
- description: {
|
126
|
|
- dataIndex: "title",
|
127
|
|
- search: false,
|
128
|
|
- },
|
|
48
|
+
|
129
|
49
|
actions: {
|
130
|
50
|
render: (text, row) => [
|
131
|
|
- <a
|
132
|
|
- href={row.url}
|
133
|
|
- target="_blank"
|
134
|
|
- rel="noopener noreferrer"
|
135
|
|
- key="link"
|
136
|
|
- >
|
137
|
|
- 链路
|
138
|
|
- </a>,
|
139
|
|
- <a
|
140
|
|
- href={row.url}
|
141
|
|
- target="_blank"
|
142
|
|
- rel="noopener noreferrer"
|
143
|
|
- key="warning"
|
144
|
|
- >
|
145
|
|
- 报警
|
|
51
|
+ <a href={row.fileAddr} download>
|
|
52
|
+ 下载
|
146
|
53
|
</a>,
|
147
|
|
- <a
|
148
|
|
- href={row.url}
|
149
|
|
- target="_blank"
|
150
|
|
- rel="noopener noreferrer"
|
151
|
|
- key="view"
|
|
54
|
+ <Popconfirm
|
|
55
|
+ key={3}
|
|
56
|
+ title="您是否确认删除 ?"
|
|
57
|
+ onConfirm={() => handleDelete(row.id)}
|
|
58
|
+ okText="确定"
|
|
59
|
+ cancelText="取消"
|
152
|
60
|
>
|
153
|
|
- 查看
|
154
|
|
- </a>,
|
|
61
|
+ {/* manualPush */}
|
|
62
|
+ <Button style={{ padding: 0 }} type="link">
|
|
63
|
+ 删除
|
|
64
|
+ </Button>
|
|
65
|
+ </Popconfirm>,
|
155
|
66
|
],
|
156
|
67
|
search: false,
|
157
|
68
|
},
|