review.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <CommonRoot>
  3. <FlexCol :padding="30">
  4. <SearchBar
  5. v-model="searchText"
  6. placeholder="搜一搜"
  7. @search="search"
  8. />
  9. <SimplePageListLoader :loader="listLoader" :noEmpty="true">
  10. <template #empty>
  11. <Empty image="search" text="暂无待审核志愿者" />
  12. </template>
  13. <FlexCol :gap="20" :margin="[20,0,0,0]">
  14. <VolunteerItem
  15. v-for="item in listLoader.list.value"
  16. :key="item.id"
  17. :item="item"
  18. >
  19. <FlexRow :gap="20">
  20. <Image
  21. :src="item.image"
  22. width="100rpx"
  23. height="100rpx"
  24. :defaultImage="UserHead"
  25. :failedImage="UserHead"
  26. round
  27. />
  28. <FlexCol>
  29. <Text :fontSize="36" bold :text="`${item.name} ${item.sex === 0 ? '男' : '女'}`" />
  30. <Text :fontSize="26" :text="`手机:${item.mobile}`" />
  31. <Text :fontSize="26" :text="`地址:${item.address || ''}`" />
  32. <Text :fontSize="26" :text="`可采编:${item.collectModuleText || '暂无'}`" />
  33. </FlexCol>
  34. </FlexRow>
  35. <template #action>
  36. <Button type="primary" icon="task-filling" :radius="40" @click="handleShowDetail(item)" />
  37. </template>
  38. </VolunteerItem>
  39. </FlexCol>
  40. </SimplePageListLoader>
  41. <Popup
  42. v-model:show="reviewPopup"
  43. :title="`审核 ${reviewItem?.title}`"
  44. size="80%"
  45. round
  46. position="bottom"
  47. closeable
  48. >
  49. <FlexCol :gap="30" :padding="30">
  50. <DynamicForm
  51. v-if="reviewItem"
  52. :model="reviewItem"
  53. :options="reviewFormDefine"
  54. :formGlobalParams="querys"
  55. />
  56. <Button type="success" @click="handleReview(VolunteerInfo.STATUS_APPROVED)">通过审核</Button>
  57. <Button type="danger" @click="handleReview(VolunteerInfo.STATUS_REJECTED)">驳回审核</Button>
  58. </FlexCol>
  59. </Popup>
  60. </FlexCol>
  61. </CommonRoot>
  62. </template>
  63. <script setup lang="ts">
  64. import { onMounted, ref } from 'vue';
  65. import { useLoadQuerys } from '@/common/composeabe/LoadQuerys';
  66. import { useSimplePageListLoader } from '@/common/composeabe/SimplePageListLoader';
  67. import { closeToast, confirm, toast } from '@/components/dialog/CommonRoot';
  68. import { showError } from '@/common/composeabe/ErrorDisplay';
  69. import { getVolunteerForm } from './data/volunteer';
  70. import type { IDynamicFormOptions, IDynamicFormRef } from '@/components/dynamic';
  71. import VillageApi, { VolunteerInfo } from '@/api/inhert/VillageApi';
  72. import SimplePageListLoader from '@/common/components/SimplePageListLoader.vue';
  73. import Button from '@/components/basic/Button.vue';
  74. import Image from '@/components/basic/Image.vue';
  75. import Text from '@/components/basic/Text.vue';
  76. import Empty from '@/components/feedback/Empty.vue';
  77. import SearchBar from '@/components/form/SearchBar.vue';
  78. import FlexCol from '@/components/layout/FlexCol.vue';
  79. import FlexRow from '@/components/layout/FlexRow.vue';
  80. import CommonRoot from '@/components/dialog/CommonRoot.vue';
  81. import UserHead from '@https://mncdn.wenlvti.net/app_static/xiangyuan/images/user/avatar.png';
  82. import VolunteerItem from './components/VolunteerItem.vue';
  83. import Popup from '@/components/dialog/Popup.vue';
  84. import DynamicForm from '@/components/dynamic/DynamicForm.vue';
  85. const { querys } = useLoadQuerys({
  86. villageId: 0,
  87. }, () => {
  88. listLoader.loadData(undefined, true);
  89. });
  90. const searchText = ref('');
  91. const listLoader = useSimplePageListLoader(8, async (page, pageSize, params) => {
  92. if (page === 1) {
  93. let res = await VillageApi.getVillageVolunteerList(querys.value.villageId, VolunteerInfo.STATUS_PENDING);
  94. if (searchText.value)
  95. res = res.filter((p) => p.name.includes(searchText.value));
  96. res.forEach((item) => {
  97. item.title = `${item.name} ${item.sex === 0 ? '男' : '女'}`;
  98. item.desc = ` 手机号:${item.mobile} 地址:${item.address || ''} 认领说明:${item.claimReason || ''}`;
  99. })
  100. return {
  101. page,
  102. total: res.length,
  103. list: res,
  104. }
  105. }
  106. return {
  107. page,
  108. total: 0,
  109. list: [],
  110. }
  111. });
  112. const reviewPopup = ref(false);
  113. const reviewItem = ref<VolunteerInfo>();
  114. const reviewFormRef = ref<IDynamicFormRef>();
  115. const reviewFormDefine = ref<IDynamicFormOptions>();
  116. function handleShowDetail(item: VolunteerInfo) {
  117. reviewItem.value = item;
  118. reviewPopup.value = true;
  119. }
  120. async function handleReview(status: number) {
  121. if (!reviewItem.value)
  122. return;
  123. if (!await confirm({
  124. title: '确认审核吗?',
  125. content: `确认审核${status === VolunteerInfo.STATUS_APPROVED ? '通过' : '驳回'}${reviewItem.value.title}吗?`,
  126. }))
  127. return;
  128. reviewPopup.value = false;
  129. toast({
  130. type: 'loading',
  131. content: '请稍后',
  132. })
  133. try {
  134. await VillageApi.reviewVillageVolunteer(querys.value.villageId, reviewItem.value.id, status);
  135. toast({ type: 'success', content: '审核成功' });
  136. } catch (e) {
  137. showError(e);
  138. } finally {
  139. closeToast();
  140. }
  141. }
  142. function search() {
  143. listLoader.loadData(undefined, true);
  144. }
  145. onMounted(() => {
  146. reviewFormDefine.value = {
  147. ...getVolunteerForm({
  148. canSetCatalog: false,
  149. villageId: querys.value.villageId,
  150. noPassword: true,
  151. isNew: ref(false),
  152. formRef: reviewFormRef,
  153. }),
  154. readonly: true,
  155. }
  156. })
  157. </script>