FunctionalTestPlan.vue 5.4 KB
Newer Older
H
haifeng414 已提交
1
<template>
H
haifeng414 已提交
2
  <div class="testplan-container" v-loading="result.loading">
H
haifeng414 已提交
3 4 5 6
    <div class="main-content">
      <el-card>
        <div slot="header">
          <el-row type="flex" justify="space-between" align="middle">
C
i18n  
Captain.B 已提交
7
            <span class="title">{{$t('commons.test')}}</span>
H
haifeng414 已提交
8
            <span class="search">
C
i18n  
Captain.B 已提交
9 10 11
            <el-input type="text" size="small" :placeholder="$t('load_test.search_by_name')"
                      prefix-icon="el-icon-search"
                      maxlength="60"
H
haifeng414 已提交
12
                      v-model="condition" @change="search" clearable/>
H
haifeng414 已提交
13 14 15
          </span>
          </el-row>
        </div>
C
style  
Captain.B 已提交
16
        <el-table :data="tableData" class="test-content">
H
haifeng414 已提交
17 18
          <el-table-column
            prop="name"
C
i18n  
Captain.B 已提交
19
            :label="$t('commons.name')"
H
haifeng414 已提交
20 21 22 23 24
            width="150"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="description"
C
i18n  
Captain.B 已提交
25
            :label="$t('commons.description')"
H
haifeng414 已提交
26 27 28 29
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="projectName"
C
i18n  
Captain.B 已提交
30
            :label="$t('load_test.project_name')"
H
haifeng414 已提交
31 32 33 34 35
            width="150"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            width="250"
C
i18n  
Captain.B 已提交
36
            :label="$t('commons.create_time')">
H
haifeng414 已提交
37 38 39 40 41 42
            <template slot-scope="scope">
              <span>{{ scope.row.createTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
          <el-table-column
            width="250"
C
i18n  
Captain.B 已提交
43
            :label="$t('commons.update_time')">
H
haifeng414 已提交
44 45 46 47 48 49
            <template slot-scope="scope">
              <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
            </template>
          </el-table-column>
          <el-table-column
            width="150"
C
i18n  
Captain.B 已提交
50
            :label="$t('commons.operating')">
H
haifeng414 已提交
51
            <template slot-scope="scope">
C
i18n  
Captain.B 已提交
52 53
              <el-button @click="handleEdit(scope.row)" type="primary" icon="el-icon-edit" size="mini" circle/>
              <el-button @click="handleDelete(scope.row)" type="danger" icon="el-icon-delete" size="mini" circle/>
H
haifeng414 已提交
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
            </template>
          </el-table-column>
        </el-table>
        <div>
          <el-row>
            <el-col :span="22" :offset="1">
              <div class="table-page">
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page.sync="currentPage"
                  :page-sizes="[5, 10, 20, 50, 100]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="total">
                </el-pagination>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-card>
H
haifeng414 已提交
75 76 77 78 79 80 81 82
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
H
haifeng414 已提交
83
        result: {},
H
haifeng414 已提交
84 85
        queryPath: "/testplan/list",
        deletePath: "/testplan/delete",
H
haifeng414 已提交
86
        condition: "",
C
Captain.B 已提交
87
        projectId: null,
H
haifeng414 已提交
88 89 90
        tableData: [],
        multipleSelection: [],
        currentPage: 1,
H
haifeng414 已提交
91
        pageSize: 5,
H
haifeng414 已提交
92
        total: 0,
H
haifeng414 已提交
93
        loading: false,
C
Captain.B 已提交
94
        testId: null,
H
haifeng414 已提交
95 96
      }
    },
C
Captain.B 已提交
97
    watch: {
C
Captain.B 已提交
98
      '$route'(to) {
C
Captain.B 已提交
99 100 101 102
        this.projectId = to.params.projectId;
        this.initTableData();
      }
    },
H
haifeng414 已提交
103
    created: function () {
C
Captain.B 已提交
104
      this.projectId = this.$route.params.projectId;
H
haifeng414 已提交
105 106 107 108
      this.initTableData();
    },
    methods: {
      initTableData() {
H
haifeng414 已提交
109
        let param = {
C
Captain.B 已提交
110
          name: this.condition,
H
haifeng414 已提交
111
        };
H
haifeng414 已提交
112

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

H
haifeng414 已提交
117
        this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
H
haifeng414 已提交
118 119 120
          let data = response.data;
          this.total = data.itemCount;
          this.tableData = data.listObject;
C
Captain.B 已提交
121
        });
H
haifeng414 已提交
122
      },
H
haifeng414 已提交
123 124 125
      search() {
        this.initTableData();
      },
H
haifeng414 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
      buildPagePath(path) {
        return path + "/" + this.currentPage + "/" + this.pageSize;
      },
      handleSizeChange(size) {
        this.pageSize = size;
        this.initTableData();
      },
      handleCurrentChange(current) {
        this.currentPage = current;
        this.initTableData();
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      handleEdit(testPlan) {
H
haifeng414 已提交
141
        this.$router.push({
142
          path: '/performance/plan/edit/' + testPlan.id,
H
haifeng414 已提交
143
        })
H
haifeng414 已提交
144 145
      },
      handleDelete(testPlan) {
C
i18n  
Captain.B 已提交
146 147
        this.$alert(this.$t('load_test.delete_confirm') + testPlan.name + "", '', {
          confirmButtonText: this.$t('commons.confirm'),
148 149 150 151
          callback: (action) => {
            if (action === 'confirm') {
              this._handleDelete(testPlan);
            }
H
haifeng414 已提交
152 153 154 155 156
          }
        });
      },
      _handleDelete(testPlan) {
        let data = {
H
haifeng414 已提交
157
          id: testPlan.id
H
haifeng414 已提交
158 159
        };

H
haifeng414 已提交
160
        this.result = this.$post(this.deletePath, data, () => {
H
haifeng414 已提交
161
          this.$message({
C
i18n  
Captain.B 已提交
162
            message: this.$t('commons.delete_success'),
H
haifeng414 已提交
163 164 165
            type: 'success'
          });
          this.initTableData();
H
haifeng414 已提交
166 167 168 169 170 171 172
        });
      },
    }
  }
</script>

<style scoped>
H
haifeng414 已提交
173
  .testplan-container {
H
haifeng414 已提交
174 175 176 177 178 179 180 181 182 183
    padding: 15px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
  }

  .main-content {
    margin: 0 auto;
    width: 100%;
    max-width: 1200px;
H
haifeng414 已提交
184
  }
H
haifeng414 已提交
185

C
style  
Captain.B 已提交
186 187 188 189
  .test-content {
    width: 100%;
  }

H
haifeng414 已提交
190 191 192 193 194
  .table-page {
    padding-top: 20px;
    margin-right: -9px;
    float: right;
  }
H
haifeng414 已提交
195
</style>