ApiTestList.vue 6.0 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 7
          <ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
                           :title="$t('commons.test')"
Q
q4speed 已提交
8
                           @create="create" :createTip="$t('load_test.create')"/>
C
chenjianxing 已提交
9
        </template>
C
chenjianxing 已提交
10
        <el-table :data="tableData" class="table-content" @sort-change="sort" @row-click="handleView"
11
                  @filter-change="filter">
12
          <el-table-column prop="name" :label="$t('commons.name')" width="250" show-overflow-tooltip>
H
haifeng414 已提交
13
          </el-table-column>
Q
q4speed 已提交
14
          <el-table-column prop="projectName" :label="$t('load_test.project_name')" width="200" show-overflow-tooltip/>
Q
q4speed 已提交
15
          <el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
W
wenyann 已提交
16 17
          <el-table-column width="250" :label="$t('commons.create_time')" sortable
                           prop="createTime">
C
v-slot  
Captain.B 已提交
18
            <template v-slot:default="scope">
H
haifeng414 已提交
19 20 21
              <span>{{ scope.row.createTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
W
wenyann 已提交
22 23
          <el-table-column width="250" :label="$t('commons.update_time')" sortable
                           prop="updateTime">
C
v-slot  
Captain.B 已提交
24
            <template v-slot:default="scope">
H
haifeng414 已提交
25 26 27
              <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
W
wenyann 已提交
28
          <el-table-column prop="status" :label="$t('commons.status')"
29
                           column-key="status"
W
wenyann 已提交
30
                           :filters="statusFilters">
Q
q4speed 已提交
31
            <template v-slot:default="{row}">
Q
q4speed 已提交
32
              <ms-api-test-status :row="row"/>
Q
q4speed 已提交
33 34
            </template>
          </el-table-column>
Q
q4speed 已提交
35
          <el-table-column width="150" :label="$t('commons.operating')">
C
v-slot  
Captain.B 已提交
36
            <template v-slot:default="scope">
Q
q4speed 已提交
37
              <ms-table-operators :buttons="buttons" :row="scope.row"/>
H
haifeng414 已提交
38 39 40
            </template>
          </el-table-column>
        </el-table>
Q
q4speed 已提交
41 42
        <ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
                             :total="total"/>
H
haifeng414 已提交
43
      </el-card>
Q
q4speed 已提交
44 45
    </ms-main-container>
  </ms-container>
H
haifeng414 已提交
46 47 48
</template>

<script>
Q
q4speed 已提交
49
  import MsTablePagination from "../../common/pagination/TablePagination";
Q
q4speed 已提交
50
  import MsTableHeader from "../../common/components/MsTableHeader";
C
Captain.B 已提交
51
  import MsTableOperator from "../../common/components/MsTableOperator";
Q
q4speed 已提交
52 53
  import MsContainer from "../../common/components/MsContainer";
  import MsMainContainer from "../../common/components/MsMainContainer";
Q
q4speed 已提交
54
  import MsApiTestStatus from "./ApiTestStatus";
Q
q4speed 已提交
55
  import MsTableOperators from "../../common/components/MsTableOperators";
56
  import {_filter, _sort} from "../../../../common/js/utils";
Q
q4speed 已提交
57

H
haifeng414 已提交
58
  export default {
Q
q4speed 已提交
59 60 61 62
    components: {
      MsTableOperators,
      MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
    },
H
haifeng414 已提交
63 64
    data() {
      return {
H
haifeng414 已提交
65
        result: {},
W
''  
wenyann 已提交
66
        condition: {},
C
Captain.B 已提交
67
        projectId: null,
H
haifeng414 已提交
68 69 70
        tableData: [],
        multipleSelection: [],
        currentPage: 1,
H
haifeng414 已提交
71
        pageSize: 5,
H
haifeng414 已提交
72
        total: 0,
Q
q4speed 已提交
73 74 75 76 77 78 79 80 81 82 83 84
        loading: false,
        buttons: [
          {
            tip: this.$t('commons.edit'), icon: "el-icon-edit",
            exec: this.handleEdit
          }, {
            tip: this.$t('commons.copy'), icon: "el-icon-copy-document", type: "success",
            exec: this.handleCopy
          }, {
            tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
            exec: this.handleDelete
          }
W
wenyann 已提交
85 86 87 88 89 90 91 92
        ],
        statusFilters: [
          {text: 'Saved', value: 'Saved'},
          {text: 'Starting', value: 'Starting'},
          {text: 'Running', value: 'Running'},
          {text: 'Reporting', value: 'Reporting'},
          {text: 'Completed', value: 'Completed'},
          {text: 'Error', value: 'Error'}
Q
q4speed 已提交
93
        ]
H
haifeng414 已提交
94 95
      }
    },
Q
q4speed 已提交
96

Q
q4speed 已提交
97
    watch: {
Q
q4speed 已提交
98
      '$route': 'init'
H
haifeng414 已提交
99
    },
Q
q4speed 已提交
100

H
haifeng414 已提交
101
    methods: {
Q
q4speed 已提交
102 103 104
      create() {
        this.$router.push('/api/test/create');
      },
Q
q4speed 已提交
105
      search() {
W
''  
wenyann 已提交
106

H
haifeng414 已提交
107

C
Captain.B 已提交
108
        if (this.projectId !== 'all') {
W
''  
wenyann 已提交
109
          this.condition.projectId = this.projectId;
C
Captain.B 已提交
110 111
        }

Q
q4speed 已提交
112
        let url = "/api/list/" + this.currentPage + "/" + this.pageSize
W
''  
wenyann 已提交
113
        this.result = this.$post(url, this.condition, response => {
H
haifeng414 已提交
114 115 116
          let data = response.data;
          this.total = data.itemCount;
          this.tableData = data.listObject;
C
Captain.B 已提交
117
        });
H
haifeng414 已提交
118 119 120 121
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
Q
q4speed 已提交
122
      handleEdit(test) {
H
haifeng414 已提交
123
        this.$router.push({
Q
q4speed 已提交
124
          path: '/api/test/edit?id=' + test.id,
H
haifeng414 已提交
125
        })
H
haifeng414 已提交
126
      },
C
chenjianxing 已提交
127 128 129 130 131
      handleView(test) {
        this.$router.push({
          path: '/api/test/view?id=' + test.id,
        })
      },
Q
q4speed 已提交
132 133
      handleDelete(test) {
        this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
C
i18n  
Captain.B 已提交
134
          confirmButtonText: this.$t('commons.confirm'),
135 136
          callback: (action) => {
            if (action === 'confirm') {
Q
q4speed 已提交
137
              this.result = this.$post("/api/delete", {id: test.id}, () => {
Q
message  
q4speed 已提交
138
                this.$success(this.$t('commons.delete_success'));
Q
q4speed 已提交
139
                this.search();
Q
q4speed 已提交
140
              });
141
            }
H
haifeng414 已提交
142 143
          }
        });
Q
q4speed 已提交
144
      },
Q
q4speed 已提交
145 146
      handleCopy(test) {
        this.result = this.$post("/api/copy", {id: test.id}, () => {
Q
q4speed 已提交
147
          this.$success(this.$t('commons.copy_success'));
Q
q4speed 已提交
148 149 150
          this.search();
        });
      },
Q
q4speed 已提交
151 152
      init() {
        this.projectId = this.$route.params.projectId;
153 154 155
        if (this.projectId && this.projectId !== "all") {
          this.$store.commit('setProjectId', this.projectId);
        }
Q
q4speed 已提交
156
        this.search();
W
wenyann 已提交
157
      },
158 159
      sort(column) {
        _sort(column, this.condition);
W
''  
wenyann 已提交
160
        this.init();
161 162 163
      },
      filter(filters) {
        _filter(filters, this.condition);
W
''  
wenyann 已提交
164
        this.init();
165
      },
Q
q4speed 已提交
166 167 168
    },
    created() {
      this.init();
H
haifeng414 已提交
169
    }
W
wenyann 已提交
170

H
haifeng414 已提交
171 172 173 174
  }
</script>

<style scoped>
Q
q4speed 已提交
175
  .table-content {
C
style  
Captain.B 已提交
176 177
    width: 100%;
  }
178 179 180 181

  .el-table {
    cursor: pointer;
  }
H
haifeng414 已提交
182
</style>