ApiTestList.vue 4.1 KB
Newer Older
H
haifeng414 已提交
1
<template>
Q
q4speed 已提交
2 3 4
  <ms-container>
    <ms-main-container>
      <el-card class="table-card" v-loading="result.loading">
C
chenjianxing 已提交
5
        <template v-slot:header>
Q
q4speed 已提交
6
          <ms-table-header :condition.sync="condition" @search="search" :title="$t('api_test.title')"
Q
q4speed 已提交
7
                           @create="create" :createTip="$t('load_test.create')"/>
C
chenjianxing 已提交
8
        </template>
Q
q4speed 已提交
9
        <el-table :data="tableData" class="table-content">
Q
q4speed 已提交
10
          <el-table-column prop="name" :label="$t('commons.name')" width="150" show-overflow-tooltip>
H
haifeng414 已提交
11
          </el-table-column>
Q
q4speed 已提交
12
          <el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip>
H
haifeng414 已提交
13
          </el-table-column>
Q
q4speed 已提交
14
          <el-table-column width="250" :label="$t('commons.create_time')">
C
v-slot  
Captain.B 已提交
15
            <template v-slot:default="scope">
H
haifeng414 已提交
16 17 18
              <span>{{ scope.row.createTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
Q
q4speed 已提交
19
          <el-table-column width="250" :label="$t('commons.update_time')">
C
v-slot  
Captain.B 已提交
20
            <template v-slot:default="scope">
H
haifeng414 已提交
21 22 23
              <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
Q
q4speed 已提交
24
          <el-table-column prop="status" :label="$t('commons.status')">
Q
q4speed 已提交
25
            <template v-slot:default="{row}">
Q
q4speed 已提交
26
              <ms-api-test-status :row="row"/>
Q
q4speed 已提交
27 28
            </template>
          </el-table-column>
Q
q4speed 已提交
29
          <el-table-column width="150" :label="$t('commons.operating')">
C
v-slot  
Captain.B 已提交
30
            <template v-slot:default="scope">
C
Captain.B 已提交
31
              <ms-table-operator @editClick="handleEdit(scope.row)" @deleteClick="handleDelete(scope.row)"/>
H
haifeng414 已提交
32 33 34
            </template>
          </el-table-column>
        </el-table>
Q
q4speed 已提交
35 36
        <ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
                             :total="total"/>
H
haifeng414 已提交
37
      </el-card>
Q
q4speed 已提交
38 39
    </ms-main-container>
  </ms-container>
H
haifeng414 已提交
40 41 42
</template>

<script>
Q
q4speed 已提交
43
  import MsTablePagination from "../../common/pagination/TablePagination";
Q
q4speed 已提交
44
  import MsTableHeader from "../../common/components/MsTableHeader";
C
Captain.B 已提交
45
  import MsTableOperator from "../../common/components/MsTableOperator";
Q
q4speed 已提交
46 47
  import MsContainer from "../../common/components/MsContainer";
  import MsMainContainer from "../../common/components/MsMainContainer";
Q
q4speed 已提交
48
  import MsApiTestStatus from "./ApiTestStatus";
Q
q4speed 已提交
49

H
haifeng414 已提交
50
  export default {
Q
q4speed 已提交
51
    components: {MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator},
H
haifeng414 已提交
52 53
    data() {
      return {
H
haifeng414 已提交
54
        result: {},
Q
q4speed 已提交
55
        condition: {name: ""},
C
Captain.B 已提交
56
        projectId: null,
H
haifeng414 已提交
57 58 59
        tableData: [],
        multipleSelection: [],
        currentPage: 1,
H
haifeng414 已提交
60
        pageSize: 5,
H
haifeng414 已提交
61
        total: 0,
Q
q4speed 已提交
62
        loading: false
H
haifeng414 已提交
63 64
      }
    },
Q
q4speed 已提交
65

Q
message  
q4speed 已提交
66 67 68 69 70
    beforeRouteEnter(to, from, next) {
      next(self => {
        self.projectId = to.params.projectId;
        self.search();
      });
H
haifeng414 已提交
71
    },
Q
q4speed 已提交
72

H
haifeng414 已提交
73
    methods: {
Q
q4speed 已提交
74 75 76
      create() {
        this.$router.push('/api/test/create');
      },
Q
q4speed 已提交
77
      search() {
H
haifeng414 已提交
78
        let param = {
Q
q4speed 已提交
79
          name: this.condition.name,
H
haifeng414 已提交
80
        };
H
haifeng414 已提交
81

C
Captain.B 已提交
82 83 84 85
        if (this.projectId !== 'all') {
          param.projectId = this.projectId;
        }

Q
q4speed 已提交
86 87
        let url = "/api/list/" + this.currentPage + "/" + this.pageSize
        this.result = this.$post(url, param, response => {
H
haifeng414 已提交
88 89 90
          let data = response.data;
          this.total = data.itemCount;
          this.tableData = data.listObject;
C
Captain.B 已提交
91
        });
H
haifeng414 已提交
92 93 94 95
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
Q
q4speed 已提交
96
      handleEdit(test) {
H
haifeng414 已提交
97
        this.$router.push({
Q
q4speed 已提交
98
          path: '/api/test/edit?id=' + test.id,
H
haifeng414 已提交
99
        })
H
haifeng414 已提交
100
      },
Q
q4speed 已提交
101 102
      handleDelete(test) {
        this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
C
i18n  
Captain.B 已提交
103
          confirmButtonText: this.$t('commons.confirm'),
104 105
          callback: (action) => {
            if (action === 'confirm') {
Q
q4speed 已提交
106
              this.result = this.$post("/api/delete", {id: test.id}, () => {
Q
message  
q4speed 已提交
107
                this.$success(this.$t('commons.delete_success'));
Q
q4speed 已提交
108
                this.search();
Q
q4speed 已提交
109
              });
110
            }
H
haifeng414 已提交
111 112
          }
        });
Q
q4speed 已提交
113
      }
H
haifeng414 已提交
114 115 116 117 118
    }
  }
</script>

<style scoped>
Q
q4speed 已提交
119
  .table-content {
C
style  
Captain.B 已提交
120 121
    width: 100%;
  }
H
haifeng414 已提交
122
</style>