<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>首页</title>
<style>
body{
background-color: #eef1f6;
}
.el-row {
display: flex;
height: 100vh;
}
.el-col {
display: flex;
flex-direction: column;
}
.el-menu {
flex-grow: 1;
}
</style>
</head>
<body>
<div id="app">
<el-row>
<el-col :span="3">
<el-menu
default-active="0"
class="el-menu-vertical-demo"
@select="handleSelect"
background-color="#303133"
text-color="#fff"
active-text-color="#ffd04b">
<h3 style="text-align: center; background-color: yellow">酒店客房管理系统</h3>
<el-menu-item index="0">首页</el-menu-item>
<el-submenu index="1">
<template slot="title">
<span>系统管理</span>
</template>
<el-menu-item index="1-1">用户管理</el-menu-item>
<el-menu-item index="1-2">日志管理</el-menu-item>
</el-submenu>
<el-submenu index="2">
<template slot="title">
<span>报表管理</span>
</template>
<el-menu-item index="2-1">预定客人报表</el-menu-item>
<el-menu-item index="2-2">在线客人报表</el-menu-item>
<el-menu-item index="2-3">离店客人报表</el-menu-item>
<el-menu-item index="2-4">财务进账报表</el-menu-item>
</el-submenu>
<el-submenu index="3">
<template slot="title">
<span>房客管理</span>
</template>
<el-menu-item index="3-1">客房预定管理</el-menu-item>
<el-menu-item index="3-2">入住登记管理</el-menu-item>
<el-menu-item index="3-3">预定转入住</el-menu-item>
<el-menu-item index="3-4">换房管理</el-menu-item>
<el-menu-item index="3-5">结账管理</el-menu-item>
</el-submenu>
<el-submenu index="4">
<template slot="title">
<span>客房管理</span>
</template>
<el-menu-item index="4-1">客房信息管理</el-menu-item>
</el-submenu>
<el-submenu index="5">
<template slot="title">
<span>消费管理</span>
</template>
<el-menu-item index="5-1">附加消费入账</el-menu-item>
</el-submenu>
<el-submenu index="6">
<template slot="title">
<span>基础信息管理</span>
</template>
<el-menu-item index="6-1">客房类型管理</el-menu-item>
<el-menu-item index="6-2">楼层管理</el-menu-item>
<el-menu-item index="6-3">商品类别管理</el-menu-item>
<el-menu-item index="6-4">商品管理</el-menu-item>
<el-menu-item index="6-5">会员管理管理</el-menu-item>
</el-submenu>
<el-menu-item index="7">
<span><a href="login.html">退出登录</a></span>
</el-menu-item>
</el-menu>
</el-col>
<el-col :span="21" v-if="this.page == 0">
<center><h1>欢迎使用酒店客房管理系统</h1></center>
<h2>你是{{user.position}}</h2>
</el-col>
<el-col :span="21" v-if="this.page == '6-1'">
<h1>客房管理</h1>
<el-divider></el-divider>
<el-button style="width: 150px" type="primary" @click="addRoomType()">新增客房类型</el-button>
<el-table
:data="roomTypeTableData"
border
style="width: 100%">
<el-table-column
type="index"
width="100">
</el-table-column>
<el-table-column
prop="type"
label="客房类型"
align="center">
</el-table-column>
<el-table-column
prop="capacity"
label="额定容量"
align="center">
</el-table-column>
<el-table-column
prop="note"
label="备注"
align="center">
</el-table-column>
<el-table-column label="操作" width="200" align="center">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="editRoomType(scope.row)">编辑</el-button>
<el-button type="danger" size="mini" @click="deleteRoomType(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<div id="dialog">
<el-dialog title="新增客房类型" :visible.sync="addRoomTypeFormVisible">
<el-form :model="roomType">
<el-form-item label="类型名" label-width="120px" :rules="[{ required: true, message: '请输入客房类型名', trigger: 'blur' }]">
<el-input v-model="roomType.type"></el-input>
</el-form-item>
<el-form-item label="额定人数" label-width="120px" :rules="[{ required: true, message: '请输入额定人数', trigger: 'blur' }]">
<el-input v-model="roomType.capacity"></el-input>
</el-form-item>
<el-form-item label="备注" label-width="120px">
<el-input type="textarea" v-model="roomType.note"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="addRoomTypeFormVisible = false">取 消</el-button>
<el-button type="primary" @click="summitRoomType">提 交</el-button>
</div>
</el-dialog>
<el-dialog title="编辑客房类型" :visible.sync="editRoomTypeFormVisible">
<el-form :model="roomType">
<el-form-item label="类型名" label-width="120px" >
<el-input v-model="roomType.type"></el-input>
</el-form-item>
<el-form-item label="额定人数" label-width="120px">
<el-input v-model="roomType.capacity"></el-input>
</el-form-item>
<el-form-item label="备注" label-width="120px">
<el-input type="textarea" v-model="roomType.note"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="editRoomTypeFormVisible = false">取 消</el-button>
<el-button type="primary" @click="updateRoomType">确 定</el-button>
</div>
</el-dialog>
</div>
</div>
<script src="js/vue.js"></script>
<script src="js/axios-0.18.0.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script>
new Vue({
el: '#app',
data() {
return {
roomType:{
id:'',
type:'',
capacity:'',
note:''
},
addRoomTypeFormVisible: false,
editRoomTypeFormVisible: false,
user:{
position:''
},
page:'0',
roomTypeTableData:[],
}
},
methods: {
updateRoomType(){
axios({
method: 'post',
url: "http://localhost:8080/Hotel_1.0/roomType/update",
data: this.roomType
}).then(res => {
if (res.data == 'success') {
this.$message.success('修改成功');
this.editRoomTypeFormVisible = false;
this.selectAll();
} else {
this.$message.error('修改失败');
}
})
},
editRoomType(index, row){
console.log(row);
this.editRoomTypeFormVisible = true;
this.roomType = row;
},
deleteRoomType(row){
this.$confirm('此操作将删除该客房类型, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
axios({
method: 'get',
url: "http://localhost:8080/Hotel_1.0/roomType/deleteById",
params: {
id:row.id
}
}).then(res => {
if (res.data == 'success') {
this.$message.success('删除成功');
this.selectAll();
} else {
this.$message.error('删除失败');
}
})
})
.catch(() => {
this.$message.info('已取消删除');
});
},
summitRoomType(){
axios({
method: 'post',
url: "http://localhost:8080/Hotel_1.0/roomType/add",
data: this.roomType
}).then(res => {
if (res.data == 'success') {
this.$message.success('添加成功');
this.addRoomTypeFormVisible = false;
this.selectAll();
} else {
this.$message.error('添加失败');
}
});
},
addRoomType(){
this.addRoomTypeFormVisible = true;
},
handleSelect(key,keyPath){
this.page = key;
if(key=='6-1'){
this.selectAll();
}
},
selectAll(){
axios({
method:'get',
url:"http://localhost:8080/Hotel_1.0/roomType/selectAll"
}).then(res=>{
this.roomTypeTableData = res.data;
})
}
},
mounted(){
this.$message({
message: '欢迎使用酒店管理系统',
type: 'success'
})
this.user.position = sessionStorage.getItem("position");
}
})
</script>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步