From b524d69cb699dfb54d1786724534075eaf2fc338 Mon Sep 17 00:00:00 2001 From: liudianxin Date: Tue, 4 Aug 2020 18:41:37 +0800 Subject: [PATCH] portal --- src/pages/workbench/fwzc_fwcs.vue | 181 +++++++++++++++--------------- 1 file changed, 91 insertions(+), 90 deletions(-) diff --git a/src/pages/workbench/fwzc_fwcs.vue b/src/pages/workbench/fwzc_fwcs.vue index a46cd31..4cadb12 100644 --- a/src/pages/workbench/fwzc_fwcs.vue +++ b/src/pages/workbench/fwzc_fwcs.vue @@ -354,8 +354,8 @@ -
- +
+
@@ -934,109 +934,109 @@ export default { addPortalItem() { console.log("添加portal"); //添加服务到portal - var url = - "https://apaasgis.wodcloud.com/portal/sharing/rest/content/users/" + + let url = + "https://apaasgis.wodcloud.com/portal//portal/sharing/rest/content/users/" + this.portalUser.username + "/addItem"; - $.ajax({ - url: url, - type: "POST", - contentType: "application/x-www-form-urlencoded", - //data: json, - data: { - f: "json", - tags: this.industryTree_apaas_Config["1"], - title: "测试添加服务5", - url: - "https://apaasgis.wodcloud.com/server/rest/services/GZ_FJXQZTT/FeatureServer", - type: this.dataTree_apaas_config["19"], - token: this.portalUser.token, - }, - dataType: "json", //dataType不能少 - success: function (result) { - if (result.error != null) { - alert("添加专题图到Portal中失败," + result.error.message); + let data = { + f: "json", + tags: this.industryTree_apaas_Config["1"], + title: "测试添加服务5", + url: + "https://apaasgis.wodcloud.com/server/rest/services/GZ_FJXQZTT/FeatureServer", + type: this.dataTree_apaas_config["19"], + token: this.portalUser.token, + }; + this.$http + .post(url, data) + .then((response) => { + if (response.data.success == 1) { + this.shareItem(response.data.id); } else { - this.shareItem(result.id); + this.$message({ + message: `删除失败`, + type: "warning", + }); } - }, - error: function (xhr, status, err) { - alert("添加专题图到Portal中失败," + xhr.responseText); - }, - }); + }) + .catch((error) => { + console.log(error); + this.$message({ + message: `添加专题图到Portal中失败,${error}`, + type: "warning", + }); + }); }, shareItem(itemid) { console.log(`共享portal${itemid}`); - var searchUrl = - "https://apaasgis.wodcloud.com/portal/sharing/rest/content/users/" + + let searchUrl = + "https://apaasgis.wodcloud.com/portal//portal/sharing/rest/content/users/" + this.portalUser.username + "/shareItems"; - $.ajax({ - url: searchUrl, - dataType: "json", - method: "POST", - data: { - items: itemid, - everyone: true, - token: this.portalUser.token, - f: "json", - groups: null, - }, - success: function (data) {}, - error: function (err) { - alert(err); - }, - }); + let data = { + items: itemid, + everyone: true, + token: this.portalUser.token, + f: "json", + groups: null, + }; + this.$http + .post(searchUrl, data) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.log(error); + }); }, getItemInfo(itemid) { console.log(`获取portal参数${itemid}`); - var searchUrl = - "https://apaasgis.wodcloud.com/portal/sharing/rest/content/users/" + + let searchUrl = + "https://apaasgis.wodcloud.com/portal//portal/sharing/rest/content/users/" + this.portalUser.username + "/items/" + itemid; - $.ajax({ - url: searchUrl, - dataType: "json", - method: "POST", - data: { - token: this.portalUser.token, - f: "json", - }, - success: function (data) { - var sectors = ""; - $(data.item.tags).each(function (i, tag) { - if (!!this.industryTree_apaas_Config[tag]) { - sectors = this.industryTree_apaas_Config[tag]; - return; - } - }); - this.form = { - name: data.item.title, - desc: data.item.description, - area: sectors, - origin: "", - code: "自动生成", - resource: 1, - }; - this.cover = - "https://apaasgis.wodcloud.com/portal/sharing/rest/content/items/" + - data.item.id + - "/info/" + - data.item.thumbnail + - "?token=" + - this.portalUser.token; - this.iportal_id = data.item.id; - this.serviceUrl = data.item.url; - this.portal_data_service_type_2 = this.dataTree_apaas_config[ - data.item.type - ]; - console.log(item); - }, - error: function (err) { - alert(err); - }, - }); + let data = { + token: this.portalUser.token, + f: "json", + }; + this.$http + .post(searchUrl, data) + .then((response) => { + console.log(response); + if (response.data.success == 1) { + var sectors = ""; + $(data.item.tags).each(function (i, tag) { + if (!!this.industryTree_apaas_Config[tag]) { + sectors = this.industryTree_apaas_Config[tag]; + return; + } + }); + this.form = { + name: data.item.title, + desc: data.item.description, + area: sectors, + origin: "", + code: "自动生成", + resource: 1, + }; + this.cover = + "https://apaasgis.wodcloud.com/portal/sharing/rest/content/items/" + + data.item.id + + "/info/" + + data.item.thumbnail + + "?token=" + + this.portalUser.token; + this.iportal_id = data.item.id; + this.serviceUrl = data.item.url; + this.portal_data_service_type_2 = this.dataTree_apaas_config[ + data.item.type + ]; + } + }) + .catch((error) => { + console.log(error); + }); }, }, mounted() { @@ -1046,6 +1046,7 @@ export default { console.log(event); if (event.data && event.data.cmd == "getPortalUser") { this.portalUser = event.data.params; + console.log(this.portalUser); this.portal_status = true; } }, -- 2.26.0