2023-04-10 00:18:56 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-form class="-mb-15px" ref="queryFormRef" :inline="true" label-width="68px">
|
|
|
|
|
<el-form-item label="公众号" prop="accountId">
|
2023-04-11 23:28:59 +08:00
|
|
|
|
<!-- TODO 芋艿:需要将 el-form 和 el-select 解耦 -->
|
2023-04-10 00:18:56 +08:00
|
|
|
|
<el-select
|
|
|
|
|
v-model="accountId"
|
|
|
|
|
placeholder="请选择公众号"
|
|
|
|
|
class="!w-240px"
|
|
|
|
|
@change="accountChanged()"
|
|
|
|
|
>
|
|
|
|
|
<el-option v-for="item in accountList" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<slot name="actions"></slot>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="WxAccountSelect">
|
|
|
|
|
import * as MpAccountApi from '@/api/mp/account'
|
|
|
|
|
const accountId = ref()
|
|
|
|
|
const accountList = ref([])
|
|
|
|
|
const queryFormRef = ref()
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['change'])
|
|
|
|
|
|
2023-04-11 23:28:59 +08:00
|
|
|
|
onMounted(() => {
|
2023-04-10 00:18:56 +08:00
|
|
|
|
handleQuery()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleQuery = async () => {
|
2023-04-11 23:28:59 +08:00
|
|
|
|
accountList.value = await MpAccountApi.getSimpleAccountList()
|
2023-04-10 00:18:56 +08:00
|
|
|
|
// 默认选中第一个
|
|
|
|
|
if (accountList.value.length > 0) {
|
|
|
|
|
accountId.value = accountList.value[0].id
|
|
|
|
|
emit('change', accountId.value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const accountChanged = () => {
|
|
|
|
|
emit('change', accountId.value)
|
|
|
|
|
}
|
|
|
|
|
</script>
|