houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-dialog
3     title="详情"
4     :close-on-click-modal="false"
5     :visible.sync="visible">
6     <el-divider content-position="left">基本信息</el-divider>
7     <el-form :model="dataForm" ref="dataForm" label-width="100px">
8       <el-form-item label="应用名称:" prop="appName">
9         {{dataForm.appName}}
10       </el-form-item>
11       <el-form-item label="appKey:" prop="appName">
12         {{dataForm.appKey}}
13       </el-form-item>
14       <el-form-item label="appSecret:" prop="appName">
15         {{dataForm.appSecret}}
16       </el-form-item>
17       <el-form-item label="应用描述:" prop="appName">
18         {{dataForm.appDesc}}
19       </el-form-item>
20     </el-form>
21     <el-divider content-position="left">已授权API</el-divider>
22     <el-table
23       :data="dataList"
24       border
25       v-loading="dataListLoading"
26       style="width: 100%;">
27       <el-table-column
28         type="index"
29         header-align="center"
30         align="center"
31         width="50">
32       </el-table-column>
33       <el-table-column
34         prop="serverName"
35         header-align="center"
36         align="center"
37         width="200"
38         label="服务名称">
39       </el-table-column>
40       <el-table-column
41         prop="apiName"
42         header-align="center"
43         align="center"
44         width="200"
45         label="API名称">
46       </el-table-column>
47       <el-table-column
48         prop="apiAddress"
49         header-align="center"
50         align="center"
51         label="URL">
52       </el-table-column>
53 <!--      <el-table-column-->
54 <!--        prop="limitMin"-->
55 <!--        header-align="center"-->
56 <!--        align="center"-->
57 <!--        width="120"-->
58 <!--        label="限流策略(分)">-->
59 <!--      </el-table-column>-->
60 <!--      <el-table-column-->
61 <!--        prop="limitHour"-->
62 <!--        header-align="center"-->
63 <!--        align="center"-->
64 <!--        width="120"-->
65 <!--        label="限流策略(时)">-->
66 <!--      </el-table-column>-->
67 <!--      <el-table-column-->
68 <!--        prop="limitDay"-->
69 <!--        header-align="center"-->
70 <!--        align="center"-->
71 <!--        width="120"-->
72 <!--        label="限流策略(天)">-->
73 <!--      </el-table-column>-->
74       <el-table-column
75         fixed="right"
76         header-align="center"
77         align="center"
78         width="80"
79         label="操作">
80         <template slot-scope="scope">
81           <el-button type="text" size="small" @click="cancelAuthorization(scope.row.id)">取消授权</el-button>
82 <!--          <el-button type="text" size="small" @click="limitSetting(scope.row.id)">限流配置</el-button>-->
83         </template>
84       </el-table-column>
85     </el-table>
86     <el-pagination
87       @size-change="sizeChangeHandle"
88       @current-change="currentChangeHandle"
89       :current-page="pageIndex"
90       :page-sizes="[10, 20, 50, 100]"
91       :page-size="pageSize"
92       :total="totalPage"
93       layout="total, sizes, prev, pager, next, jumper">
94     </el-pagination>
95     <!-- 弹窗, 新增 / 修改 -->
96     <limit-setting v-if="limitSettingVisible" ref="limitSetting" @refreshDataList="getDataList"></limit-setting>
97   </el-dialog>
98 </template>
99 <script>
100   import LimitSetting from './api-app-limit-setting'
101   export default {
102     components: {
103       LimitSetting
104     },
105     data () {
106       return {
107         visible: false,
108         dataForm: {
109           id: '',
110           appName: '',
111           appKey: '',
112           appSecret: '',
113           appDesc: ''
114         },
115         dataList: [],
116         pageIndex: 1,
117         pageSize: 10,
118         totalPage: 0,
119         dataListLoading: false,
120         dataListSelections: [],
121         limitSettingVisible: false
122       }
123     },
124     methods: {
125       init (id) {
126         this.dataForm.id = id || 0
127         this.visible = true
128         this.$nextTick(() => {
129           this.$refs['dataForm'].resetFields()
130           if (this.dataForm.id) {
131             this.$http({
132               url: `/data/api-gateway/app/info/${this.dataForm.id}`,
133               method: 'get',
134               params: this.$http.adornParams()
135             }).then(({data}) => {
136               if (data && data.code === 0) {
137                 this.dataForm.appName = data.data.appName
138                 this.dataForm.appKey = data.data.appKey
139                 this.dataForm.appSecret = data.data.appSecret
140                 this.dataForm.appDesc = data.data.appDesc
141               }
142             })
143           }
144         })
145         this.getDataList()
146       },
147       cancelAuthorization (id) {
148         this.$confirm(`确定取消授权?`, '提示', {
149           confirmButtonText: '确定',
150           cancelButtonText: '取消',
151           type: 'warning'
152         }).then(() => {
153           this.$http({
154             url: '/data/api-gateway/authorized/delete',
155             method: 'post',
156             data: this.$http.adornData({
157               id: id
158             })
159           }).then(({data}) => {
160             if (data && data.code === 0) {
161               this.$message({
162                 message: '操作成功',
163                 type: 'success',
164                 duration: 1500,
165                 onClose: () => {
166                   this.getDataList()
167                 }
168               })
169             } else {
170               this.$message.error(data.msg)
171             }
172           })
173         }).catch(() => {})
174       },
175       limitSetting (id) {
176         this.limitSettingVisible = true
177         this.$nextTick(() => {
178           this.$refs.limitSetting.init(id)
179         })
180       },
181       // 获取数据列表
182       getDataList () {
183         this.dataListLoading = true
184         this.$http({
185           url: '/data/api-gateway/authorized/list',
186           method: 'get',
187           params: this.$http.adornParams({
188             'page': this.pageIndex,
189             'limit': this.pageSize,
190             'appId': this.dataForm.id
191           })
192         }).then(({data}) => {
193           if (data && data.code === 0) {
194             this.dataList = data.page.list
195             this.totalPage = data.page.totalCount
196           } else {
197             this.dataList = []
198             this.totalPage = 0
199           }
200           this.dataListLoading = false
201         })
202       },
203       // 每页数
204       sizeChangeHandle (val) {
205         this.pageSize = val
206         this.pageIndex = 1
207         this.getDataList()
208       },
209       // 当前页
210       currentChangeHandle (val) {
211         this.pageIndex = val
212         this.getDataList()
213       },
214       // 多选
215       selectionChangeHandle (val) {
216         this.dataListSelections = val
217       }
218     }
219   }
220 </script>