index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <!-- 统计信息展示 -->
  3. <el-row :gutter="12">
  4. <el-col :span="6">
  5. <ContentWrap class="h-[110px] pb-0!">
  6. <div class="flex items-center">
  7. <div
  8. class="h-[50px] w-[50px] flex items-center justify-center"
  9. style="color: rgb(24, 144, 255); background-color: rgba(24, 144, 255, 0.1)"
  10. >
  11. <Icon :size="23" icon="fa:user-times" />
  12. </div>
  13. <div class="ml-[20px]">
  14. <div class="mb-8px text-14px text-gray-400">参与人数(个)</div>
  15. <CountTo
  16. :duration="2600"
  17. :end-val="recordSummary.userCount"
  18. :start-val="0"
  19. class="text-20px"
  20. />
  21. </div>
  22. </div>
  23. </ContentWrap>
  24. </el-col>
  25. <el-col :span="6">
  26. <ContentWrap class="h-[110px]">
  27. <div class="flex items-center">
  28. <div
  29. class="h-[50px] w-[50px] flex items-center justify-center"
  30. style="color: rgb(162, 119, 255); background-color: rgba(162, 119, 255, 0.1)"
  31. >
  32. <Icon :size="23" icon="fa:user-plus" />
  33. </div>
  34. <div class="ml-[20px]">
  35. <div class="mb-8px text-14px text-gray-400">成团数量(个)</div>
  36. <CountTo
  37. :duration="2600"
  38. :end-val="recordSummary.successCount"
  39. :start-val="0"
  40. class="text-20px"
  41. />
  42. </div>
  43. </div>
  44. </ContentWrap>
  45. </el-col>
  46. <el-col :span="6">
  47. <ContentWrap class="h-[110px]">
  48. <div class="flex items-center">
  49. <div
  50. class="h-[50px] w-[50px] flex items-center justify-center"
  51. style="color: rgb(162, 119, 255); background-color: rgba(162, 119, 255, 0.1)"
  52. >
  53. <Icon :size="23" icon="fa:user-plus" />
  54. </div>
  55. <div class="ml-[20px]">
  56. <div class="mb-8px text-14px text-gray-400">虚拟成团(个)</div>
  57. <CountTo
  58. :duration="2600"
  59. :end-val="recordSummary.virtualGroupCount"
  60. :start-val="0"
  61. class="text-20px"
  62. />
  63. </div>
  64. </div>
  65. </ContentWrap>
  66. </el-col>
  67. </el-row>
  68. <!-- 搜索工作栏 -->
  69. <ContentWrap>
  70. <el-form
  71. ref="queryFormRef"
  72. :inline="true"
  73. :model="queryParams"
  74. class="-mb-15px"
  75. label-width="68px"
  76. >
  77. <el-form-item label="创建时间" prop="createTime">
  78. <el-date-picker
  79. v-model="queryParams.createTime"
  80. :shortcuts="shortcuts"
  81. class="!w-240px"
  82. end-placeholder="结束日期"
  83. start-placeholder="开始日期"
  84. type="daterange"
  85. value-format="YYYY-MM-DD HH:mm:ss"
  86. />
  87. </el-form-item>
  88. <el-form-item label="拼团状态" prop="status">
  89. <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="全部">
  90. <el-option
  91. v-for="(dict, index) in getIntDictOptions(
  92. DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS
  93. )"
  94. :key="index"
  95. :label="dict.label"
  96. :value="dict.value"
  97. />
  98. </el-select>
  99. </el-form-item>
  100. <el-form-item>
  101. <el-button @click="handleQuery">
  102. <Icon class="mr-5px" icon="ep:search" />
  103. 搜索
  104. </el-button>
  105. <el-button @click="resetQuery">
  106. <Icon class="mr-5px" icon="ep:refresh" />
  107. 重置
  108. </el-button>
  109. </el-form-item>
  110. </el-form>
  111. </ContentWrap>
  112. <!-- 分页列表数据展示 -->
  113. <ContentWrap>
  114. <el-table v-loading="loading" :data="pageList">
  115. <el-table-column align="center" label="编号" prop="id" />
  116. <el-table-column align="center" label="头像" prop="avatar" />
  117. <el-table-column align="center" label="昵称" prop="nickname" />
  118. <el-table-column align="center" label="开团团长" prop="headId">
  119. <template #default="{ row }: { row: CombinationRecordApi.CombinationRecordVO }">
  120. {{
  121. row.headId ? pageList.find((item) => item.id === row.headId)?.nickname : row.nickname
  122. }}
  123. </template>
  124. </el-table-column>
  125. <el-table-column
  126. :formatter="dateFormatter"
  127. align="center"
  128. label="开团时间"
  129. prop="startTime"
  130. width="180"
  131. />
  132. <el-table-column
  133. align="center"
  134. label="拼团商品"
  135. prop="type"
  136. show-overflow-tooltip
  137. width="300"
  138. >
  139. <template #defaul="{ row }">
  140. <el-image
  141. :src="row.picUrl"
  142. class="mr-5px h-30px w-30px align-middle"
  143. @click="imagePreview(row.picUrl)"
  144. />
  145. <span class="align-middle">{{ row.spuName }}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column align="center" label="几人团" prop="userSize" />
  149. <el-table-column align="center" label="参与人数" prop="userCount" />
  150. <el-table-column
  151. :formatter="dateFormatter"
  152. align="center"
  153. label="参团时间"
  154. prop="createTime"
  155. width="180"
  156. />
  157. <el-table-column
  158. :formatter="dateFormatter"
  159. align="center"
  160. label="结束时间"
  161. prop="endTime"
  162. width="180"
  163. />
  164. <el-table-column align="center" label="拼团状态" prop="status">
  165. <template #default="scope">
  166. <dict-tag
  167. :type="DICT_TYPE.PROMOTION_COMBINATION_RECORD_STATUS"
  168. :value="scope.row.status"
  169. />
  170. </template>
  171. </el-table-column>
  172. <!-- TODO puhui999:这里加个查看拼团?点击后,查看完整的拼团列表? -->
  173. <el-table-column align="center" fixed="right" label="操作">
  174. <template #default></template>
  175. </el-table-column>
  176. </el-table>
  177. <!-- 分页 -->
  178. <Pagination
  179. v-model:limit="queryParams.pageSize"
  180. v-model:page="queryParams.pageNo"
  181. :total="total"
  182. @pagination="getList"
  183. />
  184. </ContentWrap>
  185. </template>
  186. <script lang="ts" setup>
  187. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  188. import { dateFormatter } from '@/utils/formatTime'
  189. import { createImageViewer } from '@/components/ImageViewer'
  190. import * as CombinationRecordApi from '@/api/mall/promotion/combination/combinationRecord'
  191. defineOptions({ name: 'CombinationRecord' })
  192. const queryParams = ref({
  193. dateType: 0, // 日期类型
  194. status: undefined, // 拼团状态
  195. createTime: undefined, // 创建时间
  196. pageSize: 10,
  197. pageNo: 1
  198. })
  199. const queryFormRef = ref() // 搜索的表单
  200. const loading = ref(true) // 列表的加载中
  201. const total = ref(0) // 总记录数
  202. const pageList = ref<CombinationRecordApi.CombinationRecordVO[]>([]) // 分页数据
  203. /** 查询列表 */
  204. const getList = async () => {
  205. loading.value = true
  206. try {
  207. const data = await CombinationRecordApi.getCombinationRecordPage(queryParams.value)
  208. pageList.value = data.list as CombinationRecordApi.CombinationRecordVO[]
  209. total.value = data.total
  210. } finally {
  211. loading.value = false
  212. }
  213. }
  214. // 拼团统计数据
  215. const recordSummary = ref({
  216. successCount: 0,
  217. userCount: 0,
  218. virtualGroupCount: 0
  219. })
  220. /** 获得拼团记录统计信息 */
  221. const getSummary = async () => {
  222. recordSummary.value = await CombinationRecordApi.getCombinationRecordSummary()
  223. }
  224. // 日期快捷选项
  225. // TODO @puhui999:不用 dateType,而是 shortcuts 选择后,设置到对应的 date 就 ok 啦。直接通过它查询。然后,看看怎么把 shortcuts 变成一个公共变量,类似 defaultProps 一样
  226. const shortcuts = ref([
  227. {
  228. text: '今天',
  229. type: 'toDay',
  230. value: () => {
  231. queryParams.value.dateType = 1
  232. return new Date()
  233. }
  234. },
  235. {
  236. text: '昨天',
  237. type: 'yesterday',
  238. value: () => {
  239. const date = new Date()
  240. date.setTime(date.getTime() - 3600 * 1000 * 24)
  241. queryParams.value.dateType = 2
  242. return [date, date]
  243. }
  244. },
  245. {
  246. text: '最近七天',
  247. type: 'lastSevenDays',
  248. value: () => {
  249. const date = new Date()
  250. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
  251. queryParams.value.dateType = 3
  252. return [date, new Date()]
  253. }
  254. },
  255. {
  256. text: '最近 30 天',
  257. type: 'last30Days',
  258. value: () => {
  259. const date = new Date()
  260. date.setTime(date.getTime() - 3600 * 1000 * 24 * 30)
  261. queryParams.value.dateType = 4
  262. return [date, new Date()]
  263. }
  264. },
  265. {
  266. text: '本月',
  267. type: 'thisMonth',
  268. value: () => {
  269. const date = new Date()
  270. date.setDate(1) // 设置为当前月的第一天
  271. queryParams.value.dateType = 5
  272. return [date, new Date()]
  273. }
  274. },
  275. {
  276. text: '今年',
  277. type: 'thisYear',
  278. value: () => {
  279. const date = new Date()
  280. queryParams.value.dateType = 6
  281. return [new Date(`${date.getFullYear()}-01-01`), date]
  282. }
  283. }
  284. ])
  285. /** 搜索按钮操作 */
  286. const handleQuery = () => {
  287. queryParams.value.pageNo = 1
  288. getList()
  289. }
  290. /** 重置按钮操作 */
  291. const resetQuery = () => {
  292. queryFormRef.value.resetFields()
  293. handleQuery()
  294. }
  295. /** 商品图预览 */
  296. const imagePreview = (imgUrl: string) => {
  297. createImageViewer({
  298. urlList: [imgUrl]
  299. })
  300. }
  301. /** 初始化 **/
  302. onMounted(async () => {
  303. await getSummary()
  304. await getList()
  305. })
  306. </script>