index.vue 4.5 KB

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