admin.vue 6.8 KB

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