You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 7.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div>
  3. <div class="title"><span>资源规格单价管理</span></div>
  4. <div class="tools-bar">
  5. <div>
  6. <el-select class="select" size="medium" v-model="selQueue" @change="selectChange">
  7. <el-option v-for="item in queueList" :key="item.k" :label="item.v" :value="item.k" />
  8. </el-select>
  9. <el-select class="select" size="medium" v-model="selStatus" @change="selectChange">
  10. <el-option v-for="item in statusList" :key="item.k" :label="item.v" :value="item.k" />
  11. </el-select>
  12. </div>
  13. <div>
  14. <!-- syncComputerNetwork -->
  15. <el-button size="medium" icon="el-icon-refresh" @click="confirmOperate">同步智算网络</el-button>
  16. <el-button type="primary" icon="el-icon-plus" size="medium" @click="showDialog('add')">新增资源规格</el-button>
  17. </div>
  18. </div>
  19. <div class="table-container">
  20. <div>
  21. <el-table border :data="tableData" style="width: 100%" v-loading="loading" stripe>
  22. <el-table-column prop="id" label="ID" align="center" header-align="center" width="100"></el-table-column>
  23. <el-table-column prop="name" label="资源规格" align="left" header-align="center"></el-table-column>
  24. <el-table-column prop="queue" label="资源池(队列)" align="center" header-align="center"></el-table-column>
  25. <el-table-column prop="specID" label="智算网络资源规格ID" align="center" header-align="center"></el-table-column>
  26. <el-table-column prop="cardNum" label="卡数 " align="center" header-align="center"></el-table-column>
  27. <el-table-column prop="cpu" label="CPU " align="center" header-align="center"></el-table-column>
  28. <el-table-column prop="mem" label="内存(GB) " align="center" header-align="center"></el-table-column>
  29. <el-table-column prop="shareMem" label="共享内存(GB)" align="center" header-align="center"></el-table-column>
  30. <el-table-column prop="updateTime" label="最后更新时间" align="center" header-align="center"></el-table-column>
  31. <el-table-column prop="price" label="单价(积分/时)" align="center" header-align="center"></el-table-column>
  32. <el-table-column prop="status" label="状态" align="center" header-align="center">
  33. <template slot-scope="scope">
  34. {{ scope.row.status }}
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="操作" align="center" header-align="center" width="100">
  38. <template slot-scope="scope">
  39. <span class="op-btn" @click="showDialog('edit', scope.row)">定价</span>
  40. <span class="op-btn" @click="showDialog('edit', scope.row)">上架</span>
  41. </template>
  42. </el-table-column>
  43. <template slot="empty">
  44. <span style="font-size: 12px">{{
  45. loading ? '加载中...' : '暂无数据'
  46. }}</span>
  47. </template>
  48. </el-table>
  49. </div>
  50. <div class="__r_p_pagination">
  51. <div style="margin-top: 2rem">
  52. <div class="center">
  53. <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
  54. :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
  55. layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
  56. </el-pagination>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <SpecificationDialog :visible.sync="specificationDialogShow" :type="specificationDialogType"
  62. :data="specificationDialogData" @confirm="specificationDialogConfirm"></SpecificationDialog>
  63. </div>
  64. </template>
  65. <script>
  66. import SpecificationDialog from '../components/SpecificationDialog.vue';
  67. import { getQueueList } from '~/apis/modules/resources';
  68. export default {
  69. data() {
  70. return {
  71. selQueue: '',
  72. queueList: [{ k: '', v: '全部资源池' }, { k: '1', v: '资源池1' }, { k: '2', v: '资源池2' }],
  73. selStatus: '',
  74. statusList: [{ k: '', v: '全部状态' }, { k: '1', v: '待上架' }, { k: '2', v: '已上架' }, { k: '3', v: '已下架' }],
  75. syncLoading: false,
  76. loading: false,
  77. tableData: [],
  78. pageInfo: {
  79. curpage: 1,
  80. pageSize: 10,
  81. pageSizes: [10],
  82. total: 0,
  83. },
  84. specificationDialogShow: false,
  85. specificationDialogType: 'add',
  86. specificationDialogData: {},
  87. };
  88. },
  89. components: { SpecificationDialog },
  90. methods: {
  91. getTableData() {
  92. const params = {
  93. queue: this.selQueue,
  94. status: this.selStatus,
  95. curpage: this.pageInfo.curpage,
  96. pagesize: this.pageInfo.pageSize,
  97. };
  98. console.log('params', params);
  99. this.loading = true;
  100. getQueueList(params).then(res => {
  101. this.loading = false;
  102. // const data = res.data.
  103. const data = new Array(20).fill(0).map((_, index) => {
  104. return {
  105. index: index,
  106. id: `id-${index}-${Math.random().toFixed(2)}`,
  107. name: `name-${index}-${Math.random().toFixed(2)}`,
  108. queue: `queue-${index}-${Math.random().toFixed(2)}`,
  109. specID: `specID-${index}-${Math.random().toFixed(2)}`,
  110. cardNum: `cardNum-${index}-${Math.random().toFixed(2)}`,
  111. cpu: `cpu-${index}-${Math.random().toFixed(2)}`,
  112. mem: `mem-${index}-${Math.random().toFixed(2)}`,
  113. shareMem: `shareMem-${index}-${Math.random().toFixed(2)}`,
  114. updateTime: `updateTime-${index}-${Math.random().toFixed(2)}`,
  115. price: `price-${index}-${Math.random().toFixed(2)}`,
  116. status: `status-${index}-${Math.random().toFixed(2)}`,
  117. };
  118. });
  119. this.tableData = data;
  120. this.pageInfo.total = 99;
  121. }).catch(err => {
  122. console.log(err);
  123. this.loading = false;
  124. });
  125. },
  126. syncComputerNetwork() {
  127. //
  128. },
  129. selectChange() {
  130. this.pageInfo.curpage = 1;
  131. this.getTableData();
  132. },
  133. currentChange(val) {
  134. this.pageInfo.curpage = val;
  135. this.getTableData();
  136. },
  137. showDialog(type, data) {
  138. this.specificationDialogType = type;
  139. this.specificationDialogData = data ? { ...data } : {};
  140. this.specificationDialogShow = true;
  141. },
  142. specificationDialogConfirm() {
  143. this.specificationDialogShow = false;
  144. this.getTableData();
  145. },
  146. confirmOperate() {
  147. this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
  148. confirmButtonText: '确定',
  149. cancelButtonText: '取消',
  150. type: 'warning',
  151. lockScroll: false,
  152. }).then(() => {
  153. this.$message({
  154. type: 'success',
  155. message: '删除成功!'
  156. });
  157. }).catch(() => {
  158. this.$message({
  159. type: 'info',
  160. message: '已取消删除'
  161. });
  162. });
  163. }
  164. },
  165. mounted: function () {
  166. this.getTableData();
  167. },
  168. beforeDestroy: function () {
  169. },
  170. };
  171. </script>
  172. <style scoped lang="less">
  173. .title {
  174. height: 30px;
  175. display: flex;
  176. align-items: center;
  177. margin-bottom: 5px;
  178. span {
  179. font-weight: 700;
  180. font-size: 16px;
  181. color: rgb(16, 16, 16);
  182. }
  183. }
  184. .tools-bar {
  185. display: flex;
  186. align-items: center;
  187. justify-content: space-between;
  188. margin-bottom: 10px;
  189. .select {
  190. margin-right: 10px;
  191. /deep/ .el-input__inner {
  192. border-radius: 0;
  193. }
  194. }
  195. }
  196. .table-container {
  197. margin-bottom: 16px;
  198. /deep/ .el-table__header {
  199. th {
  200. background: rgb(245, 245, 246);
  201. font-size: 12px;
  202. color: rgb(36, 36, 36);
  203. }
  204. }
  205. /deep/ .el-table__body {
  206. td {
  207. font-size: 12px;
  208. }
  209. }
  210. .op-btn {
  211. cursor: pointer;
  212. font-size: 12px;
  213. color: rgb(25, 103, 252);
  214. margin: 0 5px;
  215. }
  216. }
  217. .center {
  218. display: flex;
  219. justify-content: center;
  220. }
  221. </style>