1
1
<template >
2
- <el-form class =" -mb-15px" ref =" queryFormRef" :inline =" true" label-width =" 68px" >
3
- <el-form-item label =" 公众号" prop =" accountId" >
4
- <!-- TODO 芋艿:需要将 el-form 和 el-select 解耦 -->
5
- <el-select
6
- v-model =" accountId"
7
- placeholder =" 请选择公众号"
8
- class =" !w-240px"
9
- @change =" accountChanged()"
10
- >
11
- <el-option v-for =" item in accountList" :key =" item.id" :label =" item.name" :value =" item.id" />
12
- </el-select >
13
- </el-form-item >
14
- <el-form-item >
15
- <slot name =" actions" ></slot >
16
- </el-form-item >
17
- </el-form >
2
+ <el-select v-model =" account.id" placeholder =" 请选择公众号" class =" !w-240px" @change =" onChanged" >
3
+ <el-option v-for =" item in accountList" :key =" item.id" :label =" item.name" :value =" item.id" />
4
+ </el-select >
18
5
</template >
19
6
20
- <script setup name="WxAccountSelect">
7
+ <script lang="ts" setup name="WxAccountSelect">
21
8
import * as MpAccountApi from ' @/api/mp/account'
22
- const accountId = ref ()
23
- const accountList = ref ([])
24
- const queryFormRef = ref ()
25
9
26
- const emit = defineEmits ([' change' ])
10
+ const account: MpAccountApi .AccountVO = reactive ({
11
+ id: undefined ,
12
+ name: ' '
13
+ })
14
+ const accountList: Ref <MpAccountApi .AccountVO []> = ref ([])
15
+
16
+ const emit = defineEmits <{
17
+ (e : ' change' , id ? : number , name ? : string ): void
18
+ }>()
27
19
28
20
onMounted (() => {
29
21
handleQuery ()
@@ -33,12 +25,12 @@ const handleQuery = async () => {
33
25
accountList .value = await MpAccountApi .getSimpleAccountList ()
34
26
// 默认选中第一个
35
27
if (accountList .value .length > 0 ) {
36
- accountId . value = accountList .value [0 ].id
37
- emit (' change' , accountId . value )
28
+ account . id = accountList .value [0 ].id
29
+ emit (' change' , account . id , account . name )
38
30
}
39
31
}
40
32
41
- const accountChanged = () => {
42
- emit (' change' , accountId . value )
33
+ const onChanged = () => {
34
+ emit (' change' , account . id , account . name )
43
35
}
44
36
</script >
0 commit comments