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',
url: `${ApiTable.getPush}`,
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"
labelWidth="120px"
onValueChange={(values, field) => {
console.log('values', values);
for (var key in field) {
if (key == 'tactics') {
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 '../style.less'
import { Setup } from "$components";
// import { set } from 'nprogress';
const EmPush = (props) => {
const form = useRef();//
@ -15,22 +14,13 @@ const EmPush = (props) => {
const { service } = actions;
const [setup, setSetup] = useState(false); //
const [setupp, setSetupp] = useState([]);//
const [tableSetup, setTableSetup] = useState([]); //
const [query, setQuery] = useState({ limit: 10, page: 0 }); //
const [limits, setLimits] = useState()//
const mylimits = useRef(); //
const [pushModal, setPushModal] = useState(false) //
const [pushEdit, setPushEdit] = useState(false) //
const [anxincloudList, setAnxincloudList] = useState([]) //
const [peplist, setPeplist] = useState([]) //PEP
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 [change, setChange] = useState(false) //
const [allTableData, setAllTableData] = useState([]) //
const [editObj, setEditObj] = useState({});//
const [projectStatus, setProjectStatus] = useState([]); //
const page = useRef(query.page);//
@ -82,16 +72,6 @@ const EmPush = (props) => {
const [tableData, setTableData] = useState([]) //
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.setItem(
EMPUSH,
@ -99,23 +79,28 @@ const EmPush = (props) => {
)
: "";
getProjectStatusList()
getPushList(query);
}, [])
useEffect(() => {
getPushList();
}, [query]);
let showTableData = JSON.parse(JSON.stringify(allTableData)).slice(query.page * query.limit, (query.page + 1) * query.limit)
setTableData(showTableData)
mylimits.current = showTableData.length
}, [change]);
function getPushList () {
function getPushList (query) {
let val = form.current.getValues()
// , ...query
dispatch(service.getPush({ ...val })).then((res) => {//
if (res.success) {
let mytableData = JSON.parse(JSON.stringify(res.payload.data));
for (let index = 0; index < mytableData.length; index++) {
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)
mylimits.current = res.payload.data.length
mylimits.current = showTableData.length
}
})
}
@ -138,37 +123,9 @@ const EmPush = (props) => {
<div style={{ display: "flex" }}>
<Button
theme="borderless"
// disabled={row.pepProjectIsDelete == 1}
onClick={() => {
setEditObj(row)
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)
}}
>
@ -180,7 +137,7 @@ const EmPush = (props) => {
style={{ color: '#F31C1C' }}
onClick={() => {
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"
onConfirm={() => {
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"
onConfirm={() => {
dispatch(service.putPushPushId({ pushId: row?.id, del: true, disable: false, msg: '删除推送配置' })).then(() => {
// if (page.current > 0 && mylimits.current < 2) {
// setQuery({ limit: 10, page: page.current - 1 })
// } else {
// setQuery({ limit: 10, page: page.current })
// }
if (page.current > 0 && mylimits.current < 2) {
getPushList({ limit: query.limit, page: page.current - 1 });
} else {
getPushList({ limit: query.limit, page: page.current });
}
})
}}
>
@ -577,7 +534,6 @@ const EmPush = (props) => {
<div style={{ marginRight: 20, display: 'flex', alignItems: 'center' }} className='myempush'>
<Form
onSubmit={(values) => console.log(values)}
// onValueChange={values=>console.log(values)}
getFormApi={(formApi) => (form.current = formApi)}
layout="horizontal"
style={{ position: "relative", width: "100%", flex: 1 }}
@ -644,7 +600,7 @@ const EmPush = (props) => {
border: '1px solid #005ABD'
}}
onClick={() => {
getPushList()
getPushList({ limit: query.limit, page: 0 })
}}
>
查询
@ -676,8 +632,8 @@ const EmPush = (props) => {
</div>
<div style={{ marginTop: 20 }}>
<Skeleton
// loading={loading}
loading={false}
loading={loading}
// loading={false}
active={true}
placeholder={SkeletonScreen()}
>
@ -689,7 +645,7 @@ const EmPush = (props) => {
hideExpandedColumn={false}
empty="暂无数据"
expandedRowRender={expandRowRender}
// pagination={false}
pagination={false}
onRow={handleRow}
/>
</Skeleton>
@ -715,6 +671,7 @@ const EmPush = (props) => {
onChange={(currentPage, pageSize) => {
setQuery({ limit: pageSize, page: currentPage - 1 });
page.current = currentPage - 1
setChange(!change)
}}
/>
</div>
@ -732,7 +689,7 @@ const EmPush = (props) => {
}}
close={() => {
setPushModal(false);
getPushList()
getPushList(query)
}} >
</PushModal> : ''
}
@ -753,9 +710,9 @@ const EmPush = (props) => {
}
function mapStateToProps (state) {
const { auth, global, ProjectPoms } = state;
const { auth, global, getPush } = state;
return {
// loading: ProjectPoms.isRequesting,
loading: getPush.isRequesting,
user: auth.user,
actions: global.actions,
// members: members.data,

Loading…
Cancel
Save