From d42493336bbdb503a2094fc9e21134815560d09e Mon Sep 17 00:00:00 2001
From: zhangjun1
Date: Wed, 1 Jul 2020 18:01:51 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E9=94=AE=E9=83=A8=E7=BD=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/workbench/fwgl/serviceEdit.vue | 5 +-
src/pages/workbench/yygl/deployment.vue | 313 ++++++++++++++++++-----
2 files changed, 254 insertions(+), 64 deletions(-)
diff --git a/src/pages/workbench/fwgl/serviceEdit.vue b/src/pages/workbench/fwgl/serviceEdit.vue
index 0f53cac..ccb52e5 100644
--- a/src/pages/workbench/fwgl/serviceEdit.vue
+++ b/src/pages/workbench/fwgl/serviceEdit.vue
@@ -69,7 +69,7 @@
接口编码:
-
发布人:
@@ -80,7 +80,7 @@
]">
联系方式:
-
+ -->
开放程度:
@@ -395,6 +395,7 @@ export default {
if (valid) {
this.setService()
} else {
+ this.$message.error('请填写完整表单')
console.log('error submit!!');
return false;
}
diff --git a/src/pages/workbench/yygl/deployment.vue b/src/pages/workbench/yygl/deployment.vue
index 7e6e3a4..6d3ee3f 100644
--- a/src/pages/workbench/yygl/deployment.vue
+++ b/src/pages/workbench/yygl/deployment.vue
@@ -36,7 +36,7 @@
@@ -50,7 +50,7 @@
-
+
下一步
@@ -66,36 +66,35 @@
ref="step2_form"
class="step_form"
label-position="top"
- :model="app_set"
:rules="app_set_rules"
>
-
+
+
-
+
- {{ vision }}
+ {{ vision}}
-
-
+
+
@@ -109,22 +108,22 @@
-
+
M
-
+
-
+
{{ save }}
+
+
高级配置
@@ -154,7 +155,7 @@
上一步
-
+
下一步
@@ -164,13 +165,13 @@
>
高级配置:
-
+
取消
-
- 保存
+
+ 下一步
@@ -208,6 +209,7 @@ import appBuildSteps from "@/components/app-build-steps/app-build-steps";
import appBuildStep from "@/components/app-build-steps/app-build-step";
import apassDialog from "@/components/apass-dialog";
import codes from "@/components/codes";
+import yaml from "js-yaml";
var checkNumber = (rule, value, callback) => {
if (!value) {
return callback(new Error("不能为空"));
@@ -250,16 +252,8 @@ export default {
namespace: "",
name: "",
},
- app_set: {
- title: "",
- vision: "",
- memory: "",
- memory_type: 1,
- cpu: "",
- watch: 0,
- save_memory: "",
- code: "",
- },
+ app_set: {},
+ app_set_info: {},
area_options: [
{
name: "12312",
@@ -268,24 +262,37 @@ export default {
],
vision_arr: ["1.0.1", "10.1.2", "2.2.3"],
save_arr: [
- "2GI",
- "4GI",
- "8GI",
- "16GI",
- "32GI",
- "64GI",
- "128GI",
- "256GI",
- "512GI",
+ [
+ "2Gi",
+ "4Gi",
+ "8Gi",
+ "16Gi",
+ "32Gi",
+ "64Gi",
+ "128Gi",
+ "256Gi",
+ "512Gi",
+ ],
+ [
+ "2TB",
+ "4TB",
+ "8TB",
+ "16TB",
+ "32TB",
+ "64TB",
+ "128TB",
+ "256TB",
+ "512TB",
+ ],
],
memory_arr: [
{
- value: 1,
- label: "MI",
+ value: 'Mi',
+ label: "Mi",
},
{
- value: 2,
- label: "GI",
+ value: 'Gi',
+ label: "Gi",
},
],
image_rules: {
@@ -297,6 +304,9 @@ export default {
{ validator: checkName, trigger: "blur" },
],
},
+ app_set_code:'',
+ is_change:false,
+ is_loading:false,
app_set_rules: {
title: [{ required: true, message: "请输入标题", trigger: "blur" }],
memory: [
@@ -345,38 +355,215 @@ export default {
state: 2,
},
],
+ step2_arr:[],
}),
methods: {
+ get_name_space(){
+ this.$http
+ .get(`/apaas/hubApi/market/namespaces`)
+ .then((response) => {
+ console.log(response);
+ this.area_options = response.data.data
+ });
+ },
get_step_info() {
this.$http
.get(`/apaas/hubApi/market/step/${this.$route.params.app_id}`)
.then((response) => {
- console.log(JSON.parse(response.data.data));
+ let step2_arr = JSON.parse(response.data.data).configInfo
+ console.log(step2_arr);
+ step2_arr.forEach(e => {
+ if(e.type=='radio'){
+ e['val'] = e.value[0]
+ // this.deal_key_value(this.app_set_info,e.name,e.type,e.value[0])
+ }else if(e.type=='storage'){
+ e['dwtype'] = e.storage.indexOf('Gi')==-1?1:0
+ // this.deal_key_value(this.app_set_info,e.name,e.type,e.storage)
+ }else if(e.type=='resource'){
+ let memory = e.memory
+ let cpu = e.cpu
+ e['memory_type'] = memory.indexOf('Mi')==-1?'Gi':'Mi'
+ e['memory'] = parseInt(memory)
+ e['cpu'] = parseInt(cpu)
+ // this.deal_key_value(this.app_set_info,e.name,'resource',[memory,cpu])
+ }else{
+ // this.deal_key_value(this.app_set_info,e.name,e.type,e.value)
+ }
+ });
+ this.step2_arr=step2_arr;
+ console.log(this.app_set_info);
});
},
+ get_step_file(){
+ this.$http
+ .get(`/apaas/hubApi/market/values/${this.$route.params.app_id}`)
+ .then((response) => {
+ this.app_set_code = response.data.data
+ })
+ },
+ change_appset(obj,key,val){
+ console.log(key,val);
+ this.$set(obj,key,val)
+ },
+ deal_key_value(key_string,type,value){
+ var key_arr = key_string.split('.')
+ var temp = this.app_set_info
+ key_arr.forEach((e,index) => {
+ if(key_arr.length-1==index){
+ if(type == 'resource'){
+ temp[e] = {
+ limits:{
+ memory: value[1]+value[0],
+ cpu:value[2]+'m'
+ },
+ requests:{
+ memory: value[1]+value[0],
+ cpu:value[2]+'m'
+ }
+ }
+ }else if(type == 'storage'){
+ temp[e] = {
+ "volumeClaimTemplate":{
+ "spec":{
+ "storageClassName":"nfs-client",
+ "accessModes":[
+ "ReadWriteOnce"],
+ "resources":{
+ "requests":{
+ "storage":value
+ }
+ }
+ },
+ "selector":{
+ }
+ }
+ }
+ }else{
+ temp[e] = value
+ }
+ }else{
+ if(temp[e]){
+
+ }else{
+ temp[e] = {}
+ }
+ temp = temp[e]
+ }
+ });
+
+ },
+ deal_key_text(obj,key_string){
+ var key_arr = key_string.split('.')
+ var temp = obj;
+ key_arr.forEach((e,index) => {
+ if(key_arr.length-1==index){
+
+ }else{
+ temp = temp[e]
+ }
+ });
+ },
deal_code(n) {
if (n) {
- this.begin_code = this.app_set.code;
- } else {
- this.app_set.code = this.begin_code;
+ //调用接口
+ this.change_form_aploy(0)
}
this.senior_flag = false;
},
- sub_yy_form(formName) {
+ change_form_aploy(n){
+ this.is_loading = true
+ if(n==1){
+ //表单提交
+ var temp = {
+ "app_id": parseInt(this.$route.params.app_id),
+ "up_userid": this.$store.state.userInfo.user_id,
+ "name": this.baseInfoForm.name,
+ "namespace": this.baseInfoForm.namespace,
+ "uu": this.evtUuid,
+ "values": this.app_set_info
+ }
+ }else{
+ //编辑提交
+ var temp = {
+ "app_id": parseInt(this.$route.params.app_id),
+ "up_userid": this.$store.state.userInfo.user_id,
+ "name": this.baseInfoForm.name,
+ "namespace": this.baseInfoForm.namespace,
+ "uu": this.evtUuid,
+ "values": yaml.load(this.app_set_code)
+ }
+ }
+ this.$http
+ .post(`/apaas/hubApi/market/build`,temp)
+ .then((response) => {
+ this.is_loading = false
+ if(response.data.data){
+ this.$message.success('开始部署成功')
+ this.nextStep()
+ }
+ }).catch(()=>{
+ this.is_loading = false
+ })
+ },
+ sub_yy_form(formName,n) {
this.$refs[formName].validate((valid) => {
if (valid) {
- this.nextStep();
+ if(n==1){
+ this.get_work_name()
+ }else if(n==2){
+ this.sub_app_set()
+ }
} else {
console.log("error submit!!");
return false;
}
});
},
- openstart() {
- if (this.app_set.watch) {
- this.app_set.watch = 0;
+ get_work_name(){
+ this.is_loading = true
+ this.$http
+ .get(`/apaas/hubApi/market/exist/${this.baseInfoForm.namespace}?name=${this.baseInfoForm.name}`)
+ .then((response) => {
+ console.log(response);
+ this.is_loading = false
+ if(response.data.success){
+ if(response.data.data){
+ this.$message.error('工作名称已存在')
+ }else{
+ this.nextStep();
+ }
+ }
+ }).catch(()=>{
+ this.is_loading = false
+ })
+ },
+ sub_app_set(){
+ this.is_loading = true
+ this.step2_arr.forEach(e => {
+ if(e.type=='radio'){
+ this.deal_key_value(e.name,e.type,e.val)
+ }else if(e.type=='storage'){
+ this.deal_key_value(e.name,e.type,e.storage)
+ }else if(e.type=='resource'){
+ let memory = e.memory
+ let cpu = e.cpu
+ this.deal_key_value(e.name,'resource',[e.memory_type,e.memory,e.cpu])
+ }else{
+ this.deal_key_value(e.name,e.type,e.value)
+ }
+ });
+ console.log(this.app_set_info);
+ console.log(this.step2_arr);
+ //表单提交调用接口
+ this.change_form_aploy(1)
+ },
+ openstart(item,key) {
+ if (item[key]) {
+ this.$set(item,key,false)
+ // item[key] = false;
} else {
- this.app_set.watch = 1;
+ // item[key] = true;
+ this.$set(item,key,true)
}
},
preStep() {
@@ -466,7 +653,9 @@ export default {
},
created() {
this.getStatus();
+ this.get_name_space();
this.get_step_info();
+ this.get_step_file();
},
};
@@ -496,7 +685,6 @@ export default {
}
.select_box {
height: 35px;
- width: 80px;
line-height: 35px;
background-color: #f7f8f9;
border-radius: 6px;
@@ -506,6 +694,7 @@ export default {
float: left;
margin-right: 10px;
cursor: pointer;
+ padding: 0 20px;
}
.is_select {
background-color: #515fe7;
--
2.26.0