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

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

H
haifeng414 已提交
61
  export default {
Q
q4speed 已提交
62 63 64 65
    components: {
      MsTableOperators,
      MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
    },
H
haifeng414 已提交
66 67
    data() {
      return {
H
haifeng414 已提交
68
        result: {},
Q
q4speed 已提交
69
        condition: {name: ""},
C
Captain.B 已提交
70
        projectId: null,
H
haifeng414 已提交
71 72 73
        tableData: [],
        multipleSelection: [],
        currentPage: 1,
H
haifeng414 已提交
74
        pageSize: 5,
H
haifeng414 已提交
75
        total: 0,
Q
q4speed 已提交
76 77 78 79 80 81 82 83 84 85 86 87
        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 已提交
88 89 90 91 92 93 94 95
        ],
        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 已提交
96
        ]
H
haifeng414 已提交
97 98
      }
    },
Q
q4speed 已提交
99

Q
q4speed 已提交
100
    watch: {
Q
q4speed 已提交
101
      '$route': 'init'
H
haifeng414 已提交
102
    },
Q
q4speed 已提交
103

H
haifeng414 已提交
104
    methods: {
Q
q4speed 已提交
105 106 107
      create() {
        this.$router.push('/api/test/create');
      },
Q
q4speed 已提交
108
      search() {
H
haifeng414 已提交
109
        let param = {
Q
q4speed 已提交
110
          name: this.condition.name,
H
haifeng414 已提交
111
        };
H
haifeng414 已提交
112

C
Captain.B 已提交
113 114 115 116
        if (this.projectId !== 'all') {
          param.projectId = this.projectId;
        }

Q
q4speed 已提交
117 118
        let url = "/api/list/" + this.currentPage + "/" + this.pageSize
        this.result = this.$post(url, param, response => {
H
haifeng414 已提交
119 120 121
          let data = response.data;
          this.total = data.itemCount;
          this.tableData = data.listObject;
C
Captain.B 已提交
122
        });
H
haifeng414 已提交
123 124 125 126
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
Q
q4speed 已提交
127
      handleEdit(test) {
H
haifeng414 已提交
128
        this.$router.push({
Q
q4speed 已提交
129
          path: '/api/test/edit?id=' + test.id,
H
haifeng414 已提交
130
        })
H
haifeng414 已提交
131
      },
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 147 148 149 150
      handleCopy(test) {
        this.result = this.$post("/api/copy", {id: test.id}, () => {
          this.$success(this.$t('commons.delete_success'));
          this.search();
        });
      },
Q
q4speed 已提交
151 152 153
      init() {
        this.projectId = this.$route.params.projectId;
        this.search();
W
wenyann 已提交
154
      },
155
     /* filter(value, row) {
W
wenyann 已提交
156
        return row.status === value;
157 158 159 160 161 162 163 164 165
      }*/
      sort(column) {
        _sort(column, this.condition);
        this.initTableData();
      },
      filter(filters) {
        _filter(filters, this.condition);
        this.initTableData();
      },
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%;
  }
H
haifeng414 已提交
178
</style>