|
|
@@ -1,33 +1,147 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<div class="title">部署管理</div>
|
|
|
+ <div class="body">
|
|
|
+ <el-table
|
|
|
+ :data="deployments"
|
|
|
+ :height="'70vh'"
|
|
|
+ :header-cell-style="{'text-align':'center'}"
|
|
|
+ :cell-style="{'text-align':'center', 'cursor': 'pointer'}"
|
|
|
+ :default-sort = "{prop: 'deployedTime', order: 'descending'}"
|
|
|
+ @row-click="viewDetails">
|
|
|
+ <el-table-column
|
|
|
+ prop="id"
|
|
|
+ label="ID"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="pipelineId"
|
|
|
+ label="流水线ID"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="namespace"
|
|
|
+ width="auto">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag>{{ scope.row.namespace }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="deployName"
|
|
|
+ width="auto">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag type="success">{{ scope.row.deployName }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="deployedTime"
|
|
|
+ label="部署时间"
|
|
|
+ width="250"
|
|
|
+ sortable>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <div class="footer">
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="currentPage"
|
|
|
+ :page-sizes="[5, 10, 20]"
|
|
|
+ :page-size="pageSize"
|
|
|
+ layout="sizes, prev, pager, next"
|
|
|
+ :total="totalItems">
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getTotalDeployments } from '@/api/deployment'
|
|
|
+import { getTotalDeployments,
|
|
|
+ getDeploymentsByCurrentAndSize} from '@/api/deployment'
|
|
|
export default {
|
|
|
name: 'DeploymentManage',
|
|
|
data() {
|
|
|
- return {}
|
|
|
+ return {
|
|
|
+ pageTotal: 0,
|
|
|
+ pageSize: 10,
|
|
|
+ currentPage: 1,
|
|
|
+ deployments: []
|
|
|
+ }
|
|
|
},
|
|
|
- mounted() {
|
|
|
- const config = {
|
|
|
- params: {
|
|
|
- pageSize: 20
|
|
|
- }
|
|
|
+ computed: {
|
|
|
+ totalItems() {
|
|
|
+ return this.pageSize * this.pageTotal
|
|
|
}
|
|
|
- getTotalDeployments(config).then(res => {
|
|
|
- console.log(res);
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err);
|
|
|
- })
|
|
|
+ },
|
|
|
+ async mounted() {
|
|
|
+ await this.getTotalPages(this.pageSize);
|
|
|
+ await this.getDataByCurrentAndPageSize(this.currentPage, this.pageSize);
|
|
|
},
|
|
|
methods: {
|
|
|
+ getTotalPages(pageSize) {
|
|
|
+ const config = {
|
|
|
+ params: {
|
|
|
+ pageSize: pageSize
|
|
|
+ }
|
|
|
+ };
|
|
|
+ getTotalDeployments(config).then(res => {
|
|
|
+ this.pageTotal = res.data.data;
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getDataByCurrentAndPageSize(current, pageSize) {
|
|
|
+ const config = {
|
|
|
+ params: {
|
|
|
+ pageNo: current - 1,
|
|
|
+ pageSize: pageSize
|
|
|
+ }
|
|
|
+ };
|
|
|
+ getDeploymentsByCurrentAndSize(config).then(res => {
|
|
|
+ this.deployments = res.data.data;
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 切换每页大小
|
|
|
+ async handleSizeChange(val) {
|
|
|
+ this.pageSize = val;
|
|
|
+ this.currentPage = 1;
|
|
|
+ await this.getTotalPages(this.pageSize);
|
|
|
+ await this.getDataByCurrentAndPageSize(this.currentPage, this.pageSize);
|
|
|
+ },
|
|
|
+ // 切换页数
|
|
|
+ async handleCurrentChange(val) {
|
|
|
+ this.currentPage = val;
|
|
|
+ await this.getDataByCurrentAndPageSize(this.currentPage, this.pageSize);
|
|
|
+ },
|
|
|
+ // 查看详情
|
|
|
+ viewDetails(row) {
|
|
|
+ console.log(row, row.deployName, row.namespace);
|
|
|
+ this.$router.push({
|
|
|
+ path: '/deploymentDetail',
|
|
|
+ query: {
|
|
|
+ namespace: row.namespace,
|
|
|
+ deployName: row.deployName
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss">
|
|
|
+<style lang="scss" scoped>
|
|
|
+.body {
|
|
|
+ width: 80%;
|
|
|
+ height: 70vh;
|
|
|
+ margin: 0 auto;
|
|
|
+}
|
|
|
+.footer {
|
|
|
+ width: 80%;
|
|
|
+ margin: 0 auto;
|
|
|
+}
|
|
|
+.el-pagination {
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
</style>
|