File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <el-select
3
+ v-model =" accountId"
4
+ placeholder =" 请选择公众号"
5
+ class =" !w-240px"
6
+ @change =" accountChanged"
7
+ >
8
+ <el-option v-for =" item in accountList" :key =" item.id" :label =" item.name" :value =" item.id" />
9
+ </el-select >
10
+ </template >
11
+
12
+ <script lang="ts" setup name="WxMpSelect">
13
+ import * as MpAccountApi from ' @/api/mp/account'
14
+
15
+ const accountId: Ref <number | undefined > = ref ()
16
+ const accountList: Ref <MpAccountApi .AccountVO []> = ref ([])
17
+
18
+ const emit = defineEmits <{
19
+ (e : ' change' , id : number | undefined ): void
20
+ }>()
21
+
22
+ onMounted (async () => {
23
+ handleQuery ()
24
+ })
25
+
26
+ const handleQuery = async () => {
27
+ const data = await MpAccountApi .getSimpleAccountList ()
28
+ accountList .value = data
29
+ // 默认选中第一个
30
+ if (accountList .value .length > 0 ) {
31
+ accountId .value = accountList .value [0 ].id
32
+ emit (' change' , accountId .value )
33
+ }
34
+ }
35
+
36
+ const accountChanged = () => {
37
+ emit (' change' , accountId .value )
38
+ }
39
+ </script >
You can’t perform that action at this time.
0 commit comments