index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-button
  5. type="primary"
  6. plain
  7. @click="openForm('create')"
  8. v-hasPermi="['point:sign-in-config:create']"
  9. >
  10. <Icon icon="ep:plus" class="mr-5px" /> 新增
  11. </el-button>
  12. </ContentWrap>
  13. <!-- 列表 -->
  14. <ContentWrap>
  15. <el-table v-loading="loading" :data="list">
  16. <el-table-column
  17. label="签到天数"
  18. align="center"
  19. prop="day"
  20. :formatter="(_, __, cellValue) => ['第', cellValue, '天'].join(' ')"
  21. />
  22. <el-table-column label="奖励积分" align="center" prop="point" />
  23. <el-table-column label="奖励经验" align="center" prop="experience" />
  24. <el-table-column label="状态" align="center" prop="status">
  25. <template #default="scope">
  26. <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="操作" align="center">
  30. <template #default="scope">
  31. <el-button
  32. link
  33. type="primary"
  34. @click="openForm('update', scope.row.id)"
  35. v-hasPermi="['point:sign-in-config:update']"
  36. >
  37. 编辑
  38. </el-button>
  39. <el-button
  40. link
  41. type="danger"
  42. @click="handleDelete(scope.row.id)"
  43. v-hasPermi="['point:sign-in-config:delete']"
  44. >
  45. 删除
  46. </el-button>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. </ContentWrap>
  51. <!-- 表单弹窗:添加/修改 -->
  52. <SignInConfigForm ref="formRef" @success="getList" />
  53. </template>
  54. <script lang="ts" setup>
  55. import * as SignInConfigApi from '@/api/member/signin/config'
  56. import SignInConfigForm from './SignInConfigForm.vue'
  57. import { DICT_TYPE } from '@/utils/dict'
  58. defineOptions({ name: 'SignInConfig' })
  59. const message = useMessage() // 消息弹窗
  60. const { t } = useI18n() // 国际化
  61. const loading = ref(true) // 列表的加载中
  62. const list = ref([]) // 列表的数据
  63. /** 查询列表 */
  64. const getList = async () => {
  65. loading.value = true
  66. try {
  67. const data = await SignInConfigApi.getSignInConfigList()
  68. console.log(data)
  69. list.value = data
  70. } finally {
  71. loading.value = false
  72. }
  73. }
  74. /** 添加/修改操作 */
  75. const formRef = ref()
  76. const openForm = (type: string, id?: number) => {
  77. formRef.value.open(type, id)
  78. }
  79. /** 删除按钮操作 */
  80. const handleDelete = async (id: number) => {
  81. try {
  82. // 删除的二次确认
  83. await message.delConfirm()
  84. // 发起删除
  85. await SignInConfigApi.deleteSignInConfig(id)
  86. message.success(t('common.delSuccess'))
  87. // 刷新列表
  88. await getList()
  89. } catch {}
  90. }
  91. /** 初始化 **/
  92. onMounted(() => {
  93. getList()
  94. })
  95. </script>