index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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="userId">
  12. <el-input
  13. v-model="queryParams.userId"
  14. placeholder="请输入签到用户"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="签到天数" prop="day">
  21. <el-input
  22. v-model="queryParams.day"
  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>
  41. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  42. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  43. <!-- <el-button-->
  44. <!-- type="primary"-->
  45. <!-- plain-->
  46. <!-- @click="openForm('create')"-->
  47. <!-- v-hasPermi="['point:sign-in-record:create']"-->
  48. <!-- >-->
  49. <!-- <Icon icon="ep:plus" class="mr-5px" /> 新增-->
  50. <!-- </el-button>-->
  51. <el-button
  52. type="success"
  53. plain
  54. @click="handleExport"
  55. :loading="exportLoading"
  56. v-hasPermi="['point:sign-in-record:export']"
  57. >
  58. <Icon icon="ep:download" class="mr-5px" /> 导出
  59. </el-button>
  60. </el-form-item>
  61. </el-form>
  62. </ContentWrap>
  63. <!-- 列表 -->
  64. <ContentWrap>
  65. <el-table v-loading="loading" :data="list">
  66. <el-table-column label="序号" align="center" prop="id" />
  67. <el-table-column label="签到用户" align="center" prop="userId" />
  68. <el-table-column label="签到天数" align="center" prop="day" />
  69. <el-table-column label="签到的分数" align="center" prop="point" />
  70. <el-table-column
  71. label="签到时间"
  72. align="center"
  73. prop="createTime"
  74. :formatter="dateFormatter"
  75. />
  76. <el-table-column label="操作" align="center">
  77. <template #default="scope">
  78. <!-- <el-button-->
  79. <!-- link-->
  80. <!-- type="primary"-->
  81. <!-- @click="openForm('update', scope.row.id)"-->
  82. <!-- v-hasPermi="['point:sign-in-record:update']"-->
  83. <!-- >-->
  84. <!-- 编辑-->
  85. <!-- </el-button>-->
  86. <el-button
  87. link
  88. type="danger"
  89. @click="handleDelete(scope.row.id)"
  90. v-hasPermi="['point:sign-in-record:delete']"
  91. >
  92. 删除
  93. </el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <!-- 分页 -->
  98. <Pagination
  99. :total="total"
  100. v-model:page="queryParams.pageNo"
  101. v-model:limit="queryParams.pageSize"
  102. @pagination="getList"
  103. />
  104. </ContentWrap>
  105. <!-- 表单弹窗:添加/修改 -->
  106. <SignInRecordForm ref="formRef" @success="getList" />
  107. </template>
  108. <script setup lang="ts" name="SignInRecord">
  109. import { dateFormatter } from '@/utils/formatTime'
  110. import download from '@/utils/download'
  111. import * as SignInRecordApi from '@/api/point/signInRecord'
  112. import SignInRecordForm from './SignInRecordForm.vue'
  113. const message = useMessage() // 消息弹窗
  114. const { t } = useI18n() // 国际化
  115. const loading = ref(true) // 列表的加载中
  116. const total = ref(0) // 列表的总页数
  117. const list = ref([]) // 列表的数据
  118. const queryParams = reactive({
  119. pageNo: 1,
  120. pageSize: 10,
  121. userId: null,
  122. day: null,
  123. createTime: []
  124. })
  125. const queryFormRef = ref() // 搜索的表单
  126. const exportLoading = ref(false) // 导出的加载中
  127. /** 查询列表 */
  128. const getList = async () => {
  129. loading.value = true
  130. try {
  131. const data = await SignInRecordApi.getSignInRecordPage(queryParams)
  132. list.value = data.list
  133. total.value = data.total
  134. } finally {
  135. loading.value = false
  136. }
  137. }
  138. /** 搜索按钮操作 */
  139. const handleQuery = () => {
  140. queryParams.pageNo = 1
  141. getList()
  142. }
  143. /** 重置按钮操作 */
  144. const resetQuery = () => {
  145. queryFormRef.value.resetFields()
  146. handleQuery()
  147. }
  148. /** 添加/修改操作 */
  149. // const formRef = ref()
  150. // const openForm = (type: string, id?: number) => {
  151. // formRef.value.open(type, id)
  152. // }
  153. /** 删除按钮操作 */
  154. const handleDelete = async (id: number) => {
  155. try {
  156. // 删除的二次确认
  157. await message.delConfirm()
  158. // 发起删除
  159. await SignInRecordApi.deleteSignInRecord(id)
  160. message.success(t('common.delSuccess'))
  161. // 刷新列表
  162. await getList()
  163. } catch {}
  164. }
  165. /** 导出按钮操作 */
  166. const handleExport = async () => {
  167. try {
  168. // 导出的二次确认
  169. await message.exportConfirm()
  170. // 发起导出
  171. exportLoading.value = true
  172. const data = await SignInRecordApi.exportSignInRecord(queryParams)
  173. download.excel(data, '用户签到积分.xls')
  174. } catch {
  175. } finally {
  176. exportLoading.value = false
  177. }
  178. }
  179. /** 初始化 **/
  180. onMounted(() => {
  181. getList()
  182. })
  183. </script>