manage-mute.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. <template>
  2. <main class="member">
  3. <n-spin :show="muteLoading" stroke="#198CFE">
  4. <div class="sectionSearch">
  5. <n-input
  6. class="TheSearch noBorder"
  7. style="--n-font-size: 12px; --n-height: 35px; --n-caret-color: #198cfe; --n-border-hover: 1px solid #198cfe; --n-border-focus: 1px solid #198cfe; --n-loading-color: #198cfe; --n-box-shadow-focus: 0 0 0 2px rgba(25 140 254, 0.2)"
  8. round
  9. clearable
  10. placeholder="请输入群成员名称"
  11. v-model:value="keyword"
  12. @keyup="onKeyup"
  13. >
  14. <template #prefix> <span class="icon-search-input"></span></template>
  15. <template #suffix><n-button @click="debouncedRequest('')" round color="#198cfe" >搜索</n-button></template>
  16. </n-input>
  17. </div>
  18. <ul class="list">
  19. <li class="list-item" v-for="(item, index) in list" :key="index" @click="onSelectItem(item)">
  20. <aside>
  21. <!-- icon icon-selected -->
  22. <i :class="['icon', isSelect(item) ? 'icon-selected' : 'icon-unselected']"></i>
  23. <img class="avatar" :src="item?.avatar || 'https://oss.dayaedu.com/news-info/07/1690787574969.png'" onerror="this.src='https://oss.dayaedu.com/news-info/07/1690787574969.png'" />
  24. <span class="name">{{ item?.nickname || item?.userID }}</span>
  25. </aside>
  26. <!-- <i v-if="item.role !== 'Owner' && isShowDel" class="icon icon-del" @click="submit(item)"></i> -->
  27. </li>
  28. <li class="list-item" v-if="list.length < total && total > 0 && !muteLoading" @click="getMore">
  29. {{ $t(`TUIChat.manage.查看更多`) }}
  30. </li>
  31. </ul>
  32. <div class="theEmpty" v-if="!muteLoading && list.length <= 0" style="height: 75%">
  33. <img class="emptyImg" src="../../../assets/nomore.png" />
  34. <p>暂无数据</p>
  35. </div>
  36. <div class="footer">
  37. <div class="selectUser" @click="onSelectAll">
  38. <i :class="['icon', isSelectAll ? 'icon-selected' : 'icon-unselected']"></i>
  39. <span>全选(已选择{{ selectList.length || 0 }}):</span>
  40. </div>
  41. <div class="userInfo">
  42. <div class="userList" @click="showMore = true">
  43. <img class="avatar" v-for="(item, index) in selectList" :key="index" :src="item?.avatar || 'https://oss.dayaedu.com/news-info/07/1690787574969.png'" onerror="this.src='https://oss.dayaedu.com/news-info/07/1690787574969.png'" />
  44. </div>
  45. <span :class="['muteBtn', selectList.length <=0 ? 'disabled' : '']" @click="submit">
  46. {{ currentModel === 'not_mute' ? '禁言' : '解除禁言' }}
  47. </span>
  48. </div>
  49. </div>
  50. <div v-if="showMore" class="maskMute"></div>
  51. <div :class="['selectListSection', showMore ? 'show': '']">
  52. <div class="selectHeader">
  53. <i class="icon-close" @click="showMore = false"></i>
  54. <span class="title">已选择 ({{ selectList.length || 0 }})</span>
  55. <span :class="['sureBtn', selectList.length <=0 ? 'disabled' : '']" @click="showMore = false">确定</span>
  56. </div>
  57. <div class="selectContainer">
  58. <div class="list-item" v-for="(item, index) in selectList" :key="index" @click="onSelectItem(item)">
  59. <aside>
  60. <img class="avatar" :src="item?.avatar || 'https://oss.dayaedu.com/news-info/07/1690787574969.png'" onerror="this.src='https://oss.dayaedu.com/news-info/07/1690787574969.png'" />
  61. <span class="name">{{ item?.nickname || item?.userID }}</span>
  62. </aside>
  63. <i class="icon icon-remove" ></i>
  64. </div>
  65. <div class="theEmpty" v-if="selectList.length <= 0" style="margin-top: 20px;margin-bottom: 0;">
  66. <img class="emptyImg" src="../../../assets/nomore.png" />
  67. <p>暂无数据</p>
  68. </div>
  69. </div>
  70. </div>
  71. </n-spin>
  72. </main>
  73. </template>
  74. <script lang="ts">
  75. import { defineComponent, watchEffect, reactive, toRefs } from "vue";
  76. import TIM from "@tencentcloud/chat";
  77. import { imGroupGroupMute, imGroupMemberPage } from "../../../../api";
  78. import { useThrottleFn } from "@vueuse/core";
  79. const ManageMember = defineComponent({
  80. components: {},
  81. props: {
  82. list: {
  83. type: Array,
  84. default: () => [],
  85. },
  86. currentModel: {
  87. type: String,
  88. default: '',
  89. },
  90. muteLoading: {
  91. type: Boolean,
  92. default: false
  93. },
  94. total: {
  95. type: Number,
  96. default: 0
  97. },
  98. conversation: {
  99. type: Object,
  100. default: () => ({}),
  101. },
  102. isShowDel: {
  103. type: Boolean,
  104. default: () => false,
  105. },
  106. self: {
  107. type: Object,
  108. default: () => ({}),
  109. },
  110. },
  111. setup(props: any, ctx: any) {
  112. const types: any = TIM.TYPES;
  113. const data: any = reactive({
  114. conversation: {},
  115. currentModel: '',
  116. total: 0,
  117. muteLoading: false,
  118. list: [],
  119. page: 1,
  120. isShowDel: false,
  121. self: {},
  122. keyword: '',
  123. showMore: false, // 显示更多
  124. selectList: [],
  125. isSelectAll: false, // 是否全部选择
  126. });
  127. watchEffect(() => {
  128. if(data.currentModel !== props.currentModel) {
  129. data.selectList = []
  130. }
  131. data.conversation = props.conversation;
  132. data.muteLoading = props.muteLoading;
  133. data.total = props.total;
  134. data.isShowDel = props.isShowDel;
  135. data.list = props.list;
  136. data.self = props.self;
  137. data.currentModel = props.currentModel;
  138. });
  139. const handleRoleName = (item: any) => {
  140. const { t } = (window as any).TUIKitTUICore.config.i18n.useI18n();
  141. let name = "";
  142. console.log(item, data.self, "self");
  143. switch (item?.groupRoleType) {
  144. case "Admin":
  145. name = t("TUIChat.manage.管理员");
  146. break;
  147. case "Owner":
  148. name = t("TUIChat.manage.群主");
  149. break;
  150. }
  151. if (name) {
  152. name = `(${name})`;
  153. }
  154. if (item.imUserId === data.self.userID) {
  155. name += ` (${t("TUIChat.manage.我")})`;
  156. }
  157. return name;
  158. };
  159. const submit = async (item: any) => {
  160. // ctx.emit("del", [item]);
  161. try {
  162. if(data.selectList.length <= 0) return
  163. const userIds = data.selectList.map((item: any) => {
  164. return item.userId
  165. })
  166. await imGroupGroupMute({
  167. "groupId": data.conversation?.groupProfile?.groupID,
  168. "muteTime": -1,
  169. "groupMute": data.currentModel === 'not_mute' ? true : false,
  170. userIds
  171. })
  172. onBack()
  173. } catch {
  174. }
  175. };
  176. const onSelectItem = (item: any) => {
  177. const index = data.selectList.findIndex(child => child.userId === item.userId)
  178. if(index === -1) {
  179. data.selectList.push(item)
  180. } else {
  181. data.selectList.splice(index, 1)
  182. }
  183. data.isSelectAll = data.list.length === data.selectList.length ? true : false
  184. }
  185. const isSelect = (item: any) => {
  186. const index = data.selectList.findIndex(child => child.userId === item.userId)
  187. return index === -1 ? false : true
  188. }
  189. const onSelectAll = (item: any) => {
  190. if(data.list.length === data.selectList.length) {
  191. data.selectList = []
  192. data.isSelectAll = false
  193. } else {
  194. data.selectList = [...data.list]
  195. data.isSelectAll = true
  196. }
  197. }
  198. const handleMemberProfileShow = (user: any) => {
  199. ctx.emit("handleMemberProfileShow", user);
  200. };
  201. const onBack = () => {
  202. ctx.emit("back");
  203. }
  204. const onSearch = (val: string) => {
  205. ctx.emit('search', data.keyword)
  206. };
  207. const debouncedRequest = useThrottleFn((val: string) => {
  208. onSearch(val);
  209. }, 500);
  210. const onKeyup = (e: any) => {
  211. e.stopPropagation();
  212. if (e.code === "Enter") {
  213. debouncedRequest(data.keyword);
  214. }
  215. };
  216. return {
  217. ...toRefs(data),
  218. submit,
  219. isSelect,
  220. debouncedRequest,
  221. onKeyup,
  222. onSearch,
  223. onSelectItem,
  224. onSelectAll,
  225. handleRoleName,
  226. handleMemberProfileShow,
  227. };
  228. },
  229. });
  230. export default ManageMember;
  231. </script>
  232. <style lang="scss" scoped>
  233. @import url("../../../styles/common.scss");
  234. @import url("../../../styles/icon.scss");
  235. .member {
  236. position: relative;
  237. flex: 1;
  238. background: #F8F9FC;
  239. .list {
  240. display: flex;
  241. flex-direction: column;
  242. // background: #f4f5f9;
  243. padding-top: 12px;
  244. &-item {
  245. padding: 13px;
  246. display: flex;
  247. justify-content: space-between;
  248. align-items: center;
  249. background: #ffffff;
  250. font-size: 14px;
  251. overflow: hidden;
  252. cursor: pointer;
  253. aside {
  254. display: flex;
  255. align-items: center;
  256. width: 100%;
  257. overflow: hidden;
  258. .avatar {
  259. margin-left: 12px;
  260. flex-shrink: 0;
  261. }
  262. .name {
  263. padding-left: 8px;
  264. font-weight: 400;
  265. font-size: 14px;
  266. color: #000000;
  267. flex: 1;
  268. overflow: hidden;
  269. white-space: nowrap;
  270. text-overflow: ellipsis;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. .avatar {
  277. width: 36px;
  278. height: 36px;
  279. border-radius: 4px;
  280. }
  281. .sectionSearch {
  282. padding: 4px 12px 0;
  283. }
  284. ::deep .TheSearch .n-input--focus {
  285. .active {
  286. display: block;
  287. }
  288. .default {
  289. display: none;
  290. }
  291. .n-button {
  292. opacity: 1;
  293. }
  294. }
  295. .n-spin-container {
  296. height: 100%;
  297. :deep(.n-spin-content) {
  298. min-height: 100%;
  299. display: flex;
  300. flex-direction: column;
  301. }
  302. }
  303. .TheSearch {
  304. border-radius: 20Px !important;
  305. &.noBorder {
  306. --n-border: none !important;
  307. }
  308. .n-button {
  309. :deep(.n-button__content) {
  310. color: #fff;
  311. }
  312. }
  313. :deep(.n-input-wrapper) {
  314. padding-left: 12Px;
  315. padding-right: 4Px;
  316. height: 35Px !important;
  317. }
  318. .n-button {
  319. height: 26Px;
  320. font-size: 12Px;
  321. font-weight: 500;
  322. width: auto;
  323. opacity: 0.7;
  324. }
  325. .active {
  326. display: none;
  327. }
  328. .active,
  329. .default {
  330. width: 14Px;
  331. height: 14Px;
  332. }
  333. &:hover {
  334. .n-button {
  335. opacity: 1;
  336. }
  337. }
  338. }
  339. .icon-unselected, .icon-selected {
  340. width: 18px;
  341. height: 18px;
  342. cursor: pointer;
  343. }
  344. .footer {
  345. position: absolute;
  346. bottom: 0;
  347. left: 0;
  348. right: 0;
  349. // width: 100%;
  350. padding: 0 12px;
  351. height: 66px;
  352. background: #FFFFFF;
  353. display: flex;
  354. align-items: center;
  355. }
  356. .selectUser {
  357. display: flex;
  358. align-items: center;
  359. font-weight: 400;
  360. font-size: 14px;
  361. color: #777777;
  362. line-height: 20px;
  363. flex-shrink: 0;
  364. cursor: pointer;
  365. span {
  366. padding-left: 12px;
  367. }
  368. }
  369. .userInfo {
  370. display: flex;
  371. align-items: center;
  372. justify-content: space-between;
  373. flex: 1;
  374. .userList {
  375. max-width: 110px;
  376. overflow-x: auto;
  377. overflow-y: hidden;
  378. display: flex;
  379. align-items: center;
  380. cursor: pointer;
  381. .avatar {
  382. width: 28px;
  383. height: 28px;
  384. border-radius: 50%;
  385. margin-right: 5px;
  386. &:last-child {
  387. margin-right: 0;
  388. }
  389. }
  390. }
  391. .muteBtn {
  392. cursor: pointer;
  393. width: 80px;
  394. line-height: 30px;
  395. background: #198CFE;
  396. border-radius: 20px;
  397. font-weight: 500;
  398. font-size: 14px;
  399. color: #FFFFFF;
  400. text-align: center;
  401. font-style: normal;
  402. &.disabled {
  403. opacity: 0.7;
  404. cursor: not-allowed;
  405. }
  406. }
  407. }
  408. ::-webkit-scrollbar {
  409. // width: 4Px;
  410. height: 4Px;
  411. background-color: transparent;
  412. }
  413. ::-webkit-scrollbar-track {
  414. border-radius: 10Px;
  415. }
  416. ::-webkit-scrollbar-thumb {
  417. border-radius: 10Px;
  418. background-color: #d8d8d8;
  419. }
  420. .theEmpty {
  421. width: 100%;
  422. display: flex;
  423. justify-content: center;
  424. align-items: center;
  425. flex-direction: column;
  426. flex: 1;
  427. margin-bottom: 106px;
  428. .emptyImg {
  429. width: 210px;
  430. height: 210px;
  431. }
  432. }
  433. .selectListSection {
  434. position: absolute;
  435. bottom: 0;
  436. left: 0;
  437. right: 0;
  438. background: #FFFFFF;
  439. border-radius: 10px 10px 0px 0px;
  440. height: 70vh;
  441. overflow-x: hidden;
  442. overflow-y: auto;
  443. // display: none;
  444. opacity: 0;
  445. height: 0;
  446. transition: all .2s ease;
  447. &.show {
  448. // display: block;
  449. opacity: 1;
  450. height: 70vh;
  451. transition: all .2s ease;
  452. }
  453. }
  454. .selectHeader {
  455. padding: 16px 20px 16px 18px;
  456. display: flex;
  457. align-items: center;
  458. justify-content: space-between;
  459. position: sticky;
  460. top: 0;
  461. left: 0;
  462. z-index: 99;
  463. background-color: #fff;
  464. .icon-close {
  465. cursor: pointer;
  466. }
  467. .title {
  468. font-weight: 600;
  469. font-size: 16px;
  470. color: #131415;
  471. line-height: 22px;
  472. }
  473. .sureBtn {
  474. cursor: pointer;
  475. width: 52px;
  476. line-height: 26px;
  477. background: #198CFE;
  478. border-radius: 6px;
  479. font-weight: 500;
  480. font-size: 14px;
  481. color: #FFFFFF;
  482. text-align: center;
  483. &.disabled {
  484. opacity: 0.7;
  485. cursor: not-allowed;
  486. }
  487. }
  488. }
  489. .selectContainer {
  490. .list-item {
  491. padding: 10px 20px;
  492. cursor: default;
  493. &:first-child {
  494. padding-top: 0;
  495. }
  496. .avatar {
  497. margin-left: 0 !important;
  498. width: 40px;
  499. height: 40px;
  500. border-radius: 50%;
  501. }
  502. .name {
  503. padding-left: 11px;
  504. font-weight: 500;
  505. font-size: 14px;
  506. color: #333333;
  507. line-height: 20px;
  508. }
  509. .icon-remove {
  510. cursor: pointer;
  511. }
  512. }
  513. }
  514. .maskMute {
  515. position: absolute;
  516. left: 0;
  517. right: 0;
  518. top: -58px;
  519. bottom: 0;
  520. background:rgba(0, 0, 0, 0.6);
  521. }
  522. </style>