Commit 6293c53f authored by 刘殿昕's avatar 刘殿昕

+api入口文件,统一使用axios+table上传,限制table-selarr的value为字符,fwzc+模型

parent fd4c3d70
......@@ -471,6 +471,9 @@ width: 620px!important;
.el-radio__input.is-checked .el-radio__inner::after {
background-color: #e56600;
}
.el-radio__inner:hover {
border-color: #e56600;
}
/* 面包屑样式 */
.bread_crumb {
margin: 20px;
......
<template>
<div class="text-xs-center">
<el-input
ref="inp"
v-model="inputText"
:disabled="couldNotEdit || name == ''"
size="small"
@input="changeValue"
class="table_in_input"
></el-input>
<div>
<div
v-if="typeHead == 'input' || type == '' || (typeHead == 'upload' && type == 'text')"
class="text-xs-center"
>
<el-input
ref="inp"
v-model="inputText"
:disabled="couldNotEdit || name == ''"
size="small"
@input="changeValue"
class="table_in_input"
></el-input>
</div>
<div v-else-if="typeHead == 'upload' && type == 'file'" class="table_upload">
<el-input
ref="inpUp"
v-model="inputTextUp"
size="small"
:disabled="true"
clearable
class="table_in_input"
>
<el-upload
slot="append"
action="/awecloud/static/image/upload"
:file-list="fileArray"
:limit="1"
:multiple="false"
:on-remove="handleRemove"
:on-success="handleSuccess"
:on-error="handleError"
:before-upload="beforeUpload"
:data="anotherData"
:disabled="couldNotEdit"
>
<el-button size="small" type="primary">上传文件</el-button>
</el-upload>
</el-input>
</div>
</div>
</template>
......@@ -28,8 +59,7 @@ export default {
default: ""
},
name: {
type: String,
default: ""
type: String
},
rowId: {
type: Number,
......@@ -38,15 +68,29 @@ export default {
couldNotEdit: {
type: Boolean,
default: false
},
type: {
type: String,
default: ""
},
typeHead: {
type: String,
default: ""
}
},
data: () => ({
inputText: ""
inputText: "",
fileArray: [],
anotherData: {
directory: "file"
},
inputTextUp: ""
}),
mounted() {
this.inputText = this.item;
},
methods: {
// input
changeValue() {
this.$emit("changeInputValue", {
rowId: this.rowId,
......@@ -54,7 +98,31 @@ export default {
inputValue: this.inputText,
id: this.id
});
}
},
// upload
beforeUpload(file) {},
handleSuccess(response, file, fileList) {
if (response.success == 1) {
this.fileArray.push({
url: response.data,
name: response.data
});
this.inputTextUp = file.name;
this.$emit("changeUpFile", {
rowId: this.rowId,
header: this.header,
inputValue: this.inputTextUp,
id: this.id,
fileUrl: response.data
});
} else {
this.$message.error("上传文件失败,请重试");
}
},
handleError(err, file, fileList) {
this.$message.error("上传文件失败,请重试");
},
handleRemove(file, fileList) {}
}
};
</script>
......@@ -62,7 +130,9 @@ export default {
.text-xs-center {
height: 32px;
}
.table_upload {
height: 32px;
}
.table_in_input {
text-align: center;
font-size: 14px;
......@@ -75,6 +145,22 @@ export default {
border-radius: 4px;
}
.text-xs-center .el-input.is-disabled .el-input__inner {
color: #70747C;
color: #70747c;
}
.table_upload input {
width: 100%;
background-color: #f7f8f9;
border-radius: 4px;
}
.table_upload .el-input.is-disabled .el-input__inner {
color: #70747c;
}
.table_upload .el-button {
background-color: #0f2683 !important;
color: #ffffff !important;
border-radius: 0 4px 4px 0;
}
.table_upload .el-input-group__append ul {
display: none;
}
</style>
\ No newline at end of file
......@@ -11,10 +11,10 @@
>
<template v-if="selectArr && selectArr.length > 0">
<el-option
v-for="(item,index) in selectArr"
v-for="(items, index) in selectArr"
:key="index+3500"
:label="item.label"
:value="item.value"
:label="items.label"
:value="items.value"
></el-option>
</template>
</el-select>
......@@ -44,12 +44,10 @@ export default {
default: ""
},
name: {
type: String,
default: ""
type: String
},
rowId: {
type: Number,
default: 0
type: Number
},
couldNotEdit: {
type: Boolean,
......@@ -57,12 +55,16 @@ export default {
}
},
data: () => ({
selectValue: "1"
selectValue: "0"
}),
mounted() {
this.selectValue = this.item;
if (!this.selectValue || this.selectValue == "") {
this.selectValue = this.selectArr[0].value;
if (this.selectValue == null || !this.selectValue || this.selectValue == "") {
if (this.selectArr && this.selectArr.length != 0) {
this.selectValue = this.selectArr[0].value;
} else {
this.selectValue = "";
}
}
},
methods: {
......
......@@ -144,21 +144,24 @@
></v-apaas-table-umhref>
<!-- could edit -->
<v-apaas-table-input
v-else-if="item.type === 'input'"
v-else-if="item.type === 'input' || item.type === 'upload'"
:item="helper.GetProperty(scope.row, item.prop)"
:header="item.prop"
:id="scope.row.id"
:name="scope.row.name"
:rowId="scope.$index"
:type="scope.row.type ? scope.row.type : ''"
:typeHead="item.type"
:couldNotEdit="couldNotEdit"
@changeInputValue="changeInputValue"
@changeUpFile="changeUpFile"
></v-apaas-table-input>
<!-- could select -->
<v-apaas-table-select
v-else-if="item.type === 'select'"
:item="helper.GetProperty(scope.row, item.prop)"
:header="item.prop"
:id="item.id"
:id="scope.row.id"
:name="scope.row.name"
:selectArr="item.selectArr"
:rowId="scope.$index"
......@@ -182,8 +185,11 @@
{{ [1,2,3].indexOf(scope.row[item.prop])!==-1?'':scope.row[item.prop] }}
</span>
<!-- 服务添加图标 -->
<span v-else-if="item.type === 'hot'" :style="scope.row['hot']?{marginLeft:'-10px'}:{paddingLeft:'2px'}">
<img src="../assets/imgs/list_ic_hot.png" alt="" v-if="scope.row['hot']">
<span
v-else-if="item.type === 'hot'"
:style="scope.row['hot']?{marginLeft:'-10px'}:{paddingLeft:'2px'}"
>
<img src="../assets/imgs/list_ic_hot.png" alt v-if="scope.row['hot']" />
{{ scope.row[item.prop] }}
</span>
<!-- others -->
......@@ -243,19 +249,19 @@
<script>
import services from "@/services";
import tableInput from "@/components/table-input";
import tableSelect from "@/components/table-select";
import TableInput from "@/components/table-input";
import TableSelect from "@/components/table-select";
import helper from "@/services/helper";
import DConfirm from "@/components/dialog-remove";
import tableUmhref from "@/components/table-umhref";
import tableFilter from "@/components/table-filter";
import TableUmhref from "@/components/table-umhref";
import TableFilter from "@/components/table-filter";
export default {
components: {
"v-apaas-table-input": tableInput,
"v-apaas-table-select": tableSelect,
"v-apaas-table-umhref": tableUmhref,
"v-apaas-table-input": TableInput,
"v-apaas-table-select": TableSelect,
"v-apaas-table-umhref": TableUmhref,
"d-confirm": DConfirm,
"v-apaas-table-filter": tableFilter
"v-apaas-table-filter": TableFilter
},
props: {
// 表格型号:mini,medium,small
......@@ -615,6 +621,7 @@ export default {
// console.log(this.$refs.cesTable)
let arr = this.selectedTabsPage;
this.changeInput(arr, val.id, val.inputValue, val.header);
this.selectedTabsPage = arr;
this.$emit("changeTable", this.selectedTabsPage);
if (
this.autoAdd &&
......@@ -643,13 +650,14 @@ export default {
// this code is low level, you could make it stronger
// use tableData[0] as template to edit
let newRow = {};
for (var item in this.selectedTabsPage[0]) {
newRow[item] = "";
}
let arr = this.headers;
arr.forEach(item => {
newRow[item.prop] = ""
})
newRow.id =
parseInt(Math.random() * 100000, 10) +
"" +
parseInt(Math.random() * 100000, 10);
parseInt(Math.random() * 100000, 10) +
"" +
parseInt(Math.random() * 100000, 10);
this.selectedTabsPage.push(newRow);
},
// get now table data
......@@ -658,6 +666,35 @@ export default {
},
filterChange(filter) {
console.log(filter);
},
// 上传文件事件
changeUpFile(val) {
let arr = this.selectedTabsPage;
this.changeUp(arr, val.id, val.inputValue, val.fileUrl, val.header);
this.selectedTabsPage = arr;
this.$emit("changeTable", this.selectedTabsPage);
console.log(arr, this.selectedTabsPage);
if (
this.autoAdd &&
val.inputValue != "" &&
val.rowId + 1 == this.selectedTabsPage.length
) {
this.addRow();
}
},
// 根据id修改该行上传文件数据
changeUp(arr, id, input, url, header) {
let self = this;
for (let i = 0; i < arr.length; i++) {
if (arr[i].id == id) {
arr[i][header] = input;
arr[i].file_url = url;
return false;
}
if (arr[i].children && arr[i].children.length != 0) {
self.changeUp(arr[i].children, id, input, header);
}
}
}
}
};
......@@ -682,7 +719,7 @@ export default {
border-bottom: 1px solid #ebeef5 !important;
}
.ces-table .el-table--border {
border: 1px solid #EBEEF5;
border: 1px solid #ebeef5;
}
/* .ces-table .el-table--enable-row-hover, */
.ces-table .el-table tbody tr:hover > td {
......
......@@ -49,7 +49,9 @@ export default {
return {
hideUpload: false,
fileArray: [],
anotherData: {}
anotherData: {
directory: "file"
}
};
},
props: {
......@@ -148,8 +150,6 @@ export default {
}
let url = file.url;
let detection = true;
// 等于 true 说明是刚刚上传的
// 判断方法有很多 随便用一种。
if (url) detection = url.indexOf("blob") != -1;
if (detection) {
this.fileArray.forEach((item, i, arr) => {
......
......@@ -22,6 +22,9 @@ import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
import api from './request/api'
Vue.prototype.$api = api;
new Vue({
el: "#app",
router,
......
......@@ -118,13 +118,17 @@ export default {
],
headers1: [
{ label: "服务url", prop: "date", type: "input", align: "left" },
{ label: "服务名称", prop: "name", type: "input", align: "center" },
{ label: "服务名称", prop: "ssss", type: "upload", align: "center" },
{
label: "是否必要",
prop: "address",
label: "文件类型",
prop: "type",
type: "select",
align: "center",
width: 100
width: 100,
selectArr: [
{ label: "Text", value: "Text" },
{ label: "File", value: "File" }
]
}
],
headers2: [
......
......@@ -19,7 +19,7 @@
<div class="gray_line"></div>
<div v-if="activeBtn == 4">
<div class="sqxx_title">服务类型:</div>
<el-select v-model="zhyyVal" placeholder="请选择" class="zhyy_select">
<el-select @change="changeZhType" v-model="zhyyVal" placeholder="请选择" class="zhyy_select">
<el-option
v-for="item in optionsZhyy"
:key="item.value"
......@@ -58,9 +58,9 @@
ref="fwcs_sjfw_qq"
size="mini"
:border="true"
:headers="sjfw_qqcs"
:headers="sjfwQqcs"
url
:datas="datasFw"
:datas="datasSj"
:searchShow="false"
:addRowBtn="false"
:autoAdd="true"
......@@ -73,12 +73,13 @@
:paginationShow="false"
:pageSizeShow="false"
headerCellClassName="th_pink"
@changeTable="changeTable"
></ces-table>
</el-tab-pane>
<el-tab-pane label="请求体" name="1">
<div class="sjfw_qqt">
<el-radio v-model="sjfwQqt" label="JSON">JSON</el-radio>
<el-radio-group v-model="sjfwQqt">
<el-radio label="JSON">JSON</el-radio>
</el-radio-group>
</div>
<v-apaas-code ref="jsonCodes"></v-apaas-code>
</el-tab-pane>
......@@ -118,15 +119,99 @@
<el-button v-if="activeBtn == 1" @click="clickFwcs()" class="fwcs_btn_fwcs">服务测试</el-button>
</div>
</div>
<div v-if="activeBtn == 4">
<el-tabs v-model="activeZh" class="fwcs_tabs" @tab-click="clickTab">
<el-tab-pane label="请求参数" name="0">
<ces-table
ref="fwcs_zhfw_qq"
size="mini"
:border="true"
:headers="sjfwQqcs"
url
:datas="datasZh"
:searchShow="false"
:addRowBtn="false"
:autoAdd="true"
:isDialog="false"
:isSelection="false"
:isIndex="true"
:radius="true"
:emptyText="emptyText"
:stripe="false"
:paginationShow="false"
:pageSizeShow="false"
headerCellClassName="th_pink"
@changeTable="changeTable"
></ces-table>
</el-tab-pane>
<el-tab-pane label="请求体" name="1">
<div class="sjfw_qqt">
<el-radio-group v-model="zhfwQqt" @change="changeZhfwQqt">
<el-radio label="JSON">JSON</el-radio>
<el-radio label="form-data">form-data</el-radio>
<el-radio label="x-www-form-urlencoded">x-www-form-urlencoded</el-radio>
</el-radio-group>
</div>
<div v-show="zhfwQqt == 'JSON'">
<v-apaas-code ref="zhfwJsonCodes"></v-apaas-code>
</div>
<div v-show="zhfwQqt == 'form-data'">
<ces-table
ref="fwcs_zhfw_qq_form"
size="mini"
:border="true"
:headers="zhfwQqcsForm"
url
:datas="datasZhForm"
:searchShow="false"
:addRowBtn="false"
:autoAdd="true"
:isDialog="false"
:isSelection="false"
:isIndex="true"
:radius="true"
:emptyText="emptyText"
:stripe="false"
:paginationShow="false"
:pageSizeShow="false"
headerCellClassName="th_pink"
></ces-table>
</div>
<div v-show="zhfwQqt == 'x-www-form-urlencoded'">
<ces-table
ref="fwcs_zhfw_www"
size="mini"
:border="true"
:headers="sjfwQqcs"
url
:datas="datasZhwww"
:searchShow="false"
:addRowBtn="false"
:autoAdd="true"
:isDialog="false"
:isSelection="false"
:isIndex="true"
:radius="true"
:emptyText="emptyText"
:stripe="false"
:paginationShow="false"
:pageSizeShow="false"
headerCellClassName="th_pink"
@changeTable="changeTable"
></ces-table>
</div>
</el-tab-pane>
</el-tabs>
</div>
</block-radius>
<block-radius v-if="resultShow">
<div v-if="activeBtn == 0 && resSuccess">
<block-radius v-show="resultShow">
<div v-show="activeBtn == 0 && resSuccess">
<div class="sjfw_qqcstx">请求参数信息填写:</div>
<ces-table
ref="fwcs_sjfw_qqcs"
size="mini"
:border="true"
:headers="sjfw_qqcstx"
:headers="sjfwQqcstx"
url
:datas="datasQqcs"
:searchShow="false"
......@@ -141,13 +226,14 @@
:paginationShow="false"
:pageSizeShow="false"
headerCellClassName="th_pink"
@primary-del="delItemQq"
></ces-table>
<div class="sjfw_fhcstx">返回参数信息填写:</div>
<ces-table
ref="fwcs_sjfw_fhcs"
size="mini"
:border="true"
:headers="sjfw_fhcstx"
:headers="sjfwFhcstx"
url
:datas="datasFhcs"
:searchShow="false"
......@@ -162,18 +248,24 @@
:paginationShow="false"
:pageSizeShow="false"
headerCellClassName="th_pink"
@primary-del="delItemFh"
></ces-table>
</div>
<div v-else-if="(activeBtn == 1 || activeBtn == 4) && resSuccess">
<div v-show="(activeBtn == 1 || activeBtn == 4) && resSuccess">
<div class="skfw_csfwxx">测试服务信息:</div>
<div class="test_succ">
<div v-if="skfwResult" class="skcs_jg">
<div class="skcs_jg">
<img src="@/assets/imgs/test_icon_success.png" class="skcs_jg_img" />&nbsp;测试成功
</div>
</div>
</div>
<div v-else class="skcs_jg">
<img src="@/assets/imgs/test_icon_error.png" class="skcs_jg_img" />&nbsp;测试失败
<div v-show="(activeBtn == 0 || activeBtn == 1 || activeBtn == 4) && !resSuccess">
<div class="skfw_csfwxx">测试服务信息:</div>
<div class="test_succ">
<div class="skcs_jg">
<img src="@/assets/imgs/test_icon_error.png" class="skcs_jg_img" />&nbsp;测试失败
</div>
</div>
</div>
<div class="btn_footer">
<el-button class="reset" v-if="activeBtn == 0" @click="resetSjfw">重置</el-button>
......@@ -280,10 +372,13 @@ export default {
select: "GET",
optionType: [
{ label: "GET", value: "GET" },
{ label: "POST", value: "POST" }
{ label: "POST", value: "POST" },
{ label: "PUT", value: "PUT" },
{ label: "DELETE", value: "DELETE" }
],
activeName: 0,
sjfw_qqcs: [
activeZh: 0,
sjfwQqcs: [
{
label: "请求字段编码",
prop: "requestEncoding",
......@@ -292,7 +387,7 @@ export default {
},
{ label: "请求值", prop: "requestValue", type: "input", align: "left" }
],
sjfw_qqcstx: [
sjfwQqcstx: [
{ label: "字段编码", prop: "name", type: "", align: "left" },
{ label: "示例值", prop: "example", type: "input", align: "left" },
{
......@@ -315,13 +410,25 @@ export default {
align: "left",
width: 100,
selectArr: [
{ label: "", value: 1 },
{ label: "", value: 0 }
{ label: "", value: "1" },
{ label: "", value: "0" }
]
},
{ label: "字段说明", prop: "descript", type: "input", align: "left" }
{ label: "字段说明", prop: "descript", type: "input", align: "left" },
{
label: "操作",
type: "Button",
align: "center",
width: 100,
btnList: [
{
type: "primary-del",
label: "删除"
}
]
}
],
sjfw_fhcstx: [
sjfwFhcstx: [
{ label: "字段编码", prop: "name", type: "", align: "left" },
{ label: "示例值", prop: "example", type: "input", align: "left" },
{ label: "字段类型", prop: "show_type", type: "", align: "left" },
......@@ -331,8 +438,49 @@ export default {
type: "input",
align: "left"
},
{ label: "字段说明", prop: "descript", type: "input", align: "left" }
{ label: "字段说明", prop: "descript", type: "input", align: "left" },
{
label: "操作",
type: "Button",
align: "center",
width: 100,
btnList: [
{
type: "primary-del",
label: "删除"
}
]
}
],
zhfwQqcsForm: [
{ label: "请求字段编码", prop: "key", type: "input", align: "left" },
{
label: "参数类型",
prop: "field_type",
type: "select",
align: "center",
width: 100,
selectArr: [
{ label: "Text", value: "text" },
{ label: "File", value: "file" }
]
},
{ label: "请求值", prop: "val", type: "upload", align: "center" },
{
label: "操作",
type: "Button",
align: "center",
width: 100,
btnList: [
{
type: "primary-del",
label: "删除"
}
]
}
],
datasZhForm: [],
datasZhwww: [],
emptyText: "暂无数据",
resultShow: false,
resSuccess: false,
......@@ -340,6 +488,7 @@ export default {
sqfsVal: "",
tokenVal: "",
sjfwQqt: "JSON",
zhfwQqt: "JSON",
skfwRadios: [
"ArcGIS Server Web",
"文档",
......@@ -349,7 +498,6 @@ export default {
"OGS(WFS)",
"OGS(WCS)"
],
skfwResult: false,
optionsZhyy: [
{ label: "模型算法类", value: 0 },
{ label: "查询验证类", value: 1 },
......@@ -381,7 +529,8 @@ export default {
{ label: "其他", value: 10 }
],
optionsOrganization: [],
datasFw: [],
datasSj: [],
datasZh: [],
datasQqcs: [],
datasFhcs: [],
request_fields: [],
......@@ -399,6 +548,7 @@ export default {
this.activeBtn = val;
this.select = "GET";
this.serviceUrl = "";
this.noSearchUrl = "";
},
getUrl(enUrl) {
let url = decodeURI(enUrl);
......@@ -415,9 +565,15 @@ export default {
arr[i].requestValue = pair[1] ? pair[1] : "";
}
}
} else {
this.noSearchUrl = enUrl;
}
this.serviceUrl = url;
this.datasFw = arr;
if (this.activeBtn == 0) {
this.datasSj = arr;
} else if (this.activeBtn == 4) {
this.datasZh = arr;
}
},
clickFwcs() {
let headers = {};
......@@ -428,7 +584,30 @@ export default {
headers.Authorization[0] = this.sqfsVal + " " + this.tokenVal;
}
let request = this.$refs.fwcs_sjfw_qq.getTableData();
console.log(request);
for (let i = 0; i < request.length; i++) {
if (
request[i] &&
request[i].requestEncoding &&
request[i].requestValue &&
request[i].requestEncoding != "" &&
request[i].requestValue != ""
) {
if (
Object.keys(requestData).indexOf(request[i].requestEncoding) == -1
) {
requestData[request[i].requestEncoding] = [];
requestData[request[i].requestEncoding][0] =
request[i].requestValue;
} else {
requestData[request[i].requestEncoding].push(
request[i].requestValue
);
}
}
}
} else if (this.activeBtn == 1) {
} else if (this.activeBtn == 4) {
let request = this.$refs.fwcs_zhfw_qq.getTableData();
for (let i = 0; i < request.length; i++) {
if (
request[i] &&
......@@ -451,42 +630,56 @@ export default {
}
}
}
let url = `/apaas/service/v3/service/manager/test`;
let bodys = "";
let contentType = "";
if (this.activeBtn == 0) {
bodys = this.$refs.jsonCodes.getCodesVal();
contentType = this.sjfwQqt;
} else if (this.activeBtn == 4) {
if (this.activeZh == 1) {
contentType = this.zhfwQqt;
if (this.zhfwQqt == "JSON") {
bodys = this.$refs.zhfwJsonCodes.getCodesVal();
} else if (this.zhfwQqt == "form-data") {
let request = this.$refs.fwcs_zhfw_qq_form.getTableData();
bodys = JSON.stringify(request);
} else if (this.zhfwQqt == "x-www-form-urlencoded") {
let request = this.$refs.fwcs_zhfw_www.getTableData();
bodys = JSON.stringify(request);
}
}
}
let query = {
method: this.select,
url: this.serviceUrl,
headers: headers,
params: requestData,
body: this.$refs.jsonCodes.getCodesVal()
body: bodys,
content_type: contentType
};
this.$http
.post(url, query)
.then(response => {
if (response.data.success == 1) {
let data = response.data.data;
if (this.activeBtn == 0 && this.activeName == 1) {
this.datasQqcs = data.body_fields;
} else if (this.activeBtn == 0) {
this.datasQqcs = data.param_fields;
}
this.datasFhcs = data.response_fields;
this.resSuccess = true;
this.resultShow = true;
} else {
this.resSuccess = false;
this.resultShow = true;
console.log(response.data.console.error);
this.$api.workbench.fwzcFwcs(query).then(response => {
console.log(response);
if (response.data.success == 1) {
let data = response.data.data;
if (this.activeBtn == 0 && this.activeName == 1) {
this.datasQqcs = data.body_fields;
} else if (this.activeBtn == 0) {
this.datasQqcs = data.param_fields;
}
})
.catch(function(response) {
console.log("unkonw error");
});
this.datasFhcs = data.response_fields;
this.resSuccess = true;
this.resultShow = true;
} else {
this.resSuccess = false;
this.resultShow = true;
console.log(response.data.console.error);
}
});
},
clickTab() {},
clickNext() {
console.log(this.$refs.fwcs_sjfw_qq.getTableData());
resetSjfw() {
this.clickFwcs();
},
resetSjfw() {},
nextJcxx() {
let requestData = this.$refs.fwcs_sjfw_qqcs.getTableData();
let responseData = this.$refs.fwcs_sjfw_fhcs.getTableData();
......@@ -509,7 +702,6 @@ export default {
for (let i = 0; i < arr.length; i++) {
if (arr[i].name && arr[i].name != "") {
if (!arr[i].label || arr[i].label == "") {
console.log(arr[i]);
if (rule == 0) {
this.requestRules = 1;
} else if (rule == 1) {
......@@ -528,6 +720,8 @@ export default {
this.cover = val;
},
previous() {
this.datasQqcs = this.request_fields;
this.datasFhcs = this.response_fields;
this.jcxxtx = false;
},
registe() {
......@@ -552,31 +746,55 @@ export default {
response_fields: this.response_fields
};
let url = `/apaas/service/v3/service/manager`;
this.$http
.post(url, query)
.then(response => {
if (response.data.success == 1) {
this.$message.success("服务注册成功");
} else {
console.log(response.data.errMsg);
this.$message.success(response.data.errMsg);
}
})
.catch(function(response) {
console.log("unkonw error");
});
this.$api.workbench.serviceAdd(query).then(response => {
if (response.data.success == 1) {
this.$message.success("服务注册成功");
} else {
console.log(response.data.errMsg);
this.$message.success(response.data.errMsg);
}
});
},
changeTable(val) {
let search = "?";
for (let i = 0; i < val.length; i++) {
if (val[i].requestEncoding != "") {
search =
search + val[i].requestEncoding + "=" + val[i].requestValue + "&";
search +
val[i].requestEncoding +
"=" +
(val[i].requestValue ? val[i].requestValue : "") +
"&";
}
}
let searchDel = search.substring(0, search.length - 1);
this.serviceUrl = this.noSearchUrl + searchDel;
}
},
delItemQq(val) {
let arr = this.$refs.fwcs_sjfw_qqcs.getTableData();
this.delById(arr, val.id);
},
delItemFh(val) {
let arr = this.$refs.fwcs_sjfw_fhcs.getTableData();
this.delById(arr, val.id);
},
delById(arr, id) {
let self = this;
for (let i = 0; i < arr.length; i++) {
if (arr[i].id == id) {
arr.splice(i, 1);
return false;
}
if (arr[i].children && arr[i].children.length != 0) {
self.delById(arr[i].children, id);
}
}
},
changeZhType(val) {
this.resultShow = false;
this.resSuccess = false;
},
changeZhfwQqt() {}
},
mounted() {}
};
......
import workbench from '@/request/api/workbench';
export default {
workbench,
}
\ No newline at end of file
import axios from '@/request/http'; // 导入http中创建的axios实例
import qs from 'qs'; // 根据需求是否导入qs模块
const workbench = {
// 新闻列表
fwzcFwcs(params) {
return axios.post(`/apaas/service/v3/service/manager/test`, params);
},
serviceAdd(params) {
return axios.post(`/apaas/service/v3/service/manager`, params)
}
}
export default workbench;
/**
* axios封装
* 请求拦截、响应拦截、错误统一处理
*/
import axios from 'axios';
import router from '../router';
import store from '../store/index';
/**
* 提示函数
* 禁止点击蒙层、显示一秒后关闭
*/
const tip = msg => {
this.$message({
message: msg,
type: 'warning'
});
}
/**
* 跳转登录页
* 携带当前页面路由,以期在登录页面完成登录后返回当前页面
*/
const toLogin = () => {
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
}
/**
* 请求失败后的错误统一处理
* @param {Number} status 请求失败的状态码
*/
const errorHandle = (status, other) => {
// 状态码判断
switch (status) {
// 401: 未登录状态,跳转登录页
case 401:
toLogin();
break;
// 403 token过期
// 清除token并跳转登录页
case 403:
tip('登录过期,请重新登录');
localStorage.removeItem('token');
store.commit('loginSuccess', null);
setTimeout(() => {
toLogin();
}, 1000);
break;
// 404请求不存在
case 404:
tip('请求的资源不存在');
break;
default:
console.log(other);
}
}
// 创建axios实例
var instance = axios.create({ timeout: 1000 * 12 });
// 设置post请求头
instance.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
/**
* 请求拦截器
* 每次请求前,如果存在token则在请求头中携带token
*/
instance.interceptors.request.use(
config => {
const token = store.state.token;
token && (config.headers.Authorization = token);
return config;
},
error => Promise.error(error))
// 响应拦截器
instance.interceptors.response.use(
// 请求成功
res => res.status === 200 ? Promise.resolve(res) : Promise.reject(res),
// 请求失败
error => {
const { response } = error;
if (response) {
// 请求已发出,但是不在2xx的范围
errorHandle(response.status, response.data.message);
return Promise.reject(response);
}
});
export default instance;
......@@ -4,28 +4,28 @@
{
"date": "2016-05-02",
"name": "王小虎",
"address": "0",
"type": "File",
"id": "ssss2722",
"state": 0
},
{
"date": "2016-05-04",
"name": "王小虎",
"address": "0",
"type": "Text",
"id": "ssss2224",
"state": 0
},
{
"date": "2016-05-01",
"name": "王小虎",
"address": "0",
"type": "Text",
"id": "ssss222",
"state": 1
},
{
"date": "2016-05-03",
"name": "王小虎",
"address": "0",
"type": "File",
"id": "ssss22",
"state": 2
}
......
......@@ -1362,6 +1362,13 @@ axios@^0.15.3:
dependencies:
follow-redirects "1.0.0"
axios@^0.19.2:
version "0.19.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
dependencies:
follow-redirects "1.5.10"
babel-helper-vue-jsx-merge-props@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-2.0.3.tgz#22aebd3b33902328e513293a8e4992b384f9f1b6"
......@@ -2418,6 +2425,13 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
dependencies:
ms "2.0.0"
debug@=3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"
debug@^3.0.0, debug@^3.1.1, debug@^3.2.5:
version "3.2.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
......@@ -3136,6 +3150,13 @@ follow-redirects@1.0.0:
dependencies:
debug "^2.2.0"
follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
dependencies:
debug "=3.1.0"
follow-redirects@^1.0.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.10.0.tgz#01f5263aee921c6a54fb91667f08f4155ce169eb"
......@@ -5777,6 +5798,11 @@ qs@6.7.0:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
qs@^6.9.4:
version "6.9.4"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.4.tgz#9090b290d1f91728d3c22e54843ca44aea5ab687"
integrity sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==
query-string@^4.3.2:
version "4.3.4"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-4.3.4.tgz#bbb693b9ca915c232515b228b1a02b609043dbeb"
......
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