楼栋增删改查完成, 接着房屋

This commit is contained in:
Zy
2026-04-08 18:37:30 +08:00
parent cd292d5bf4
commit 6e998d4e87
9 changed files with 241 additions and 82 deletions

View File

@@ -13,12 +13,11 @@
active: item.id === currentBuildingInfo.id
}"
:key="index"
@click="switchBuilding(item.id)"
>
<div class="buildingname">{{ item.buildingName ?? '测试数据' }}</div>
<div class="buildingname" @click="switchBuilding(item.id)">{{ item.buildingName ?? '测试数据' }}</div>
<div class="buildactions flex align-center justify-around">
<el-icon class="pointer hover-color-blue"><Setting /></el-icon>
<el-icon class="pointer hover-color-red"><Delete /></el-icon>
<el-icon class="pointer hover-color-blue" @click="editBuilding(item.id)"><Setting /></el-icon>
<el-icon class="pointer hover-color-red" @click="deleteBuilding(item.id)"><Delete /></el-icon>
</div>
</li>
</ul>
@@ -26,17 +25,35 @@
</template>
<script setup lang="ts">
import { deleteBuildingApi } from '@/api/system/house';
import { useHouseStore } from '@/store/modules/house';
const houseStore = useHouseStore();
const { switchBuilding } = houseStore; // 方法
const { currentBuildingInfoList, currentBuildingInfo } = storeToRefs(houseStore); // 数据
const router = useRouter();
console.log(currentBuildingInfoList);
const handleAddBuilding = () => {
router.push({
path: '/house/addbuilding'
});
};
const editBuilding = (id: number) => {
router.push({
path: '/house/addbuilding',
query: {
buildingId: id
}
});
};
const deleteBuilding = (id: number) => {
deleteBuildingApi(id)
.then(() => {
console.log('删除成功');
houseStore.deleteBuildingFun(id);
})
.catch(() => {
console.log('删除失败');
});
};
</script>
<style scoped lang="scss">
@@ -64,12 +81,15 @@ $primary_color: #1978fe;
line-height: 45px;
color: rgba(16, 16, 16, 1);
position: relative;
cursor: pointer;
border-bottom: 1px solid #f2f2f2;
&:hover {
background-color: #1978fe0c;
}
.buildingname {
text-align: center;
width: 100%;
padding: 0 20px 0 0;
cursor: pointer;
}
.buildactions {
position: absolute;

View File

@@ -1,7 +1,7 @@
<template>
<div class="TableBox p-5 h-full">
<el-table border :data="currentFloorInfoList">
<el-table-column align="center" fixed label="楼层\单元" width="85">
<el-table border :data="houseStore.currentFloorInfoList">
<el-table-column align="center" fixed label="楼层\单元" min-width="85">
<template #default="{ row }">
<span>{{ row }}</span>
</template>
@@ -10,18 +10,12 @@
min-width="160"
class="column"
align="center"
:label="`${units.unitNo}单元`"
v-for="(units, index) in currentHouseInfoList"
:label="`${unit.unitNo}单元`"
v-for="(unit, index) in houseStore.currentHouseInfoList?.units ?? []"
:key="index"
>
<template #default="{ row }">
<houseItem
@contextmenufun="contextMenuFun"
@change="handleChange"
:menu-list="menutlist"
:unit="units.floors_Json"
:f-idx="row"
></houseItem>
<houseItem @contextmenufun="contextMenuFun" @change="handleChange" :menu-list="menutlist" :unit="unit.floors" :f-idx="row"></houseItem>
</template>
</el-table-column>
</el-table>
@@ -33,6 +27,7 @@ import houseItem from './houseItem.vue';
import { useHouseStore } from '@/store/modules/house';
const houseStore = useHouseStore();
const { currentHouseInfoList, currentFloorInfoList } = storeToRefs(houseStore); // 数据
console.log(currentHouseInfoList);
const menutlist = [
{ label: '编辑', value: 'edit' },
{ label: '收费标准', value: 'money' },

View File

@@ -6,7 +6,7 @@
<strong>{{ houseStore.currentBuildingInfo.buildingName }}</strong>
</span>
<span class="mr-30px">楼栋朝向:{{ houseStore.currentBuildingInfo.buildToward }}</span>
<span class="mr-30px">楼高{{ houseStore.currentBuildingInfo.buildTall }}</span>
<span class="mr-30px">楼高{{ houseStore.currentBuildingInfo.buildTall }}(m)</span>
<span class="mr-30px">楼栋结构{{ houseStore.currentBuildingInfo.buildStructure }} </span>
</div>
<div class="rightActions">
@@ -22,7 +22,6 @@
</template>
<script setup lang="ts">
import { ref } from 'vue';
import TableUnit from './components/table.vue';
import { useHouseStore } from '@/store/modules/house';
const houseStore = useHouseStore();