Skip to content

Commit c33e4de

Browse files
committed
refactor: 抽离组件【公众号下拉选择】
1 parent 521b521 commit c33e4de

File tree

1 file changed

+44
-0
lines changed
  • src/views/mp/components/wx-account-select

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<template>
2+
<el-form class="-mb-15px" ref="queryFormRef" :inline="true" label-width="68px">
3+
<el-form-item label="公众号" prop="accountId">
4+
<el-select
5+
v-model="accountId"
6+
placeholder="请选择公众号"
7+
class="!w-240px"
8+
@change="accountChanged()"
9+
>
10+
<el-option v-for="item in accountList" :key="item.id" :label="item.name" :value="item.id" />
11+
</el-select>
12+
</el-form-item>
13+
<el-form-item>
14+
<slot name="actions"></slot>
15+
</el-form-item>
16+
</el-form>
17+
</template>
18+
19+
<script setup name="WxAccountSelect">
20+
import * as MpAccountApi from '@/api/mp/account'
21+
const accountId = ref()
22+
const accountList = ref([])
23+
const queryFormRef = ref()
24+
25+
const emit = defineEmits(['change'])
26+
27+
onMounted(async () => {
28+
handleQuery()
29+
})
30+
31+
const handleQuery = async () => {
32+
const data = await MpAccountApi.getSimpleAccountList()
33+
accountList.value = data
34+
// 默认选中第一个
35+
if (accountList.value.length > 0) {
36+
accountId.value = accountList.value[0].id
37+
emit('change', accountId.value)
38+
}
39+
}
40+
41+
const accountChanged = () => {
42+
emit('change', accountId.value)
43+
}
44+
</script>

0 commit comments

Comments
 (0)