fix(高级搜索): 修改请求方式

--bug=1017762 --user=李玉号 【接口测试】高级搜索,责任人 / 关注人 / 所属模块 下拉框没有内容
https://www.tapd.cn/55049933/s/1258909
This commit is contained in:
shiziyuan9527 2022-10-11 18:51:23 +08:00 committed by lyh
parent 12af180b4b
commit 0002f98f7a
4 changed files with 25 additions and 22 deletions

View File

@ -1,13 +1,16 @@
<template>
<ms-table-search-component v-model="component.operator.value" :component="component" v-bind="$attrs" v-on="$listeners">
<ms-table-search-component v-model="component.operator.value" :component="component" v-bind="$attrs"
v-on="$listeners">
<template v-slot="scope">
<el-select v-if="!component.showInput" v-model="scope.component.value" :placeholder="$t('commons.please_select')" size="small"
filterable v-bind="scope.component.props" class="search-select" v-loading="result.loading">
<el-select v-if="!component.showInput" v-model="scope.component.value" :placeholder="$t('commons.please_select')"
size="small"
filterable v-bind="scope.component.props" class="search-select" v-loading="loading">
<el-option v-for="op in options" :key="op.value" :label="label(op)" :value="op.value">
<span class="demand-span">{{label(op)}}</span>
<span class="demand-span">{{ label(op) }}</span>
</el-option>
</el-select>
<el-input v-model="scope.component.value" v-if="component.showInput" :placeholder="$t('commons.input_content')" size="small"/>
<el-input v-model="scope.component.value" v-if="component.showInput" :placeholder="$t('commons.input_content')"
size="small"/>
</template>
</ms-table-search-component>
</template>
@ -15,6 +18,7 @@
<script>
import MsTableSearchComponent from "./MsTableSearchComponet";
import {getCurrentProjectID, getCurrentUser} from "../../utils/token";
import {get} from "../../plugins/request";
export default {
name: "MsTableSearchMix",
@ -23,9 +27,7 @@ export default {
inheritAttrs: false,
data() {
return {
result: {
loading: false
},
loading: false,
options: !(this.component.options instanceof Array) ? [] : this.component.options || []
}
},
@ -37,7 +39,7 @@ export default {
projectId = getCurrentUser().lastProjectId;
}
this.component.options.url += '/' + projectId;
this.result = this.$get(this.component.options.url, response => {
this.loading = get(this.component.options.url).then(response => {
if (response.data) {
response.data.forEach(item => {
this.options.push({
@ -72,6 +74,7 @@ export default {
display: inline-block;
width: 100%;
}
.demand-span {
display: inline-block;
max-width: 400px;

View File

@ -6,7 +6,7 @@
v-bind="$attrs">
<template v-slot="scope">
<el-select
v-loading="result.loading"
v-loading="loading"
v-model="scope.component.value"
:placeholder="$t('commons.please_select')"
:popper-append-to-body="false"
@ -51,7 +51,8 @@
import MsTableSearchComponent from "./MsTableSearchComponet";
import MsNodeTree from "../module/MsNodeTree";
import {cloneDeep} from "lodash";
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
import {getCurrentProjectID} from "../../utils/token";
import {get, post} from "../../plugins/request";
export default {
@ -64,7 +65,7 @@ export default {
data() {
return {
treeOptions: [],
result: {},
loading: false,
treeNodes: [],
filterText: '',
}
@ -87,15 +88,15 @@ export default {
if (!url) return;
url += '/' + getCurrentProjectID();
if (type === "POST") {
this.result = this.$post(url, params || {}, response => {
this.loading = post(url, params || {}).then(response => {
this.handleTreeNodes(response.data);
});
})
return;
}
if (type === "GET") {
this.result = this.$get(this.handleGETUrl(url, params), response => {
this.loading = get(this.handleGETUrl(url, params)).then(response => {
this.handleTreeNodes(response.data);
});
})
}
},
reload() {

View File

@ -2,7 +2,7 @@
<ms-table-search-component v-model="component.operator.value" :component="component" v-bind="$attrs" v-on="$listeners">
<template v-slot="scope">
<el-select v-model="scope.component.value" :placeholder="$t('commons.please_select')" size="small"
filterable v-bind="scope.component.props" class="search-select" v-loading="result.loading">
filterable v-bind="scope.component.props" class="search-select" v-loading="loading">
<el-option v-for="op in options" :key="op.value" :label="label(op)" :value="op.value">
<span class="demand-span">{{label(op)}}</span>
</el-option>
@ -13,6 +13,7 @@
<script>
import MsTableSearchComponent from "./MsTableSearchComponet";
import {get} from "../../plugins/request";
export default {
name: "MsTableSearchSelect",
@ -21,15 +22,13 @@ export default {
inheritAttrs: false,
data() {
return {
result: {
loading: false
},
loading: false,
options: !(this.component.options instanceof Array) ? [] : this.component.options || []
}
},
created() {
if (!(this.component.options instanceof Array) && this.component.options.url) {
this.result = this.$get(this.component.options.url, response => {
this.loading = get(this.component.options.url).then(response => {
if (response.data) {
response.data.forEach(item => {
this.options.push({

View File

@ -485,7 +485,7 @@ export const PRINCIPAL = {
}
}
},
options: MS_USER_OPTIONS,
options: MS_PROJECT_USER_OPTIONS,
props: {
multiple: true
},