Commit 0aa96a0b authored by Bill's avatar Bill

fix: 消息bug以及内容管理bug

parent 4f7da662
......@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { FilterTable } from '../components/FilterTable';
import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Popconfirm, Modal } from 'antd';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
import { history, Link } from 'umi';
import { history, Link } from 'umi';
import { DownOutlined, UpOutlined } from '@ant-design/icons';
import { timeRange } from '@/utils/index';
import { PublicApi } from '@/services/api';
......@@ -41,9 +41,9 @@ const Advertisement = () => {
state.visible = false;
})
})
merge(
onFieldValueChange$('status'),
onFieldValueChange$('status'),
onFieldValueChange$('time'),
).subscribe(
fieldState => {
......@@ -65,9 +65,9 @@ const Advertisement = () => {
const postData = {
title: title || '',
status: status != 0 ? status : '',
startTime: st && st * 1000,
endTime: et && et * 1000,
current: 1,
startTime: st || null,
endTime: et || null,
current: 1,
pageSize: 10,
...params,
}
......@@ -85,7 +85,7 @@ const Advertisement = () => {
})
},
})
}
// 修改状态
......@@ -109,7 +109,7 @@ const Advertisement = () => {
return (
<Card>
<FilterTable
<FilterTable
schema={advertisementSchema}
components={{
CustomSearch,
......@@ -148,7 +148,7 @@ const Advertisement = () => {
</span>
)
},
toggleFilters: () => {
actions.setFieldState('FILTERS', state => {
const visible = !state.visible;
......@@ -160,10 +160,10 @@ const Advertisement = () => {
)
})
});
},
renderOperation: (val, record) => {
const status = ["", "上架", "下架", "上架"];
const status = ["", "上架", "下架", "上架"];
const canModify = [1, 3]
const menu = (
<Menu>
......@@ -176,7 +176,7 @@ const Advertisement = () => {
<a>
删除
</a>
</Menu.Item>
</Menu.Item>
</Menu>
)
return (
......@@ -192,7 +192,7 @@ const Advertisement = () => {
</Popconfirm>
{/* // 只有待上架, 已下架架才有 修改和删除 */}
{
canModify.includes(record.status)
canModify.includes(record.status)
? (
<Dropdown overlay={menu}>
<a>
......@@ -205,7 +205,7 @@ const Advertisement = () => {
</Space>
)
},
}}
effects={advertisementEffects()}
>
......@@ -214,4 +214,4 @@ const Advertisement = () => {
)
}
export default Advertisement;
\ No newline at end of file
export default Advertisement;
......@@ -29,8 +29,8 @@ const AdvertisementInfo = () => {
const isView = id && preview;
useEffect(() => {
const data = initialValues.data || {}
const content = data.content;
const data = initialValues?.data || {}
const content = data?.content;
if(content) {
const editorState = BraftEditor.createEditorState(content);
actions.setFieldValue('layout.contentLayout.content', editorState);
......
......@@ -29,7 +29,7 @@ const columns = [
)
},
{
title: '操作时间',
title: '发布时间',
dataIndex: 'createTime',
render: (text) => (
moment(text).format('YYYY-MM-DD HH:mm:ss')
......@@ -169,6 +169,7 @@ const announcementSchema = {
type: 'string',
'x-component': 'Select',
'x-component-props': {
placeholder: '发布时间(全部)',
options: TimeList,
style: {
width: '160px',
......
......@@ -6,7 +6,7 @@
*/
export const TimeList = [
{
label: '单据时间(全部)', value: 0
label: '发布时间(全部)', value: 0
},
{
label: '今天', value: 1
......
......@@ -15,21 +15,33 @@ interface Irole {
value: number
}
type SubmitType = {
/** 消息标题 */
title: string,
/** 消息内容 */
content: string,
/** 跳转链接 */
url: string,
/** 发送对象 */
roleIds: number,
}
const AddMessage: React.FC<{}> = () => {
const [roles, setRoles] = useState<Irole[]>([])
const { pageStatus } = usePageStatus()
const [loading, setLoading] = useState<boolean>(false);
const handleSubmit = (val) => {
const data = {
const handleSubmit = async (val: SubmitType) => {
setLoading(true)
const postData = {
...val,
roleIds: val.roleIds === 0 ? roles.map((item) => item.value) : [val.roleIds],
}
PublicApi.postReportMessagePlatformSend(data)
.then((data) => {
if(data.code === 1000) {
history.push('/message/messageList');
}
})
const { data, code } = await PublicApi.postMessageMessagePlatformSend(postData);
setLoading(false)
if(data.code === 1000) {
history.push('/message/messageList');
}
}
const getSendTargets = async () => {
const res = await PublicApi.getMemberManageRoleAll();
......@@ -55,7 +67,7 @@ const AddMessage: React.FC<{}> = () => {
title="新建消息"
>
<Card>
<NiceForm
<NiceForm
labelCol={4}
labelAlign="left"
wrapperCol={12}
......@@ -68,12 +80,7 @@ const AddMessage: React.FC<{}> = () => {
type: 'string',
title: '发送对象',
required: true,
enum: [
{ label: 'One', value: '1' },
{ label: 'Two', value: '2' },
{ label: 'Three', value: '3' },
{ label: 'Four', value: '4' }
],
enum: [],
},
title: {
type: 'textarea',
......@@ -115,12 +122,12 @@ const AddMessage: React.FC<{}> = () => {
}
}}
onSubmit={handleSubmit}
effects={creatEffect()}
>
<FormButtonGroup offset={4}>
<Submit>发送</Submit>
<Button onClick={()=>history.goBack()}>取消</Button>
<Submit loading={loading}>发送</Submit>
{/* <Button onClick={()=>history.goBack()}>取消</Button> */}
</FormButtonGroup>
</NiceForm>
</Card>
......@@ -128,4 +135,4 @@ const AddMessage: React.FC<{}> = () => {
);
}
export default AddMessage
\ No newline at end of file
export default AddMessage
......@@ -2,6 +2,7 @@
display: flex;
flex-direction: row;
justify-content: space-between;
margin-bottom: 8px;
}
.customList{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment