3
3
4
4
<!-- 搜索工作栏 -->
5
5
<ContentWrap >
6
- <el-form
7
- class =" -mb-15px"
8
- :model =" queryParams"
9
- ref =" queryFormRef"
10
- :inline =" true"
11
- label-width =" 68px"
12
- >
13
- <el-form-item label =" 公众号" prop =" accountId" >
14
- <el-select v-model =" queryParams.accountId" placeholder =" 请选择公众号" class =" !w-240px" >
15
- <el-option
16
- v-for =" item in accountList"
17
- :key =" item.id"
18
- :label =" item.name"
19
- :value =" item.id"
20
- />
21
- </el-select >
22
- </el-form-item >
23
- <el-form-item label =" 标签名称" prop =" name" >
24
- <el-input
25
- v-model =" queryParams.name"
26
- placeholder =" 请输入标签名称"
27
- clearable
28
- @keyup.enter =" handleQuery"
29
- class =" !w-240px"
30
- />
31
- </el-form-item >
32
- <el-form-item >
33
- <el-form-item >
34
- <el-button @click =" handleQuery" ><Icon icon =" ep:search" class =" mr-5px" /> 搜索</el-button >
35
- <el-button @click =" resetQuery" ><Icon icon =" ep:refresh" class =" mr-5px" /> 重置</el-button >
36
- </el-form-item >
6
+ <WxAccountSelect @change =" (accountId) => accountChanged(accountId)" >
7
+ <template #actions >
37
8
<el-button type =" primary" plain @click =" openForm('create')" v-hasPermi =" ['mp:tag:create']" >
38
9
<Icon icon =" ep:plus" class =" mr-5px" /> 新增
39
10
</el-button >
40
11
<el-button type =" success" plain @click =" handleSync" v-hasPermi =" ['mp:tag:sync']" >
41
12
<Icon icon =" ep:refresh" class =" mr-5px" /> 同步
42
13
</el-button >
43
- </el-form-item >
44
- </el-form >
14
+ </template >
15
+ </WxAccountSelect >
45
16
</ContentWrap >
46
17
47
18
<!-- 列表 -->
92
63
</template >
93
64
<script setup lang="ts" name="MpTag">
94
65
import { dateFormatter } from ' @/utils/formatTime'
66
+ import WxAccountSelect from ' @/views/mp/components/wx-account-select/main.vue'
95
67
import * as MpTagApi from ' @/api/mp/tag'
96
- import * as MpAccountApi from ' @/api/mp/account'
97
68
import TagForm from ' ./TagForm.vue'
98
69
const message = useMessage () // 消息弹窗
99
70
const { t } = useI18n () // 国际化
@@ -104,19 +75,18 @@ const list = ref([]) // 列表的数据
104
75
const queryParams = reactive ({
105
76
pageNo: 1 ,
106
77
pageSize: 10 ,
107
- accountId: undefined ,
108
- name: null
78
+ accountId: undefined
109
79
})
110
- const queryFormRef = ref () // 搜索的表单
111
- const accountList = ref <MpAccountApi .AccountVO []>([]) // 公众号账号列表
80
+
81
+ /** 侦听公众号变化 **/
82
+ const accountChanged = (accountId ) => {
83
+ queryParams .pageNo = 1
84
+ queryParams .accountId = accountId
85
+ getList ()
86
+ }
112
87
113
88
/** 查询列表 */
114
89
const getList = async () => {
115
- // 如果没有选中公众号账号,则进行提示。
116
- if (! queryParams .accountId ) {
117
- await message .error (' 未选中公众号,无法查询标签' )
118
- return
119
- }
120
90
try {
121
91
loading .value = true
122
92
const data = await MpTagApi .getTagPage (queryParams )
@@ -127,22 +97,6 @@ const getList = async () => {
127
97
}
128
98
}
129
99
130
- /** 搜索按钮操作 */
131
- const handleQuery = () => {
132
- queryParams .pageNo = 1
133
- getList ()
134
- }
135
-
136
- /** 重置按钮操作 */
137
- const resetQuery = () => {
138
- queryFormRef .value .resetFields ()
139
- // 默认选中第一个
140
- if (accountList .value .length > 0 ) {
141
- queryParams .accountId = accountList .value [0 ].id
142
- }
143
- handleQuery ()
144
- }
145
-
146
100
/** 添加/修改操作 */
147
101
const formRef = ref ()
148
102
const openForm = (type : string , id ? : number ) => {
@@ -172,14 +126,4 @@ const handleSync = async () => {
172
126
await getList ()
173
127
} catch {}
174
128
}
175
-
176
- /** 初始化 **/
177
- onMounted (async () => {
178
- accountList .value = await MpAccountApi .getSimpleAccountList ()
179
- // 选中第一个
180
- if (accountList .value .length > 0 ) {
181
- queryParams .accountId = accountList .value [0 ].id
182
- }
183
- await getList ()
184
- })
185
129
</script >
0 commit comments