浏览代码

Merge remote-tracking branch 'origin/res-manage' into res-manage

pull/2765/head
chenyifan01 2 年前
父节点
当前提交
1a00b0e4c7
共有 5 个文件被更改,包括 153 次插入16 次删除
  1. +10
    -0
      web_src/vuepages/apis/modules/resources.js
  2. +3
    -0
      web_src/vuepages/langs/config/en-US.js
  3. +3
    -0
      web_src/vuepages/langs/config/zh-CN.js
  4. +13
    -5
      web_src/vuepages/pages/resources/components/SpecificationDialog.vue
  5. +124
    -11
      web_src/vuepages/pages/resources/specification/index.vue

+ 10
- 0
web_src/vuepages/apis/modules/resources.js 查看文件

@@ -74,6 +74,16 @@ export const addResSpecification = (data) => {
});
}

// 查询资源规格所属场景 - 下架时提醒
export const getResSpecificationScenes = (data) => { // data => { ID: 1 }
return service({
url: `/admin/resources/specification/scenes/${data.ID}`,
method: 'get',
params: {},
data: {}
});
}

// 更新资源规格
// params: action edit-编辑 on-shelf 上架 off-shelf 下架
// data: UnitPrice


+ 3
- 0
web_src/vuepages/langs/config/en-US.js 查看文件

@@ -129,6 +129,9 @@ const en = {
point_hr: 'Point/hr',
onShelfConfirm: 'Are you sure to on shelf the resources specification?',
offShelfConfirm: 'Are you sure to off shelf the resources specification?',
onShelfCode1001: 'On shelf failed, the resources queues not available.',
offShelfDlgTip1: 'The resources specification has already used in scene:',
offShelfDlgTip2: 'Please confirm to off shelf?',
resSceneManagement: 'Resources Scene Management',
addResScene: 'Add Resources Scene',
addResSceneBtn: 'Add Resources Scene',


+ 3
- 0
web_src/vuepages/langs/config/zh-CN.js 查看文件

@@ -129,6 +129,9 @@ const zh = {
point_hr: '积分/时',
onShelfConfirm: '请确认是否上架该规格?',
offShelfConfirm: '请确认是否下架该规格?',
onShelfCode1001: '上架失败,资源池(队列)不可用。',
offShelfDlgTip1: '当前资源规格已在以下场景中使用:',
offShelfDlgTip2: '请确认是否进行下架操作?',
resSceneManagement: '算力资源应用场景管理',
addResScene: '新建算力资源应用场景',
addResSceneBtn: '新增应用场景',


+ 13
- 5
web_src/vuepages/pages/resources/components/SpecificationDialog.vue 查看文件

@@ -220,9 +220,10 @@ export default {
return;
}
const setApi = this.type === 'add' ? addResSpecification : updateResSpecification;
const action = this.editOr ? 'edit' : this.type === 'edit' ? 'on-shelf' : undefined;
setApi({
...this.dataInfo,
action: this.editOr ? 'edit' : this.type === 'edit' ? 'on-shelf' : undefined,
action: action,
AccCardsNum: Number(this.dataInfo.AccCardsNum),
CpuCores: Number(this.dataInfo.CpuCores),
MemGiB: Number(this.dataInfo.MemGiB),
@@ -239,10 +240,17 @@ export default {
});
this.$emit("confirm");
} else {
this.$message({
type: 'error',
message: this.$t('submittedFailed')
});
if (action === 'on-shelf' && res.Code === 1001) {
this.$message({
type: 'info',
message: this.$t('resourcesManagement.onShelfCode1001')
});
} else {
this.$message({
type: 'error',
message: this.$t('submittedFailed')
});
}
}
}).catch(err => {
console.log(err);


+ 124
- 11
web_src/vuepages/pages/resources/specification/index.vue 查看文件

@@ -27,7 +27,7 @@
<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"
<el-table-column prop="SourceSpecId" :label="$t('resourcesManagement.sourceSpecCode')" align="center"
header-align="center">
</el-table-column>
<el-table-column prop="AccCardsNum" :label="$t('resourcesManagement.accCardsNum')" align="center"
@@ -66,12 +66,12 @@
</span>
<span v-if="scope.row.Status == '2'">
<span class="op-btn" @click="showDialog('edit', scope.row, true)">{{ $t('edit') }}</span>
<span class="op-btn" @click="onOrOffShelf('off-shelf', scope.row)">{{
<span class="op-btn" @click="offShelfPrev(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)">{{
<span class="op-btn" @click="onShelf(scope.row)">{{
$t('resourcesManagement.toOnShelf')
}}</span>
</span>
@@ -98,12 +98,29 @@
<SpecificationDialog :visible.sync="specificationDialogShow" :type="specificationDialogType"
:editOr="specificationDialogEditOr" :data="specificationDialogData" @confirm="specificationDialogConfirm">
</SpecificationDialog>

<BaseDialog :visible.sync="offShelfDialogShow" :width="`600px`" :title="$t('tips')">
<div class="form">
<div class="form-row" style="flex-direction:column;">
<div class="content" style="margin:8px 0">{{ $t('resourcesManagement.offShelfDlgTip1') }}</div>
<div class="content" style="margin:8px 0;font-weight: bold;">{{ offSelfDialogContent }}</div>
<div class="content" style="margin:8px 0">{{ $t('resourcesManagement.offShelfDlgTip2') }}</div>
</div>
<div class="form-row" style="margin-top: 20px">
<div class="content">
<el-button type="primary" class="btn confirm-btn" @click="offShelf">{{ $t('confirm') }}</el-button>
<el-button class="btn" @click="offShelfDialogShow = false">{{ $t('cancel') }}</el-button>
</div>
</div>
</div>
</BaseDialog>
</div>
</template>

<script>
import SpecificationDialog from '../components/SpecificationDialog.vue';
import { getResQueueCode, getResSpecificationList, updateResSpecification, syncResSpecification } from '~/apis/modules/resources';
import BaseDialog from '~/components/BaseDialog.vue';
import { getResQueueCode, getResSpecificationList, updateResSpecification, syncResSpecification, getResSpecificationScenes } from '~/apis/modules/resources';
import { SPECIFICATION_STATUS, CLUSTERS, ACC_CARD_TYPE } from '~/const';
import { getListValueWithKey } from '~/utils';
import { formatDate } from 'element-ui/lib/utils/date-util';
@@ -130,9 +147,13 @@ export default {
specificationDialogType: 'add',
specificationDialogEditOr: false,
specificationDialogData: {},

offShelfDialogShow: false,
offShelfDialogData: {},
offSelfDialogContent: '',
};
},
components: { SpecificationDialog },
components: { BaseDialog, SpecificationDialog },
methods: {
getQueueList() {
getResQueueCode().then(res => {
@@ -233,7 +254,8 @@ export default {
this.specificationDialogShow = false;
this.getTableData();
},
onOrOffShelf(type, data) {
onShelf(data) {
const type = 'on-shelf';
this.$confirm(type === 'on-shelf' ? this.$t('resourcesManagement.onShelfConfirm') : this.$t('resourcesManagement.offShelfConfirm'), this.$t('tips'), {
confirmButtonText: this.$t('confirm'),
cancelButtonText: this.$t('cancel'),
@@ -252,10 +274,17 @@ export default {
});
this.getTableData();
} else {
this.$message({
type: 'error',
message: this.$t('submittedFailed')
});
if (type === 'on-shelf' && res.Code === 1001) {
this.$message({
type: 'info',
message: this.$t('resourcesManagement.onShelfCode1001')
});
} else {
this.$message({
type: 'error',
message: this.$t('submittedFailed')
});
}
}
}).catch(err => {
console.log(err);
@@ -265,7 +294,59 @@ export default {
});
});
}).catch(() => { });
}
},
offShelfPrev(data) {
this.$confirm(this.$t('resourcesManagement.offShelfConfirm'), this.$t('tips'), {
confirmButtonText: this.$t('confirm'),
cancelButtonText: this.$t('cancel'),
type: 'warning',
lockScroll: false,
}).then(() => {
this.offShelfDialogData = data;
getResSpecificationScenes({ ID: data.ID }).then(res => {
res = res.data;
if (res.Code === 0) {
if (res.Data.List.length) {
this.offShelfDialogShow = true;
this.offSelfDialogContent = res.Data.List.map((item) => `[${item.ID}]${item.SceneName}`).join(', ');
} else {
this.offShelf();
}
} else {
console.log(res);
}
}).catch(err => {
console.log(err);
});
}).catch(() => { });
},
offShelf() {
updateResSpecification({
ID: this.offShelfDialogData.ID,
action: 'off-shelf'
}).then(res => {
res = res.data;
if (res.Code === 0) {
this.$message({
type: 'success',
message: this.$t('submittedSuccessfully')
});
this.offShelfDialogShow = false;
this.getTableData();
} else {
this.$message({
type: 'error',
message: this.$t('submittedFailed')
});
}
}).catch(err => {
console.log(err);
this.$message({
type: 'error',
message: this.$t('submittedFailed')
});
});
},
},
mounted: function () {
this.getQueueList();
@@ -334,4 +415,36 @@ export default {
display: flex;
justify-content: center;
}

.form {
margin: 5px 0 5px 0;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}

.form-row {
display: flex;
min-height: 42px;
margin-bottom: 4px;

.content {
width: 500px;
display: flex;
align-items: center;
}
}

.btn {
color: rgb(2, 0, 4);
background-color: rgb(194, 199, 204);
border-color: rgb(194, 199, 204);

&.confirm-btn {
color: #fff;
background-color: rgb(56, 158, 13);
border-color: rgb(56, 158, 13);
}
}
</style>

正在加载...
取消
保存