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.apiName" placeholder="API名称" 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="apiName"
26                 header-align="center"
27                 align="center"
28                 label="API名称">
29         </el-table-column>
30         <el-table-column
31                 prop="groupName"
32                 header-align="center"
33                 align="center"
34                 label="分组名称">
35         </el-table-column>
36         <el-table-column
37                 prop="serverName"
38                 header-align="center"
39                 align="center"
40                 label="服务提供方">
41         </el-table-column>
42         <el-table-column
43                 prop="apiAddress"
44                 header-align="center"
45                 align="left"
46                 label="URL">
47         </el-table-column>
48         <el-table-column
49                 prop="apiDesc"
50                 header-align="center"
51                 align="center"
52                 label="描述">
53         </el-table-column>
54         <el-table-column
55                 prop="createTime"
56                 header-align="center"
57                 align="center"
58                 label="创建时间">
59         </el-table-column>
60         <el-table-column
61                 fixed="right"
62                 header-align="center"
63                 align="center"
64                 width="200"
65                 label="操作">
66           <template slot-scope="scope">
67             <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
68             <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
69           </template>
70         </el-table-column>
71       </el-table>
72       <el-pagination
73               @size-change="sizeChangeHandle"
74               @current-change="currentChangeHandle"
75               :current-page="pageIndex"
76               :page-sizes="[10, 20, 50, 100]"
77               :page-size="pageSize"
78               :total="totalPage"
79               layout="total, sizes, prev, pager, next, jumper">
80       </el-pagination>
81       <!-- 弹窗, 新增 / 修改 -->
82       <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
83     </div>
84   </el-card>
85 </template>
86 <script>
87   import AddOrUpdate from './api-info-add-or-update'
88   export default {
89     data () {
90       return {
91         dataForm: {
92           apiName: ''
93         },
94         dataList: [],
95         pageIndex: 1,
96         pageSize: 10,
97         totalPage: 0,
98         dataListLoading: false,
99         dataListSelections: [],
100         addOrUpdateVisible: false
101       }
102     },
103     components: {
104       AddOrUpdate
105     },
106     activated () {
107       this.getDataList()
108     },
109     mounted () {
110       this.getDataList()
111     },
112     methods: {
113       // 获取数据列表
114       getDataList () {
115         this.dataListLoading = true
116         this.$http({
117           url: '/data/api-gateway/info/list',
118           method: 'get',
119           params: this.$http.adornParams({
120             'page': this.pageIndex,
121             'limit': this.pageSize,
122             'apiName': this.dataForm.apiName,
123           })
124         }).then(({data}) => {
125           if (data && data.code === 0) {
126             this.dataList = data.page.list
127             this.totalPage = data.page.totalCount
128           } else {
129             this.dataList = []
130             this.totalPage = 0
131           }
132           this.dataListLoading = false
133         })
134       },
135       // 每页数
136       sizeChangeHandle (val) {
137         this.pageSize = val
138         this.pageIndex = 1
139         this.getDataList()
140       },
141       // 当前页
142       currentChangeHandle (val) {
143         this.pageIndex = val
144         this.getDataList()
145       },
146       // 多选
147       selectionChangeHandle (val) {
148         this.dataListSelections = val
149       },
150       // 新增 / 修改
151       addOrUpdateHandle (id) {
152         this.addOrUpdateVisible = true
153         this.$nextTick(() => {
154           this.$refs.addOrUpdate.init(id)
155         })
156       },
157       // 删除
158       deleteHandle (id) {
159         this.$confirm(`确定对选中项进行删除操作?`, '提示', {
160           confirmButtonText: '确定',
161           cancelButtonText: '取消',
162           type: 'warning'
163         }).then(() => {
164           this.$http['post'](`/data/api-gateway/info/delete`, {id: id}).then(({ data: res }) => {
165             if (res.code !== 0) {
166               return this.$message.error(res.msg)
167             }
168             this.$message({
169               message: this.$t('prompt.success'),
170               type: 'success',
171               duration: 500,
172               onClose: () => {
173                 this.getDataList()
174               }
175             })
176           }).catch(() => {})
177         }).catch(() => {})
178       }
179     }
180   }
181 </script>