index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <style scoped lang="scss">
  2. .system-container {
  3. :deep(.el-card__body) {
  4. display: flex;
  5. flex-direction: column;
  6. justify-content: space-between;
  7. flex: 1;
  8. overflow: auto;
  9. .el-table {
  10. flex: 1;
  11. }
  12. }
  13. }
  14. .page-content {
  15. margin-bottom: 20px;
  16. }
  17. </style>
  18. <template>
  19. <div class="system-container layout-padding">
  20. <el-card shadow="hover" class="layout-padding-auto">
  21. <div class="page-search mb10">
  22. <el-select-v2
  23. v-model="state.filterStationId"
  24. :options="state.stationOptions"
  25. placeholder="按站点筛选"
  26. clearable
  27. style="width: 240px"
  28. @change="loadData"
  29. />
  30. <el-button v-auth="'rechargeConfig.add'" size="default" plain type="success" class="ml10" @click="handleRowClick('add', null)">
  31. <SvgIcon name="ele-FolderAdd"/>
  32. 新增
  33. </el-button>
  34. </div>
  35. <el-table
  36. border
  37. stripe
  38. :height="state.tableData.height"
  39. highlight-current-row
  40. row-key="id"
  41. :data="state.tableData.data"
  42. v-loading="state.tableData.loading">
  43. <template #empty>
  44. <el-empty></el-empty>
  45. </template>
  46. <el-table-column label="站点" prop="stationId" width="160">
  47. <template #default="{ row }">
  48. <el-tag v-if="row.stationId" type="success">{{ row.stationId }}</el-tag>
  49. <el-tag v-else type="info">平台默认</el-tag>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="充值金额" prop="rechargeAmount" width="140">
  53. <template #default="{ row }">
  54. {{ u.fmt.fmtMoney(row.rechargeAmount) }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="赠款金额" prop="grantsAmount" width="140">
  58. <template #default="{ row }">
  59. {{ u.fmt.fmtMoney(row.grantsAmount) }}
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="标签" prop="label" min-width="120">
  63. <template #default="{ row }">
  64. {{ row.label || '-' }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="创建时间" prop="createTime" width="180">
  68. <template #default="{ row }">
  69. {{ u.fmt.fmtDateTime(row.createTime) }}
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="操作" prop="action" width="160" align="center" fixed="right">
  73. <template #default="{ row }">
  74. <el-button v-auth="'rechargeConfig.modify'" type="warning" size="small" text @click="handleRowClick('edit', row)">编辑</el-button>
  75. <el-button v-auth="'rechargeConfig.remove'" type="danger" size="small" text @click="handleRowDelete(row)">删除</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. </el-card>
  80. </div>
  81. <RechargeConfigDialog ref="rechargeConfigDialogRef" @refresh="loadData"/>
  82. </template>
  83. <script setup lang="ts" name="AdminRechargeConfig">
  84. import { defineAsyncComponent, reactive, onMounted, ref, nextTick } from 'vue';
  85. import { $body, $get } from "/@/utils/request";
  86. import u from '/@/utils/u'
  87. import { Msg } from "/@/utils/message";
  88. const RechargeConfigDialog = defineAsyncComponent(() => import("/@/views/admin/platform/rechargeConfig/dialog.vue"));
  89. const rechargeConfigDialogRef = ref();
  90. const state = reactive({
  91. filterStationId: null as string | null,
  92. stationOptions: [] as Array<{ value: string; label: string }>,
  93. tableData: {
  94. height: 500,
  95. data: [] as Array<any>,
  96. loading: false,
  97. },
  98. });
  99. onMounted(() => {
  100. loadStations();
  101. loadData();
  102. });
  103. const loadStations = () => {
  104. $body('/washStation/list', { pageNum: 1, pageSize: 200 }).then((res: any) => {
  105. state.stationOptions = [
  106. { value: '__all__', label: '全部' },
  107. ...(res.list || []).map((s: any) => ({ value: s.stationId, label: s.stationName + ' (' + s.stationId + ')' })),
  108. ];
  109. });
  110. };
  111. const loadData = () => {
  112. state.tableData.loading = true;
  113. const url = state.filterStationId && state.filterStationId !== '__all__'
  114. ? `/rechargeConfig/list?stationId=${state.filterStationId}`
  115. : '/rechargeConfig/listAll';
  116. $get(url).then((res: any) => {
  117. state.tableData.data = res || [];
  118. state.tableData.loading = false;
  119. }).catch(() => {
  120. state.tableData.loading = false;
  121. });
  122. };
  123. const handleRowClick = (type: string, row: any) => {
  124. rechargeConfigDialogRef.value.open(type, row);
  125. };
  126. const handleRowDelete = (row: any) => {
  127. Msg.confirm(`此操作将永久删除该充值配置,是否继续?`).then(() => {
  128. $get(`/rechargeConfig/remove/${row.id}`).then(() => {
  129. Msg.message("删除成功", 'success');
  130. loadData();
  131. }).catch(() => {
  132. Msg.message("删除失败", 'error');
  133. });
  134. });
  135. };
  136. </script>