楼栋增删改查完成, 接着房屋
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user