185 lines
3.7 KiB
Vue
Raw Normal View History

2025-01-26 21:07:26 +08:00
<template>
2025-02-12 21:40:09 +08:00
<div class="list-wrap">
2025-01-26 21:07:26 +08:00
<div class="search">
2025-03-02 11:11:08 +08:00
<el-input
v-model="params.userName"
size="mini"
placeholder="请输入用户昵称"
clearable
/>
2025-02-12 21:40:09 +08:00
<el-button type="primary" size="mini" @click="searchMsg">搜索</el-button>
2025-01-26 21:07:26 +08:00
</div>
2025-03-02 11:11:08 +08:00
<userItems
:group-id="groupId"
:list="list"
:loading="loading"
:has-next="hasNext"
@getList="getList"
@toPrivateChat="toPrivateChat"
@modifyStateCallback="modifyStateCallback"
/>
2025-01-26 21:07:26 +08:00
</div>
</template>
2025-02-08 23:04:37 +08:00
<script>
2025-03-02 11:11:08 +08:00
import { getCustomerList } from "@/api/circle";
import userItems from "./components/userItems.vue";
2025-02-08 23:04:37 +08:00
export default {
2025-03-02 11:11:08 +08:00
components: {
userItems
},
2025-02-12 21:40:09 +08:00
props: {
groupId: {
type: Number,
2025-03-02 11:11:08 +08:00
default: null
2025-02-13 22:04:59 +08:00
},
modifyStateObj: {
// 修改了状态的对象
2025-03-02 11:11:08 +08:00
type: Object,
default: () => {}
2025-02-12 21:40:09 +08:00
}
},
data() {
return {
loading: true,
hasNext: true,
2025-03-02 11:11:08 +08:00
params: {
userName: "",
current: 0,
id: null,
size: 10
},
list: [],
userIdsObj: {}
2025-02-12 21:40:09 +08:00
};
},
watch: {
2025-03-02 11:11:08 +08:00
groupId(value) {
this.params.id = value;
this.params.userName = "";
2025-02-12 21:40:09 +08:00
this.searchMsg();
2025-02-13 22:04:59 +08:00
},
modifyStateObj(value) {
2025-03-02 11:11:08 +08:00
// modifyType: 1审核通过 2禁言操作 isForbidden: 是否被禁言 1是 2否
if (value.modifyType === 2 && this.userIdsObj[value.userId]) {
this.userIdsObj[value.userId].isForbidden = value.isForbidden;
2025-02-13 22:04:59 +08:00
}
2025-02-12 21:40:09 +08:00
}
},
2025-02-08 23:04:37 +08:00
methods: {
2025-03-02 11:11:08 +08:00
modifyStateCallback(item) {
this.$emit("modifyStateCallback", item);
2025-02-12 21:40:09 +08:00
},
async getList() {
2025-03-02 11:11:08 +08:00
this.loading = true;
this.params.current++;
const ret = await getCustomerList(this.params).catch(() => {
2025-02-12 21:40:09 +08:00
this.loading = false;
2025-03-02 11:11:08 +08:00
});
if (ret && ret.code === 0 && ret.data.list) {
const list = ret.data.list;
2025-03-02 16:56:23 +08:00
list.forEach((item, index) => {
if (this.userIdsObj[item.privateUserId]) {
list.splice(index, 1);
} else {
this.userIdsObj[item.privateUserId] = item;
}
2025-03-02 11:11:08 +08:00
});
this.list = this.list.concat(list);
this.hasNext = ret.data.list.length === this.params.size;
2025-02-12 21:40:09 +08:00
}
2025-03-02 11:11:08 +08:00
this.loading = false;
2025-02-08 23:04:37 +08:00
},
2025-02-12 21:40:09 +08:00
searchMsg() {
2025-03-02 11:11:08 +08:00
this.hasNext = true;
this.params.current = 0;
2025-03-02 16:56:23 +08:00
this.userIdsObj = {};
2025-02-12 21:40:09 +08:00
this.list = [];
this.getList();
},
toPrivateChat(item) {
this.$emit("toPrivateChat", item);
2025-02-08 23:04:37 +08:00
}
}
};
</script>
2025-01-26 21:07:26 +08:00
<style lang="scss" scoped>
2025-02-12 21:40:09 +08:00
.list-wrap {
height: 600px;
overflow-y: scroll;
}
2025-01-26 21:07:26 +08:00
.search {
display: flex;
margin-bottom: 10px;
.el-input {
margin-right: 10px;
}
}
dl {
list-style: none;
margin: 0;
padding: 0;
list-style: none;
padding: 10px;
dt {
padding: 10px 0;
}
dd {
margin: 0;
padding: 0;
}
dt,
dd {
display: flex;
border-bottom: 1px dashed #999;
& > div {
display: flex;
2025-02-12 21:40:09 +08:00
// flex-direction: column;
2025-01-26 21:07:26 +08:00
justify-content: center;
padding: 6px 0;
2025-02-12 21:40:09 +08:00
align-items: center;
2025-01-26 21:07:26 +08:00
}
& > div:nth-child(1) {
width: 60px;
}
& > div:nth-child(2) {
2025-02-12 21:40:09 +08:00
flex: 1;
text-align: center;
2025-01-26 21:07:26 +08:00
}
& > div:nth-child(3) {
width: 100px;
2025-02-12 21:40:09 +08:00
text-align: center;
2025-01-26 21:07:26 +08:00
}
& > div:nth-child(4) {
width: 100px;
2025-02-12 21:40:09 +08:00
text-align: center;
2025-01-26 21:07:26 +08:00
}
& > div:nth-child(5) {
2025-02-12 21:40:09 +08:00
display: block;
width: 60px;
text-align: right;
& > div {
text-align: right;
}
2025-01-26 21:07:26 +08:00
}
p {
font-size: 14px;
margin: 0;
line-height: 16px;
}
::v-deep .el-button--medium {
padding: 4px 8px;
}
img {
width: 36px;
height: 36px;
border-radius: 50%;
}
}
}
2025-02-12 21:40:09 +08:00
.load-tip {
text-align: center;
line-height: 50px;
}
2025-01-26 21:07:26 +08:00
</style>