index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="用户昵称" prop="nickname">
  12. <el-input
  13. v-model="queryParams.nickname"
  14. placeholder="请输入用户昵称"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="手机号" prop="mobile">
  21. <el-input
  22. v-model="queryParams.mobile"
  23. placeholder="请输入手机号"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. class="!w-240px"
  27. />
  28. </el-form-item>
  29. <el-form-item label="注册时间" prop="createTime">
  30. <el-date-picker
  31. v-model="queryParams.createTime"
  32. value-format="YYYY-MM-DD HH:mm:ss"
  33. type="daterange"
  34. start-placeholder="开始日期"
  35. end-placeholder="结束日期"
  36. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  37. class="!w-240px"
  38. />
  39. </el-form-item>
  40. <el-form-item label="登录时间" prop="loginDate">
  41. <el-date-picker
  42. v-model="queryParams.loginDate"
  43. value-format="YYYY-MM-DD HH:mm:ss"
  44. type="daterange"
  45. start-placeholder="开始日期"
  46. end-placeholder="结束日期"
  47. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  48. class="!w-240px"
  49. />
  50. </el-form-item>
  51. <el-form-item label="用户标签" prop="tagIds">
  52. <MemberTagSelect v-model="queryParams.tagIds" />
  53. </el-form-item>
  54. <el-form-item label="用户等级" prop="levelId">
  55. <MemberLevelSelect v-model="queryParams.levelId" />
  56. </el-form-item>
  57. <el-form-item label="用户分组" prop="groupId">
  58. <MemberGroupSelect v-model="queryParams.groupId" />
  59. </el-form-item>
  60. <el-form-item>
  61. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  62. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  63. </el-form-item>
  64. </el-form>
  65. </ContentWrap>
  66. <!-- 列表 -->
  67. <ContentWrap>
  68. <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
  69. <el-table-column label="用户编号" align="center" prop="id" width="120px" />
  70. <el-table-column label="头像" align="center" prop="avatar" width="80px">
  71. <template #default="scope">
  72. <img :src="scope.row.avatar" style="width: 40px" />
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="手机号" align="center" prop="mobile" width="120px" />
  76. <el-table-column label="昵称" align="center" prop="nickname" width="80px" />
  77. <el-table-column label="等级" align="center" prop="levelName" width="100px" />
  78. <el-table-column label="分组" align="center" prop="groupName" width="100px" />
  79. <el-table-column
  80. label="用户标签"
  81. align="center"
  82. prop="tagNames"
  83. :show-overflow-tooltip="false"
  84. >
  85. <template #default="scope">
  86. <el-tag v-for="(tagName, index) in scope.row.tagNames" :key="index" class="mr-5px">
  87. {{ tagName }}
  88. </el-tag>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="积分" align="center" prop="point" width="100px" />
  92. <el-table-column label="状态" align="center" prop="status" width="100px">
  93. <template #default="scope">
  94. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. label="登录时间"
  99. align="center"
  100. prop="loginDate"
  101. :formatter="dateFormatter"
  102. width="180px"
  103. />
  104. <el-table-column
  105. label="注册时间"
  106. align="center"
  107. prop="createTime"
  108. :formatter="dateFormatter"
  109. width="180px"
  110. />
  111. <el-table-column label="操作" align="center">
  112. <template #default="scope">
  113. <el-button
  114. link
  115. type="primary"
  116. @click="goMemberDetail(scope.row.id)"
  117. v-hasPermi="['member:user:update']"
  118. >
  119. 详情
  120. </el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <!-- 分页 -->
  125. <Pagination
  126. :total="total"
  127. v-model:page="queryParams.pageNo"
  128. v-model:limit="queryParams.pageSize"
  129. @pagination="getList"
  130. />
  131. </ContentWrap>
  132. </template>
  133. <script setup lang="ts">
  134. import { dateFormatter } from '@/utils/formatTime'
  135. import * as UserApi from '@/api/member/user'
  136. import { DICT_TYPE } from '@/utils/dict'
  137. import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
  138. import MemberLevelSelect from '@/views/member/level/components/MemberLevelSelect.vue'
  139. import MemberGroupSelect from '@/views/member/group/components/MemberGroupSelect.vue'
  140. defineOptions({ name: 'MemberUser' })
  141. const loading = ref(true) // 列表的加载中
  142. const total = ref(0) // 列表的总页数
  143. const list = ref([]) // 列表的数据
  144. const queryParams = reactive({
  145. pageNo: 1,
  146. pageSize: 10,
  147. nickname: null,
  148. mobile: null,
  149. loginDate: [],
  150. createTime: [],
  151. tagIds: [],
  152. levelId: null,
  153. groupId: null
  154. })
  155. const queryFormRef = ref() // 搜索的表单
  156. /** 查询列表 */
  157. const getList = async () => {
  158. loading.value = true
  159. try {
  160. const data = await UserApi.getUserPage(queryParams)
  161. list.value = data.list
  162. total.value = data.total
  163. } finally {
  164. loading.value = false
  165. }
  166. }
  167. /** 搜索按钮操作 */
  168. const handleQuery = () => {
  169. queryParams.pageNo = 1
  170. getList()
  171. }
  172. /** 重置按钮操作 */
  173. const resetQuery = () => {
  174. queryFormRef.value.resetFields()
  175. handleQuery()
  176. }
  177. const { push } = useRouter()
  178. const goMemberDetail = (id: number) => {
  179. push({ name: 'MemberUserDetail', params: { member_id: id } })
  180. }
  181. /** 初始化 **/
  182. onMounted(() => {
  183. getList()
  184. })
  185. </script>