Skip to content

Commit dc32b92

Browse files
committed
refactor: 删除WxAccountSelect
1 parent 92da7e3 commit dc32b92

File tree

3 files changed

+19
-63
lines changed

3 files changed

+19
-63
lines changed

src/views/mp/components/WxMpSelect.vue

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
<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>
185
</template>
196

20-
<script setup name="WxAccountSelect">
7+
<script lang="ts" setup name="WxAccountSelect">
218
import * as MpAccountApi from '@/api/mp/account'
22-
const accountId = ref()
23-
const accountList = ref([])
24-
const queryFormRef = ref()
259
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+
}>()
2719
2820
onMounted(() => {
2921
handleQuery()
@@ -33,12 +25,12 @@ const handleQuery = async () => {
3325
accountList.value = await MpAccountApi.getSimpleAccountList()
3426
// 默认选中第一个
3527
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)
3830
}
3931
}
4032
41-
const accountChanged = () => {
42-
emit('change', accountId.value)
33+
const onChanged = () => {
34+
emit('change', account.id, account.name)
4335
}
4436
</script>

src/views/mp/message/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
label-width="68px"
1010
>
1111
<el-form-item label="公众号" prop="accountId">
12-
<WxMpSelect @change="onAccountChanged" />
12+
<WxAccountSelect @change="onAccountChanged" />
1313
</el-form-item>
1414
<el-form-item label="消息类型" prop="type">
1515
<el-select v-model="queryParams.type" placeholder="请选择消息类型" class="!w-240px">
@@ -203,7 +203,7 @@ import WxMsg from '@/views/mp/components/wx-msg/main.vue'
203203
import WxLocation from '@/views/mp/components/wx-location/main.vue'
204204
import WxMusic from '@/views/mp/components/wx-music/main.vue'
205205
import WxNews from '@/views/mp/components/wx-news/main.vue'
206-
import WxMpSelect from '@/views/mp/components/WxMpSelect.vue'
206+
import WxAccountSelect from '@/views/mp/components/wx-account-select/main.vue'
207207
import * as MpMessageApi from '@/api/mp/message'
208208
import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
209209
import { dateFormatter } from '@/utils/formatTime'

0 commit comments

Comments
 (0)