|
@@ -1,10 +1,12 @@
|
1
|
1
|
import React, { useState, useEffect, useRef } from 'react'
|
2
|
2
|
import { Select, Spin, Table, Button, Form, Input, Divider, Tag, Modal,Popconfirm } from 'antd'
|
|
3
|
+import { connect } from 'dva';
|
3
|
4
|
import NavLink from 'umi/navlink'
|
4
|
5
|
import { fetch, apis, fetchList } from '@/utils/request'
|
5
|
6
|
import Search from '../../components/Search'
|
6
|
7
|
import List from '../../components/List'
|
7
|
8
|
import Editor from './Editor'
|
|
9
|
+import Preview from './components/Preview'
|
8
|
10
|
|
9
|
11
|
const listMessageEvent = fetchList(apis.announcement.messageEvent.list)
|
10
|
12
|
const saveMessageEvent = fetch(apis.announcement.messageEvent.save)
|
|
@@ -57,12 +59,14 @@ const Condition = props => {
|
57
|
59
|
)
|
58
|
60
|
}
|
59
|
61
|
|
60
|
|
-export default props => {
|
|
62
|
+export default connect(({user}) => ({user}))(props => {
|
61
|
63
|
const [loading, setLoading] = useState(false)
|
62
|
64
|
const [listData, setListData] = useState([])
|
63
|
65
|
const [pagination, setPagination] = useState({})
|
64
|
66
|
const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10 })
|
65
|
67
|
const [showEditor, setShowEditor] = useState(false)
|
|
68
|
+ const [showPreview, setShowPreview] = useState(false)
|
|
69
|
+ const currentRow = useRef({})
|
66
|
70
|
|
67
|
71
|
const handleSearch = vals => {
|
68
|
72
|
setQueryParams({
|
|
@@ -72,6 +76,14 @@ export default props => {
|
72
|
76
|
})
|
73
|
77
|
}
|
74
|
78
|
|
|
79
|
+ const handleNameClick = row => {
|
|
80
|
+ currentRow.current = {
|
|
81
|
+ ...row,
|
|
82
|
+ org: props.user.currentUser.orgName
|
|
83
|
+ }
|
|
84
|
+ setShowPreview(true)
|
|
85
|
+ }
|
|
86
|
+
|
75
|
87
|
const handleSubmit = data => {
|
76
|
88
|
saveMessageEvent({data}).then(res => {
|
77
|
89
|
Modal.success({
|
|
@@ -90,7 +102,7 @@ export default props => {
|
90
|
102
|
const data = {...row, status}
|
91
|
103
|
updateMessageEvent({data, urlData: {id: row.evtId}}).then(res => {
|
92
|
104
|
Modal.success({
|
93
|
|
- content: '删除内容成功',
|
|
105
|
+ content: '操作成功',
|
94
|
106
|
onOk: () => {
|
95
|
107
|
// 触发数据刷新
|
96
|
108
|
setQueryParams({...queryParams})
|
|
@@ -137,7 +149,9 @@ export default props => {
|
137
|
149
|
</div>
|
138
|
150
|
<List dataSource={listData} loading={loading} pagination={pagination} onPageChange={handlePageChange} rowKey="evtId">
|
139
|
151
|
<Table.Column title="类型" dataIndex="evtType" key="evtType" render={t => EvtTypeDict[t] || ''} />
|
140
|
|
- <Table.Column title="名称" dataIndex="name" key="name" />
|
|
152
|
+ <Table.Column title="名称" dataIndex="name" key="name" render={(t, row) => {
|
|
153
|
+ return <Button type="link" onClick={() => handleNameClick(row)}>{t}</Button>
|
|
154
|
+ }} />
|
141
|
155
|
<Table.Column title="发生日" dataIndex="evtDate" key="evtDate" render={(_, row) => {
|
142
|
156
|
return row.evtDate && (
|
143
|
157
|
<span>
|
|
@@ -156,15 +170,21 @@ export default props => {
|
156
|
170
|
render={(_, row) => {
|
157
|
171
|
return (
|
158
|
172
|
<>
|
159
|
|
- <Popconfirm
|
160
|
|
- title="确认进行作废操作?"
|
161
|
|
- onConfirm={() => handleDeleteRow(row)}
|
162
|
|
- okText="作废"
|
163
|
|
- cancelText="取消"
|
164
|
|
- >
|
165
|
|
- <Button type="link">删除</Button>
|
166
|
|
- </Popconfirm>
|
167
|
|
- <Divider type="vertical" />
|
|
173
|
+ {
|
|
174
|
+ row.evtType !== 'birthday' && (
|
|
175
|
+ <>
|
|
176
|
+ <Popconfirm
|
|
177
|
+ title="确认进行删除操作?"
|
|
178
|
+ onConfirm={() => handleDeleteRow(row)}
|
|
179
|
+ okText="删除"
|
|
180
|
+ cancelText="取消"
|
|
181
|
+ >
|
|
182
|
+ <Button type="link">删除</Button>
|
|
183
|
+ </Popconfirm>
|
|
184
|
+ <Divider type="vertical" />
|
|
185
|
+ </>
|
|
186
|
+ )
|
|
187
|
+ }
|
168
|
188
|
<Button type="link" onClick={() => handleEdit(row)}>{row.status === 1 ? '取消发布' : '发布'}</Button>
|
169
|
189
|
</>
|
170
|
190
|
)
|
|
@@ -172,6 +192,7 @@ export default props => {
|
172
|
192
|
/>
|
173
|
193
|
</List>
|
174
|
194
|
<Editor visible={showEditor} onCancel={() => setShowEditor(false)} onSubmit={handleSubmit} />
|
|
195
|
+ <Preview visible={showPreview} dataSource={currentRow.current} onOk={() => setShowPreview(false)} onCancel={() => setShowPreview(false)} />
|
175
|
196
|
</div>
|
176
|
197
|
)
|
177
|
|
-}
|
|
198
|
+})
|