index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="quota">
  3. <div class="quota-list">
  4. <el-table :data="data_list">
  5. <el-table-column label="机构" width="176">
  6. <template slot-scope="{ row }">
  7. <router-link :to="`/quota/usageRecord/${row.org_id}/${row.org_name}`">
  8. {{ row.org_name }}
  9. </router-link>
  10. </template>
  11. </el-table-column>
  12. <el-table-column prop="quota_lave" label="1v1余量" width="160">
  13. <template slot-scope="{ row }"> {{ row.quota_lave_1v1_online }}小时 </template>
  14. </el-table-column>
  15. <el-table-column prop="quota_lave" label="1v1余额" width="160">
  16. <template slot-scope="{ row }"> {{ row.money_lave_1v1_online }}元 </template>
  17. </el-table-column>
  18. <el-table-column prop="quota_lave" label="1v多余量" width="160">
  19. <template slot-scope="{ row }"> {{ row.quota_lave_1vm_online }}小时 </template>
  20. </el-table-column>
  21. <el-table-column prop="quota_lave" label="1v多余额" width="160">
  22. <template slot-scope="{ row }"> {{ row.money_lave_1vm_online }}元 </template>
  23. </el-table-column>
  24. <el-table-column prop="quota_status" label="状态" width="160">
  25. <template slot-scope="{ row }">
  26. <span :style="{ color: row.quota_status ? '#019319' : '#CA0000' }">
  27. {{ row.quota_status ? '使用中' : '已停用' }}
  28. </span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="操作" fixed="right">
  32. <template slot-scope="{ row }">
  33. <span class="set-quota operation" @click="setQuota(row.org_id)">设置配额</span>
  34. <span class="operation" @click="setStatus(row.org_id, !row.quota_status)">
  35. {{ row.quota_status ? '停用' : '启用' }}
  36. </span>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. </div>
  41. <el-pagination
  42. background
  43. :page-sizes="[10, 20, 30, 40, 50]"
  44. :page-size="page_capacity"
  45. layout="prev, pager, next, total, sizes, jumper"
  46. :total="total_count"
  47. :current-page="cur_page"
  48. @prev-click="changePage"
  49. @next-click="changePage"
  50. @current-change="changePage"
  51. @size-change="changePageSize"
  52. />
  53. <set-quota :org-id="curOrgId" :visible="visible" @close="closeSetQuota" />
  54. </div>
  55. </template>
  56. <script>
  57. import { PageQueryOrgQuotaList } from '@/api/list';
  58. import { EnableOrgQuota } from '@/api/org';
  59. import SetQuota from './SetQuota.vue';
  60. export default {
  61. name: 'QuotaList',
  62. components: { SetQuota },
  63. data() {
  64. return {
  65. data_list: [],
  66. page_capacity: 10,
  67. total_count: 0,
  68. cur_page: 1,
  69. visible: false,
  70. curOrgId: ''
  71. };
  72. },
  73. created() {
  74. this.pageQueryOrgQuotaList();
  75. },
  76. methods: {
  77. pageQueryOrgQuotaList() {
  78. PageQueryOrgQuotaList({
  79. page_capacity: this.page_capacity,
  80. cur_page: this.cur_page
  81. }).then(({ data_list, total_count, cur_page }) => {
  82. this.data_list = data_list;
  83. this.total_count = total_count;
  84. this.cur_page = cur_page;
  85. });
  86. },
  87. changePage(newPage) {
  88. this.cur_page = newPage;
  89. this.pageQueryOrgQuotaList();
  90. },
  91. changePageSize(pageSize) {
  92. this.page_capacity = pageSize;
  93. this.pageQueryOrgQuotaList();
  94. },
  95. setQuota(org_id) {
  96. this.visible = true;
  97. this.curOrgId = org_id;
  98. },
  99. setStatus(org_id, is_enabled) {
  100. EnableOrgQuota({
  101. org_id,
  102. is_enabled
  103. }).then(() => {
  104. this.$message.success(`${is_enabled ? '启用' : '停用'}机构配额成功`);
  105. this.pageQueryOrgQuotaList();
  106. });
  107. },
  108. closeSetQuota() {
  109. this.visible = false;
  110. this.curOrgId = '';
  111. }
  112. }
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. @import '~@/styles/mixin';
  117. .quota {
  118. @include container;
  119. @include pagination;
  120. @include dialog;
  121. padding: 24px 0 46px;
  122. &-list {
  123. @include list;
  124. padding: 0 32px;
  125. .el-table {
  126. .set-quota {
  127. margin-right: 12px;
  128. }
  129. ::v-deep th.el-table__cell {
  130. color: #000;
  131. }
  132. }
  133. }
  134. }
  135. </style>