Files
leaser_front/src/views/business/project/index.vue
T

140 lines
4.2 KiB
Vue
Raw Normal View History

2025-06-22 23:55:55 +08:00
<template>
<div class="business_project_wrap">
<Breadcrumb :items="['menu.business', 'menu.business.project']" />
2025-07-31 23:43:28 +08:00
<a-card class="general-card full_height">
<template #title>
<div class="card-title_between">
2025-07-06 00:12:32 +08:00
<p class="title">{{ t('menu.business.project') }}</p>
<div class="flex_center_between">
<a-space>
<a-input-search
:style="{ width: '320px' }"
2025-07-06 00:12:32 +08:00
:placeholder="t('please.enter', { placeholder: t('content') })"
/>
<a-button>
<template #icon>
<icon-filter />
2025-06-24 01:24:43 +08:00
</template>
2025-07-06 00:12:32 +08:00
{{ t('table.filter') }}
</a-button>
<a-button>
<template #icon>
<icon-download />
2025-06-24 01:24:43 +08:00
</template>
2025-07-06 00:12:32 +08:00
{{ t('table.export') }}
</a-button>
<a-button type="primary">
<template #icon>
<icon-plus />
2025-06-24 01:24:43 +08:00
</template>
2025-07-06 00:12:32 +08:00
{{ t('add-project') }}
</a-button>
</a-space>
</div>
</div>
</template>
2025-07-06 00:12:32 +08:00
<!-- 使用新的 DataTable 组件 -->
<DataTable
:data="renderData"
2025-07-06 00:12:32 +08:00
:columns="projectColumn"
:loading="loading"
:total="total"
:current="current"
:page-size="pageSize"
@page-change="onPageChange"
2025-07-06 00:12:32 +08:00
@page-size-change="onPageSizeChange"
>
2025-07-31 23:43:28 +08:00
<!-- <template #type="{ record }">
<a-tag checkable :color="getTypeColor(record.type)">{{
getTypeText(record.type)
2025-07-31 23:43:28 +08:00
}}</a-tag>
</template>
<template #rate="{ record }">
2025-07-31 23:43:28 +08:00
<a-progress :percent="record.rate" color="green" :style="{ width: '100px' }" />
</template> -->
<template #operate>
<a-space>
<a-button>查看</a-button>
<a-button type="primary">编辑</a-button>
<a-button>更多</a-button>
</a-space>
</template>
2025-07-06 00:12:32 +08:00
</DataTable>
</a-card>
</div>
2025-06-22 23:55:55 +08:00
</template>
2025-06-24 01:24:43 +08:00
<script lang="ts" setup>
2025-07-31 23:43:28 +08:00
import { ref, onMounted } from 'vue';
import useLoading from '@/hooks/loading';
2025-07-06 00:12:32 +08:00
import { useI18n } from 'vue-i18n';
import type { TableColumnData } from '@arco-design/web-vue';
import useDataTable from '@/composables/useDataTable';
2025-07-31 23:43:28 +08:00
import { ProjectItem } from '@/types/business';
import { getProjectList } from '@/api/business';
2025-07-06 00:12:32 +08:00
const { t } = useI18n();
const { loading } = useLoading(false);
2025-07-31 23:43:28 +08:00
const projectList = ref<ProjectItem[]>([]);
2025-07-06 00:12:32 +08:00
const {
data: renderData,
columns: projectColumn,
total,
current,
pageSize,
setData,
setColumns,
setTotal,
setCurrent,
setPageSize,
2025-07-31 23:43:28 +08:00
setLoading,
2025-07-06 00:12:32 +08:00
} = useDataTable({
initialPage: 1,
initialPageSize: 10,
pageSizeOptions: [10, 20, 50, 100],
});
// 列配置
const columns: TableColumnData[] = [
{ title: '项目信息', dataIndex: 'name', key: 'name' },
{ title: '项目类型', dataIndex: 'type', key: 'type', slotName: 'type' },
{ title: '管理面积', dataIndex: 'size', key: 'size' },
{ title: '可租面积', dataIndex: 'kezu', key: 'kezu' },
{ title: '出租率', dataIndex: 'rate', key: 'rate', slotName: 'rate' },
{ title: '房源数量', dataIndex: 'count', key: 'count' },
{ title: '创建时间', dataIndex: 'create_time', key: 'create_time' },
{ title: '操作', key: 'operate', slotName: 'operate', width: 200 },
];
2025-07-31 23:43:28 +08:00
const getProjectListData = async () => {
const params = {
page: current.value,
page_size: pageSize.value,
};
setLoading(true);
const { code, data } = await getProjectList(params);
if (code === 200 && data) {
const { projectsList, page } = data;
projectList.value = Array.isArray(projectsList) ? projectsList : [];
setTotal(page?.total ? page.total : 0);
}
setLoading(false);
};
2025-07-06 00:12:32 +08:00
// 分页事件处理
const onPageChange = (page: number) => {
setCurrent(page);
2025-07-31 23:43:28 +08:00
current.value = page;
};
2025-07-31 23:43:28 +08:00
const onPageSizeChange = (size: number) => {
setPageSize(size);
pageSize.value = size;
};
2025-07-31 23:43:28 +08:00
onMounted(() => {
setColumns(columns);
getProjectListData();
});
</script>