Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
794bcbeb
Commit
794bcbeb
authored
Dec 31, 2021
by
邓超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复测试推送搜索bug
parent
554e0920
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
56 deletions
+79
-56
CardCheck.jsx
...ageManage/projectManage/components/PushTest/CardCheck.jsx
+73
-41
PushTest.jsx
...sageManage/projectManage/components/PushTest/PushTest.jsx
+6
-15
No files found.
src/pages/platformCenter/messageManage/projectManage/components/PushTest/CardCheck.jsx
View file @
794bcbeb
...
@@ -25,58 +25,90 @@ const CardCheck = props => {
...
@@ -25,58 +25,90 @@ const CardCheck = props => {
setIndeterminate
(
cardMsg
.
indeterminate
);
setIndeterminate
(
cardMsg
.
indeterminate
);
setCheckAll
(
cardMsg
.
checkAll
);
setCheckAll
(
cardMsg
.
checkAll
);
},
[]);
},
[]);
useEffect
(()
=>
{
// useEffect(() => {
if
(
prevAmount
)
{
// if (prevAmount) {
// let newCheckList = [...checkList];
// console.log(newCheckList);
// // 当前选中的
// let currentArr = checkedList;
// // 上一次选中的
// let preArr = prevAmount.checkedList;
// currentArr = new Set(currentArr);
// preArr = new Set(preArr);
// // 找出相同的部分
// let someArr = [...new Set([...currentArr].filter(x => preArr.has(x)))];
// // 复选框事选中还是取消选中 add or del
// let checkType;
// if ([...currentArr].length > [...preArr].length) {
// checkType = 'add';
// } else if ([...currentArr].length < [...preArr].length) {
// checkType = 'del';
// }
// if (checkType === 'add') {
// // 添加新选中的元素
// currentArr.forEach(item => {
// if (someArr.indexOf(item) === -1) {
// let checkName = plainOptions.find(ele => ele.value === item);
// newCheckList.push(checkName);
// }
// });
// } else if (checkType === 'del') {
// // 删除取消勾选的元素
// preArr.forEach(item => {
// if (someArr.indexOf(item) === -1) {
// newCheckList.splice(newCheckList.findIndex(ele => ele.value === item), 1);
// }
// });
// }
// callback(checkedList, newCheckList);
// }
// }, [checkedList]);
// 获取勾选新增得数据
const
addData
=
(
arr1
,
arr2
)
=>
arr2
.
filter
(
val
=>
arr1
.
indexOf
(
val
)
===
-
1
);
// 获取勾选删除得数据
const
delData
=
(
arr1
,
arr2
)
=>
arr1
.
filter
(
val
=>
arr2
.
indexOf
(
val
)
===
-
1
);
// 单选监听
const
onChange
=
list
=>
{
let
newCheckList
=
[...
checkList
];
let
newCheckList
=
[...
checkList
];
console
.
log
(
newCheckList
);
let
arr
;
// 当前选中的
if
(
checkedList
.
length
>
list
.
length
)
{
let
currentArr
=
checkedList
;
// 取消勾选
// 上一次选中的
arr
=
delData
(
checkedList
,
list
);
let
preArr
=
prevAmount
.
checkedList
;
arr
.
forEach
(
item
=>
{
currentArr
=
new
Set
(
currentArr
);
newCheckList
.
splice
(
newCheckList
.
findIndex
(
ele
=>
ele
.
value
===
item
),
1
);
preArr
=
new
Set
(
preArr
);
});
// 找出相同的部分
}
else
{
let
someArr
=
[...
new
Set
([...
currentArr
].
filter
(
x
=>
preArr
.
has
(
x
)))];
// 勾选元素
// 复选框事选中还是取消选中 add or del
arr
=
addData
(
checkedList
,
list
);
let
checkType
;
arr
.
forEach
(
item
=>
{
if
([...
currentArr
].
length
>
[...
preArr
].
length
)
{
checkType
=
'add'
;
}
else
if
([...
currentArr
].
length
<
[...
preArr
].
length
)
{
checkType
=
'del'
;
}
if
(
checkType
===
'add'
)
{
// 添加新选中的元素
currentArr
.
forEach
(
item
=>
{
if
(
someArr
.
indexOf
(
item
)
===
-
1
)
{
let
checkName
=
plainOptions
.
find
(
ele
=>
ele
.
value
===
item
);
let
checkName
=
plainOptions
.
find
(
ele
=>
ele
.
value
===
item
);
newCheckList
.
push
(
checkName
);
newCheckList
.
push
(
checkName
);
}
});
});
}
else
if
(
checkType
===
'del'
)
{
// 删除取消勾选的元素
preArr
.
forEach
(
item
=>
{
if
(
someArr
.
indexOf
(
item
)
===
-
1
)
{
newCheckList
.
splice
(
newCheckList
.
findIndex
(
ele
=>
ele
.
value
===
item
),
1
,
);
}
});
}
callback
(
checkedList
,
newCheckList
);
}
}
},
[
checkedList
]);
callback
(
newCheckList
);
// 单选监听
const
onChange
=
list
=>
{
setCheckedList
(
list
);
setCheckedList
(
list
);
setIndeterminate
(
!!
list
.
length
&&
list
.
length
<
plainOptions
.
length
);
setIndeterminate
(
!!
list
.
length
&&
list
.
length
<
plainOptions
.
length
);
setCheckAll
(
list
.
length
===
plainOptions
.
length
);
setCheckAll
(
list
.
length
===
plainOptions
.
length
);
};
};
// 全选监听
// 全选监听
const
onCheckAllChange
=
e
=>
{
const
onCheckAllChange
=
e
=>
{
setCheckedList
(
let
newCheckList
=
[...
checkList
];
e
.
target
.
checked
?
plainOptions
.
map
(
item
=>
item
.
value
)
:
[],
let
arr
;
);
if
(
e
.
target
.
checked
)
{
// 全选
arr
=
addData
(
checkedList
,
plainOptions
.
map
(
item
=>
item
.
value
));
arr
.
forEach
(
item
=>
{
let
checkName
=
plainOptions
.
find
(
ele
=>
ele
.
value
===
item
);
newCheckList
.
push
(
checkName
);
});
}
else
{
arr
=
delData
(
checkedList
,
[]);
arr
.
forEach
(
item
=>
{
newCheckList
.
splice
(
newCheckList
.
findIndex
(
ele
=>
ele
.
value
===
item
),
1
);
});
}
callback
(
newCheckList
);
setCheckedList
(
e
.
target
.
checked
?
plainOptions
.
map
(
item
=>
item
.
value
)
:
[]);
setIndeterminate
(
false
);
setIndeterminate
(
false
);
setCheckAll
(
e
.
target
.
checked
);
setCheckAll
(
e
.
target
.
checked
);
};
};
...
...
src/pages/platformCenter/messageManage/projectManage/components/PushTest/PushTest.jsx
View file @
794bcbeb
...
@@ -26,8 +26,8 @@ const PushTest = props => {
...
@@ -26,8 +26,8 @@ const PushTest = props => {
}
}
},
[
visible
]);
},
[
visible
]);
// 选中后得回调函数
// 选中后得回调函数
const
checkCallBack
=
useCallback
(
(
val
,
newCheckList
)
=>
{
const
checkCallBack
=
useCallback
(
newCheckList
=>
{
if
(
val
)
{
if
(
newCheckList
)
{
setCheckList
(
newCheckList
);
setCheckList
(
newCheckList
);
}
}
});
});
...
@@ -43,9 +43,7 @@ const PushTest = props => {
...
@@ -43,9 +43,7 @@ const PushTest = props => {
theme
:
pushTestMsg
.
ThemeName
,
theme
:
pushTestMsg
.
ThemeName
,
msgType
:
pushTestMsg
.
MsgType
,
msgType
:
pushTestMsg
.
MsgType
,
tousers
:
checkList
.
map
(
item
=>
item
.
value
),
tousers
:
checkList
.
map
(
item
=>
item
.
value
),
pushPath
:
pushTestMsg
.
item
.
AgentConfig
pushPath
:
pushTestMsg
.
item
.
AgentConfig
?
pushTestMsg
.
item
.
AgentConfig
.
Url
:
''
,
?
pushTestMsg
.
item
.
AgentConfig
.
Url
:
''
,
msgTypeId
:
pushTestMsg
.
ID
.
toString
(),
msgTypeId
:
pushTestMsg
.
ID
.
toString
(),
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
...
@@ -103,10 +101,7 @@ const PushTest = props => {
...
@@ -103,10 +101,7 @@ const PushTest = props => {
value
:
val
.
userId
,
value
:
val
.
userId
,
};
};
});
});
if
(
if
(
checkedList
.
length
===
options
.
length
&&
checkedList
.
length
>
0
)
{
checkedList
.
length
===
options
.
length
&&
checkedList
.
length
>
0
)
{
checkAll
=
true
;
checkAll
=
true
;
}
}
if
(
checkedList
.
length
<
options
.
length
&&
checkedList
.
length
>
0
)
{
if
(
checkedList
.
length
<
options
.
length
&&
checkedList
.
length
>
0
)
{
...
@@ -181,9 +176,7 @@ const PushTest = props => {
...
@@ -181,9 +176,7 @@ const PushTest = props => {
<
CardCheck
<
CardCheck
cardMsg=
{
item
}
cardMsg=
{
item
}
cardIndex=
{
index
}
cardIndex=
{
index
}
callback=
{
(
val
,
newCheckList
)
=>
callback=
{
(
val
,
newCheckList
)
=>
checkCallBack
(
val
,
newCheckList
)
}
checkCallBack
(
val
,
newCheckList
)
}
checkList=
{
checkList
}
checkList=
{
checkList
}
/>
/>
</
div
>
</
div
>
...
@@ -193,9 +186,7 @@ const PushTest = props => {
...
@@ -193,9 +186,7 @@ const PushTest = props => {
{
/* 分页 */
}
{
/* 分页 */
}
<
Pagination
<
Pagination
total=
{
total
}
total=
{
total
}
showTotal=
{
(
totals
,
range
)
=>
showTotal=
{
(
totals
,
range
)
=>
`第${range[0]}-${range[1]} 条/共 ${totals} 条`
}
`第${range[0]}-${range[1]} 条/共 ${totals} 条`
}
defaultPageSize=
{
pageSize
}
defaultPageSize=
{
pageSize
}
defaultCurrent=
{
1
}
defaultCurrent=
{
1
}
current=
{
currentPage
}
current=
{
currentPage
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment