mirror of
https://github.com/TangSengDaoDao/TangSengDaoDaoWeb
synced 2025-06-06 17:57:13 +00:00
fix: 🐛修复成员列表成员名称重复
This commit is contained in:
parent
19d3870200
commit
e9802cf091
@ -13,44 +13,54 @@ import { Checkbox } from "@douyinfe/semi-ui/lib/es/checkbox";
|
|||||||
import { GroupRole } from "../../Service/Const";
|
import { GroupRole } from "../../Service/Const";
|
||||||
|
|
||||||
export interface SubscriberListProps {
|
export interface SubscriberListProps {
|
||||||
channel: Channel
|
channel: Channel;
|
||||||
canSelect?: boolean; // 是否支持多选
|
canSelect?: boolean; // 是否支持多选
|
||||||
disableSelectList?: string[]; // 禁选列表
|
disableSelectList?: string[]; // 禁选列表
|
||||||
onSelect?: (items: Subscriber[]) => void;
|
onSelect?: (items: Subscriber[]) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SubscriberListState {
|
export interface SubscriberListState {
|
||||||
selectedList: Subscriber[]
|
selectedList: Subscriber[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SubscriberList extends Component<SubscriberListProps, SubscriberListState> {
|
export class SubscriberList extends Component<
|
||||||
|
SubscriberListProps,
|
||||||
|
SubscriberListState
|
||||||
|
> {
|
||||||
constructor(props: SubscriberListProps) {
|
constructor(props: SubscriberListProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedList: []
|
selectedList: [],
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearch = (v: string, vm: SubscriberListVM) => {
|
onSearch = (v: string, vm: SubscriberListVM) => {
|
||||||
vm.search(v)
|
vm.search(v);
|
||||||
}
|
};
|
||||||
|
|
||||||
handleScroll = (e: React.UIEvent<HTMLDivElement>, vm: SubscriberListVM) => {
|
handleScroll = (e: React.UIEvent<HTMLDivElement>, vm: SubscriberListVM) => {
|
||||||
const target = e.target as HTMLDivElement;
|
const target = e.target as HTMLDivElement;
|
||||||
const offset = 200;
|
const offset = 200;
|
||||||
if (target.scrollTop + target.clientHeight + offset >= target.scrollHeight) {
|
if (
|
||||||
|
target.scrollTop + target.clientHeight + offset >=
|
||||||
|
target.scrollHeight
|
||||||
|
) {
|
||||||
console.log("到底了");
|
console.log("到底了");
|
||||||
vm.loadMoreSubscribersIfNeed()
|
vm.loadMoreSubscribersIfNeed();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// 获取显示名称
|
// 获取显示名称
|
||||||
getShowName = (subscriber: Subscriber) => {
|
getShowName = (subscriber: Subscriber) => {
|
||||||
|
|
||||||
// 优先显示个人备注
|
// 优先显示个人备注
|
||||||
const channelInfo = WKSDK.shared().channelManager.getChannelInfo(new Channel(subscriber.uid, ChannelTypePerson))
|
const channelInfo = WKSDK.shared().channelManager.getChannelInfo(
|
||||||
if (channelInfo && channelInfo.orgData.remark && channelInfo.orgData.remark.trim() !== "") {
|
new Channel(subscriber.uid, ChannelTypePerson)
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
channelInfo &&
|
||||||
|
channelInfo.orgData.remark &&
|
||||||
|
channelInfo.orgData.remark.trim() !== ""
|
||||||
|
) {
|
||||||
return channelInfo.orgData.remark;
|
return channelInfo.orgData.remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,17 +70,17 @@ export class SubscriberList extends Component<SubscriberListProps, SubscriberLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 最后显示昵称
|
// 最后显示昵称
|
||||||
return subscriber.name
|
return subscriber.name;
|
||||||
}
|
};
|
||||||
|
|
||||||
onItemClick = (subscriber: Subscriber) => {
|
onItemClick = (subscriber: Subscriber) => {
|
||||||
const { canSelect } = this.props
|
const { canSelect } = this.props;
|
||||||
if (!canSelect) {
|
if (!canSelect) {
|
||||||
WKApp.shared.baseContext.showUserInfo(subscriber.uid, this.props.channel)
|
WKApp.shared.baseContext.showUserInfo(subscriber.uid, this.props.channel);
|
||||||
return
|
return;
|
||||||
}
|
|
||||||
this.checkItem(subscriber)
|
|
||||||
}
|
}
|
||||||
|
this.checkItem(subscriber);
|
||||||
|
};
|
||||||
|
|
||||||
isDisableItem(id: string) {
|
isDisableItem(id: string) {
|
||||||
const { disableSelectList } = this.props;
|
const { disableSelectList } = this.props;
|
||||||
@ -120,28 +130,31 @@ export class SubscriberList extends Component<SubscriberListProps, SubscriberLis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getRoleName = (item: Subscriber) => {
|
getRoleName = (item: Subscriber) => {
|
||||||
if (item.role === GroupRole.owner) {
|
if (item.role === GroupRole.owner) {
|
||||||
return "群主"
|
return "群主";
|
||||||
} else if (item.role === GroupRole.manager) {
|
} else if (item.role === GroupRole.manager) {
|
||||||
return "管理员"
|
return "管理员";
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { canSelect } = this.props;
|
||||||
const { canSelect } = this.props
|
return (
|
||||||
return <Provider
|
<Provider
|
||||||
create={() => {
|
create={() => {
|
||||||
return new SubscriberListVM(this.props.channel);
|
return new SubscriberListVM(this.props.channel);
|
||||||
}}
|
}}
|
||||||
render={(vm: SubscriberListVM) => {
|
render={(vm: SubscriberListVM) => {
|
||||||
|
return (
|
||||||
return <div className="wk-subscrierlist" onScroll={(e) => { this.handleScroll(e, vm) }}>
|
<div
|
||||||
|
className="wk-subscrierlist"
|
||||||
|
onScroll={(e) => {
|
||||||
|
this.handleScroll(e, vm);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<div className="wk-indextable-search-box">
|
<div className="wk-indextable-search-box">
|
||||||
<div className="wk-indextable-search-icon">
|
<div className="wk-indextable-search-icon">
|
||||||
<IconSearchStroked
|
<IconSearchStroked
|
||||||
@ -161,15 +174,21 @@ export class SubscriberList extends Component<SubscriberListProps, SubscriberLis
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="wk-subscrierlist-list">
|
<div className="wk-subscrierlist-list">
|
||||||
{
|
{vm.subscribers.map((item) => {
|
||||||
vm.subscribers.map((item) => {
|
return (
|
||||||
|
<div
|
||||||
return <div className="wk-subscrierlist-list-item" key={item.uid} onClick={() => { this.onItemClick(item) }}>
|
className="wk-subscrierlist-list-item"
|
||||||
|
key={item.uid}
|
||||||
|
onClick={() => {
|
||||||
|
this.onItemClick(item);
|
||||||
|
}}
|
||||||
|
>
|
||||||
{canSelect ? (
|
{canSelect ? (
|
||||||
<div className="wk-indextable-checkbox">
|
<div className="wk-indextable-checkbox">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={
|
checked={
|
||||||
this.isDisableItem(item.uid) || this.isCheckItem(item)
|
this.isDisableItem(item.uid) ||
|
||||||
|
this.isCheckItem(item)
|
||||||
}
|
}
|
||||||
disabled={this.isDisableItem(item.uid)}
|
disabled={this.isDisableItem(item.uid)}
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
@ -179,18 +198,21 @@ export class SubscriberList extends Component<SubscriberListProps, SubscriberLis
|
|||||||
<WKAvatar src={item.avatar}></WKAvatar>
|
<WKAvatar src={item.avatar}></WKAvatar>
|
||||||
</div>
|
</div>
|
||||||
<div className="wk-subscrierlist-item-content">
|
<div className="wk-subscrierlist-item-content">
|
||||||
<div className="wk-subscrierlist-item-name">{this.getShowName(item)}{this.getShowName(item)}</div>
|
<div className="wk-subscrierlist-item-name">
|
||||||
<div className="wk-subscrierlist-item-desc">{this.getRoleName(item)}</div>
|
{this.getShowName(item)}
|
||||||
|
</div>
|
||||||
|
<div className="wk-subscrierlist-item-desc">
|
||||||
|
{this.getRoleName(item)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
})
|
</div>
|
||||||
}
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
></Provider>
|
||||||
|
);
|
||||||
</Provider>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user