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