|
- <template>
- <div>
- <div class="title"><span>资源规格单价管理</span></div>
- <div class="tools-bar">
- <div>
- <el-select class="select" size="medium" v-model="selQueue" @change="selectChange">
- <el-option v-for="item in queueList" :key="item.k" :label="item.v" :value="item.k" />
- </el-select>
- <el-select class="select" size="medium" v-model="selStatus" @change="selectChange">
- <el-option v-for="item in statusList" :key="item.k" :label="item.v" :value="item.k" />
- </el-select>
- </div>
- <div>
- <!-- syncComputerNetwork -->
- <el-button size="medium" icon="el-icon-refresh" @click="confirmOperate">同步智算网络</el-button>
- <el-button type="primary" icon="el-icon-plus" size="medium" @click="showDialog('add')">新增资源规格</el-button>
- </div>
- </div>
- <div class="table-container">
- <div>
- <el-table border :data="tableData" style="width: 100%" v-loading="loading" stripe>
- <el-table-column prop="id" label="ID" align="center" header-align="center" width="100"></el-table-column>
- <el-table-column prop="name" label="资源规格" align="left" header-align="center"></el-table-column>
- <el-table-column prop="queue" label="资源池(队列)" align="center" header-align="center"></el-table-column>
- <el-table-column prop="specID" label="智算网络资源规格ID" align="center" header-align="center"></el-table-column>
- <el-table-column prop="cardNum" label="卡数 " align="center" header-align="center"></el-table-column>
- <el-table-column prop="cpu" label="CPU " align="center" header-align="center"></el-table-column>
- <el-table-column prop="mem" label="内存(GB) " align="center" header-align="center"></el-table-column>
- <el-table-column prop="shareMem" label="共享内存(GB)" align="center" header-align="center"></el-table-column>
- <el-table-column prop="updateTime" label="最后更新时间" align="center" header-align="center"></el-table-column>
- <el-table-column prop="price" label="单价(积分/时)" align="center" header-align="center"></el-table-column>
- <el-table-column prop="status" label="状态" align="center" header-align="center">
- <template slot-scope="scope">
- {{ scope.row.status }}
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" header-align="center" width="100">
- <template slot-scope="scope">
- <span class="op-btn" @click="showDialog('edit', scope.row)">定价</span>
- <span class="op-btn" @click="showDialog('edit', scope.row)">上架</span>
- </template>
- </el-table-column>
- <template slot="empty">
- <span style="font-size: 12px">{{
- loading ? '加载中...' : '暂无数据'
- }}</span>
- </template>
- </el-table>
- </div>
- <div class="__r_p_pagination">
- <div style="margin-top: 2rem">
- <div class="center">
- <el-pagination background @current-change="currentChange" :current-page="pageInfo.curpage"
- :page-sizes="pageInfo.pageSizes" :page-size="pageInfo.pageSize"
- layout="total, sizes, prev, pager, next, jumper" :total="pageInfo.total">
- </el-pagination>
- </div>
- </div>
- </div>
- </div>
- <SpecificationDialog :visible.sync="specificationDialogShow" :type="specificationDialogType"
- :data="specificationDialogData" @confirm="specificationDialogConfirm"></SpecificationDialog>
- </div>
- </template>
-
- <script>
- import SpecificationDialog from '../components/SpecificationDialog.vue';
- import { getQueueList } from '~/apis/modules/resources';
-
- export default {
- data() {
- return {
- selQueue: '',
- queueList: [{ k: '', v: '全部资源池' }, { k: '1', v: '资源池1' }, { k: '2', v: '资源池2' }],
- selStatus: '',
- statusList: [{ k: '', v: '全部状态' }, { k: '1', v: '待上架' }, { k: '2', v: '已上架' }, { k: '3', v: '已下架' }],
- syncLoading: false,
- loading: false,
- tableData: [],
- pageInfo: {
- curpage: 1,
- pageSize: 10,
- pageSizes: [10],
- total: 0,
- },
- specificationDialogShow: false,
- specificationDialogType: 'add',
- specificationDialogData: {},
- };
- },
- components: { SpecificationDialog },
- methods: {
- getTableData() {
- const params = {
- queue: this.selQueue,
- status: this.selStatus,
- curpage: this.pageInfo.curpage,
- pagesize: this.pageInfo.pageSize,
- };
- console.log('params', params);
- this.loading = true;
- getQueueList(params).then(res => {
- this.loading = false;
- // const data = res.data.
- const data = new Array(20).fill(0).map((_, index) => {
- return {
- index: index,
- id: `id-${index}-${Math.random().toFixed(2)}`,
- name: `name-${index}-${Math.random().toFixed(2)}`,
- queue: `queue-${index}-${Math.random().toFixed(2)}`,
- specID: `specID-${index}-${Math.random().toFixed(2)}`,
- cardNum: `cardNum-${index}-${Math.random().toFixed(2)}`,
- cpu: `cpu-${index}-${Math.random().toFixed(2)}`,
- mem: `mem-${index}-${Math.random().toFixed(2)}`,
- shareMem: `shareMem-${index}-${Math.random().toFixed(2)}`,
- updateTime: `updateTime-${index}-${Math.random().toFixed(2)}`,
- price: `price-${index}-${Math.random().toFixed(2)}`,
- status: `status-${index}-${Math.random().toFixed(2)}`,
- };
- });
- this.tableData = data;
- this.pageInfo.total = 99;
- }).catch(err => {
- console.log(err);
- this.loading = false;
- });
- },
- syncComputerNetwork() {
- //
- },
- selectChange() {
- this.pageInfo.curpage = 1;
- this.getTableData();
- },
- currentChange(val) {
- this.pageInfo.curpage = val;
- this.getTableData();
- },
- showDialog(type, data) {
- this.specificationDialogType = type;
- this.specificationDialogData = data ? { ...data } : {};
- this.specificationDialogShow = true;
- },
- specificationDialogConfirm() {
- this.specificationDialogShow = false;
- this.getTableData();
- },
- confirmOperate() {
- this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- lockScroll: false,
- }).then(() => {
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- }
- },
- mounted: function () {
- this.getTableData();
- },
- beforeDestroy: function () {
- },
- };
- </script>
-
- <style scoped lang="less">
- .title {
- height: 30px;
- display: flex;
- align-items: center;
- margin-bottom: 5px;
-
- span {
- font-weight: 700;
- font-size: 16px;
- color: rgb(16, 16, 16);
- }
- }
-
- .tools-bar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 10px;
-
- .select {
- margin-right: 10px;
-
- /deep/ .el-input__inner {
- border-radius: 0;
- }
- }
- }
-
- .table-container {
- margin-bottom: 16px;
-
- /deep/ .el-table__header {
- th {
- background: rgb(245, 245, 246);
- font-size: 12px;
- color: rgb(36, 36, 36);
- }
- }
-
- /deep/ .el-table__body {
- td {
- font-size: 12px;
- }
- }
-
- .op-btn {
- cursor: pointer;
- font-size: 12px;
- color: rgb(25, 103, 252);
- margin: 0 5px;
- }
- }
-
- .center {
- display: flex;
- justify-content: center;
- }
- </style>
|