2025-06-22 23:55:55 +08:00
|
|
|
<template>
|
2025-06-24 19:46:34 +08:00
|
|
|
<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">
|
2025-06-24 19:46:34 +08:00
|
|
|
<template #title>
|
|
|
|
|
<div class="card-title_between">
|
2025-07-06 00:12:32 +08:00
|
|
|
<p class="title">{{ t('menu.business.project') }}</p>
|
2025-06-24 19:46:34 +08:00
|
|
|
<div class="flex_center_between">
|
|
|
|
|
<a-space>
|
|
|
|
|
<a-input-search
|
2025-08-06 23:26:38 +08:00
|
|
|
v-model="queryParams.keyword"
|
2025-06-24 19:46:34 +08:00
|
|
|
:style="{ width: '320px' }"
|
2025-07-06 00:12:32 +08:00
|
|
|
:placeholder="t('please.enter', { placeholder: t('content') })"
|
2025-08-06 23:26:38 +08:00
|
|
|
@search="handleSearch"
|
2025-06-24 19:46:34 +08:00
|
|
|
/>
|
|
|
|
|
<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') }}
|
2025-06-24 19:46:34 +08:00
|
|
|
</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') }}
|
2025-06-24 19:46:34 +08:00
|
|
|
</a-button>
|
2025-08-06 23:26:38 +08:00
|
|
|
<a-button type="primary" @click="handleAddProject">
|
2025-06-24 19:46:34 +08:00
|
|
|
<template #icon>
|
|
|
|
|
<icon-plus />
|
2025-06-24 01:24:43 +08:00
|
|
|
</template>
|
2025-07-06 00:12:32 +08:00
|
|
|
{{ t('add-project') }}
|
2025-06-24 19:46:34 +08:00
|
|
|
</a-button>
|
|
|
|
|
</a-space>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2025-07-06 00:12:32 +08:00
|
|
|
<!-- 使用新的 DataTable 组件 -->
|
|
|
|
|
<DataTable
|
2025-06-24 19:46:34 +08:00
|
|
|
:data="renderData"
|
2025-07-06 00:12:32 +08:00
|
|
|
:columns="projectColumn"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
:total="total"
|
|
|
|
|
:current="current"
|
|
|
|
|
:page-size="pageSize"
|
2025-06-24 19:46:34 +08:00
|
|
|
@page-change="onPageChange"
|
2025-07-06 00:12:32 +08:00
|
|
|
@page-size-change="onPageSizeChange"
|
2025-06-24 19:46:34 +08:00
|
|
|
>
|
2025-08-06 23:26:38 +08:00
|
|
|
<template #type="{ record }">
|
|
|
|
|
<a-tag checkable :color="getProjectTypeColor(record.type)">
|
|
|
|
|
{{ record.typeName }}
|
|
|
|
|
</a-tag>
|
2025-06-24 19:46:34 +08:00
|
|
|
</template>
|
|
|
|
|
<template #rate="{ record }">
|
2025-08-06 23:26:38 +08:00
|
|
|
<a-progress
|
|
|
|
|
:percent="Number(record.rentRate)"
|
|
|
|
|
color="green"
|
|
|
|
|
:style="{ width: '100px' }"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<template #operate="{ record }">
|
2025-06-24 19:46:34 +08:00
|
|
|
<a-space>
|
|
|
|
|
<a-button>查看</a-button>
|
2025-08-06 23:26:38 +08:00
|
|
|
<a-button
|
|
|
|
|
:loading="isLoadingEdit"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="handleEditProject(record.id)"
|
|
|
|
|
>编辑</a-button
|
|
|
|
|
>
|
2025-06-24 19:46:34 +08:00
|
|
|
<a-button>更多</a-button>
|
|
|
|
|
</a-space>
|
|
|
|
|
</template>
|
2025-07-06 00:12:32 +08:00
|
|
|
</DataTable>
|
2025-06-24 19:46:34 +08:00
|
|
|
</a-card>
|
2025-08-06 23:26:38 +08:00
|
|
|
<projectFormDrawer
|
|
|
|
|
v-model:visible="showDrawer"
|
|
|
|
|
:is-edit="isEdit"
|
|
|
|
|
:record="currentProjectInfo"
|
|
|
|
|
/>
|
2025-06-24 19:46:34 +08:00
|
|
|
</div>
|
2025-06-22 23:55:55 +08:00
|
|
|
</template>
|
2025-06-24 01:24:43 +08:00
|
|
|
|
2025-06-24 19:46:34 +08:00
|
|
|
<script lang="ts" setup>
|
2025-07-31 23:43:28 +08:00
|
|
|
import { ref, onMounted } from 'vue';
|
2025-06-24 19:46:34 +08:00
|
|
|
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-08-06 23:26:38 +08:00
|
|
|
import { ProjectItem, ProjectInfo } from '@/types/business';
|
|
|
|
|
import { getProjectList, getProjectDetail } from '@/api/business';
|
|
|
|
|
import { ProjectPaginationParams, ProjectType } from '@/types/comm';
|
|
|
|
|
import projectFormDrawer from './drawer/project-form-drawer.vue';
|
2025-06-24 19:46:34 +08:00
|
|
|
|
2025-07-06 00:12:32 +08:00
|
|
|
const { t } = useI18n();
|
|
|
|
|
const { loading } = useLoading(false);
|
2025-08-06 23:26:38 +08:00
|
|
|
const showDrawer = ref<boolean>(false);
|
|
|
|
|
const isLoadingEdit = ref<boolean>(false);
|
|
|
|
|
const isEdit = ref<boolean>(false);
|
|
|
|
|
const currentProjectInfo = ref<ProjectInfo | null>(null);
|
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' },
|
2025-08-06 23:26:38 +08:00
|
|
|
{ title: '管理面积', dataIndex: 'RentAreaStr', key: 'RentAreaStr' },
|
|
|
|
|
{ title: '可租面积', dataIndex: 'RoomAreaStr', key: 'RoomAreaStr' },
|
|
|
|
|
{
|
|
|
|
|
title: '出租率',
|
|
|
|
|
dataIndex: 'RentRateStr',
|
|
|
|
|
key: 'RentRateStr',
|
|
|
|
|
slotName: 'rate',
|
|
|
|
|
},
|
|
|
|
|
{ title: '房源数量', dataIndex: 'roomNum', key: 'roomNum' },
|
|
|
|
|
{ title: '创建时间', dataIndex: 'createdAt', key: 'createdAt' },
|
2025-07-06 00:12:32 +08:00
|
|
|
{ title: '操作', key: 'operate', slotName: 'operate', width: 200 },
|
|
|
|
|
];
|
2025-08-06 23:26:38 +08:00
|
|
|
const queryParams = ref<ProjectPaginationParams>({
|
|
|
|
|
page: current.value,
|
|
|
|
|
page_size: pageSize.value,
|
|
|
|
|
keyword: '',
|
|
|
|
|
type: null,
|
|
|
|
|
province_ids: null,
|
|
|
|
|
rent_rate_min: null,
|
|
|
|
|
rent_rate_max: null,
|
|
|
|
|
});
|
2025-07-31 23:43:28 +08:00
|
|
|
const getProjectListData = async () => {
|
|
|
|
|
setLoading(true);
|
2025-08-06 23:26:38 +08:00
|
|
|
const { code, data } = await getProjectList(queryParams.value);
|
2025-07-31 23:43:28 +08:00
|
|
|
if (code === 200 && data) {
|
|
|
|
|
const { projectsList, page } = data;
|
|
|
|
|
projectList.value = Array.isArray(projectsList) ? projectsList : [];
|
2025-08-06 23:26:38 +08:00
|
|
|
setData(projectList.value);
|
2025-07-31 23:43:28 +08:00
|
|
|
setTotal(page?.total ? page.total : 0);
|
|
|
|
|
}
|
|
|
|
|
setLoading(false);
|
2025-06-24 19:46:34 +08:00
|
|
|
};
|
2025-08-06 23:26:38 +08:00
|
|
|
const getProjectDetailData = async (id: number) => {
|
|
|
|
|
isLoadingEdit.value = true;
|
|
|
|
|
const { code, data } = await getProjectDetail(id);
|
|
|
|
|
if (code === 200 && data) {
|
|
|
|
|
currentProjectInfo.value = data.project;
|
|
|
|
|
}
|
|
|
|
|
isLoadingEdit.value = 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-06-24 19:46:34 +08:00
|
|
|
};
|
2025-07-31 23:43:28 +08:00
|
|
|
const onPageSizeChange = (size: number) => {
|
|
|
|
|
setPageSize(size);
|
|
|
|
|
pageSize.value = size;
|
2025-06-28 00:10:30 +08:00
|
|
|
};
|
2025-08-06 23:26:38 +08:00
|
|
|
const handleAddProject = () => {
|
|
|
|
|
isEdit.value = false;
|
|
|
|
|
currentProjectInfo.value = null;
|
|
|
|
|
showDrawer.value = true;
|
|
|
|
|
};
|
|
|
|
|
const handleEditProject = async (id: number) => {
|
|
|
|
|
isEdit.value = true;
|
|
|
|
|
await getProjectDetailData(id);
|
|
|
|
|
showDrawer.value = true;
|
|
|
|
|
};
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
|
getProjectListData();
|
|
|
|
|
};
|
|
|
|
|
const getProjectTypeColor = (type: ProjectType) => {
|
|
|
|
|
const typeMap = { 1: 'green', 2: 'red', 3: 'orange' };
|
|
|
|
|
return typeMap[type];
|
|
|
|
|
};
|
2025-07-31 23:43:28 +08:00
|
|
|
onMounted(() => {
|
|
|
|
|
setColumns(columns);
|
|
|
|
|
getProjectListData();
|
|
|
|
|
});
|
2025-06-24 19:46:34 +08:00
|
|
|
</script>
|