Commit eeb5b235 authored by 徐一鸣's avatar 徐一鸣

SDK示例管理

parent 5e701a5b
<template> <template>
<el-upload <el-upload
ref="upload"
drag drag
action="/apaas/static/file/upload" action="/apaas/static/file/upload"
:data="{ :data="{
...@@ -34,6 +35,11 @@ export default { ...@@ -34,6 +35,11 @@ export default {
default: "", default: "",
}, },
}, },
data() {
return {
preUrl: "",
};
},
computed: { computed: {
fileList() { fileList() {
let list = []; let list = [];
...@@ -68,6 +74,7 @@ export default { ...@@ -68,6 +74,7 @@ export default {
const filtType = this.getFileType(file.name); const filtType = this.getFileType(file.name);
if (filtType === "rar" || filtType === "zip") { if (filtType === "rar" || filtType === "zip") {
this.preUrl = this.url;
return true; return true;
} else { } else {
this.$message.error("仅支持rar和zip格式!"); this.$message.error("仅支持rar和zip格式!");
...@@ -76,6 +83,21 @@ export default { ...@@ -76,6 +83,21 @@ export default {
}, },
uploadSuccess({ data }) { uploadSuccess({ data }) {
this.$emit("change", data); this.$emit("change", data);
// 替换文件后要把旧文件删除掉
if (this.preUrl) {
this.$http
.delete("/apaas/static/file/delete", {
params: {
url: this.preUrl,
},
})
.then(({ data }) => {
if (data.success === 1) {
this.preUrl = "";
}
});
}
}, },
}, },
}; };
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
<el-breadcrumb-item to="/technical_support/doc_manage"> <el-breadcrumb-item to="/technical_support/doc_manage">
开发文档 开发文档
</el-breadcrumb-item> </el-breadcrumb-item>
<el-breadcrumb-item> <el-breadcrumb-item> 文档编辑 - {{ title }} </el-breadcrumb-item>
文档编辑 - {{ title }}
</el-breadcrumb-item>
</el-breadcrumb> </el-breadcrumb>
</div> </div>
...@@ -31,21 +29,26 @@ ...@@ -31,21 +29,26 @@
<script> <script>
import wangE from "@/components/wangE"; import wangE from "@/components/wangE";
export default { export default {
components: {
wangE,
},
data() { data() {
return { return {
title: "", title: "",
content: "", content: "",
}; };
}, },
components: { computed: {
wangE, id() {
return parseFloat(this.$route.params.id);
},
}, },
created() { created() {
if (this.$route.params.id) { if (this.id) {
this.$http this.$http
.get("/apaas/support/document/get", { .get("/apaas/support/document/get", {
params: { params: {
id: this.$route.params.id, id: this.id,
}, },
}) })
.then(({ data }) => { .then(({ data }) => {
...@@ -63,13 +66,13 @@ export default { ...@@ -63,13 +66,13 @@ export default {
submitAction() { submitAction() {
this.$http this.$http
.put("/apaas/support/document/put", { .put("/apaas/support/document/put", {
id: parseFloat(this.$route.params.id), id: this.id,
content: this.content, content: this.content,
}) })
.then(({ data }) => { .then(({ data }) => {
if (data.success === 1) { if (data.success === 1) {
this.$message.success("保存成功"); this.$message.success("保存成功");
this.$router.push("/technical_support/doc_manage") this.$router.push("/technical_support/doc_manage");
} else { } else {
this.$message.error(data.errMsg || "保存失败"); this.$message.error(data.errMsg || "保存失败");
} }
......
...@@ -250,7 +250,10 @@ export default { ...@@ -250,7 +250,10 @@ export default {
{ max: 20, message: "长度应小于20个字符", trigger: "change" }, { max: 20, message: "长度应小于20个字符", trigger: "change" },
], ],
}, },
detail: "", detail: {
title: "",
content: "",
},
deleteDialogInfo: { deleteDialogInfo: {
msg: "", msg: "",
submit: null, submit: null,
...@@ -424,7 +427,7 @@ export default { ...@@ -424,7 +427,7 @@ export default {
<style> <style>
.doc_manage_detail_dialog .el-dialog__body { .doc_manage_detail_dialog .el-dialog__body {
padding: 10px; padding: 15px;
} }
.doc_manage_detail_dialog .el-dialog__footer { .doc_manage_detail_dialog .el-dialog__footer {
display: none; display: none;
......
...@@ -21,20 +21,15 @@ export default { ...@@ -21,20 +21,15 @@ export default {
sideNavBar, sideNavBar,
}, },
data: () => ({ data: () => ({
activePath: "",
navList: [], navList: [],
}), }),
/* watch: {
"$route.fullPath"(path) {
this.initNavList();
},
}, */
methods: { methods: {
initNavList() { initNavList() {
this.$api.general.getNowMenu({ teamName: "APAAS3" }).then(({ data }) => { this.$api.general.getNowMenu({ teamName: "APAAS3" }).then(({ data }) => {
if (data.success == 1) { if (data.success == 1) {
let menu = data.data[0].Child; let menu = data.data[0].Child;
let nav = []; let nav = [];
let activePath = "";
for (let i = 0; i < menu.length; i++) { for (let i = 0; i < menu.length; i++) {
let first = menu[i]; let first = menu[i];
...@@ -83,8 +78,8 @@ export default { ...@@ -83,8 +78,8 @@ export default {
if (children.length === 0) { if (children.length === 0) {
this.$set(nav[index], "disabled", true); this.$set(nav[index], "disabled", true);
} else { } else {
if (activePath === "") { if (this.activePath === "") {
activePath = children[0].path; this.activePath = children[0].path;
} }
this.$set(nav[index], "path", children[0].path); this.$set(nav[index], "path", children[0].path);
...@@ -97,9 +92,9 @@ export default { ...@@ -97,9 +92,9 @@ export default {
}); });
this.navList = nav; this.navList = nav;
if (activePath && this.$route.params.id === undefined) { if (this.activePath && this.$route.params.id === undefined) {
this.$router.push(activePath); this.$router.push(this.activePath);
} else if (activePath === "") { } else if (this.activePath === "") {
this.$message.error("您尚未创建任何文档"); this.$message.error("您尚未创建任何文档");
} }
}); });
......
<template>
<div class="doc_manage_container">
<div class="apass_breadcrumb">
<el-breadcrumb separator="/">
<el-breadcrumb-item to="/technical_support">
技术支持
</el-breadcrumb-item>
<el-breadcrumb-item to="/technical_support/sdk_manage/example">
SDK管理
</el-breadcrumb-item>
<el-breadcrumb-item>
SDK示例编辑 - {{ detail.example_name }}
</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="editpage">
<wang-e v-model="detail.content"></wang-e>
<div class="apaas_button">
<el-button type="defalut" size="mini" @click="cancelAction">
取消
</el-button>
<el-button type="primary" size="mini" @click="submitAction">
保存
</el-button>
</div>
</div>
</div>
</template>
<script>
import wangE from "@/components/wangE";
export default {
components: {
wangE,
},
data() {
return {
detail: {},
};
},
computed: {
id() {
return parseFloat(this.$route.params.id);
},
},
created() {
if (this.id) {
this.$http
.get("/apaas/support/sdk/example/detail", {
params: {
id: this.id,
},
})
.then(({ data }) => {
if (data.success === 1) {
this.detail = data.data;
}
});
}
},
methods: {
cancelAction() {
this.$router.push("/technical_support/sdk_manage");
},
submitAction() {
this.$http
.put("/apaas/support/sdk/example/put", {
id: this.id,
style_id: this.detail.style_id,
example_name: this.detail.example_name,
content: this.detail.content,
})
.then(({ data }) => {
if (data.success === 1) {
this.$message.success("保存成功");
this.$router.push("/technical_support/sdk_manage/example");
} else {
this.$message.error(data.errMsg || "保存失败");
}
})
.catch((error) => {
console.log(error);
this.$message.error("保存失败");
});
},
},
};
</script>
<style scoped>
.doc_manage_container {
height: 100%;
padding: 0 20px 30px;
box-sizing: border-box;
}
.main_container {
height: calc(100% - 53px);
background-color: #fff;
border-radius: 10px;
}
.editpage {
background-color: #fff;
height: calc(100% - 45px);
margin-bottom: 20px;
box-shadow: 0px 3px 6px 0px #f4f7fc;
border-radius: 12px;
}
.editpage .wangeditor_class {
height: calc(100% - 100px);
padding: 0 20px;
box-sizing: border-box;
}
.apaas_button {
border-top: 1px solid #e3e5ef;
box-sizing: border-box;
text-align: right;
padding-top: 30px;
}
.apaas_button .el-button + .el-button {
margin-right: 30px;
}
</style>
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
:title="detailForm.type === 0 ? '新增' : '修改'" :title="detailForm.type === 0 ? '新增' : '修改'"
> >
<div class="add_content" slot="content"> <div class="add_content" slot="content">
<el-form ref="addForm" :model="detailForm" :rules="detailFormRules"> <el-form ref="detailForm" :model="detailForm" :rules="detailFormRules">
<el-form-item <el-form-item
label="SDK类型" label="SDK类型"
prop="style_name" prop="style_name"
...@@ -103,10 +103,6 @@ ...@@ -103,10 +103,6 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="SDK包上传" prop="file_url"> <el-form-item label="SDK包上传" prop="file_url">
<!-- <el-input
v-model="detailForm.file_url"
placeholder="支持扩展名:.rar .zip"
></el-input> -->
<apass-upload <apass-upload
v-model="detailForm.file_url" v-model="detailForm.file_url"
tip="支持扩展名:.rar .zip" tip="支持扩展名:.rar .zip"
...@@ -282,11 +278,23 @@ export default { ...@@ -282,11 +278,23 @@ export default {
this.$refs.list.resetCurrentPage(); this.$refs.list.resetCurrentPage();
}, },
deleteSlection() { deleteSlection() {
this.deleteDialogInfo.msg = `确认删除要删除所选项吗?`; if (this.selection.length) {
this.deleteDialogInfo.submit = () => { let names = [];
this.deleteRequest(this.selection.map((row) => row.id)); let ids = [];
};
this.$refs.deleteDialog.show(); this.selection.forEach((item) => {
names.push(item.style_name);
ids.push(item.id);
});
this.deleteDialogInfo.msg = `您确认要删除${names.join("")}吗?`;
this.deleteDialogInfo.submit = () => {
this.deleteRequest(ids);
};
this.$refs.deleteDialog.show();
} else {
this.$message.warning("您尚未选中任何SDK类型");
}
}, },
clearSelection() { clearSelection() {
this.$refs.list.clearSelection(); this.$refs.list.clearSelection();
...@@ -307,58 +315,60 @@ export default { ...@@ -307,58 +315,60 @@ export default {
this.$refs.detailDialog.hide(); this.$refs.detailDialog.hide();
}, },
detailSubmitAction() { detailSubmitAction() {
if (this.detailForm.type === 0) { this.$refs.detailForm.validate((valid) => {
this.$http if (valid) {
.post("/apaas/support/sdk/styles/create", { if (this.detailForm.type === 0) {
style_name: this.detailForm.style_name, this.$http
version: this.detailForm.version, .post("/apaas/support/sdk/styles/create", {
file_url: this.detailForm.file_url, style_name: this.detailForm.style_name,
}) version: this.detailForm.version,
.then(({ data }) => { file_url: this.detailForm.file_url,
if (data.success === 1) { })
this.$message.success("新增成功"); .then(({ data }) => {
this.refreshPage(); if (data.success === 1) {
this.$refs.detailDialog.hide(); this.$message.success("新增成功");
} else { this.refreshPage();
this.$message.error("新增失败"); this.$refs.detailDialog.hide();
} } else {
}) this.$message.error("新增失败");
.catch((error) => { }
console.log(error); })
this.$message.error("新增失败"); .catch((error) => {
}); console.log(error);
} else { this.$message.error("新增失败");
this.$http });
.put("/apaas/support/sdk/styles/put", { } else {
id: this.detailForm.id, this.$http
style_name: this.detailForm.style_name, .put("/apaas/support/sdk/styles/put", {
version: this.detailForm.version, id: this.detailForm.id,
file_url: this.detailForm.file_url, style_name: this.detailForm.style_name,
}) version: this.detailForm.version,
.then(({ data }) => { file_url: this.detailForm.file_url,
if (data.success === 1) { })
this.$message.success("修改成功"); .then(({ data }) => {
this.refreshPage(); if (data.success === 1) {
this.$refs.detailDialog.hide(); this.$message.success("修改成功");
} else { this.refreshPage();
this.$message.error("修改失败"); this.$refs.detailDialog.hide();
} } else {
}) this.$message.error("修改失败");
.catch((error) => { }
console.log(error); })
this.$message.error("修改失败"); .catch((error) => {
}); console.log(error);
} this.$message.error("修改失败");
});
}
} else {
return false;
}
});
}, },
editItem(item) { editItem(item) {
this.detailForm = { this.detailForm = {
type: 1, type: 1,
id: item.id,
style_name: item.style_name,
version: item.version,
file_url: item.file_url,
}; };
/* this.$http this.$http
.get("/apaas/support/sdk/styles/detail", { .get("/apaas/support/sdk/styles/detail", {
params: { params: {
id: item.id, id: item.id,
...@@ -366,9 +376,12 @@ export default { ...@@ -366,9 +376,12 @@ export default {
}) })
.then(({ data }) => { .then(({ data }) => {
if (data.success === 1) { if (data.success === 1) {
this.detailForm = data.data; this.detailForm = {
...data.data,
type: 1,
};
} }
}); */ });
this.$refs.detailDialog.show(); this.$refs.detailDialog.show();
}, },
deleteItem(item) { deleteItem(item) {
......
...@@ -99,6 +99,7 @@ export default { ...@@ -99,6 +99,7 @@ export default {
.main_container { .main_container {
flex-grow: 1; flex-grow: 1;
height: calc(100% - 53px); height: calc(100% - 53px);
overflow: hidden;
} }
.download_action { .download_action {
background-color: #fff; background-color: #fff;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
title="SDK中心" title="SDK中心"
imgSrc="tool_ic_kaifawendang" imgSrc="tool_ic_kaifawendang"
:nav-list="navList" :nav-list="navList"
:title-path="navList[0] && navList[0].path" :title-path="activePath"
style="width: 250px;" style="width: 250px;"
></side-nav-bar> ></side-nav-bar>
<div class="main_container"> <div class="main_container">
...@@ -21,76 +21,52 @@ export default { ...@@ -21,76 +21,52 @@ export default {
sideNavBar, sideNavBar,
}, },
data: () => ({ data: () => ({
activePath: "",
navList: [], navList: [],
}), }),
methods: { methods: {
initNavList() { initNavList() {
let activePath = ""; this.$http.get("/apaas/support/sdk/menus").then(({ data }) => {
let baseUrl = "/technical_support/sdk"; if (data.success === 1) {
let data = [ let baseUrl = "/technical_support/sdk";
{ let menu = data.data || [];
name: "JavaScript SDK",
id: 1,
children: [
{
name: "在地图上添加图层",
id: 101,
},
{
name: "测测测自己创建测",
id: 102,
},
],
},
{
name: "Android SDK",
id: 2,
children: [
{
name: "Android",
id: 201,
},
{
name: "测测测自己创建测",
id: 202,
},
],
},
];
this.navList = data.map((item) => { this.navList = menu.map((item) => {
let children = item.children; let children = item.children || [];
let nav = {
name: item.name,
path: `${baseUrl}/${item.name}`,
};
if (children.length > 0) { let nav = {
nav.children = children.map((v) => { name: item.name,
let path = `${baseUrl}/${item.name}/${v.id}`; path: `${baseUrl}/${item.name}`,
};
if (children.length > 0) {
nav.children = children.map((v) => {
let path = `${baseUrl}/${item.name}/${v.id}`;
if (activePath === "") { if (this.activePath === "") {
activePath = path; this.activePath = path;
}
return {
name: v.name,
path: path,
};
});
nav.open = true;
} else {
nav.disabled = true;
} }
return { return nav;
name: v.name,
path: path,
};
}); });
nav.open = true;
} else {
nav.disabled = true;
}
return nav; if (this.activePath && this.$route.params.id === undefined) {
this.$router.push(this.activePath);
} else if (this.activePath === "") {
this.$message.error("您尚未创建任何SDK文档");
}
}
}); });
if (activePath && this.$route.params.id === undefined) {
this.$router.push(activePath);
} else if (activePath === "") {
this.$message.error("您尚未创建任何SDK文档");
}
}, },
}, },
mounted() { mounted() {
......
...@@ -257,6 +257,14 @@ export default new Router({ ...@@ -257,6 +257,14 @@ export default new Router({
"@/pages/technical-support/sdk-manage/example/index" "@/pages/technical-support/sdk-manage/example/index"
), ),
}, // SDK示例管理 }, // SDK示例管理
{
path: "/technical_support/sdk_manage/example/:id",
name: "technicalSupportSdkExampleDetail",
component: () =>
import(
"@/pages/technical-support/sdk-manage/example/detail"
),
}, // SDK示例详情
], ],
}, // SDK管理 }, // SDK管理
], ],
......
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