|
- <template>
- <div>
- <div class="title"><span>{{ $t('resourcesManagement.resSpecificationAndPriceManagement') }}</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">
- {{ $t('resourcesManagement.syncAiNetwork') }}</el-button>
- <el-button type="primary" icon="el-icon-plus" size="medium" @click="showDialog('add')">
- {{ $t('resourcesManagement.addResSpecificationBtn') }}</el-button>
- </div>
- </div>
- <div class="table-container">
- <div style="min-height:600px;">
- <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="60"></el-table-column>
- <el-table-column prop="SpecStr" :label="$t('resourcesManagement.resourceSpecification')" align="left"
- header-align="center" min-width="160">
- </el-table-column>
- <el-table-column prop="QueueInfo" :label="$t('resourcesManagement.resQueue')" align="center"
- header-align="center" min-width="100">
- </el-table-column>
- <el-table-column prop="SourceSpecId" :label="$t('resourcesManagement.sourceSpecId')" align="center"
- header-align="center">
- </el-table-column>
- <el-table-column prop="AccCardsNum" :label="$t('resourcesManagement.accCardsNum')" align="center"
- header-align="center"></el-table-column>
- <el-table-column prop="CpuCores" :label="$t('resourcesManagement.cpuNum') " align="center" header-align="center"></el-table-column>
- <el-table-column prop="GPUMemGiB" :label="`${$t('resourcesManagement.gpuMem')}(GB)`" align="center"
- header-align="center"></el-table-column>
- <el-table-column prop="MemGiB" :label="`${$t('resourcesManagement.mem')}(GB)`" align="center"
- header-align="center"></el-table-column>
- <el-table-column prop="ShareMemGiB" :label="`${$t('resourcesManagement.shareMem')}(GB)`" align="center"
- header-align="center"></el-table-column>
- <el-table-column prop="UpdatedTimeStr" :label="$t('resourcesManagement.lastUpdateTime')" align="center"
- header-align="center"></el-table-column>
- <el-table-column prop="UnitPrice"
- :label="`${$t('resourcesManagement.unitPrice')}(${$t('resourcesManagement.point_hr')})`" align="center"
- header-align="center">
- <template slot-scope="scope">
- <span style="font-weight:600;font-size:14px;">{{ scope.row.UnitPrice }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="StatusStr" :label="$t('resourcesManagement.status')" align="center"
- header-align="center" width="100">
- <template slot-scope="scope">
- <span :style="{ color: scope.row.Status == '2' ? 'rgb(82, 196, 26)' : 'rgb(245, 34, 45)' }">{{
- scope.row.StatusStr
- }}</span>
- </template>
- </el-table-column>
- <el-table-column :label="$t('operation')" align="center" header-align="center" width="100">
- <template slot-scope="scope">
- <span v-if="scope.row.Status == '1' && !scope.row.UnitPrice">
- <span class="op-btn" @click="showDialog('edit', scope.row)">{{
- $t('resourcesManagement.toSetPriceAndOnShelf')
- }}</span>
- </span>
- <span v-if="scope.row.Status == '2'">
- <span class="op-btn" @click="showDialog('edit', scope.row)">{{ $t('edit') }}</span>
- <span class="op-btn" @click="onOrOffShelf('off-shelf', scope.row)">{{
- $t('resourcesManagement.toOffShelf')
- }}</span>
- </span>
- <span v-if="scope.row.Status == '3' || scope.row.Status == '1' && scope.row.UnitPrice">
- <span class="op-btn" @click="onOrOffShelf('on-shelf', scope.row)">{{
- $t('resourcesManagement.toOnShelf')
- }}</span>
- </span>
- </template>
- </el-table-column>
- <template slot="empty">
- <span style="font-size: 12px">{{
- loading ? $t('loading') : $t('noData')
- }}</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 { getResQueueCode, getResSpecificationList, updateResSpecification } from '~/apis/modules/resources';
- import { SPECIFICATION_STATUS, CLUSTERS, AI_CENTER, ACC_CARD_TYPE } from '~/const';
- import { getListValueWithKey } from '~/utils';
- import { formatDate } from 'element-ui/lib/utils/date-util';
-
- export default {
- data() {
- return {
- selQueue: '',
- queueList: [{ k: '', v: this.$t('resourcesManagement.allResQueue') }],
- selStatus: '',
- statusList: [{ k: '', v: this.$t('resourcesManagement.allStatus') }, ...SPECIFICATION_STATUS],
- clusterList: [...CLUSTERS],
- aiCenterList: [...AI_CENTER],
- accCardTypeList: [...ACC_CARD_TYPE],
- syncLoading: false,
- loading: false,
- tableData: [],
- pageInfo: {
- curpage: 1,
- pageSize: 10,
- pageSizes: [10],
- total: 0,
- },
- specificationDialogShow: false,
- specificationDialogType: 'add',
- specificationDialogData: {},
- };
- },
- components: { SpecificationDialog },
- methods: {
- getQueueList() {
- getResQueueCode().then(res => {
- res = res.data;
- if (res.Code === 0) {
- const data = res.Data;
- const list = [];
- for (let i = 0, iLen = data.length; i < iLen; i++) {
- const item = data[i];
- list.push({
- k: item.ID,
- v: `${item.QueueCode}(${getListValueWithKey(this.clusterList, item.Cluster)} - ${getListValueWithKey(this.aiCenterList, item.AiCenterCode)})`,
- });
- }
- this.queueList.push(...list);
- }
- }).catch(err => {
- console.log(err);
- });
- },
- getTableData() {
- const params = {
- queue: this.selQueue,
- status: this.selStatus,
- page: this.pageInfo.curpage,
- pagesize: this.pageInfo.pageSize,
- };
- this.loading = true;
- getResSpecificationList(params).then(res => {
- this.loading = false;
- res = res.data;
- if (res.Code === 0) {
- const list = res.Data.List;
- const data = list.map((item) => {
- const Queue = item.Queue;
- const Spec = item.Spec;
- const NGPU = `${Queue.ComputeResource}:${Spec.AccCardsNum === 0 ? '0' : Spec.AccCardsNum + '*' + getListValueWithKey(this.accCardTypeList, Queue.AccCardType)}`;
- return {
- ...Spec,
- SpecStr: `${NGPU}, CPU:${Spec.CpuCores}, ${this.$t('resourcesManagement.gpuMem')}:${Spec.GPUMemGiB}GB, ${this.$t('resourcesManagement.mem')}:${Spec.MemGiB}GB, ${this.$t('resourcesManagement.shareMem')}:${Spec.ShareMemGiB}GB`,
- QueueId: Queue.ID,
- QueueInfo: `${Queue.QueueCode}(${getListValueWithKey(this.clusterList, Queue.Cluster)} - ${getListValueWithKey(this.aiCenterList, Queue.AiCenterCode)})`,
- UpdatedTimeStr: formatDate(new Date(Spec.UpdatedTime * 1000), 'yyyy-MM-dd HH:mm:ss'),
- Status: Spec.Status.toString(),
- StatusStr: getListValueWithKey(this.statusList, Spec.Status.toString()),
- }
- });
- this.tableData = data;
- this.pageInfo.total = res.Data.TotalSize;
- }
- }).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();
- },
- onOrOffShelf(type, data) {
- this.$confirm(type === 'on-shelf' ? this.$t('resourcesManagement.onShelfConfirm') : this.$t('resourcesManagement.offShelfConfirm'), this.$t('tips'), {
- confirmButtonText: this.$t('confirm'),
- cancelButtonText: this.$t('cancel'),
- type: 'warning',
- lockScroll: false,
- }).then(() => {
- updateResSpecification({
- ID: data.ID,
- action: type
- }).then(res => {
- res = res.data;
- if (res.Code === 0) {
- this.$message({
- type: 'success',
- message: this.$t('submittedSuccessfully')
- });
- this.getTableData();
- } else {
- this.$message({
- type: 'error',
- message: this.$t('submittedFailed')
- });
- }
- }).catch(err => {
- console.log(err);
- this.$message({
- type: 'error',
- message: this.$t('submittedFailed')
- });
- });
- }).catch(() => { });
- },
- confirmOperate() {
- this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- lockScroll: false,
- }).then(() => {
- this.$message({
- type: 'success',
- message: '删除成功!'
- });
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- }
- },
- mounted: function () {
- this.getQueueList();
- 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-right: 4px;
- }
- }
-
- .center {
- display: flex;
- justify-content: center;
- }
- </style>
|