feat(property-marketing): 重构仪表盘图表组件,新增计划选择组件并优化数据展示逻辑
This commit is contained in:
58
src/views/components/common/PlanSelect.vue
Normal file
58
src/views/components/common/PlanSelect.vue
Normal file
@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<a-select v-model="selectedValue" placeholder="请选择计划" allow-clear filterable @change="handleChange">
|
||||
<a-option v-for="item in listData" :key="item.id" :value="item.id" :label="item.name">
|
||||
{{ item.name }}
|
||||
</a-option>
|
||||
</a-select>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { getplacementAccountProjectsLlist } from '@/api/all/propertyMarketing';
|
||||
|
||||
interface Account {
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'change']);
|
||||
|
||||
// 响应式数据
|
||||
const selectedValue = ref(props.modelValue);
|
||||
const allAccounts = ref<Account[]>([]);
|
||||
const listData = ref<Account[]>([]);
|
||||
const loading = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const { code, data } = await getplacementAccountProjectsLlist({
|
||||
names: searchKeyword.value,
|
||||
});
|
||||
if (code === 200) {
|
||||
allAccounts.value = data;
|
||||
listData.value = data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取账号列表失败:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
// 搜索处理
|
||||
const handleSearch = (value: string) => {};
|
||||
|
||||
const handleChange = (value: any) => {
|
||||
emit('update:modelValue', [value]);
|
||||
};
|
||||
|
||||
onMounted(fetchData);
|
||||
</script>
|
||||
Reference in New Issue
Block a user