ApiTestList.vue 5.5 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('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>
Q
q4speed 已提交
84 85
    </ms-main-container>
  </ms-container>
H
haifeng414 已提交
86 87 88
</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 93
  import MsContainer from "../../common/components/MsContainer";
  import MsMainContainer from "../../common/components/MsMainContainer";
Q
q4speed 已提交
94

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

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

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

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

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

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