index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <CommonRoot>
  3. <FlexCol :padding="30">
  4. <FlexRow justify="space-between">
  5. <SearchBar
  6. v-model="searchText"
  7. placeholder="搜一搜"
  8. :innerStyle="{ width: '300rpx' }"
  9. @search="search"
  10. />
  11. <ButtonGroup>
  12. <NButton :radius="40" size="small" @click="navTo('review', { villageId: querys.villageId })">待审核志愿者</NButton>
  13. <NButton :radius="40" size="small" type="primary" @click="newData">+ 新增</NButton>
  14. </ButtonGroup>
  15. </FlexRow>
  16. <FlexCol :gap="20" :margin="[20,0,0,0]">
  17. <button class="remove-button-style" open-type="share">
  18. <Touchable
  19. direction="column"
  20. center
  21. :padding="20"
  22. :height="300"
  23. :innerStyle="{
  24. backgroundImage: `url('https://mn.wenlvti.net/app_static/xiangyuan/images/share-btn.jpg')`,
  25. backgroundSize: 'cover',
  26. }"
  27. >
  28. <FlexCol position="relative">
  29. <Icon icon="smile-filling" color="primary" :size="156" />
  30. <Icon icon="share" color="warning" :size="56" :innerStyle="{ position: 'absolute', bottom: 0, right: '-40rpx' }" />
  31. </FlexCol>
  32. <Height :height="20" />
  33. <Text :fontSize="26" color="primary" text="分享给志愿者注册,加入志愿者队伍" />
  34. </Touchable>
  35. </button>
  36. <VolunteerItem
  37. v-for="item in listLoader.list.value"
  38. :key="item.id"
  39. :item="(item as unknown as VolunteerInfo)"
  40. >
  41. <template #action>
  42. <BubbleBox
  43. :innerStyle="{ left: '0' }"
  44. position="bottom"
  45. :items="[
  46. {
  47. icon: 'edit-filling',
  48. text: '编辑信息',
  49. onClick: () => goDetail(item.id),
  50. },
  51. {
  52. icon: 'browse',
  53. text: '修改密码',
  54. onClick: () => goDetail(item.id, true),
  55. },
  56. {
  57. icon: 'trash',
  58. text: '删除账号',
  59. textColor: 'danger',
  60. onClick: () => doDeleteUser(item as unknown as VolunteerInfo),
  61. },
  62. ]"
  63. >
  64. <NButton type="primary" icon="edit-filling" :radius="40" />
  65. </BubbleBox>
  66. </template>
  67. </VolunteerItem>
  68. </FlexCol>
  69. <SimplePageListLoader :loader="listLoader" :noEmpty="true">
  70. <template #empty>
  71. <Empty image="search" text="暂无数据,点击按钮新增数据">
  72. <NButton type="primary" @click="newData">+ 新增数据</NButton>
  73. </Empty>
  74. </template>
  75. </SimplePageListLoader>
  76. </FlexCol>
  77. </CommonRoot>
  78. </template>
  79. <script setup lang="ts">
  80. import { ref } from 'vue';
  81. import { navTo } from '@/components/utils/PageAction';
  82. import { useLoadQuerys } from '@/common/composeabe/LoadQuerys';
  83. import { useSimplePageListLoader } from '@/common/composeabe/SimplePageListLoader';
  84. import { onShareAppMessage } from '@dcloudio/uni-app';
  85. import { alert, confirm, toast } from '@/components/dialog/CommonRoot';
  86. import VillageApi, { VolunteerInfo } from '@/api/inhert/VillageApi';
  87. import SimplePageListLoader from '@/common/components/SimplePageListLoader.vue';
  88. import NButton from '@/components/basic/Button.vue';
  89. import Icon from '@/components/basic/Icon.vue';
  90. import Text from '@/components/basic/Text.vue';
  91. import Empty from '@/components/feedback/Empty.vue';
  92. import SearchBar from '@/components/form/SearchBar.vue';
  93. import FlexCol from '@/components/layout/FlexCol.vue';
  94. import FlexRow from '@/components/layout/FlexRow.vue';
  95. import Touchable from '@/components/feedback/Touchable.vue';
  96. import Height from '@/components/layout/space/Height.vue';
  97. import BubbleBox from '@/components/feedback/BubbleBox.vue';
  98. import CommonRoot from '@/components/dialog/CommonRoot.vue';
  99. import VolunteerItem from './components/VolunteerItem.vue';
  100. import ButtonGroup from '@/components/basic/ButtonGroup.vue';
  101. const { querys } = useLoadQuerys({
  102. id: 0,
  103. name: '',
  104. points: 0,
  105. level: 0,
  106. villageId: 0,
  107. villageVolunteerId: 0,
  108. }, () => {
  109. listLoader.loadData(undefined, true);
  110. });
  111. const searchText = ref('');
  112. const listLoader = useSimplePageListLoader(8, async (page, pageSize, params) => {
  113. if (page === 1) {
  114. let res = await VillageApi.getVillageVolunteerList(querys.value.id);
  115. if (searchText.value)
  116. res = res.filter((p) => p.name.includes(searchText.value));
  117. return {
  118. page,
  119. total: res.length,
  120. list: res.map((item) => ({
  121. ...item,
  122. title: `${item.name} ${item.sex === 0 ? '男' : '女'} 手机号:${item.mobile} 地址:${item.address || ''}`,
  123. desc: `可采编:${item.collectModuleText || '暂无'}`,
  124. })),
  125. }
  126. }
  127. return {
  128. page,
  129. total: 0,
  130. list: [],
  131. }
  132. });
  133. function newData() {
  134. navTo('./volunteer', {
  135. id: -1,
  136. villageId: querys.value.id,
  137. villageVolunteerId: querys.value.villageVolunteerId,
  138. });
  139. }
  140. function goDetail(id: number, onlyPassword: boolean = false) {
  141. navTo('./volunteer', {
  142. id,
  143. villageId: querys.value.id,
  144. villageVolunteerId: querys.value.villageVolunteerId,
  145. onlyPassword,
  146. });
  147. }
  148. function doDeleteUser(item: VolunteerInfo) {
  149. confirm({
  150. title: '确认要删除用户?',
  151. content: `请注意:删除${item.name}后将无法继续登录,请确认此账号不再继续使用。`,
  152. confirmColor: 'danger',
  153. confirmCountDown: 10,
  154. width: 560,
  155. }).then((res) => {
  156. if (res) {
  157. VillageApi.deleteVolunteer(item.id, querys.value.villageId).then(() => {
  158. listLoader.loadData(undefined, true);
  159. toast({ content: '删除成功' })
  160. }).catch((e) => {
  161. alert({
  162. title: '删除失败',
  163. content: '请联系管理员处理。' + e,
  164. icon: 'delete-filling',
  165. })
  166. });
  167. }
  168. });
  169. }
  170. function search() {
  171. listLoader.loadData(undefined, true);
  172. }
  173. onShareAppMessage(() => ({
  174. title: '邀请你成为村社挖掘志愿者',
  175. desc: '分享给你的志愿者可以采编村社文化资源信息,加入志愿者队伍,为村社贡献力量。',
  176. path: '/pages/dig/sharereg/share-reg-page?villageId=' + querys.value.villageId,
  177. imageUrl: 'https://mn.wenlvti.net/app_static/xiangyuan/images/share-post.jpg',
  178. }))
  179. </script>