index.vue 2.8 KB

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