zustand Notice
parent
df915c6114
commit
64f32d9093
@ -0,0 +1,51 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
|
||||
import { fetchJSON, postForm, } from '@/utils/request';
|
||||
import { HT_HOST } from '@/config';
|
||||
|
||||
/**
|
||||
* Notice 相关的请求
|
||||
*/
|
||||
|
||||
export const fetchBulletinList = async (LMI_SN) => {
|
||||
const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/GetBulletinList`, { LMI_SN });
|
||||
return errcode !== 0 ? [] : Result;
|
||||
};
|
||||
|
||||
export const fetchBulletinUnReadCount = async (LMI_SN) => {
|
||||
const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/GetBulletinUnReadCount`, { LMI_SN });
|
||||
return errcode !== 0 ? 0 : Result.CCP_BulletinCount;
|
||||
}
|
||||
|
||||
export const fetchNoticeDetail = async (LMI_SN, CCP_BLID) => {
|
||||
const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/GetBulletinDetail`, { LMI_SN, CCP_BLID });
|
||||
return errcode !== 0 ? {} : Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notice Store
|
||||
*/
|
||||
const initialState = {
|
||||
noticeUnRead: 0, //未读公告数量
|
||||
};
|
||||
export const useNoticeStore = create(
|
||||
devtools((set, get) => ({
|
||||
// 初始化状态
|
||||
...initialState,
|
||||
|
||||
// state actions
|
||||
setNoticeUnRead: (noticeUnRead) => set(() => ({ noticeUnRead })),
|
||||
|
||||
reset: () => set(initialState),
|
||||
|
||||
// side effects
|
||||
getBulletinUnReadCount: async (LMI_SN) => {
|
||||
const { setNoticeUnRead } = get();
|
||||
const noticeUnRead = await fetchBulletinUnReadCount(LMI_SN);
|
||||
setNoticeUnRead(noticeUnRead);
|
||||
},
|
||||
|
||||
}))
|
||||
);
|
||||
export default useNoticeStore;
|
@ -1,42 +1,43 @@
|
||||
import { NavLink, useParams } from "react-router-dom";
|
||||
import { useEffect, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { toJS } from "mobx";
|
||||
import { Row, Col, Space, Button, Table, Input, Typography, Badge, Divider } from "antd";
|
||||
import { useStore } from "@/stores/StoreContext.js";
|
||||
import * as config from "@/config";
|
||||
import * as comm from "@/utils/commons";
|
||||
import dayjs from "dayjs";
|
||||
import { NavLink, useParams } from 'react-router-dom';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Row, Col, Space, Typography, Divider } from 'antd';
|
||||
import { useStore } from '@/stores/StoreContext.js';
|
||||
import * as comm from '@/utils/commons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { fetchNoticeDetail } from '@/stores/Notice1';
|
||||
|
||||
const { Title, Paragraph, Text } = Typography;
|
||||
const { Title, Paragraph } = Typography;
|
||||
|
||||
function Detail() {
|
||||
const { noticeStore, authStore } = useStore();
|
||||
const { noticeInfo } = noticeStore;
|
||||
const { CCP_BLID } = useParams();
|
||||
const { t } = useTranslation();
|
||||
const { authStore } = useStore();
|
||||
const { CCP_BLID } = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
console.info("notice detail .useEffect " + CCP_BLID);
|
||||
noticeStore.getNoticeDetail(authStore.login.userId, CCP_BLID);
|
||||
}, []);
|
||||
const [noticeInfo, setNoticeInfo] = useState({});
|
||||
useEffect(() => {
|
||||
// console.info("notice detail .useEffect " + CCP_BLID);
|
||||
fetchNoticeDetail(authStore.login.userId, CCP_BLID).then((res) => {
|
||||
setNoticeInfo(res);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Row gutter={16}>
|
||||
<Col span={4}></Col>
|
||||
<Col span={16}>
|
||||
<Title level={1}>{noticeInfo.CCP_BLTitle}</Title>
|
||||
<Divider orientation="right">{noticeInfo.CCP_LastEditTime}</Divider>
|
||||
<Paragraph>
|
||||
<div dangerouslySetInnerHTML={{ __html: comm.escape2Html(noticeInfo.CCP_BLContent) }}></div>
|
||||
</Paragraph>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<NavLink to="/notice">Back</NavLink>
|
||||
</Col>
|
||||
</Row>
|
||||
</Space>
|
||||
);
|
||||
return (
|
||||
<Space direction='vertical' style={{ width: '100%' }}>
|
||||
<Row gutter={16}>
|
||||
<Col span={4}></Col>
|
||||
<Col span={16}>
|
||||
<Title level={1}>{noticeInfo.CCP_BLTitle}</Title>
|
||||
<Divider orientation='right'>{noticeInfo.CCP_LastEditTime}</Divider>
|
||||
<Paragraph>
|
||||
<div dangerouslySetInnerHTML={{ __html: comm.escape2Html(noticeInfo.CCP_BLContent) }}></div>
|
||||
</Paragraph>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<NavLink to='/notice'>{t('Back')}</NavLink>
|
||||
</Col>
|
||||
</Row>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
export default observer(Detail);
|
||||
export default Detail;
|
||||
|
Loading…
Reference in New Issue