|
@@ -0,0 +1,198 @@
|
|
1
|
+<template>
|
|
2
|
+ <div v-loading="loading" class="miniProManage-wrap">
|
|
3
|
+ <div class="screenBox flex">
|
|
4
|
+ <div class="flex">
|
|
5
|
+ <selfInput label_name="搜索小程序" @inputChange="onInputKeyword" />
|
|
6
|
+ </div>
|
|
7
|
+ <div class="right">
|
|
8
|
+ <el-button type="primary" size="mini" @click="onClickAddMiniPro">添加小程序</el-button>
|
|
9
|
+ </div>
|
|
10
|
+ </div>
|
|
11
|
+ <el-table :height="height" :data="miniProList" tooltip-effect="dark" style="width: 100%;margin-top:10px">
|
|
12
|
+ <el-table-column label="小程序" prop="name" min-width="200" align="center" />
|
|
13
|
+ <el-table-column label="APPID" prop="name" min-width="200" align="center" />
|
|
14
|
+ <el-table-column label="创建时间" prop="created_at" min-width="160" align="center" />
|
|
15
|
+ <el-table-column label="状态" min-width="160" align="center">
|
|
16
|
+ <template slot-scope="{ row }">
|
|
17
|
+ <span v-if="row.enable == 1" class="c-448AFF">启用</span>
|
|
18
|
+ <span v-else class="c-F03F5C">禁用</span>
|
|
19
|
+ </template>
|
|
20
|
+ </el-table-column>
|
|
21
|
+ <el-table-column label="操作" min-width="160" align="center">
|
|
22
|
+ <template slot-scope="{ row }">
|
|
23
|
+ <el-button type="primary" size="mini" @click="onClickEditMiniPro(row)">编辑</el-button>
|
|
24
|
+ <el-button v-if="row.enable == 1" type="danger" size="mini" @click="onClickEnable(row, 0)">禁用</el-button>
|
|
25
|
+ <el-button v-else type="primary" size="mini" @click="onClickEnable(row, 1)">启用</el-button>
|
|
26
|
+ </template>
|
|
27
|
+ </el-table-column>
|
|
28
|
+ </el-table>
|
|
29
|
+ <div class="pagination" v-show="pagination.total > 0">
|
|
30
|
+ <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count="Number(pagination.pages)">
|
|
31
|
+ </el-pagination>
|
|
32
|
+ </div>
|
|
33
|
+
|
|
34
|
+ <!-- S 添加小程序 & 编辑小程序 -->
|
|
35
|
+ <addMiniProDialog
|
|
36
|
+ :dialogVisible="addMiniProDialogVisible"
|
|
37
|
+ :miniProInfo="currentMiniProInfo"
|
|
38
|
+ @confirm="handleAddMiniProConfirm"
|
|
39
|
+ @cancel="handleAddMiniProCancel"
|
|
40
|
+ />
|
|
41
|
+ <!-- E 添加小程序 & 编辑小程序 -->
|
|
42
|
+ </div>
|
|
43
|
+</template>
|
|
44
|
+<script>
|
|
45
|
+import selfInput from '@/components/assembly/screen/input.vue'
|
|
46
|
+import addMiniProDialog from './dialog/addMiniProDialog.vue'
|
|
47
|
+export default {
|
|
48
|
+ name: 'miniProManage',
|
|
49
|
+ components: {
|
|
50
|
+ selfInput,
|
|
51
|
+ addMiniProDialog,
|
|
52
|
+ },
|
|
53
|
+ data () {
|
|
54
|
+ return {
|
|
55
|
+ height: '',
|
|
56
|
+ loading: false,
|
|
57
|
+ pagination: {
|
|
58
|
+ page: 1,
|
|
59
|
+ page_size: 20,
|
|
60
|
+ pages: 0,
|
|
61
|
+ total: 0,
|
|
62
|
+ },
|
|
63
|
+ filter: {
|
|
64
|
+ keyword: '',
|
|
65
|
+ },
|
|
66
|
+ miniProList: [],
|
|
67
|
+
|
|
68
|
+ addMiniProDialogVisible: false, // 控制"添加账号"弹框显示
|
|
69
|
+ currentMiniProInfo: {}, // 当前编辑的账号信息
|
|
70
|
+ }
|
|
71
|
+ },
|
|
72
|
+ created () {
|
|
73
|
+ this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
|
|
74
|
+ this.handleGetMiniPro()
|
|
75
|
+ },
|
|
76
|
+ methods: {
|
|
77
|
+ // 获取列表数据
|
|
78
|
+ async handleGetMiniPro() {
|
|
79
|
+ try {
|
|
80
|
+ this.loading = true
|
|
81
|
+ const url = `${this.URL.BASEURL}${this.URL.pitcher_dramaList}`
|
|
82
|
+ const params = {
|
|
83
|
+ is_select: 0,
|
|
84
|
+ keyword: this.filter.keyword,
|
|
85
|
+ page: this.pagination.page,
|
|
86
|
+ page_size: this.pagination.page_size,
|
|
87
|
+ }
|
|
88
|
+ const { data: res = {} } = await this.$axios.get(url, { params })
|
|
89
|
+ if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
|
|
90
|
+ this.miniProList = res.rst.data;
|
|
91
|
+ this.pagination.total = res.rst.pageInfo.total;
|
|
92
|
+ this.pagination.pages = res.rst.pageInfo.pages;
|
|
93
|
+ } else if (res.errno != 4002) {
|
|
94
|
+ this.$message.warning(res.err)
|
|
95
|
+ this.miniProList = [];
|
|
96
|
+ this.pagination.total = 0;
|
|
97
|
+ this.pagination.pages = 0;
|
|
98
|
+ }
|
|
99
|
+ } catch (error) {
|
|
100
|
+ console.log(error)
|
|
101
|
+ this.miniProList = [];
|
|
102
|
+ this.pagination.total = 0;
|
|
103
|
+ this.pagination.pages = 0;
|
|
104
|
+ } finally {
|
|
105
|
+ this.loading = false
|
|
106
|
+ }
|
|
107
|
+ },
|
|
108
|
+ // 监听当前页数变化
|
|
109
|
+ handleCurrentChange(currentPage) {
|
|
110
|
+ this.pagination.page = currentPage
|
|
111
|
+ this.handleGetMiniPro()
|
|
112
|
+ },
|
|
113
|
+ // 监听搜索小程序变化
|
|
114
|
+ onInputKeyword(val) {
|
|
115
|
+ console.log('onInputKeyword => ', val)
|
|
116
|
+ this.filter.keyword = val || ''
|
|
117
|
+ this.pagination.page = 1
|
|
118
|
+ this.handleGetMiniPro()
|
|
119
|
+ },
|
|
120
|
+
|
|
121
|
+ // S 添加 & 编辑账号
|
|
122
|
+ // 监听点击"添加账号"
|
|
123
|
+ onClickAddMiniPro() {
|
|
124
|
+ this.currentMiniProInfo = {}
|
|
125
|
+ this.addMiniProDialogVisible = true
|
|
126
|
+ },
|
|
127
|
+ // 监听点击"编辑账号"
|
|
128
|
+ onClickEditMiniPro(miniProInfo) {
|
|
129
|
+ this.currentMiniProInfo = miniProInfo
|
|
130
|
+ this.addMiniProDialogVisible = true
|
|
131
|
+ },
|
|
132
|
+ // 添加小程序 & 编辑小程序 => 确定
|
|
133
|
+ handleAddMiniProConfirm({ isEdit }) {
|
|
134
|
+ this.addMiniProDialogVisible = false
|
|
135
|
+ if (!isEdit) this.pagination.page = 1
|
|
136
|
+ this.handleGetMiniPro()
|
|
137
|
+ },
|
|
138
|
+ // 添加小程序 & 编辑小程序 => 取消
|
|
139
|
+ handleAddMiniProCancel() {
|
|
140
|
+ this.addMiniProDialogVisible = false
|
|
141
|
+ },
|
|
142
|
+ // E 添加 & 编辑账号
|
|
143
|
+
|
|
144
|
+ // S 禁用、启用平台
|
|
145
|
+ // 监听点击"禁用"、"启用"按钮
|
|
146
|
+ async onClickEnable(currentAccount, eventCode) {
|
|
147
|
+ try {
|
|
148
|
+ const h = this.$createElement
|
|
149
|
+ await this.$confirm('', {
|
|
150
|
+ message:h('div', null, [
|
|
151
|
+ h('span', null, `确定${eventCode === 0 ? '禁用' : '启用'}`),
|
|
152
|
+ h('span', { style:'color: #32B38A;' }, `${currentAccount.name}`),
|
|
153
|
+ h('span', null, '吗?'),
|
|
154
|
+ ]),
|
|
155
|
+ confirmButtonText: '确定',
|
|
156
|
+ cancelButtonText: '取消',
|
|
157
|
+ type: 'warning',
|
|
158
|
+ })
|
|
159
|
+ this.handleEnable(currentAccount, eventCode)
|
|
160
|
+ } catch (error) {
|
|
161
|
+ console.log(error)
|
|
162
|
+ }
|
|
163
|
+ },
|
|
164
|
+ // 执行"禁用"、"启用"
|
|
165
|
+ async handleEnable(currentAccount, eventCode) {
|
|
166
|
+ try {
|
|
167
|
+ let url = `${this.URL.BASEURL}${this.URL.xxx}`
|
|
168
|
+ const params = {
|
|
169
|
+ id: currentAccount.id,
|
|
170
|
+ enable: eventCode,
|
|
171
|
+ }
|
|
172
|
+ console.log('url => ', url)
|
|
173
|
+ console.log('params => ', params)
|
|
174
|
+ return // mock
|
|
175
|
+ this.loading = true
|
|
176
|
+ const { data: res = {} } = await this.$axios.post(url, params)
|
|
177
|
+ if (res && res.errno == 0) {
|
|
178
|
+ this.$message.success('操作成功')
|
|
179
|
+ this.handleGetMiniPro()
|
|
180
|
+ } else if (res.errno != 4002) {
|
|
181
|
+ this.$message.warning(res.err || '操作失败')
|
|
182
|
+ }
|
|
183
|
+ } catch (error) {
|
|
184
|
+ console.log('error => ', error)
|
|
185
|
+ } finally {
|
|
186
|
+ this.loading = false
|
|
187
|
+ }
|
|
188
|
+ },
|
|
189
|
+ // E 禁用、启用平台
|
|
190
|
+ }
|
|
191
|
+}
|
|
192
|
+</script>
|
|
193
|
+<style lang="scss" scoped>
|
|
194
|
+.screenBox {
|
|
195
|
+ background: #fff;
|
|
196
|
+ padding: 5px 20px;
|
|
197
|
+}
|
|
198
|
+</style>
|