This commit is contained in:
wenyann 2020-06-02 16:47:24 +08:00
parent 03c39aee90
commit 6e57757d61
2 changed files with 26 additions and 18 deletions

View File

@ -3,10 +3,12 @@
<ms-main-container> <ms-main-container>
<el-card class="table-card" v-loading="result.loading"> <el-card class="table-card" v-loading="result.loading">
<template v-slot:header> <template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search" :title="$t('api_report.title')" <ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
:title="$t('api_report.title')"
:show-create="false"/> :show-create="false"/>
</template> </template>
<el-table :data="tableData" class="table-content"> <el-table :data="tableData" class="table-content" @sort-change="sort"
@filter-change="filter">
<el-table-column :label="$t('commons.name')" width="200" show-overflow-tooltip> <el-table-column :label="$t('commons.name')" width="200" show-overflow-tooltip>
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-link type="info" @click="handleView(scope.row)">{{ scope.row.name }}</el-link> <el-link type="info" @click="handleView(scope.row)">{{ scope.row.name }}</el-link>
@ -22,7 +24,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="status" :label="$t('commons.status')" <el-table-column prop="status" :label="$t('commons.status')"
:filter-method="filter" column-key="status"
:filters="statusFilters"> :filters="statusFilters">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<ms-api-report-status :row="row"/> <ms-api-report-status :row="row"/>
@ -50,13 +52,14 @@
import MsContainer from "../../common/components/MsContainer"; import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import MsApiReportStatus from "./ApiReportStatus"; import MsApiReportStatus from "./ApiReportStatus";
import {_filter, _sort} from "../../../../common/js/utils";
export default { export default {
components: {MsApiReportStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination}, components: {MsApiReportStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination},
data() { data() {
return { return {
result: {}, result: {},
condition: {name: ""}, condition: {},
tableData: [], tableData: [],
multipleSelection: [], multipleSelection: [],
currentPage: 1, currentPage: 1,
@ -80,16 +83,14 @@
methods: { methods: {
search() { search() {
let param = {
name: this.condition.name,
};
if (this.testId !== 'all') { if (this.testId !== 'all') {
param.testId = this.testId; this.condition.testId = this.testId;
} }
let url = "/api/report/list/" + this.currentPage + "/" + this.pageSize let url = "/api/report/list/" + this.currentPage + "/" + this.pageSize
this.result = this.$post(url, param, response => { this.result = this.$post(url, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
@ -120,9 +121,18 @@
this.testId = this.$route.params.testId; this.testId = this.$route.params.testId;
this.search(); this.search();
}, },
filter(value, row) { /* filter(value, row) {
return row.status === value; return row.status === value;
} },*/
sort(column) {
_sort(column, this.condition);
this.init();
},
filter(filters) {
_filter(filters, this.condition);
this.init();
},
}, },
created() { created() {

View File

@ -66,7 +66,7 @@
data() { data() {
return { return {
result: {}, result: {},
condition: {name: ""}, condition: {},
projectId: null, projectId: null,
tableData: [], tableData: [],
multipleSelection: [], multipleSelection: [],
@ -106,16 +106,14 @@
this.$router.push('/api/test/create'); this.$router.push('/api/test/create');
}, },
search() { search() {
let param = {
name: this.condition.name,
};
if (this.projectId !== 'all') { if (this.projectId !== 'all') {
param.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
let url = "/api/list/" + this.currentPage + "/" + this.pageSize let url = "/api/list/" + this.currentPage + "/" + this.pageSize
this.result = this.$post(url, param, response => { this.result = this.$post(url, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;