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 =" openid" >
24
- <el-input
25
- v-model =" queryParams.openid"
26
- placeholder =" 请输入用户标识"
27
- clearable
28
- @keyup.enter =" handleQuery"
29
- class =" !w-240px"
30
- />
31
- </el-form-item >
32
- <el-form-item label =" 昵称" prop =" nickname" >
33
- <el-input
34
- v-model =" queryParams.nickname"
35
- placeholder =" 请输入昵称"
36
- clearable
37
- @keyup.enter =" handleQuery"
38
- class =" !w-240px"
39
- />
40
- </el-form-item >
41
- <el-form-item >
42
- <el-button @click =" handleQuery" ><Icon icon =" ep:search" />搜索</el-button >
43
- <el-button @click =" resetQuery" ><Icon icon =" ep:refresh" />重置</el-button >
6
+ <WxAccountSelect @change =" (accountId) => accountChanged(accountId)" >
7
+ <template #actions >
44
8
<el-button type =" success" plain @click =" handleSync" v-hasPermi =" ['mp:user:sync']" >
45
9
<Icon icon =" ep:refresh" class =" mr-5px" /> 同步
46
10
</el-button >
47
- </el-form-item >
48
- </el-form >
11
+ </template >
12
+ </WxAccountSelect >
49
13
</ContentWrap >
50
14
51
15
<!-- 列表 -->
101
65
<UserForm ref =" formRef" @success =" getList" />
102
66
</template >
103
67
<script lang="ts" setup name="MpUser">
68
+ import WxAccountSelect from ' @/views/mp/components/wx-account-select/main.vue'
104
69
import { dateFormatter } from ' @/utils/formatTime'
105
- import * as MpAccountApi from ' @/api/mp/account'
106
70
import * as MpUserApi from ' @/api/mp/user'
107
71
import * as MpTagApi from ' @/api/mp/tag'
108
72
import UserForm from ' ./UserForm.vue'
73
+
109
74
const message = useMessage () // 消息
110
75
111
76
const loading = ref (true ) // 列表的加载中
@@ -118,17 +83,22 @@ const queryParams = reactive({
118
83
openid: null ,
119
84
nickname: null
120
85
})
121
- const queryFormRef = ref () // 搜索的表单
122
- const accountList = ref ([]) // 公众号账号列表
123
86
const tagList = ref ([]) // 公众号标签列表
124
87
88
+ /** 初始化 */
89
+ onMounted (async () => {
90
+ tagList .value = await MpTagApi .getSimpleTagList ()
91
+ })
92
+
93
+ /** 侦听公众号变化 **/
94
+ const accountChanged = (accountId ) => {
95
+ queryParams .pageNo = 1
96
+ queryParams .accountId = accountId
97
+ getList ()
98
+ }
99
+
125
100
/** 查询列表 */
126
101
const getList = async () => {
127
- // 如果没有选中公众号账号,则进行提示。
128
- if (! queryParams .accountId ) {
129
- message .error (' 未选中公众号,无法查询用户' )
130
- return false
131
- }
132
102
try {
133
103
loading .value = true
134
104
const data = await MpUserApi .getUserPage (queryParams )
@@ -139,22 +109,6 @@ const getList = async () => {
139
109
}
140
110
}
141
111
142
- /** 搜索按钮操作 */
143
- const handleQuery = () => {
144
- queryParams .pageNo = 1
145
- getList ()
146
- }
147
-
148
- /** 重置按钮操作 */
149
- const resetQuery = () => {
150
- queryFormRef .value .resetFields ()
151
- // 默认选中第一个
152
- if (accountList .value .length > 0 ) {
153
- queryParams .accountId = accountList .value [0 ].id
154
- }
155
- handleQuery ()
156
- }
157
-
158
112
/** 添加/修改操作 */
159
113
const formRef = ref ()
160
114
const openForm = (id : number ) => {
@@ -171,17 +125,4 @@ const handleSync = async () => {
171
125
await getList ()
172
126
} catch {}
173
127
}
174
-
175
- /** 初始化 */
176
- onMounted (async () => {
177
- // 加载标签
178
- tagList .value = await MpTagApi .getSimpleTagList ()
179
-
180
- // 加载账号
181
- accountList .value = await MpAccountApi .getSimpleAccountList ()
182
- if (accountList .value .length > 0 ) {
183
- queryParams .accountId = accountList .value [0 ].id
184
- }
185
- await getList ()
186
- })
187
128
</script >
0 commit comments