ApiTestList.vue 5.3 KB
Newer Older
H
haifeng414 已提交
1
<template>
Q
q4speed 已提交
2
  <div class="container" v-loading="result.loading">
H
haifeng414 已提交
3
    <div class="main-content">
王振 已提交
4
      <el-card class="table-card">
C
chenjianxing 已提交
5
        <template v-slot:header>
Q
q4speed 已提交
6
          <ms-table-header :condition.sync="condition" @search="search" :title="$t('commons.test')"
Q
q4speed 已提交
7
                           @create="create" :createTip="$t('load_test.create')"/>
C
chenjianxing 已提交
8
        </template>
Q
q4speed 已提交
9
        <el-table :data="tableData" class="table-content">
H
haifeng414 已提交
10 11
          <el-table-column
            prop="name"
C
i18n  
Captain.B 已提交
12
            :label="$t('commons.name')"
H
haifeng414 已提交
13 14 15
            width="150"
            show-overflow-tooltip>
          </el-table-column>
Q
q4speed 已提交
16 17 18 19 20
<!--          <el-table-column-->
<!--            prop="description"-->
<!--            :label="$t('commons.description')"-->
<!--            show-overflow-tooltip>-->
<!--          </el-table-column>-->
H
haifeng414 已提交
21 22
          <el-table-column
            prop="projectName"
C
i18n  
Captain.B 已提交
23
            :label="$t('load_test.project_name')"
H
haifeng414 已提交
24 25 26 27 28
            width="150"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            width="250"
C
i18n  
Captain.B 已提交
29
            :label="$t('commons.create_time')">
C
v-slot  
Captain.B 已提交
30
            <template v-slot:default="scope">
H
haifeng414 已提交
31 32 33 34 35
              <span>{{ scope.row.createTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
          <el-table-column
            width="250"
C
i18n  
Captain.B 已提交
36
            :label="$t('commons.update_time')">
C
v-slot  
Captain.B 已提交
37
            <template v-slot:default="scope">
H
haifeng414 已提交
38 39 40
              <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
Q
q4speed 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
          <el-table-column
            prop="status"
            :label="$t('commons.status')">
            <template v-slot:default="{row}">
              <el-tag size="mini" type="info" v-if="row.status === 'Saved'">
                {{ row.status }}
              </el-tag>
              <el-tag size="mini" type="primary" v-else-if="row.status === 'Starting'">
                {{ row.status }}
              </el-tag>
              <el-tag size="mini" type="success" v-else-if="row.status === 'Running'">
                {{ row.status }}
              </el-tag>
              <el-tag size="mini" type="warning" v-else-if="row.status === 'Reporting'">
                {{ row.status }}
              </el-tag>
              <el-tag size="mini" type="info" v-else-if="row.status === 'Completed'">
                {{ row.status }}
              </el-tag>
              <el-tooltip placement="top" v-else-if="row.status === 'Error'" effect="light">
                <template v-slot:content>
                  <div>{{row.description}}</div>
                </template>
                <el-tag size="mini" type="danger">
                  {{ row.status }}
                </el-tag>
              </el-tooltip>
              <span v-else>
                {{ row.status }}
              </span>
            </template>
          </el-table-column>
H
haifeng414 已提交
73 74
          <el-table-column
            width="150"
C
i18n  
Captain.B 已提交
75
            :label="$t('commons.operating')">
C
v-slot  
Captain.B 已提交
76
            <template v-slot:default="scope">
C
Captain.B 已提交
77
              <ms-table-operator @editClick="handleEdit(scope.row)" @deleteClick="handleDelete(scope.row)"/>
H
haifeng414 已提交
78 79 80
            </template>
          </el-table-column>
        </el-table>
Q
q4speed 已提交
81 82
        <ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
                             :total="total"/>
H
haifeng414 已提交
83
      </el-card>
H
haifeng414 已提交
84 85 86 87 88
    </div>
  </div>
</template>

<script>
Q
q4speed 已提交
89
  import MsTablePagination from "../../common/pagination/TablePagination";
Q
q4speed 已提交
90
  import MsTableHeader from "../../common/components/MsTableHeader";
C
Captain.B 已提交
91
  import MsTableOperator from "../../common/components/MsTableOperator";
Q
q4speed 已提交
92

H
haifeng414 已提交
93
  export default {
C
Captain.B 已提交
94
    components: {MsTableHeader, MsTablePagination, MsTableOperator},
H
haifeng414 已提交
95 96
    data() {
      return {
H
haifeng414 已提交
97
        result: {},
Q
q4speed 已提交
98
        condition: {name: ""},
C
Captain.B 已提交
99
        projectId: null,
H
haifeng414 已提交
100 101 102
        tableData: [],
        multipleSelection: [],
        currentPage: 1,
H
haifeng414 已提交
103
        pageSize: 5,
H
haifeng414 已提交
104
        total: 0,
Q
q4speed 已提交
105
        loading: false
H
haifeng414 已提交
106 107
      }
    },
Q
q4speed 已提交
108

Q
message  
q4speed 已提交
109 110 111 112 113
    beforeRouteEnter(to, from, next) {
      next(self => {
        self.projectId = to.params.projectId;
        self.search();
      });
H
haifeng414 已提交
114
    },
Q
q4speed 已提交
115

H
haifeng414 已提交
116
    methods: {
Q
q4speed 已提交
117 118 119
      create() {
        this.$router.push('/api/test/create');
      },
Q
q4speed 已提交
120
      search() {
H
haifeng414 已提交
121
        let param = {
Q
q4speed 已提交
122
          name: this.condition.name,
H
haifeng414 已提交
123
        };
H
haifeng414 已提交
124

C
Captain.B 已提交
125 126 127 128
        if (this.projectId !== 'all') {
          param.projectId = this.projectId;
        }

Q
q4speed 已提交
129 130
        let url = "/api/list/" + this.currentPage + "/" + this.pageSize
        this.result = this.$post(url, param, response => {
H
haifeng414 已提交
131 132 133
          let data = response.data;
          this.total = data.itemCount;
          this.tableData = data.listObject;
C
Captain.B 已提交
134
        });
H
haifeng414 已提交
135 136 137 138
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
Q
q4speed 已提交
139
      handleEdit(test) {
H
haifeng414 已提交
140
        this.$router.push({
Q
q4speed 已提交
141
          path: '/api/test/edit?id=' + test.id,
H
haifeng414 已提交
142
        })
H
haifeng414 已提交
143
      },
Q
q4speed 已提交
144 145
      handleDelete(test) {
        this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
C
i18n  
Captain.B 已提交
146
          confirmButtonText: this.$t('commons.confirm'),
147 148
          callback: (action) => {
            if (action === 'confirm') {
Q
q4speed 已提交
149
              this.result = this.$post("/api/delete", {id: test.id}, () => {
Q
message  
q4speed 已提交
150
                this.$success(this.$t('commons.delete_success'));
Q
q4speed 已提交
151
                this.search();
Q
q4speed 已提交
152
              });
153
            }
H
haifeng414 已提交
154 155
          }
        });
Q
q4speed 已提交
156
      }
H
haifeng414 已提交
157 158 159 160 161
    }
  }
</script>

<style scoped>
Q
q4speed 已提交
162
  .table-content {
C
style  
Captain.B 已提交
163 164
    width: 100%;
  }
H
haifeng414 已提交
165
</style>