Commit 435b250c authored by 徐一鸣's avatar 徐一鸣

应用构建(镜像)接口调试

parent e4d790a4
...@@ -31,7 +31,11 @@ ...@@ -31,7 +31,11 @@
placeholder="请输入版本号" placeholder="请输入版本号"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="上传镜像包:" prop="file"> <el-form-item
label="上传镜像包:"
prop="file"
ref="step1_upload_item"
>
<el-upload <el-upload
ref="step1_upload" ref="step1_upload"
:auto-upload="false" :auto-upload="false"
...@@ -41,6 +45,7 @@ ...@@ -41,6 +45,7 @@
}" }"
:limit="1" :limit="1"
:on-change="imageUploadChange" :on-change="imageUploadChange"
:on-remove="imageUploadRemove"
:on-success="imageUploadSuccess" :on-success="imageUploadSuccess"
:on-error="imageUploadError" :on-error="imageUploadError"
action="/apaas/hubApi/image/upload" action="/apaas/hubApi/image/upload"
...@@ -102,7 +107,11 @@ ...@@ -102,7 +107,11 @@
:model="deploy_info" :model="deploy_info"
:rules="deploy_rules" :rules="deploy_rules"
> >
<el-form-item label="上传部署文件:" prop="file"> <el-form-item
label="上传部署文件:"
prop="file"
ref="step2_upload_item"
>
<div class="description_info"> <div class="description_info">
<i class="el-icon-warning-outline"></i> <i class="el-icon-warning-outline"></i>
<p> <p>
...@@ -119,7 +128,9 @@ ...@@ -119,7 +128,9 @@
:data="app_info" :data="app_info"
action="/apaas/hubApi/market/app" action="/apaas/hubApi/market/app"
:on-change="deployUploadChange" :on-change="deployUploadChange"
:on-remove="deployUploadRemove"
:on-success="deployUploadSuccess" :on-success="deployUploadSuccess"
:on-error="deployUploadError"
name="file" name="file"
drag drag
> >
...@@ -186,17 +197,17 @@ ...@@ -186,17 +197,17 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="应用封面:" prop="logo"> <el-form-item label="应用封面:" prop="logo">
<el-upload <upload-file
class="avatar-uploader" :multiple="false"
action="/apaas/static/image/upload" :max="1"
:data="{ directory: 'hub' }" type="cropper"
:show-file-list="false" :readOnly="false"
:on-success="handleLogoSuccess" fit="fill"
:before-upload="beforeLogoUpload" :list="logo"
> @getNewList="getNewList"
<img v-if="app_info.logo" class="avatar" :src="app_info.logo" /> ref="servicepic"
<i v-else class="el-icon-plus avatar-uploader-icon"></i> directory="hub"
</el-upload> ></upload-file>
</el-form-item> </el-form-item>
<el-form-item label="所属组织:" prop="org"> <el-form-item label="所属组织:" prop="org">
<el-select v-model="app_info.org" placeholder="请选择所属组织"> <el-select v-model="app_info.org" placeholder="请选择所属组织">
...@@ -257,12 +268,14 @@ ...@@ -257,12 +268,14 @@
import appBuildSteps from "@/components/app-build-steps/app-build-steps"; import appBuildSteps from "@/components/app-build-steps/app-build-steps";
import appBuildStep from "@/components/app-build-steps/app-build-step"; import appBuildStep from "@/components/app-build-steps/app-build-step";
import apassTable from "@/components/apass-table"; import apassTable from "@/components/apass-table";
import uploadFile from "@/components/upload_file";
export default { export default {
components: { components: {
appBuildSteps, appBuildSteps,
appBuildStep, appBuildStep,
apassTable, apassTable,
uploadFile,
}, },
data: () => ({ data: () => ({
step: 0, step: 0,
...@@ -323,6 +336,7 @@ export default { ...@@ -323,6 +336,7 @@ export default {
ywlys: [], ywlys: [],
types: [], types: [],
orgs: [], orgs: [],
logo: [],
submitLoading: false, submitLoading: false,
}), }),
methods: { methods: {
...@@ -333,16 +347,17 @@ export default { ...@@ -333,16 +347,17 @@ export default {
this.step++; this.step++;
}, },
initImageList() { initImageList() {
this.image_loading = true;
this.$http this.$http
.get("/apaas/hubApi/image/imageUpList", { .get("/apaas/hubApi/image/imageUpList", {
params: { params: {
page: this.image_page, page: this.image_page,
size: 5, size: 10,
}, },
}) })
.then((response) => { .then(({ data }) => {
this.image_total = response.data.total; this.image_total = data.total || 0;
this.image_datas.push(...response.data.data); this.image_datas.push(...(data.data || []));
this.image_loading = false; this.image_loading = false;
this.image_noMore = false; this.image_noMore = false;
}) })
...@@ -352,7 +367,6 @@ export default { ...@@ -352,7 +367,6 @@ export default {
}, },
loadImageList() { loadImageList() {
if (this.image_datas.length < this.image_total) { if (this.image_datas.length < this.image_total) {
this.image_loading = true;
this.image_page++; this.image_page++;
this.initImageList(); this.initImageList();
} else { } else {
...@@ -360,27 +374,32 @@ export default { ...@@ -360,27 +374,32 @@ export default {
} }
}, },
imageUploadChange(file) { imageUploadChange(file) {
this.image_info.file = file; if (file.raw.type !== "application/x-tar") {
this.$message.error("镜像文件只能是 TAR 格式!");
/* this.$refs["step1_form"].validate((valid) => { this.image_info.file = "";
if (valid) { this.$refs.step1_upload.clearFiles();
// } else {
} else { this.image_info.file = file;
return false; this.$refs.step1_upload_item.clearValidate();
} }
}); */
}, },
imageUploadSuccess(response) { imageUploadSuccess(response) {
// console.log("新增成功", response); this.$message({
this.$refs.step1_upload.clearFiles(); message: `上传镜像成功`,
type: "success",
});
this.image_info.image_name = ""; this.image_info.image_name = "";
this.image_info.tag = ""; this.image_info.tag = "";
this.image_info.file = ""; this.image_info.file = "";
this.$refs.step1_upload.clearFiles();
this.step1UplaodLoading = false; this.step1UplaodLoading = false;
this.image_datas = []; this.image_datas = [];
this.image_page = 1; this.image_page = 1;
this.initImageList(); this.initImageList();
}, },
imageUploadRemove() {
this.image_info.file = "";
},
imageUploadError(response) { imageUploadError(response) {
this.$message({ this.$message({
message: `上传失败`, message: `上传失败`,
...@@ -411,9 +430,6 @@ export default { ...@@ -411,9 +430,6 @@ export default {
console.log(error); console.log(error);
}); });
}, },
deployUploadChange(file) {
this.deploy_info.file = file;
},
goToStep2(formName) { goToStep2(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
...@@ -423,20 +439,8 @@ export default { ...@@ -423,20 +439,8 @@ export default {
} }
}); });
}, },
handleLogoSuccess(response) { getNewList(file) {
this.app_info.logo = response.data; this.app_info.logo = file.url;
},
beforeLogoUpload(file) {
const isPic = file.type === "image/jpeg" || file.type === "image/png";
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isPic) {
this.$message.error("上传头像图片只能是 JPG 或 PNG 格式!");
}
if (!isLt10M) {
this.$message.error("上传头像图片大小不能超过 10MB!");
}
return isPic && isLt10M;
}, },
getYwlys() { getYwlys() {
this.$http this.$http
...@@ -468,10 +472,38 @@ export default { ...@@ -468,10 +472,38 @@ export default {
console.log(error); console.log(error);
}); });
}, },
deployUploadChange(file) {
const filtType = this.getFileType(file.name);
if (filtType === "zip" || filtType === "gz" || filtType === "tgz") {
this.deploy_info.file = file;
this.$refs.step2_upload_item.clearValidate();
} else {
this.$message.error("部署文件格式错误!");
this.deploy_info.file = "";
this.$refs.step2_upload.clearFiles();
}
},
deployUploadRemove() {
this.deploy_info.file = "";
},
deployUploadSuccess(response) {
this.$message({
message: `提交成功`,
type: "success",
});
this.submitLoading = false;
this.$router.push("/yygl/2/0");
},
deployUploadError() {
this.$message({
message: `提交失败`,
type: "warning",
});
},
sunbmitAction(formName) { sunbmitAction(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
if (valid) { if (valid) {
console.log("submit action");
this.submitLoading = true; this.submitLoading = true;
this.$refs.step2_upload.submit(); this.$refs.step2_upload.submit();
} else { } else {
...@@ -479,10 +511,16 @@ export default { ...@@ -479,10 +511,16 @@ export default {
} }
}); });
}, },
deployUploadSuccess(response) { getFileType(fileName) {
console.log("提交成功", response); const startIndex = fileName.lastIndexOf(".");
this.submitLoading = false;
this.$router.push("/yygl/2/0"); if (startIndex != -1) {
return fileName
.substring(startIndex + 1, fileName.length)
.toLowerCase();
} else {
return "";
}
}, },
}, },
mounted() { mounted() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment