diff --git a/src/components/apass-upload.vue b/src/components/apass-upload.vue index ca81c87b50441b5f3cabccbd199f02ab9abde493..d47f954853828f22bfbdb06ebf7034cdf92b9905 100644 --- a/src/components/apass-upload.vue +++ b/src/components/apass-upload.vue @@ -1,5 +1,6 @@ @@ -73,28 +164,106 @@ import helper from "@/services/helper.js"; import apassList from "@/components/apass-list"; import apassDialog from "@/components/apass-dialog"; +import apassUpload from "@/components/apass-upload"; import showMoreFilter from "@/components/show-more-filter"; export default { components: { apassList, apassDialog, + apassUpload, showMoreFilter, }, data() { return { - paddingLeft: 25, + paddingLeft: 0, listTotal: 0, - listHeader: [{}], + listHeader: [ + { + label: "示例名称", + prop: "example_name", + type: "button", + callback: this.viewItem, + width: 320, + }, + { + label: "SDK类型", + prop: "style_name", + align: "center", + }, + { + label: "版本号", + prop: "version", + align: "center", + }, + { + label: "是否提供SDK包下载", + prop: "is_sdk", + align: "center", + }, + { + label: "操作人", + prop: "user_name", + align: "center", + }, + { + label: "最后更新时间", + prop: "updated", + getText: ({ updated }) => this.getTimeText(updated || ""), + align: "center", + }, + { + label: "操作", + type: "buttons", + align: "center", + width: 240, + actionList: [ + { + label: "修改", + callback: this.editItem, + }, + { + label: "删除", + callback: this.deleteItem, + class: "warn", + }, + ], + }, + ], listData: [], topFilter: { type: "", + name: "", time: "", }, types: [], tempFilter: {}, + detailForm: { + type: 0, // 0:新增 1:修改 + style_id: "", + example_name: "", + content: "", + }, + detailFormRules: { + style_id: [ + { required: true, message: "请选择SDK类型", trigger: "change" }, + ], + example_name: [ + { required: true, message: "请输入示例名称", trigger: "blur" }, + { max: 20, message: "长度应小于20个字符", trigger: "change" }, + ], + }, + deleteDialogInfo: { + msg: "", + submit: null, + }, + saveSection: false, + selection: [], }; }, + created() { + this.getTypes(); + }, methods: { init(filter) { let fullFilter = { @@ -103,13 +272,48 @@ export default { }; this.tempFilter = filter; + this.saveSection = true; + + this.$http + .get("/apaas/support/sdk/example/list", { + params: { + style: fullFilter.type, + name: fullFilter.name, + start: fullFilter.time && fullFilter.time[0], + end: fullFilter.time && fullFilter.time[1], + limit: fullFilter.size, + page: fullFilter.page, + }, + }) + .then(({ data }) => { + if (data.success === 1) { + this.listTotal = data.total; + this.listData = data.data || []; - console.log(fullFilter); + this.$nextTick(() => { + this.selection.forEach((item) => { + let target = this.listData.find((v) => v.id === item.id); + + if (target) { + this.setCurrentRow(target, true); + } + }); + this.saveSection = false; + }); + } + }); + }, + getTypes() { + this.$http.get("/apaas/support/sdk/styleNames/list").then(({ data }) => { + if (data.success === 1) { + this.types = data.data || []; + } + }); }, topFilterClear() { this.topFilter = { - name: "", type: "", + name: "", time: "", }; this.refreshPage(); @@ -120,6 +324,262 @@ export default { refreshPage() { this.$refs.list.resetCurrentPage(); }, + deleteSlection() { + if (this.selection.length) { + let names = []; + let ids = []; + + this.selection.forEach((item) => { + names.push(item.example_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() { + this.$refs.list.clearSelection(); + }, + setCurrentRow(row, flag) { + this.$refs.list.setSelectedRow(row, flag); + }, + addNewSdk() { + this.detailForm = { + type: 0, + style_id: (this.types[0] && this.types[0].id) || "", + example_name: "", + content: "", + }; + this.$refs.detailDialog.show(); + }, + viewItem(item) { + this.detailForm = { + type: 1, + }; + this.detailRequest(item.id); + this.$refs.viewDialog.show(); + }, + editItem(item) { + this.detailRequest(item.id); + this.$refs.detailDialog.show(); + }, + deleteItem(item) { + this.deleteDialogInfo.msg = `确认删除${item.example_name}吗?`; + this.deleteDialogInfo.submit = () => { + this.deleteRequest([item.id]); + }; + this.$refs.deleteDialog.show(); + }, + getTimeText(time) { + return helper.dateStringTransform(time); + }, + selectAction(values) { + if (this.saveSection) { + return; + } + + let cleanPage = values.length === 0; // 是否清空当前页所有选中 + let selection = [...this.selection]; + + if (cleanPage) { + selection = selection.filter((item) => { + return !this.listData.find((v) => { + return v.id === item.id; + }); + }); + } else { + selection.push(...values); + } + + this.selection = selection; + }, + detailEditContent() { + this.$router.push({ + name: "technicalSupportSdkExampleDetail", + params: { + id: this.detailForm.id, + }, + }); + }, + detailCancelAction() { + this.$refs.detailDialog.hide(); + }, + detailSubmitAction() { + this.$refs.detailForm.validate((valid) => { + if (valid) { + if (this.detailForm.type === 0) { + this.addRequest( + { + style_id: this.detailForm.style_id, + example_name: this.detailForm.example_name, + content: this.detailForm.content, + }, + (data) => { + this.$router.push({ + name: "technicalSupportSdkExampleDetail", + params: { + id: data.id, + }, + }); + } + ); + } else { + this.editRequest( + { + id: this.detailForm.id, + style_id: this.detailForm.style_id, + example_name: this.detailForm.example_name, + content: this.detailForm.content, + }, + () => { + this.refreshPage(); + this.$refs.detailDialog.hide(); + } + ); + } + } else { + return false; + } + }); + }, + detailRequest(id) { + this.$http + .get("/apaas/support/sdk/example/detail", { + params: { + id: id, + }, + }) + .then(({ data }) => { + if (data.success === 1) { + this.detailForm = { + ...data.data, + type: 1, + }; + } + }); + }, + deleteRequest(ids) { + this.$http + .delete("/apaas/support/sdk/example/delete", { + body: { + ids: ids, + }, + }) + .then(({ data }) => { + if (data.success === 1) { + this.$message.success("删除成功"); + this.selection = []; + this.refreshPage(); + } else { + this.$message.error("删除失败"); + } + }) + .catch((error) => { + console.log(error); + this.$message.error("删除失败"); + }); + }, + addRequest(data, callback) { + this.$http + .post("/apaas/support/sdk/example/create", data) + .then(({ data }) => { + if (data.success === 1) { + this.$message.success("新增成功"); + typeof callback === "function" && callback(data.data); + } else { + this.$message.error(data.errMsg || "新增失败"); + } + }) + .catch((error) => { + console.log(error); + this.$message.error("新增失败"); + }); + }, + editRequest(data, callback) { + this.$http + .put("/apaas/support/sdk/example/put", data) + .then(({ data }) => { + if (data.success === 1) { + this.$message.success("修改成功"); + typeof callback === "function" && callback(); + } else { + this.$message.error(data.errMsg || "修改失败"); + } + }) + .catch((error) => { + console.log(error); + this.$message.error("修改失败"); + }); + }, }, }; + + + + diff --git a/src/pages/technical-support/sdk-manage/type/index.vue b/src/pages/technical-support/sdk-manage/type/index.vue index 9c3010887c203019afdd0de706476d28d1b8d18d..471e8c1cff7ebccf8699096b8d90e762c523066a 100644 --- a/src/pages/technical-support/sdk-manage/type/index.vue +++ b/src/pages/technical-support/sdk-manage/type/index.vue @@ -85,7 +85,7 @@ :title="detailForm.type === 0 ? '新增' : '修改'" >
- + - { - this.deleteRequest(this.selection.map((row) => row.id)); - }; - this.$refs.deleteDialog.show(); + if (this.selection.length) { + let names = []; + let ids = []; + + 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() { this.$refs.list.clearSelection(); @@ -307,58 +315,60 @@ export default { this.$refs.detailDialog.hide(); }, detailSubmitAction() { - if (this.detailForm.type === 0) { - this.$http - .post("/apaas/support/sdk/styles/create", { - style_name: this.detailForm.style_name, - version: this.detailForm.version, - file_url: this.detailForm.file_url, - }) - .then(({ data }) => { - if (data.success === 1) { - this.$message.success("新增成功"); - this.refreshPage(); - this.$refs.detailDialog.hide(); - } else { - this.$message.error("新增失败"); - } - }) - .catch((error) => { - console.log(error); - this.$message.error("新增失败"); - }); - } else { - this.$http - .put("/apaas/support/sdk/styles/put", { - id: this.detailForm.id, - style_name: this.detailForm.style_name, - version: this.detailForm.version, - file_url: this.detailForm.file_url, - }) - .then(({ data }) => { - if (data.success === 1) { - this.$message.success("修改成功"); - this.refreshPage(); - this.$refs.detailDialog.hide(); - } else { - this.$message.error("修改失败"); - } - }) - .catch((error) => { - console.log(error); - this.$message.error("修改失败"); - }); - } + this.$refs.detailForm.validate((valid) => { + if (valid) { + if (this.detailForm.type === 0) { + this.$http + .post("/apaas/support/sdk/styles/create", { + style_name: this.detailForm.style_name, + version: this.detailForm.version, + file_url: this.detailForm.file_url, + }) + .then(({ data }) => { + if (data.success === 1) { + this.$message.success("新增成功"); + this.refreshPage(); + this.$refs.detailDialog.hide(); + } else { + this.$message.error("新增失败"); + } + }) + .catch((error) => { + console.log(error); + this.$message.error("新增失败"); + }); + } else { + this.$http + .put("/apaas/support/sdk/styles/put", { + id: this.detailForm.id, + style_name: this.detailForm.style_name, + version: this.detailForm.version, + file_url: this.detailForm.file_url, + }) + .then(({ data }) => { + if (data.success === 1) { + this.$message.success("修改成功"); + this.refreshPage(); + this.$refs.detailDialog.hide(); + } else { + this.$message.error("修改失败"); + } + }) + .catch((error) => { + console.log(error); + this.$message.error("修改失败"); + }); + } + } else { + return false; + } + }); }, editItem(item) { this.detailForm = { 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", { params: { id: item.id, @@ -366,9 +376,12 @@ export default { }) .then(({ data }) => { if (data.success === 1) { - this.detailForm = data.data; + this.detailForm = { + ...data.data, + type: 1, + }; } - }); */ + }); this.$refs.detailDialog.show(); }, deleteItem(item) { diff --git a/src/pages/technical-support/sdk/detail.vue b/src/pages/technical-support/sdk/detail.vue index a27aa76c2195f820baf99c15b06485125864c7b5..2e03c3a952774981ca0a20420485d5349402b5a5 100644 --- a/src/pages/technical-support/sdk/detail.vue +++ b/src/pages/technical-support/sdk/detail.vue @@ -99,6 +99,7 @@ export default { .main_container { flex-grow: 1; height: calc(100% - 53px); + overflow: hidden; } .download_action { background-color: #fff; diff --git a/src/pages/technical-support/sdk/index.vue b/src/pages/technical-support/sdk/index.vue index 3ec268d939ceb1ef8b65acf77a3ac88d531dfb13..a8e03229c756c38c7dcc9589663cce6a495829a3 100644 --- a/src/pages/technical-support/sdk/index.vue +++ b/src/pages/technical-support/sdk/index.vue @@ -4,7 +4,7 @@ title="SDK中心" imgSrc="tool_ic_kaifawendang" :nav-list="navList" - :title-path="navList[0] && navList[0].path" + :title-path="activePath" style="width: 250px;" >
@@ -21,76 +21,52 @@ export default { sideNavBar, }, data: () => ({ + activePath: "", navList: [], }), methods: { initNavList() { - let activePath = ""; - let baseUrl = "/technical_support/sdk"; - let 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.$http.get("/apaas/support/sdk/menus").then(({ data }) => { + if (data.success === 1) { + let baseUrl = "/technical_support/sdk"; + let menu = data.data || []; - this.navList = data.map((item) => { - let children = item.children; - let nav = { - name: item.name, - path: `${baseUrl}/${item.name}`, - }; + this.navList = menu.map((item) => { + let children = item.children || []; - if (children.length > 0) { - nav.children = children.map((v) => { - let path = `${baseUrl}/${item.name}/${v.id}`; + let nav = { + name: item.name, + path: `${baseUrl}/${item.name}`, + }; + + if (children.length > 0) { + nav.children = children.map((v) => { + let path = `${baseUrl}/${item.name}/${v.id}`; - if (activePath === "") { - activePath = path; + if (this.activePath === "") { + this.activePath = path; + } + + return { + name: v.name, + path: path, + }; + }); + nav.open = true; + } else { + nav.disabled = true; } - return { - name: v.name, - path: path, - }; + return nav; }); - 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() { diff --git a/src/router/index.js b/src/router/index.js index a46bddb4173910bce58ca46615251274a49707db..51832ac1b039608558452a6dcf38669e770dbd65 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -257,6 +257,14 @@ export default new Router({ "@/pages/technical-support/sdk-manage/example/index" ), }, // SDK示例管理 + { + path: "/technical_support/sdk_manage/example/:id", + name: "technicalSupportSdkExampleDetail", + component: () => + import( + "@/pages/technical-support/sdk-manage/example/detail" + ), + }, // SDK示例详情 ], }, // SDK管理 ],