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