|
@@ -1,5 +1,5 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react'
|
2
|
|
-import { Select, Spin, Table, Button, Form, Input, Divider, Modal,Popconfirm } from 'antd'
|
|
2
|
+import { Select, Spin, Table, Button, Form, Input, Divider, Modal,Popconfirm, notification } from 'antd'
|
3
|
3
|
import NavLink from 'umi/navlink'
|
4
|
4
|
import { fetch, apis } from '@/utils/request'
|
5
|
5
|
import Search from '../components/Search'
|
|
@@ -7,6 +7,7 @@ import List from '../components/List'
|
7
|
7
|
|
8
|
8
|
const listAnnouncement = fetch(apis.announcement.listAnnouncement)
|
9
|
9
|
const deleteAnnouncement = fetch(apis.announcement.deleteAnnouncement)
|
|
10
|
+const updateannouncement = fetch(apis.announcement.updateannouncement)
|
10
|
11
|
|
11
|
12
|
const Condition = props => {
|
12
|
13
|
return (
|
|
@@ -46,7 +47,7 @@ const Condition = props => {
|
46
|
47
|
}
|
47
|
48
|
|
48
|
49
|
const StatusDict = {
|
49
|
|
- '0': '已作废',
|
|
50
|
+ '0': '未发布',
|
50
|
51
|
'1': '已发布',
|
51
|
52
|
'2': '草稿'
|
52
|
53
|
}
|
|
@@ -65,15 +66,13 @@ export default props => {
|
65
|
66
|
})
|
66
|
67
|
}
|
67
|
68
|
|
68
|
|
- const handleDeleteRow = row => {
|
69
|
|
- deleteAnnouncement({ data: [row.id] }).then(res => {
|
70
|
|
- Modal.success({
|
71
|
|
- content: '删除内容成功',
|
72
|
|
- onOk: () => {
|
73
|
|
- // 触发数据刷新
|
74
|
|
- setQueryParams({...queryParams})
|
75
|
|
- }
|
76
|
|
- })
|
|
69
|
+ const handleEditRow = row => {
|
|
70
|
+ updateannouncement({data: {
|
|
71
|
+ ...row,
|
|
72
|
+ status: Math.abs(row.status - 1)
|
|
73
|
+ }}).then(res => {
|
|
74
|
+ notification.success({message: '操作成功'})
|
|
75
|
+ setQueryParams({...queryParams})
|
77
|
76
|
})
|
78
|
77
|
}
|
79
|
78
|
|
|
@@ -88,7 +87,6 @@ export default props => {
|
88
|
87
|
useEffect(() => {
|
89
|
88
|
setLoading(true)
|
90
|
89
|
listAnnouncement({ data: queryParams }).then(res => {
|
91
|
|
- console.log(res,"222")
|
92
|
90
|
const { list, ...pageInfo } = res || {}
|
93
|
91
|
setListData(list)
|
94
|
92
|
setPagination(pageInfo)
|
|
@@ -124,13 +122,7 @@ export default props => {
|
124
|
122
|
title="状态"
|
125
|
123
|
dataIndex="status"
|
126
|
124
|
key="status"
|
127
|
|
- render={(_, row) => {
|
128
|
|
- if (row.status === '1' && (row.updateDate > row.createDate)) {
|
129
|
|
- return '已修改'
|
130
|
|
- }
|
131
|
|
-
|
132
|
|
- return StatusDict[row.status]
|
133
|
|
- }}
|
|
125
|
+ render={(_, row) => StatusDict[row.status]}
|
134
|
126
|
/>
|
135
|
127
|
<Table.Column title="创建时间" dataIndex="createDate" key="createDate" />
|
136
|
128
|
{/* <Table.Column title="发布人" dataIndex="createUserName" key="createUserName" />
|
|
@@ -143,12 +135,12 @@ export default props => {
|
143
|
135
|
return (
|
144
|
136
|
<>
|
145
|
137
|
<Popconfirm
|
146
|
|
- title="确认进行作废操作?"
|
147
|
|
- onConfirm={() => handleDeleteRow(row)}
|
148
|
|
- okText="作废"
|
|
138
|
+ title="确认进行当前操作?"
|
|
139
|
+ onConfirm={() => handleEditRow(row)}
|
|
140
|
+ okText="确定"
|
149
|
141
|
cancelText="取消"
|
150
|
142
|
>
|
151
|
|
- <Button type="link">删除</Button>
|
|
143
|
+ <Button type="link">{row.status === '1' ? '取消发布' : '发布'}</Button>
|
152
|
144
|
</Popconfirm>
|
153
|
145
|
<Divider type="vertical" />
|
154
|
146
|
<NavLink to={`/property/notice/edit?id=${row.id}`}>
|