Browse Source

em推送分页

dev
deartibers 2 years ago
parent
commit
01333be4e8
  1. 2
      web/client/src/sections/service/actions/emPush.js
  2. 1
      web/client/src/sections/service/components/pushModal.jsx
  3. 99
      web/client/src/sections/service/containers/emPush.jsx

2
web/client/src/sections/service/actions/emPush.js

@ -10,7 +10,7 @@ export function getPush (query) { //获取推送配置列表
actionType: 'GET_PUSH', actionType: 'GET_PUSH',
url: `${ApiTable.getPush}`, url: `${ApiTable.getPush}`,
msg: { error: '获取推送配置列表失败' }, msg: { error: '获取推送配置列表失败' },
reducer: { name: '' } reducer: { name: "getPush", params: { noClear: true } },
}); });
} }

1
web/client/src/sections/service/components/pushModal.jsx

@ -378,7 +378,6 @@ function pushModal (props) {
labelAlign="right" labelAlign="right"
labelWidth="120px" labelWidth="120px"
onValueChange={(values, field) => { onValueChange={(values, field) => {
console.log('values', values);
for (var key in field) { for (var key in field) {
if (key == 'tactics') { if (key == 'tactics') {
if (values.tactics == 'abnormal_rate') { if (values.tactics == 'abnormal_rate') {

99
web/client/src/sections/service/containers/emPush.jsx

@ -7,7 +7,6 @@ import moment from "moment";
import PushModal from '../components/pushModal' import PushModal from '../components/pushModal'
import '../style.less' import '../style.less'
import { Setup } from "$components"; import { Setup } from "$components";
// import { set } from 'nprogress';
const EmPush = (props) => { const EmPush = (props) => {
const form = useRef();// const form = useRef();//
@ -15,22 +14,13 @@ const EmPush = (props) => {
const { service } = actions; const { service } = actions;
const [setup, setSetup] = useState(false); // const [setup, setSetup] = useState(false); //
const [setupp, setSetupp] = useState([]);// const [setupp, setSetupp] = useState([]);//
const [tableSetup, setTableSetup] = useState([]); //
const [query, setQuery] = useState({ limit: 10, page: 0 }); // const [query, setQuery] = useState({ limit: 10, page: 0 }); //
const [limits, setLimits] = useState()// const [limits, setLimits] = useState()//
const mylimits = useRef(); // const mylimits = useRef(); //
const [pushModal, setPushModal] = useState(false) // const [pushModal, setPushModal] = useState(false) //
const [pushEdit, setPushEdit] = useState(false) // const [pushEdit, setPushEdit] = useState(false) //
const [anxincloudList, setAnxincloudList] = useState([]) // const [change, setChange] = useState(false) //
const [peplist, setPeplist] = useState([]) //PEP const [allTableData, setAllTableData] = useState([]) //
const [appList, setAppList] = useState([]) //
const [pepProjectId, setPepProjectId] = useState() //id
const [anxincloudArr, setAnxincloudArr] = useState([]) //
const [pepname, setPepname] = useState() //
const [anxinDelete, setAnxinDelete] = useState([]) //,
const [appArr, setAppArr] = useState([]) //
const [bindId, setBindId] = useState() //id
const [tableKey, setTableKey] = useState([]) //id
const [editObj, setEditObj] = useState({});// const [editObj, setEditObj] = useState({});//
const [projectStatus, setProjectStatus] = useState([]); // const [projectStatus, setProjectStatus] = useState([]); //
const page = useRef(query.page);// const page = useRef(query.page);//
@ -82,16 +72,6 @@ const EmPush = (props) => {
const [tableData, setTableData] = useState([]) // const [tableData, setTableData] = useState([]) //
useEffect(() => { useEffect(() => {
// dispatch(service.getPush(query)).then((res) => {//
// console.log('res.payload.datares.payload.data',res.payload.data);
// setAnxincloudList(res.payload.data)
// })
// dispatch(install.getProjectPmanage(query)).then((res) => {//PEP
// setPeplist(res.payload.data)
// })
// dispatch(install.getProjectAppList(query)).then((res) => {//
// setAppList(res.payload.data)
// })
localStorage.getItem(EMPUSH) == null localStorage.getItem(EMPUSH) == null
? localStorage.setItem( ? localStorage.setItem(
EMPUSH, EMPUSH,
@ -99,23 +79,28 @@ const EmPush = (props) => {
) )
: ""; : "";
getProjectStatusList() getProjectStatusList()
getPushList(query);
}, []) }, [])
useEffect(() => { useEffect(() => {
getPushList(); let showTableData = JSON.parse(JSON.stringify(allTableData)).slice(query.page * query.limit, (query.page + 1) * query.limit)
}, [query]); setTableData(showTableData)
mylimits.current = showTableData.length
}, [change]);
function getPushList () { function getPushList (query) {
let val = form.current.getValues() let val = form.current.getValues()
// , ...query
dispatch(service.getPush({ ...val })).then((res) => {// dispatch(service.getPush({ ...val })).then((res) => {//
if (res.success) { if (res.success) {
let mytableData = JSON.parse(JSON.stringify(res.payload.data)); let mytableData = JSON.parse(JSON.stringify(res.payload.data));
for (let index = 0; index < mytableData.length; index++) { for (let index = 0; index < mytableData.length; index++) {
mytableData[index].key = String(mytableData[index].id) mytableData[index].key = String(mytableData[index].id)
} }
setTableData(mytableData) setAllTableData(mytableData)
let showTableData = mytableData.slice(query.page * query.limit, (query.page + 1) * query.limit)
setTableData(showTableData)
setQuery(query)
setLimits(res.payload.data.length) setLimits(res.payload.data.length)
mylimits.current = res.payload.data.length mylimits.current = showTableData.length
} }
}) })
} }
@ -138,37 +123,9 @@ const EmPush = (props) => {
<div style={{ display: "flex" }}> <div style={{ display: "flex" }}>
<Button <Button
theme="borderless" theme="borderless"
// disabled={row.pepProjectIsDelete == 1}
onClick={() => { onClick={() => {
setEditObj(row) setEditObj(row)
setPushModal(true); setPushModal(true);
// setPepname(row.name)
// if (!row.name) {
// setPepProjectId(row.pepProjectId)
// }
// else {
// setPepProjectId()
// }
// let myanxinArr = []
// let anxinErrorList = []
// for (let i = 0; i < row.anxinProject.length; i++) {
// if (row.anxinProject[i].projectState !== -1) {
// myanxinArr.push(row.anxinProject[i].id)
// }
// else {
// anxinErrorList.push(row.anxinProject[i].name)
// }
// }
// setAnxinDelete(anxinErrorList)
// let myapparr = []
// let myarrarrList = JSON.parse(JSON.stringify(row.apps))
// for (let j = 0; j < row.apps.length; j++) {
// delete myarrarrList[j].projectApp
// myapparr.push(JSON.stringify(myarrarrList[j]))
// }
// setAppArr(myapparr)
// setAnxincloudArr(myanxinArr)
// setBindId(row.id)
setPushEdit(true) setPushEdit(true)
}} }}
> >
@ -180,7 +137,7 @@ const EmPush = (props) => {
style={{ color: '#F31C1C' }} style={{ color: '#F31C1C' }}
onClick={() => { onClick={() => {
dispatch(service.putPushPushId({ pushId: row?.id, del: false, disable: false, msg: '更改推送配置状态' })).then(() => { dispatch(service.putPushPushId({ pushId: row?.id, del: false, disable: false, msg: '更改推送配置状态' })).then(() => {
// setQuery({ limit: 10, page: page.current }) getPushList({ limit: query.limit, page: page.current });
}) })
}} }}
> >
@ -194,7 +151,7 @@ const EmPush = (props) => {
position="topRight" position="topRight"
onConfirm={() => { onConfirm={() => {
dispatch(service.putPushPushId({ pushId: row?.id, del: false, disable: true, msg: '更改推送配置状态' })).then(() => { dispatch(service.putPushPushId({ pushId: row?.id, del: false, disable: true, msg: '更改推送配置状态' })).then(() => {
// setQuery({ limit: 10, page: page.current }) getPushList({ limit: query.limit, page: page.current });
}) })
}} }}
> >
@ -208,11 +165,11 @@ const EmPush = (props) => {
position="topRight" position="topRight"
onConfirm={() => { onConfirm={() => {
dispatch(service.putPushPushId({ pushId: row?.id, del: true, disable: false, msg: '删除推送配置' })).then(() => { dispatch(service.putPushPushId({ pushId: row?.id, del: true, disable: false, msg: '删除推送配置' })).then(() => {
// if (page.current > 0 && mylimits.current < 2) { if (page.current > 0 && mylimits.current < 2) {
// setQuery({ limit: 10, page: page.current - 1 }) getPushList({ limit: query.limit, page: page.current - 1 });
// } else { } else {
// setQuery({ limit: 10, page: page.current }) getPushList({ limit: query.limit, page: page.current });
// } }
}) })
}} }}
> >
@ -577,7 +534,6 @@ const EmPush = (props) => {
<div style={{ marginRight: 20, display: 'flex', alignItems: 'center' }} className='myempush'> <div style={{ marginRight: 20, display: 'flex', alignItems: 'center' }} className='myempush'>
<Form <Form
onSubmit={(values) => console.log(values)} onSubmit={(values) => console.log(values)}
// onValueChange={values=>console.log(values)}
getFormApi={(formApi) => (form.current = formApi)} getFormApi={(formApi) => (form.current = formApi)}
layout="horizontal" layout="horizontal"
style={{ position: "relative", width: "100%", flex: 1 }} style={{ position: "relative", width: "100%", flex: 1 }}
@ -644,7 +600,7 @@ const EmPush = (props) => {
border: '1px solid #005ABD' border: '1px solid #005ABD'
}} }}
onClick={() => { onClick={() => {
getPushList() getPushList({ limit: query.limit, page: 0 })
}} }}
> >
查询 查询
@ -676,8 +632,8 @@ const EmPush = (props) => {
</div> </div>
<div style={{ marginTop: 20 }}> <div style={{ marginTop: 20 }}>
<Skeleton <Skeleton
// loading={loading} loading={loading}
loading={false} // loading={false}
active={true} active={true}
placeholder={SkeletonScreen()} placeholder={SkeletonScreen()}
> >
@ -689,7 +645,7 @@ const EmPush = (props) => {
hideExpandedColumn={false} hideExpandedColumn={false}
empty="暂无数据" empty="暂无数据"
expandedRowRender={expandRowRender} expandedRowRender={expandRowRender}
// pagination={false} pagination={false}
onRow={handleRow} onRow={handleRow}
/> />
</Skeleton> </Skeleton>
@ -715,6 +671,7 @@ const EmPush = (props) => {
onChange={(currentPage, pageSize) => { onChange={(currentPage, pageSize) => {
setQuery({ limit: pageSize, page: currentPage - 1 }); setQuery({ limit: pageSize, page: currentPage - 1 });
page.current = currentPage - 1 page.current = currentPage - 1
setChange(!change)
}} }}
/> />
</div> </div>
@ -732,7 +689,7 @@ const EmPush = (props) => {
}} }}
close={() => { close={() => {
setPushModal(false); setPushModal(false);
getPushList() getPushList(query)
}} > }} >
</PushModal> : '' </PushModal> : ''
} }
@ -753,9 +710,9 @@ const EmPush = (props) => {
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { auth, global, ProjectPoms } = state; const { auth, global, getPush } = state;
return { return {
// loading: ProjectPoms.isRequesting, loading: getPush.isRequesting,
user: auth.user, user: auth.user,
actions: global.actions, actions: global.actions,
// members: members.data, // members: members.data,

Loading…
Cancel
Save