del-users.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
  3. <view>
  4. <cu-custom bgImage="/static/bg.png" :isBack="true">
  5. <template v-slot:content>
  6. <text class="text-black">{{ groupName }}</text>
  7. </template>
  8. </cu-custom>
  9. <index-bar :indexMap="map">
  10. <checkbox-group class="block" @change="checkboxChange">
  11. <view v-for="(item,key) in map.keys()" :key="key" :class="'indexItem-' + item" :id="'indexes-' + item"
  12. :data-index="item">
  13. <view class="padding">{{ item }}</view>
  14. <view class="cu-list menu-avatar no-padding">
  15. <view class="cu-item" v-for="(user,sub) in map.get(item)" :key="sub">
  16. <checkbox class="checkbox" :value="user.id" :disabled="checkedIds.indexOf(user.id)>-1"></checkbox>
  17. <image class="cu-avatar radius lg" :src="user.avatar"></image>
  18. <view class="content">
  19. <view class="text-black text-bold">{{ user.name }}</view>
  20. <view class="text-black text-sm">
  21. {{ user.name }}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view style="height: 140rpx;"></view>
  28. </checkbox-group>
  29. </index-bar>
  30. <view class="cu-form-group margin-top text-center" style="bottom: 0.5rem;position: fixed;width: 100%;">
  31. <button class="cu-btn bg-red lg margin-top" style="width: 100%;margin-bottom: 30rpx;" @tap="del">删除</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script setup lang="ts">
  36. import IndexBar from '@/components/IndexBar.vue'
  37. import {getCurrentInstance, ref} from "vue";
  38. import Tools from "@/utils/Tools";
  39. import CuCustom from '@/colorui/components/cu-custom.vue'
  40. import GroupApi from "@/api/GroupApi";
  41. import MessageUtils from "@/utils/MessageUtils";
  42. import {onLoad} from '@dcloudio/uni-app';
  43. import Auth from "@/api/Auth";
  44. const fontValue=ref(Auth.getfontSize());
  45. //@ts-ignore
  46. const {proxy} = getCurrentInstance();
  47. const map = ref(new Map());
  48. const avatar = ref('');
  49. const groupId = ref('');
  50. const groupName = ref('');
  51. //选中的用户id
  52. const ids = ref([]);
  53. const checkedIds = ref<string[]>([]);
  54. const checkboxChange = (e: any) => {
  55. ids.value = e.detail.value;
  56. }
  57. onLoad((opt) => {
  58. if (opt?.id) {
  59. groupId.value = opt?.id;
  60. GroupApi.get(groupId.value)
  61. .then((res: any) => {
  62. groupName.value = res.data.name;
  63. avatar.value = res.data.avatar;
  64. checkedIds.value.push(res.data.master)
  65. return GroupApi.users(groupId.value)
  66. })
  67. .then((res) => {
  68. map.value = Tools.listToMap(res.data);
  69. })
  70. }
  71. })
  72. const del = () => {
  73. GroupApi.deleteUsers(groupId.value, ids.value)
  74. .then(() => {
  75. return GroupApi.users(groupId.value)
  76. })
  77. .then((res) => {
  78. MessageUtils.message('操作成功');
  79. map.value = Tools.listToMap(res.data);
  80. uni.navigateTo({
  81. url: '/pages/group/group?id=' + groupId.value
  82. })
  83. })
  84. .catch((err) => {
  85. MessageUtils.error(err)
  86. })
  87. }
  88. </script>
  89. <style scoped>
  90. .cu-list.menu-avatar > .cu-item > .cu-avatar {
  91. left: 3.9375rem;
  92. }
  93. .cu-list.menu-avatar > .cu-item .content {
  94. left: 7.5625rem;
  95. }
  96. .cu-list.menu-avatar > .cu-item .checkbox {
  97. left: 1rem;
  98. position: absolute;
  99. }
  100. </style>