1
1
<template >
2
- <!-- 搜索 -->
3
- <content-wrap >
2
+ <!-- 搜索工作栏 -->
3
+ <ContentWrap >
4
4
<el-form
5
5
class =" -mb-15px"
6
6
:model =" queryParams"
9
9
label-width =" 68px"
10
10
>
11
11
<el-form-item label =" 公众号" prop =" accountId" >
12
- <el-select v-model =" queryParams.accountId" placeholder =" 请选择公众号" >
12
+ <el-select v-model =" queryParams.accountId" placeholder =" 请选择公众号" class = " !w-240px " >
13
13
<el-option
14
- v-for =" item in accounts "
14
+ v-for =" item in accountList "
15
15
:key =" parseInt(item.id)"
16
16
:label =" item.name"
17
17
:value =" parseInt(item.id)"
24
24
placeholder =" 请输入标签名称"
25
25
clearable
26
26
@keyup.enter =" handleQuery"
27
+ class =" !w-240px"
27
28
/>
28
29
</el-form-item >
29
30
<el-form-item >
30
31
<el-button @click =" handleQuery" ><Icon icon =" ep:search" class =" mr-5px" /> 搜索</el-button >
31
32
<el-button @click =" resetQuery" ><Icon icon =" ep:refresh" class =" mr-5px" /> 重置</el-button >
32
- <el-button type =" primary" @click =" openModal ('create')" v-hasPermi =" ['mp:tag:create']" >
33
+ <el-button type =" primary" plain @click =" openForm ('create')" v-hasPermi =" ['mp:tag:create']" >
33
34
<Icon icon =" ep:plus" class =" mr-5px" /> 新增
34
35
</el-button >
35
- <el-button type =" info " @click =" handleSync" v-hasPermi =" ['mp:tag:sync']" >
36
+ <el-button type =" success " plain @click =" handleSync" v-hasPermi =" ['mp:tag:sync']" >
36
37
<Icon icon =" ep:refresh" class =" mr-5px" /> 同步
37
38
</el-button >
38
- <el-button
39
- type =" success"
40
- plain
41
- @click =" handleExport"
42
- :loading =" exportLoading"
43
- v-hasPermi =" ['mp:tag:export']"
44
- >
45
- <Icon icon =" ep:download" class =" mr-5px" /> 导出
46
- </el-button >
47
39
</el-form-item >
48
40
</el-form >
49
- </content-wrap >
41
+ </ContentWrap >
50
42
51
43
<!-- 列表 -->
52
- <content-wrap >
44
+ <ContentWrap >
53
45
<el-table v-loading =" loading" :data =" list" >
54
46
<el-table-column label =" 编号" align =" center" prop =" id" />
55
47
<el-table-column label =" 标签名称" align =" center" prop =" name" />
66
58
<el-button
67
59
link
68
60
type =" primary"
69
- size =" small"
70
- @click =" openModal('update', scope.row.id)"
61
+ @click =" openForm('update', scope.row.id)"
71
62
v-hasPermi =" ['mp:tag:update']"
72
- ><Icon icon =" ep:edit" class =" mr-5px" />修改
63
+ >
64
+ 修改
73
65
</el-button >
74
66
<el-button
75
67
link
76
- size =" small"
77
68
type =" danger"
78
69
@click =" handleDelete(scope.row.id)"
79
70
v-hasPermi =" ['mp:tag:delete']"
80
71
>
81
- < Icon icon = " ep:delete " class = " mr-5px " /> 删除
72
+ 删除
82
73
</el-button >
83
74
</template >
84
75
</el-table-column >
90
81
v-model:limit =" queryParams.pageSize"
91
82
@pagination =" getList"
92
83
/>
93
- </content-wrap >
84
+ </ContentWrap >
94
85
95
86
<!-- 表单弹窗:添加/修改 -->
96
- <mpTagForm ref =" modalRef " @success =" getList" />
87
+ <TagForm ref =" formRef " @success =" getList" />
97
88
</template >
98
89
<script setup lang="ts" name="MpTag">
99
90
import { dateFormatter } from ' @/utils/formatTime'
100
- // import download from '@/utils/download'
101
91
import * as MpTagApi from ' @/api/mp/tag'
102
- import * as MpAccountAPI from ' @/api/mp/account'
103
- import mpTagForm from ' ./form .vue'
92
+ import * as MpAccountApi from ' @/api/mp/account'
93
+ import TagForm from ' ./TagForm .vue'
104
94
const message = useMessage () // 消息弹窗
105
95
const { t } = useI18n () // 国际化
106
96
@@ -110,44 +100,29 @@ const list = ref([]) // 列表的数据
110
100
const queryParams = reactive ({
111
101
pageNo: 1 ,
112
102
pageSize: 10 ,
113
- accountId: ' ' ,
103
+ accountId: undefined ,
114
104
name: null
115
105
})
116
-
117
- interface accountsType {
118
- id? : string | number | any
119
- name? : string | any
120
- }
121
- let accounts = [] as accountsType // 公众号账号列表
122
106
const queryFormRef = ref () // 搜索的表单
123
- const exportLoading = ref ( false ) // 导出的加载中
107
+ const accountList = ref < MpAccountApi . AccountVO []>([] ) // 公众号账号列表
124
108
125
109
/** 查询参数列表 */
126
110
const getList = async () => {
127
111
// 如果没有选中公众号账号,则进行提示。
112
+ if (! queryParams .accountId ) {
113
+ await message .error (' 未选中公众号,无法查询标签' )
114
+ return
115
+ }
128
116
try {
129
- if (! queryParams .accountId ) {
130
- await message .error (' 未选中公众号,无法查询标签' )
131
- return false
132
- }
133
117
loading .value = true
134
-
135
118
const data = await MpTagApi .getTagPage (queryParams )
136
119
list .value = data .list
137
120
total .value = data .total
138
121
} finally {
139
122
loading .value = false
140
123
}
141
124
}
142
- /** 同步 */
143
- const handleSync = async () => {
144
- try {
145
- await message .confirm (' 是否确认同步标签?' ) // 未做国际化处理
146
- await MpTagApi .syncTag (queryParams .accountId )
147
- message .success (' 同步标签成功' ) // 未做国际化处理
148
- getList ()
149
- } catch {}
150
- }
125
+
151
126
/** 搜索按钮操作 */
152
127
const handleQuery = () => {
153
128
queryParams .pageNo = 1
@@ -158,53 +133,50 @@ const handleQuery = () => {
158
133
const resetQuery = () => {
159
134
queryFormRef .value .resetFields ()
160
135
// 默认选中第一个
161
- if (accounts .length > 0 ) {
162
- queryParams .accountId = accounts [0 ].id
136
+ if (accountList .value .length > 0 ) {
137
+ // @ts-ignore
138
+ queryParams .accountId = accountList .value [0 ].id
163
139
}
164
140
handleQuery ()
165
141
}
166
142
167
143
/** 添加/修改操作 */
168
- const modalRef = ref ()
169
- const openModal = (type : string , id ? : number ) => {
170
- modalRef .value .openModal (type , id )
144
+ const formRef = ref ()
145
+ const openForm = (type : string , id ? : number ) => {
146
+ formRef .value .open (type , queryParams . accountId , id )
171
147
}
172
148
173
149
/** 删除按钮操作 */
174
150
const handleDelete = async (id : number ) => {
175
151
try {
176
152
// 删除的二次确认
177
- await message .delConfirm (' 是否确认删除公众号标签编号为" ' + id + ' "的数据项? ' ) // 未做国际化处理
153
+ await message .delConfirm ()
178
154
// 发起删除
179
155
await MpTagApi .deleteTag (id )
180
-
156
+ message . success ( t ( ' common.delSuccess ' ))
181
157
// 刷新列表
182
158
await getList ()
183
- message .success (t (' common.delSuccess' ))
184
159
} catch {}
185
160
}
186
161
187
- /** 导出按钮操作 */
188
- const handleExport = async () => {
162
+ /** 同步操作 */
163
+ const handleSync = async () => {
189
164
try {
190
- // 导出的二次确认
191
- await message .exportConfirm ()
192
- // 发起导出
193
- exportLoading .value = true
194
- message .info (' 功能不支持' )
195
- // const data = await MpTagApi.exportConfigApi(queryParams)
196
- // download.excel(data, '参数配置.xls')
197
- } catch {
198
- } finally {
199
- exportLoading .value = false
200
- }
165
+ await message .confirm (' 是否确认同步标签?' )
166
+ // @ts-ignore
167
+ await MpTagApi .syncTag (queryParams .accountId )
168
+ message .success (' 同步标签成功' )
169
+ await getList ()
170
+ } catch {}
201
171
}
202
172
203
173
/** 初始化 **/
204
174
onMounted (async () => {
205
- accounts = await MpAccountAPI .getSimpleAccounts ()
206
- if (accounts .length > 0 ) {
207
- queryParams .accountId = accounts [0 ].id
175
+ accountList .value = await MpAccountApi .getSimpleAccountList ()
176
+ // 选中第一个
177
+ if (accountList .value .length > 0 ) {
178
+ // @ts-ignore
179
+ queryParams .accountId = accountList .value [0 ].id
208
180
}
209
181
await getList ()
210
182
})
0 commit comments