houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-card shadow="never" class="aui-card--fill">
3     <div class="mod-api-group">
4       <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
5         <el-form-item>
6           <el-input v-model="dataForm.serverName" placeholder="服务提供方" clearable></el-input>
7         </el-form-item>
8         <el-form-item>
9           <el-button @click="getDataList()">查询</el-button>
10           <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
11         </el-form-item>
12       </el-form>
13       <el-table
14               :data="dataList"
15               border
16               v-loading="dataListLoading"
17               style="width: 100%;">
18         <el-table-column
19                 type="index"
20                 header-align="center"
21                 align="center"
22                 width="50">
23         </el-table-column>
24         <el-table-column
25                 prop="serverName"
26                 header-align="center"
27                 align="center"
28                 width="150"
29                 label="服务名称">
30         </el-table-column>
31         <el-table-column
32                 prop="serverDesc"
33                 header-align="center"
34                 align="center"
35                 label="服务描述">
36         </el-table-column>
37         <el-table-column
38                 prop="serverAddress"
39                 header-align="center"
40                 align="center"
41                 label="服务地址">
42         </el-table-column>
43         <el-table-column
44                 prop="limitMin"
45                 header-align="center"
46                 align="center"
47                 width="150"
48                 label="限流策略(分)">
49         </el-table-column>
50         <el-table-column
51                 prop="statusName"
52                 header-align="center"
53                 align="center"
54                 width="100"
55                 label="状态">
56         </el-table-column>
57         <el-table-column
58                 prop="createTime"
59                 header-align="center"
60                 align="center"
61                 width="180"
62                 label="创建时间">
63         </el-table-column>
64         <el-table-column
65                 fixed="right"
66                 header-align="center"
67                 align="center"
68                 width="200"
69                 label="操作">
70           <template slot-scope="scope">
71             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
72             <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
73           </template>
74         </el-table-column>
75       </el-table>
76       <el-pagination
77               @size-change="sizeChangeHandle"
78               @current-change="currentChangeHandle"
79               :current-page="pageIndex"
80               :page-sizes="[10, 20, 50, 100]"
81               :page-size="pageSize"
82               :total="totalPage"
83               layout="total, sizes, prev, pager, next, jumper">
84       </el-pagination>
85       <!-- 弹窗, 新增 / 修改 -->
86       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
87     </div>
88   </el-card>
89 </template>
90 <script>
91   import AddOrUpdate from './api-server-add-or-update'
92   export default {
93     data () {
94       return {
95         dataForm: {
96           serverName: ''
97         },
98         dataList: [],
99         pageIndex: 1,
100         pageSize: 10,
101         totalPage: 0,
102         dataListLoading: false,
103         dataListSelections: [],
104         addOrUpdateVisible: false
105       }
106     },
107     components: {
108       AddOrUpdate
109     },
110     activated () {
111       this.getDataList()
112     },
113     mounted () {
114       this.getDataList()
115     },
116     methods: {
117       // 获取数据列表
118       getDataList () {
119         this.dataListLoading = true
120         this.$http({
121           url: '/data/api-gateway/server/list',
122           method: 'get',
123           params: this.$http.adornParams({
124             'page': this.pageIndex,
125             'limit': this.pageSize,
126             'serverName': this.dataForm.serverName,
127
128           })
129         }).then(({data}) => {
130           if (data && data.code === 0) {
131             this.dataList = data.page.list
132             this.totalPage = data.page.totalCount
133           } else {
134             this.dataList = []
135             this.totalPage = 0
136           }
137           this.dataListLoading = false
138         })
139       },
140       // 每页数
141       sizeChangeHandle (val) {
142         this.pageSize = val
143         this.pageIndex = 1
144         this.getDataList()
145       },
146       // 当前页
147       currentChangeHandle (val) {
148         this.pageIndex = val
149         this.getDataList()
150       },
151       // 多选
152       selectionChangeHandle (val) {
153         this.dataListSelections = val
154       },
155       // 新增 / 修改
156       addOrUpdateHandle (id) {
157         this.addOrUpdateVisible = true
158         this.$nextTick(() => {
159           this.$refs.addOrUpdate.init(id)
160         })
161       },
162       // 删除
163       deleteHandle (id) {
164         this.$confirm(`确定对选中项进行删除操作?`, '提示', {
165           confirmButtonText: '确定',
166           cancelButtonText: '取消',
167           type: 'warning'
168         }).then(() => {
169           this.$http({
170             url: '/data/api-gateway/server/delete',
171             method: 'post',
172             data: this.$http.adornData({
173               id: id
174             })
175           }).then(({data}) => {
176             if (data && data.code === 0) {
177               this.$message({
178                 message: '操作成功',
179                 type: 'success',
180                 duration: 1500,
181                 onClose: () => {
182                   this.getDataList()
183                 }
184               })
185             } else {
186               this.$message.error(data.msg)
187             }
188           })
189         }).catch(() => {})
190       }
191     }
192   }
193 </script>