index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <ele-page flex-table :bodyStyle="{ padding: 0 }">
  3. <page-search @search="reload" />
  4. <common-table ref="tableRef" :columns="columns" :page-config="pageConfig" :bodyStyle="{ padding: 0 }">
  5. <template #toolbar>
  6. <el-button type="primary" plain :icon="Plus" @click="handleCreate">
  7. 新增
  8. </el-button>
  9. </template>
  10. <template #time="{ row }">
  11. {{ row.startTime }} 至 {{ row.endTime }}
  12. </template>
  13. <template #limitFirst="{ row }">
  14. <el-tag :type="String(row.limitFirst) === '1' ? 'success' : 'info'">
  15. {{ String(row.limitFirst) === '1' ? '限制' : '不限制' }}
  16. </el-tag>
  17. </template>
  18. <template #status="{ row }">
  19. <el-tag :type="String(row.status) === '1' ? 'success' : 'danger'">
  20. {{ String(row.status) === '1' ? '开启' : '关闭' }}
  21. </el-tag>
  22. </template>
  23. <template #action="{ row }">
  24. <div>
  25. <el-button type="primary" link @click="handleEdit(row)">
  26. [编辑]
  27. </el-button>
  28. <el-button type="success" link @click="handleViewData(row)">
  29. [查看数据]
  30. </el-button>
  31. <el-button :type="String(row.status) === '1' ? 'danger' : 'success'" link
  32. @click="handleToggleStatus(row)">
  33. [{{ String(row.status) === '1' ? '关闭活动' : '启动活动' }}]
  34. </el-button>
  35. </div>
  36. </template>
  37. </common-table>
  38. <activity-edit ref="activityEditRef" @success="reload" />
  39. </ele-page>
  40. </template>
  41. <script setup>
  42. import { ref, reactive } from 'vue';
  43. import { EleMessage } from 'ele-admin-plus/es';
  44. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  45. import request from '@/utils/request';
  46. import PageSearch from './components/PageSearch.vue';
  47. import ActivityEdit from './components/ActivityEdit.vue';
  48. import { Plus } from '@element-plus/icons-vue';
  49. defineOptions({ name: 'ShareDiscountActivity' });
  50. const tableRef = ref(null);
  51. const activityEditRef = ref(null);
  52. const pageConfig = reactive({
  53. pageUrl: '/activity/activityReduceInfo/pagelist',
  54. fileName: '分享降价活动列表',
  55. cacheKey: 'shareDiscountActivityTable',
  56. rowKey: 'id'
  57. });
  58. const columns = ref([
  59. { label: '活动名称', prop: 'activityName', minWidth: 150 },
  60. { label: '活动时间', slot: 'time', minWidth: 300 },
  61. { label: '是否限制首单', slot: 'limitFirst', minWidth: 120 },
  62. { label: '状态', slot: 'status', minWidth: 100 },
  63. { label: '创建时间', prop: 'createTime', minWidth: 180 },
  64. { label: '操作', slot: 'action', minWidth: 200, fixed: 'right' }
  65. ]);
  66. const reload = (where) => {
  67. tableRef.value?.reload(where);
  68. };
  69. const handleCreate = () => {
  70. activityEditRef.value?.handleOpen();
  71. };
  72. const handleEdit = (row) => {
  73. activityEditRef.value?.handleOpen(row);
  74. };
  75. const handleViewData = (row) => {
  76. EleMessage.info('查看数据功能待对接');
  77. };
  78. const handleToggleStatus = (row) => {
  79. // 0-关闭 1-开启
  80. let message = row.status == 1 ? '确认关闭活动?' : '确认开启活动?';
  81. let data = {
  82. activityId: row.id,
  83. status: row.status == 1 ? 0 : 1
  84. };
  85. pageRef.value?.messageBoxConfirm({
  86. message,
  87. fetch: () => request.post('/activity/activityReduceInfo/changeStatus', data)
  88. });
  89. };
  90. </script>