index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <doc-alert title="【营销】拼团活动" url="https://doc.iocoder.cn/mall/promotion-combination/" />
  3. <!-- 统计信息展示 -->
  4. <el-row :gutter="12">
  5. <el-col :span="6">
  6. <ContentWrap class="h-[110px] pb-0!">
  7. <div class="flex items-center">
  8. <div
  9. class="h-[50px] w-[50px] flex items-center justify-center"
  10. style="color: rgb(24 144 255); background-color: rgb(24 144 255 / 10%)"
  11. >
  12. <Icon :size="23" icon="fa:user-times" />
  13. </div>
  14. <div class="ml-[20px]">
  15. <div class="mb-8px text-14px text-gray-400">参与人数(个)</div>
  16. <CountTo
  17. :duration="2600"
  18. :end-val="recordSummary.userCount"
  19. :start-val="0"
  20. class="text-20px"
  21. />
  22. </div>
  23. </div>
  24. </ContentWrap>
  25. </el-col>
  26. <el-col :span="6">
  27. <ContentWrap class="h-[110px]">
  28. <div class="flex items-center">
  29. <div
  30. class="h-[50px] w-[50px] flex items-center justify-center"
  31. style="color: rgb(162 119 255); background-color: rgb(162 119 255 / 10%)"
  32. >
  33. <Icon :size="23" icon="fa:user-plus" />
  34. </div>
  35. <div class="ml-[20px]">
  36. <div class="mb-8px text-14px text-gray-400">成团数量(个)</div>
  37. <CountTo
  38. :duration="2600"
  39. :end-val="recordSummary.successCount"
  40. :start-val="0"
  41. class="text-20px"
  42. />
  43. </div>
  44. </div>
  45. </ContentWrap>
  46. </el-col>
  47. <el-col :span="6">
  48. <ContentWrap class="h-[110px]">
  49. <div class="flex items-center">
  50. <div
  51. class="h-[50px] w-[50px] flex items-center justify-center"
  52. style="color: rgb(162 119 255); background-color: rgb(162 119 255 / 10%)"
  53. >
  54. <Icon :size="23" icon="fa:user-plus" />
  55. </div>
  56. <div class="ml-[20px]">
  57. <div class="mb-8px text-14px text-gray-400">虚拟成团(个)</div>
  58. <CountTo
  59. :duration="2600"
  60. :end-val="recordSummary.virtualGroupCount"
  61. :start-val="0"
  62. class="text-20px"
  63. />
  64. </div>
  65. </div>
  66. </ContentWrap>
  67. </el-col>
  68. </el-row>
  69. <!-- 搜索工作栏 -->
  70. <ContentWrap>
  71. <el-form
  72. ref="queryFormRef"
  73. :inline="true"
  74. :model="queryParams"
  75. class="-mb-15px"
  76. label-width="68px"
  77. >
  78. <el-form-item label="创建时间" prop="createTime">
  79. <el-date-picker
  80. v-model="queryParams.createTime"
  81. :shortcuts="defaultShortcuts"
  82. class="!w-240px"
  83. end-placeholder="结束日期"
  84. start-placeholder="开始日期"
  85. type="daterange"
  86. value-format="YYYY-MM-DD HH:mm:ss"
  87. />
  88. </el-form-item>
  89. <el-form-item label="拼团状态" prop="status">
  90. <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部">
  91. <el-option
  92. v-for="(dict, index) in getIntDictOptions(
  93. DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS
  94. )"
  95. :key="index"
  96. :label="dict.label"
  97. :value="dict.value"
  98. />
  99. </el-select>
  100. </el-form-item>
  101. <el-form-item>
  102. <el-button @click="handleQuery">
  103. <Icon class="mr-5px" icon="ep:search" />
  104. 搜索
  105. </el-button>
  106. <el-button @click="resetQuery">
  107. <Icon class="mr-5px" icon="ep:refresh" />
  108. 重置
  109. </el-button>
  110. </el-form-item>
  111. </el-form>
  112. </ContentWrap>
  113. <!-- 分页列表数据展示 -->
  114. <ContentWrap>
  115. <el-table v-loading="loading" :data="pageList">
  116. <el-table-column align="center" label="编号" min-width="50" prop="id" />
  117. <el-table-column align="center" label="头像" min-width="80" prop="avatar">
  118. <template #default="scope">
  119. <el-avatar :src="scope.row.avatar" />
  120. </template>
  121. </el-table-column>
  122. <el-table-column align="center" label="昵称" min-width="100" prop="nickname" />
  123. <el-table-column align="center" label="开团团长" min-width="100" prop="headId">
  124. <template #default="{ row }: { row: CombinationRecordApi.CombinationRecordVO }">
  125. {{
  126. row.headId ? pageList.find((item) => item.id === row.headId)?.nickname : row.nickname
  127. }}
  128. </template>
  129. </el-table-column>
  130. <el-table-column
  131. :formatter="dateFormatter"
  132. align="center"
  133. label="开团时间"
  134. prop="startTime"
  135. width="180"
  136. />
  137. <el-table-column
  138. align="center"
  139. label="拼团产品"
  140. min-width="300"
  141. prop="type"
  142. show-overflow-tooltip
  143. >
  144. <template #defaul="{ row }">
  145. <el-image
  146. :src="row.picUrl"
  147. class="mr-5px h-30px w-30px align-middle"
  148. @click="imagePreview(row.picUrl)"
  149. />
  150. <span class="align-middle">{{ row.spuName }}</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column align="center" label="几人团" min-width="100" prop="userSize" />
  154. <el-table-column align="center" label="参与人数" min-width="100" prop="userCount" />
  155. <el-table-column
  156. :formatter="dateFormatter"
  157. align="center"
  158. label="参团时间"
  159. prop="createTime"
  160. width="180"
  161. />
  162. <el-table-column
  163. :formatter="dateFormatter"
  164. align="center"
  165. label="结束时间"
  166. prop="endTime"
  167. width="180"
  168. />
  169. <el-table-column align="center" label="拼团状态" min-width="150" prop="status">
  170. <template #default="scope">
  171. <dict-tag
  172. :type="DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS"
  173. :value="scope.row.status"
  174. />
  175. </template>
  176. </el-table-column>
  177. <el-table-column align="center" fixed="right" label="操作">
  178. <template #default="scope">
  179. <el-button
  180. v-hasPermi="['promotion:combination-record:query']"
  181. link
  182. type="primary"
  183. @click="openRecordListDialog(scope.row)"
  184. >
  185. 查看拼团
  186. </el-button>
  187. </template>
  188. </el-table-column>
  189. </el-table>
  190. <!-- 分页 -->
  191. <Pagination
  192. v-model:limit="queryParams.pageSize"
  193. v-model:page="queryParams.pageNo"
  194. :total="total"
  195. @pagination="getList"
  196. />
  197. </ContentWrap>
  198. <!-- 表单弹窗 -->
  199. <CombinationRecordListDialog ref="combinationRecordListRef" />
  200. </template>
  201. <script lang="ts" setup>
  202. import CombinationRecordListDialog from './CombinationRecordListDialog.vue'
  203. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  204. import { dateFormatter, defaultShortcuts } from '@/utils/formatTime'
  205. import { createImageViewer } from '@/components/ImageViewer'
  206. import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord'
  207. defineOptions({ name: 'PromotionCombinationRecord' })
  208. const queryParams = ref({
  209. status: undefined, // 拼团状态
  210. createTime: undefined, // 创建时间
  211. pageSize: 10,
  212. pageNo: 1
  213. })
  214. const queryFormRef = ref() // 搜索的表单
  215. const combinationRecordListRef = ref() // 查询表单 Ref
  216. const loading = ref(true) // 列表的加载中
  217. const total = ref(0) // 总记录数
  218. const pageList = ref<CombinationRecordApi.CombinationRecordVO[]>([]) // 分页数据
  219. /** 查询列表 */
  220. const getList = async () => {
  221. loading.value = true
  222. try {
  223. const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value)
  224. pageList.value = data.list as CombinationRecordApi.CombinationRecordVO[]
  225. total.value = data.total
  226. } finally {
  227. loading.value = false
  228. }
  229. }
  230. // 拼团统计数据
  231. const recordSummary = ref({
  232. successCount: 0,
  233. userCount: 0,
  234. virtualGroupCount: 0
  235. })
  236. /** 获得拼团记录统计信息 */
  237. const getSummary = async () => {
  238. recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary()
  239. }
  240. /** 查看拼团详情 */
  241. const openRecordListDialog = (row: CombinationRecordApi.CombinationRecordVO) => {
  242. combinationRecordListRef.value?.open(row.headId || row.id) // 多表达式的原因,团长的 headId 为空,就是自身的情况
  243. }
  244. /** 搜索按钮操作 */
  245. const handleQuery = () => {
  246. queryParams.value.pageNo = 1
  247. getList()
  248. }
  249. /** 重置按钮操作 */
  250. const resetQuery = () => {
  251. queryFormRef.value.resetFields()
  252. handleQuery()
  253. }
  254. /** 产品图预览 */
  255. const imagePreview = (imgUrl: string) => {
  256. createImageViewer({
  257. urlList: [imgUrl]
  258. })
  259. }
  260. /** 初始化 **/
  261. onMounted(async () => {
  262. await getSummary()
  263. await getList()
  264. })
  265. </script>