commit 94ab5b139658a820bf2b788433acb3e1aff43dea Author: Gary <3489015381@qq.com> Date: Mon Dec 2 18:58:32 2024 +0800 初始化前端代码 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78a752d --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +.DS_Store +node_modules/ +dist/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* +**/*.log + +tests/**/coverage/ +tests/e2e/reports +selenium-debug.log + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.local + +package-lock.json +yarn.lock diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..c94e729 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/cli-plugin-babel/preset' + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d3269d7 --- /dev/null +++ b/package.json @@ -0,0 +1,34 @@ +{ + "name": "YueDorm", + "version": "0.1.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build" + }, + "dependencies": { + "@element-plus/icons-vue": "^0.2.7", + "axios": "^0.25.0", + "core-js": "^3.6.5", + "echarts": "^5.3.0", + "element-plus": "^2.0.1", + "vue": "^3.0.0", + "vue-axios": "^3.4.1", + "vue-router": "^4.0.13", + "vuex": "^4.0.0-0", + "wangeditor": "^4.7.11" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-plugin-router": "~4.5.0", + "@vue/cli-plugin-vuex": "~4.5.0", + "@vue/cli-service": "~4.5.0", + "@vue/compiler-sfc": "^3.0.0", + "element": "^0.1.4" + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not dead" + ] +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..c979538 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..01ba963 --- /dev/null +++ b/public/index.html @@ -0,0 +1,18 @@ + + + + + + + + YueDorm + + + +
+ + + diff --git a/public/login_Team.png b/public/login_Team.png new file mode 100644 index 0000000..519d96e Binary files /dev/null and b/public/login_Team.png differ diff --git a/public/myRoom.png b/public/myRoom.png new file mode 100644 index 0000000..5c6c529 Binary files /dev/null and b/public/myRoom.png differ diff --git a/public/self_Space.png b/public/self_Space.png new file mode 100644 index 0000000..4c79b0c Binary files /dev/null and b/public/self_Space.png differ diff --git a/public/waoku.jpg b/public/waoku.jpg new file mode 100644 index 0000000..9a432d6 Binary files /dev/null and b/public/waoku.jpg differ diff --git a/public/wuwu.jpeg b/public/wuwu.jpeg new file mode 100644 index 0000000..60b9aef Binary files /dev/null and b/public/wuwu.jpeg differ diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..204bd28 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,17 @@ + + + + + diff --git a/src/assets/QQ.png b/src/assets/QQ.png new file mode 100644 index 0000000..805245e Binary files /dev/null and b/src/assets/QQ.png differ diff --git a/src/assets/WeChat.png b/src/assets/WeChat.png new file mode 100644 index 0000000..6c2dfbb Binary files /dev/null and b/src/assets/WeChat.png differ diff --git a/src/assets/css/Home.css b/src/assets/css/Home.css new file mode 100644 index 0000000..c2aa045 --- /dev/null +++ b/src/assets/css/Home.css @@ -0,0 +1,99 @@ +.wv-lt-refresh { + display: none; +} + +.topInfo { + margin: 0 auto; +} + +.el-colDiv { + margin: 20px auto; + max-width: 340px; + min-width: 200px; + overflow: hidden; + height: 115px; + border-radius: 5px; + background-color: black; + color: white; + padding-left: 15px; + padding-top: 15px; + position: relative; +} + +.el-colDiv:hover { + background-position: right; +} + +.nowDiv { + width: 38px; + height: 19px; + position: absolute; + right: 5%; + font-size: 15px; + display: flex; + justify-content: center; + align-items: center; + border-radius: 3px; +} + +.digital { + font-size: 25px; + line-height: normal; + margin-left: 2px; +} + +.title { + font-size: 18px; +} + +.last-span { + font-size: 13px; +} + +#stuNumDiv { + /*background-color: #2e4057;*/ + background-image: linear-gradient(to left, #FFC312, #EE5A24, #FFC312); + background-size: 200%; + transition: 0.6s; +} + +#haveRoomDiv { + /*background-color: #1398ff;*/ + background-image: linear-gradient(to left, #C4E538, #009432, #C4E538); + background-size: 200%; + transition: 0.6s; + +} + +#repairNum { + /*background-color: #008789;*/ + background-image: linear-gradient(to left, #12CBC4, #0652DD, #12CBC4); + background-size: 200%; + transition: 0.6s; +} + +#emptyRoom { + /*background-color: #ffb400;*/ + background-image: linear-gradient(to left, #FDA7DF, #9980FA, #FDA7DF); + background-size: 200%; + transition: 0.6s; +} + +#ssv1-main-text { + background-color: #1398ff; +} + + +#ssv2-main-text { + background-color: #2e4057; +} + + +#ssv3-main-text { + background-color: #ffb400; +} + + +#ssv4-main-text { + background-color: #008789; +} \ No newline at end of file diff --git a/src/assets/css/Login.css b/src/assets/css/Login.css new file mode 100644 index 0000000..21b7565 --- /dev/null +++ b/src/assets/css/Login.css @@ -0,0 +1,21 @@ +.login-container { + height: 100%; + position: fixed; + top: 0; + left: 0; + transform: translate(-50%, -50%); + display: flex; + justify-content: center; + align-items: center; +} +@keyframes myanimation { + 0% { + background-position: 0% 50%; + } + 50% { + background-position: 0% 50%; + } + 100% { + background-position: 0% 50%; + } +} \ No newline at end of file diff --git a/src/assets/css/MyRoomInfo.css b/src/assets/css/MyRoomInfo.css new file mode 100644 index 0000000..33de7e2 --- /dev/null +++ b/src/assets/css/MyRoomInfo.css @@ -0,0 +1,4 @@ +.rightSpan { + display: inline-block; + width: 80px; +} \ No newline at end of file diff --git a/src/assets/css/RoomInfo.css b/src/assets/css/RoomInfo.css new file mode 100644 index 0000000..9b203b1 --- /dev/null +++ b/src/assets/css/RoomInfo.css @@ -0,0 +1,34 @@ +.demo-table-expand { + font-size: 0; +} + +.demo-table-expand label { + text-align: center; + width: 90px; + color: #99a9bf; +} + +.demo-table-expand .el-form-item { + text-align: center; + margin-right: 0; + margin-bottom: 0; + width: 25%; +} + +.el-form--inline-icon { + margin-left: 5px; + display: flex; + font-size: 16px; +} + +.el-form--inline-icon > .el-icon { + cursor: pointer; + margin: 0 5px; +} + +.item { + margin-left: 50px; + margin-bottom: 0; + width: 20%; + +} \ No newline at end of file diff --git a/src/assets/css/SelfInfo.css b/src/assets/css/SelfInfo.css new file mode 100644 index 0000000..55c8330 --- /dev/null +++ b/src/assets/css/SelfInfo.css @@ -0,0 +1,40 @@ +.img { + +} + +.editImg { + width: 78px; + height: 78px; + border-radius: 39px; + display: flex; + align-items: center; + justify-content: center; + text-align: center; + font-size: 14px; + line-height: 79px; + color: #cccccc; + position: absolute; + left: 261px; + background-color: rgba(0, 0, 0, 0.5); + display: none; +} + +.AvatarDiv { + width: 80px; + height: 80px; + border-radius: 40px; + display: flex; + margin: 0 auto; +} + +.AvatarDiv:hover .editImg { + display: block; + cursor: pointer; +} + +.upload-demo { + display: grid; + width: 80px; + height: 80px; + margin: 40px auto; +} \ No newline at end of file diff --git a/src/assets/css/global.css b/src/assets/css/global.css new file mode 100644 index 0000000..fbc0218 --- /dev/null +++ b/src/assets/css/global.css @@ -0,0 +1,8 @@ +@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap'); + +* { + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: 'Poppins', sans-serif; +} \ No newline at end of file diff --git a/src/assets/js/AdjustRoomInfo.js b/src/assets/js/AdjustRoomInfo.js new file mode 100644 index 0000000..bf496db --- /dev/null +++ b/src/assets/js/AdjustRoomInfo.js @@ -0,0 +1,201 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); +export default { + name: "AdjustRoomInfo", + data() { + const checkRoomState = (rule, value, callback) => { + this.dormRoomId = value + request.get("/room/checkRoomState/" + value).then((res) => { + if (res.code === "0") { + callback(); + } else { + callback(new Error(res.msg)); + } + }); + }; + const checkBedState = (rule, value, callback) => { + request.get("/room/checkBedState/" + this.dormRoomId + '/' + value).then((res) => { + if (res.code === "0") { + callback(); + } else { + callback(new Error(res.msg)); + } + }); + }; + const checkApplyState = (rule, value, callback) => { + console.log(this.form.finishTime) + if (value === "通过" && this.form.finishTime !== null) { + callback(); + } else if (value === "驳回" && this.form.finishTime !== null) { + callback(); + } else { + callback(new Error("请检查订单完成状态与选择时间是否匹配")); + } + }; + return { + loading: true, + dialogVisible: false, + detailDialog: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + form: {}, + dormRoomId: 0, + orderState: false, + rules: { + username: [ + {required: true, message: "请输入学号", trigger: "blur"}, + {pattern: /^[a-zA-Z0-9]{4,9}$/, message: "必须由 2 到 5 个字母或数字组成", trigger: "blur",}, + ], + name: [ + {required: true, message: "请输入姓名", trigger: "blur"}, + {pattern: /^(?:[\u4E00-\u9FA5·]{2,10})$/, message: "必须由 2 到 10 个汉字组成", trigger: "blur",}, + ], + currentRoomId: [ + {required: true, message: "请输入当前房间号", trigger: "blur"}, + ], + currentBedId: [ + {required: true, message: "请输入当前床位号", trigger: "blur"}, + ], + state: [{validator: checkApplyState, trigger: "blur"},], + towardsRoomId: [{validator: checkRoomState, trigger: "blur"}], + towardsBedId: [{validator: checkBedState, trigger: "blur"}], + }, + } + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/adjustRoom/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/adjustRoom/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.gender === value; + }, + judgeOrderState(state) { + if (state === '通过') { + this.orderState = true + } else if (state === '驳回') { + this.orderState = false + } + }, + save() { + this.$refs.form.validate((valid) => { + if (valid) { + this.judgeOrderState(this.form.state) + //修改 + request.put("/adjustRoom/update/" + this.orderState, this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else if (res.msg === "重复操作") { + ElMessage({ + message: res.msg, + type: "error", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + this.detailDialog = false; + }, + showDetail(row) { + // 查看详情 + this.detailDialog = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(JSON.stringify(row)); + }); + }, + handleEdit(row) { + //修改 + // 生拷贝 + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(JSON.stringify(row)); + }); + }, + async handleDelete(id) { + //删除 + request.delete("/adjustRoom/delete/" + id).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +} \ No newline at end of file diff --git a/src/assets/js/ApplyChangeRoom.js b/src/assets/js/ApplyChangeRoom.js new file mode 100644 index 0000000..7c61a7a --- /dev/null +++ b/src/assets/js/ApplyChangeRoom.js @@ -0,0 +1,215 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); +export default { + name: "AdjustRoomInfo", + data() { + const checkRoomState = (rule, value, callback) => { + this.dormRoomId = value + if (typeof value === "number") { + request.get("/room/checkRoomState/" + value).then((res) => { + request.get("/room/checkRoomExist/" + value).then((result) => { + if (result.code === "-1") { + callback(new Error(result.msg)); + } + if (res.code === "-1") { + callback(new Error(res.msg)); + } + callback(); + }) + }); + } else { + callback(new Error("请输入正确的数据")); + } + }; + const checkBedState = (rule, value, callback) => { + request.get("/room/checkBedState/" + this.dormRoomId + '/' + value).then((res) => { + if (res.code === "0") { + callback(); + } else { + callback(new Error(res.msg)); + } + }); + }; + return { + loading: true, + dialogVisible: false, + detailDialog: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + form: {}, + dormRoomId: 0, + orderState: false, + judgeOption: false, + rules: { + username: [ + {required: true, message: "请输入学号", trigger: "blur"}, + {pattern: /^[a-zA-Z0-9]{4,9}$/, message: "必须由 2 到 5 个字母或数字组成", trigger: "blur",}, + ], + name: [ + {required: true, message: "请输入姓名", trigger: "blur"}, + {pattern: /^(?:[\u4E00-\u9FA5·]{2,10})$/, message: "必须由 2 到 10 个汉字组成", trigger: "blur",}, + ], + currentRoomId: [ + {required: true, message: "请输入当前房间号", trigger: "blur"}, + ], + currentBedId: [ + {required: true, message: "请输入当前床位号", trigger: "blur"}, + ], + towardsRoomId: [ + {validator: checkRoomState, trigger: "blur"}, + ], + towardsBedId: [ + {validator: checkBedState, trigger: "blur"}, + ], + }, + } + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/adjustRoom/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.gender === value; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form.username = JSON.parse(sessionStorage.getItem("user")).username; + this.form.name = JSON.parse(sessionStorage.getItem("user")).name; + request.get("/room/getMyRoom/" + this.form.username).then((res) => { + this.form.currentRoomId = res.data.dormRoomId + this.form.currentBedId = this.calBedNum(this.form.username, res.data) + }); + this.judgeOption = true; + }); + }, + calBedNum(username, data) { + if (data.firstBed === username) { + return 1; + } else if (data.secondBed === username) { + return 2; + } else if (data.thirdBed === username) { + return 3; + } else if (data.fourthBed === username) { + return 4; + } + }, + judgeOrderState(state) { + if (state === '通过') { + this.orderState = true + } else if (state === '驳回') { + this.orderState = false + } else if (state === '未处理') { + this.orderState = false + } + }, + save() { + this.$refs.form.validate((valid) => { + if (valid) { + if (this.judgeOption === false) { + //修改 + this.judgeOrderState(this.form.state) + request.put("/adjustRoom/update/" + this.orderState, this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else if (res.msg === "重复操作") { + ElMessage({ + message: res.msg, + type: "error", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else if (this.judgeOption === true) { + //添加 + request.post("/adjustRoom/add", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "添加成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + this.detailDialog = false; + }, + showDetail(row) { + // 查看详情 + this.detailDialog = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(JSON.stringify(row)); + }); + }, + handleEdit(row) { + //修改 + // 生拷贝 + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(JSON.stringify(row)); + this.judgeOption = false; + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +} \ No newline at end of file diff --git a/src/assets/js/ApplyRepairInfo.js b/src/assets/js/ApplyRepairInfo.js new file mode 100644 index 0000000..76abb89 --- /dev/null +++ b/src/assets/js/ApplyRepairInfo.js @@ -0,0 +1,136 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "ApplyRepairInfo", + components: {}, + data() { + return { + loading: true, + dialogVisible: false, + detailDialog: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + detail: {}, + name: '', + username: '', + form: {}, + room: { + dormRoomId: '', + dormBuildId: '', + }, + rules: { + title: [{required: true, message: "请输入标题", trigger: "blur"}], + content: [{required: true, message: "请输入内容", trigger: "blur"}], + orderBuildTime: [{required: true, message: "请选择时间", trigger: "blur"},], + }, + }; + }, + created() { + this.init() + this.getInfo() + this.load() + this.loading = true + setTimeout(() => { + //设置延迟执行 + this.loading = false + }, 1000); + }, + methods: { + init() { + this.form = JSON.parse(sessionStorage.getItem("user")); + this.name = this.form.name; + this.username = this.form.username; + }, + async load() { + request.get("/repair/find/" + this.name, { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + getInfo() { + request.get("/room/getMyRoom/" + this.username).then((res) => { + if (res.code === "0") { + this.room = res.data; + console.log(this.room); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + filterTag(value, row) { + return row.state === value; + }, + showDetail(row) { + this.detailDialog = true; + this.$nextTick(() => { + this.detail = row; + }); + }, + closeDetails() { + this.detailDialog = false; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form.repairer = this.name + this.form.dormBuildId = this.room.dormBuildId + this.form.dormRoomId = this.room.dormRoomId + }); + }, + save() { + this.$refs.form.validate(async (valid) => { + if (valid) { + //新增 + console.log(this.form) + await request.post("/repair/add", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }) + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/BuildingInfo.js b/src/assets/js/BuildingInfo.js new file mode 100644 index 0000000..d07ed00 --- /dev/null +++ b/src/assets/js/BuildingInfo.js @@ -0,0 +1,181 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "BuildingInfo", + components: {}, + data() { + return { + loading: true, + disabled: false, + judge: false, + dialogVisible: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + form: { + dormBuildId: "", + dormBuildName: "", + dormBuildDetail: "", + }, + rules: { + dormBuildId: [ + {required: true, message: "请输入编号", trigger: "blur"}, + { + pattern: /^(1|[1-9]\d?|100)$/, + message: "范围:1-100", + trigger: "blur", + }, + ], + dormBuildName: [ + {required: true, message: "请输入名称", trigger: "blur"}, + ], + dormBuildDetail: [ + {required: true, message: "请输入备注", trigger: "blur"}, + ], + }, + }; + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/building/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/building/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.dormBuildDetail === value; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.$refs.form.validate((valid) => { + if (valid) { + if (this.judge === false) { + //新增 + request.post("/building/add", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + request.put("/building/update", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + }, + handleEdit(row) { + //修改 + this.judge = true; + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(row)); + this.disabled = true; + }); + }, + handleDelete(id) { + console.log(id); + request.delete("/building/delete/" + id).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/DormManagerInfo.js b/src/assets/js/DormManagerInfo.js new file mode 100644 index 0000000..5909511 --- /dev/null +++ b/src/assets/js/DormManagerInfo.js @@ -0,0 +1,277 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "StuInfo", + components: {}, + data() { + // 手机号验证 + const checkPhone = (rule, value, callback) => { + const phoneReg = /^1[3|4|5|6|7|8][0-9]{9}$/; + if (!value) { + return callback(new Error("电话号码不能为空")); + } + setTimeout(() => { + if (!Number.isInteger(+value)) { + callback(new Error("请输入数字值")); + } else { + if (phoneReg.test(value)) { + callback(); + } else { + callback(new Error("电话号码格式不正确")); + } + } + }, 100); + }; + const checkPass = (rule, value, callback) => { + if (!this.editJudge) { + console.log("验证"); + if (value == "") { + callback(new Error("请再次输入密码")); + } else if (value !== this.form.password) { + callback(new Error("两次输入密码不一致!")); + } else { + callback(); + } + } else { + console.log("不验证"); + callback(); + } + }; + return { + showpassword: true, + editJudge: true, + judgeAddOrEdit: true, + loading: true, + disabled: false, + judge: false, + dialogVisible: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + form: { + username: "", + name: "", + age: "", + gender: "", + phoneNum: "", + email: "", + dormBuildId: "", + }, + rules: { + username: [ + {required: true, message: "请输入账号", trigger: "blur"}, + { + pattern: /^[a-zA-Z0-9]{4,9}$/, + message: "必须由 4 到 9 个字母或数字组成", + trigger: "blur", + }, + ], + name: [ + {required: true, message: "请输入姓名", trigger: "blur"}, + { + pattern: /^(?:[\u4E00-\u9FA5·]{2,10})$/, + message: "必须由 2 到 10 个汉字组成", + trigger: "blur", + }, + ], + age: [ + {required: true, message: "请输入年龄", trigger: "blur"}, + {type: "number", message: "年龄必须为数字值", trigger: "blur"}, + { + pattern: /^(1|[1-9]\d?|100)$/, + message: "范围:1-100", + trigger: "blur", + }, + ], + gender: [{required: true, message: "请选择性别", trigger: "change"}], + phoneNum: [{required: true, validator: checkPhone, trigger: "blur"}], + email: [ + {type: "email", message: "请输入正确的邮箱地址", trigger: "blur"}, + ], + password: [ + {required: true, message: "请输入密码", trigger: "blur"}, + { + min: 6, + max: 32, + message: "长度在 6 到 16 个字符", + trigger: "blur", + }, + ], + checkPass: [{validator: checkPass, trigger: "blur"}], + dormBuildId: [], + }, + editDisplay: { + display: "block", + }, + display: { + display: "none", + }, + }; + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/dormManager/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/dormManager/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.gender === value; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.judgeAddOrEdit = false; + this.editDisplay = {display: "none"}; + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.$refs.form.validate(async (valid) => { + if (valid) { + if (this.judge === false) { + //新增 + request.post("/dormManager/add", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + request.put("/dormManager/update", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.display = {display: "none"}; + this.editJudge = true; + this.disabled = true; + this.showpassword = true; + this.dialogVisible = false; + }, + EditPass() { + if (this.editJudge) { + this.showpassword = false; + this.display = {display: "flex"}; + this.disabled = false; + this.editJudge = false; + } else { + this.showpassword = true; + this.display = {display: "none"}; + this.editJudge = true; + this.disabled = true; + } + }, + handleEdit(row) { + //修改 + //判断操作类型 + this.judge = true; + // 生拷贝 + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(JSON.stringify(row)); + this.judgeAddOrEdit = true; + this.editDisplay = {display: "block"}; + this.disabled = true; + }); + }, + async handleDelete(username) { + //删除 + console.log(username); + request.delete("/dormManager/delete/" + username).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/Home.js b/src/assets/js/Home.js new file mode 100644 index 0000000..bbcf08d --- /dev/null +++ b/src/assets/js/Home.js @@ -0,0 +1,92 @@ +import weather from "@/components/weather"; +import Calender from "@/components/Calendar"; +import request from "@/utils/request"; +import home_echarts from "@/components/home_echarts"; + +export default { + name: "Home", + components: { + weather, + Calender, + home_echarts, + }, + data() { + return { + studentNum: "", + haveRoomStudentNum: "", + detailDialog: false, + repairOrderNum: "", + noFullRoomNum: "", + activities: [], + }; + }, + created() { + this.getHomePageNotice(); + this.getStuNum(); + this.getHaveRoomNum(); + this.getOrderNum(); + this.getNoFullRoom(); + }, + methods: { + async getStuNum() { + request.get("/stu/stuNum").then((res) => { + if (res.code === "0") { + this.studentNum = res.data; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + async getHaveRoomNum() { + request.get("/room/selectHaveRoomStuNum").then((res) => { + if (res.code === "0") { + this.haveRoomStudentNum = res.data; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + async getOrderNum() { + request.get("/repair/orderNum").then((res) => { + if (res.code === "0") { + this.repairOrderNum = res.data; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + async getNoFullRoom() { + request.get("/room/noFullRoom").then((res) => { + if (res.code === "0") { + this.noFullRoomNum = res.data; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + async getHomePageNotice() { + request.get("/notice/homePageNotice").then((res) => { + if (res.code === "0") { + this.activities = res.data; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/Login.js b/src/assets/js/Login.js new file mode 100644 index 0000000..765f578 --- /dev/null +++ b/src/assets/js/Login.js @@ -0,0 +1,181 @@ +import request from "@/utils/request"; +import router from '@/router'; // 根据你的项目结构和路由文件的位置进行调整 +import { registerRuntimeCompiler } from "vue"; + +const {ElMessage} = require("element-plus"); +export default { + name: "Login", + data() { + return { + flag:true, + identity: "", + options: [{ + value: '选项1', + label: '学生' + }, { + value: '选项2', + label: '宿舍管理员' + }, { + value: '选项3', + label: '后勤管理中心' + }], + value: '', + form: { + username: "", + password: "", + confirmPassword:"", + identity: "", + }, + rules: { + username: [ + {required: true, message: "请输入用户名", trigger: "blur"}, + ], + password: [{required: true, message: "请输入密码", trigger: "blur"}], + confirmPassword: [{required: true, message: "请确认密码", trigger: "blur"}], + identity: [{required: true, message: "请选择身份", trigger: "blur"}], + }, + }; + }, + computed: { + disabled() { + const {username, password, identity} = this.form; + return Boolean(username && password && identity); + }, + }, + methods: { + register() { + const preBox = document.querySelector(".pre-box"); + const img = document.querySelector("img"); + // if(this.form.username == '123') { + // router.push('/home'); + // } + this.$refs.form.validate((valid) => { + console.log(this.form); + if (valid) { + this.identity = this.form.identity; + request.post("/" + this.identity + "/register", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "注册成功", + type: "success", + }); + alert('注册成功,请登录'); + preBox.style.transform = "translateX(0%)"; + preBox.style.backgroundColor = "#edd4dc"; + img.src = "img/sleep.5db2c1bc.png"; + // 注册成功跳转登录页面 + window.sessionStorage.setItem("user", JSON.stringify(res.data)); + window.sessionStorage.setItem("identity", JSON.stringify(this.form.identity)); + this.$router.replace({path: "/Login"}); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }); + }, + // register() { + // let url = this.axios.urls.SYSTEM_USER_DOREG; + // let params = { + // username: this.username, + // password: this.password, + + // } + // this.axios.post(url,params).then(r=> { + // // console.log(r); + // if (r.data.success) { + // this.$message({ + // message: r.data.msg, + // type: 'success', + // }); + // this.$router.push('/Login') + // } else { + // this.$message.error(r.data.msg); + // } + + // }).catch(r=> { + // //如果有问题就会走这里 + // // console.log(error); + // }); + // }, + login() { + // if(this.form.username == '123') { + // router.push('/home'); + // } + this.$refs.form.validate((valid) => { + if (valid) { + this.identity = this.form.identity; + console.log(this.form.username); + //console.log(this.identity); + request.post("/" + this.identity + "/login", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "登陆成功", + type: "success", + }); + // 登陆成功跳转主页 + window.sessionStorage.setItem("user", JSON.stringify(res.data)); + window.sessionStorage.setItem("identity", JSON.stringify(this.form.identity)); + this.$router.replace({path: "/home"}); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }); + }, + // 滑动的状态 + mySwitch() { + const preBox = document.querySelector(".pre-box"); + const img = document.querySelector("img"); + if (this.flag) { + // 修改滑动盒子的移动位置和背景颜色 + preBox.style.transform = "translateX(100%)"; + preBox.style.backgroundColor = "#c9e0ed"; + // 修改图片的路径 + img.src = "img/wake.b9344131.png"; + } else { + preBox.style.transform = "translateX(0%)"; + preBox.style.backgroundColor = "#edd4dc"; + img.src = "img/sleep.5db2c1bc.png"; + } + this.flag = !this.flag; + }, + + // createBubbles() { + // //console.log("Creating bubbles!"); + // // 获取body元素 + // const body = document.querySelector('.login') + // // 创建泡泡元素 + // const buble = document.createElement("span") + // buble.classList.add("buble"); + // // 设置泡泡半径 + // let r = Math.random()*5 + 25 //半径大小为25~30 + // // 设置泡泡的宽高 + // buble.style.width=r+'px' + // buble.style.height=r+'px' + // // 设置泡泡的随机起点 + // buble.style.left=Math.random()*innerWidth+'px' + // // 为body添加buble元素 + // body.append(buble) + // // 4s清除一次泡泡 + // setTimeout(() => { + // buble.remove() + // }, 4000); + // //console.log("Box element:", body); + // }, + // }, + + // created() { + // // 每200ms生成一个泡泡 + // setInterval(() => { + // this.createBubbles() + // }, 200); + }, +}; \ No newline at end of file diff --git a/src/assets/js/MyRoomInfo.js b/src/assets/js/MyRoomInfo.js new file mode 100644 index 0000000..cbf2960 --- /dev/null +++ b/src/assets/js/MyRoomInfo.js @@ -0,0 +1,49 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "MyRoomInfo", + data() { + return { + name: "", + form: { + username: "", + }, + room: { + dormRoomId: "", + dormBuildId: "", + floorNum: "", + maxCapacity: "", + currentCapacity: "", + firstBed: "", + secondBed: "", + thirdBed: "", + fourthBed: "", + }, + }; + }, + created() { + this.init(); + this.getInfo(); + }, + methods: { + init() { + this.form = JSON.parse(sessionStorage.getItem("user")); + this.name = this.form.username; + }, + getInfo() { + request.get("/room/getMyRoom/" + this.name).then((res) => { + if (res.code === "0") { + this.room = res.data; + console.log(this.room); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/NoticeInfo.js b/src/assets/js/NoticeInfo.js new file mode 100644 index 0000000..ef3a941 --- /dev/null +++ b/src/assets/js/NoticeInfo.js @@ -0,0 +1,207 @@ +import request from "@/utils/request"; +import E from "wangeditor"; + +const {ElMessage} = require("element-plus"); +let editor; +export default { + name: "BuildingInfo", + components: { + E, + }, + data() { + return { + author: "", + loading: true, + disabled: false, + judge: false, + dialogVisible: false, + detailDialog: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + detail: {}, + form: { + id: "", + title: "", + content: "", + author: "", + releaseTime: "", + }, + rules: { + title: [{required: true, message: "请输入标题", trigger: "blur"}], + content: [{required: true, message: "请输入内容", trigger: "blur"}], + releaseTime: [ + {required: true, message: "请选择时间", trigger: "blur"}, + ], + }, + }; + }, + created() { + this.getSessionInfo(); + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + mounted() { + }, + methods: { + async load() { + request.get("/notice/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/notice/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + getSessionInfo() { + let user = JSON.parse(sessionStorage.getItem("user")); + this.author = user.name; + }, + showDetail(row) { + this.detailDialog = true; + this.$nextTick(() => { + this.detail = row; + }); + }, + closeDetailDialog() { + this.detailDialog = false; + }, + add() { + this.form.author = this.author; + console.log(this.form.author); + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + //加载wangEdit + editor = new E("#div1"); + editor.create(); + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.form.content = editor.txt.html(); //获取编辑器内容并赋值 + this.form.author = this.author; + console.log(this.form.author); + this.$refs.form.validate((valid) => { + if (valid) { + if (this.judge === false) { + //新增 + request.post("/notice/add", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + request.put("/notice/update", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + editor.txt.clear(); + editor.destroy(); + this.dialogVisible = false; + }, + handleEdit(row) { + //修改 + this.judge = true; + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + //加载wangEdit + editor = new E("#div1"); + editor.create(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(row)); + editor.txt.html(this.form.content); + this.disabled = true; + }); + }, + handleDelete(id) { + console.log(id); + request.delete("/notice/delete/" + id).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/RepairInfo.js b/src/assets/js/RepairInfo.js new file mode 100644 index 0000000..5db2e81 --- /dev/null +++ b/src/assets/js/RepairInfo.js @@ -0,0 +1,204 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "RepairInfo", + components: {}, + data() { + const checkOrderState = (rule, value, callback) => { + if (this.judge) { + if (value === "未完成" && this.form.orderFinishTime === null) { + callback(); + } else if (value === "完成" && this.form.orderFinishTime !== null) { + callback(); + } else { + callback(new Error("请检查订单完成状态与选择时间是否匹配")); + } + } else { + callback(); + } + }; + return { + buildTimeDisabled: true, + loading: true, + disabled: false, + judge: false, + dialogVisible: false, + detailDialog: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + detail: {}, + form: {}, + rules: { + title: [{required: true, message: "请输入标题", trigger: "blur"}], + content: [{required: true, message: "请输入内容", trigger: "blur"}], + repairer: [ + {required: true, message: "请输入申请人", trigger: "blur"}, + ], + orderBuildTime: [ + {required: true, message: "请选择时间", trigger: "blur"}, + ], + state: [{validator: checkOrderState, trigger: "blur"}], + }, + finishTime: { + display: "none", + }, + }; + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/repair/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/repair/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.state === value; + }, + showDetail(row) { + this.detailDialog = true; + this.$nextTick(() => { + this.detail = row; + }); + }, + closeDetails() { + this.detailDialog = false; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.buildTimeDisabled = false; + this.finishTime = {display: "none"}; + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.$refs.form.validate(async (valid) => { + if (valid) { + if (this.judge === false) { + //新增 + await request.post("/repair/add", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + await request.put("/repair/update", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + }, + handleEdit(row) { + //修改 + this.judge = true; + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(row)); + this.disabled = true; + this.buildTimeDisabled = true; + this.finishTime = {display: "flex"}; + }); + }, + handleDelete(id) { + console.log(id); + request.delete("/repair/delete/" + id).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/RoomInfo.js b/src/assets/js/RoomInfo.js new file mode 100644 index 0000000..40c1887 --- /dev/null +++ b/src/assets/js/RoomInfo.js @@ -0,0 +1,374 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "BuildingInfo", + components: {}, + data() { + const checkStuNum = (rule, value, callback) => { + request.get("/stu/exist/" + value).then((res) => { + request.get("/room/judgeHadBed/" + value).then((result) => { + if (res.code === "0" && result.code === "0") { + callback(); + } else if (res.code === "-1" && result.code === "0") { + callback(new Error(res.msg)); + } else if (res.code === "0" && result.code === "-1") { + callback(new Error(result.msg)); + } else { + callback(new Error("请输入正确的数据")); + } + }); + }); + }; + return { + bedNum: 0, + havePeopleNum: 0, + loading: true, + disabled: false, + judge: false, + dialogVisible: false, + bedDialog: false, + stuInfoDialog: false, + bedName: "", + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + form: { + dormRoomId: "", + dormBuildId: "", + floorNum: "", + maxCapacity: "", + currentCapacity: "", + firstBed: "", + secondBed: "", + thirdBed: "", + fourthBed: "", + }, + rules: { + dormRoomId: [ + {required: true, message: "请输入房间号", trigger: "blur"}, + {pattern: /^[0-9]{4}$/, message: "范围:1000-9999", trigger: "blur"}, + ], + floorNum: [ + {required: true, message: "请输入楼层数", trigger: "blur"}, + {pattern: /^[1-3]$/, message: "范围:1-3", trigger: "blur"}, + ], + dormBuildId: [ + {required: true, message: "请输入楼宇号数", trigger: "blur"}, + {pattern: /^[1-4]$/, message: "范围:1-4", trigger: "blur"}, + ], + maxCapacity: [ + {required: true, message: "请输入房间可住人数", trigger: "blur"}, + {pattern: /^[0-4]$/, message: "范围:0-4", trigger: "blur"}, + ], + currentCapacity: [ + {required: true, message: "请输入当前已住人数", trigger: "blur"}, + {pattern: /^[0-4]$/, message: "范围:0-4", trigger: "blur"}, + ], + firstBed: [{validator: checkStuNum, trigger: "blur"}], + secondBed: [{validator: checkStuNum, trigger: "blur"}], + thirdBed: [{validator: checkStuNum, trigger: "blur"}], + fourthBed: [{validator: checkStuNum, trigger: "blur"}], + }, + }; + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/room/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/room/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.currentCapacity === value; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.$refs.form.validate(async (valid) => { + if (valid) { + if (this.judge === false) { + //新增 + request.post("/room/add", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.loading = true; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + request.put("/room/update", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + this.bedDialog = false; + this.stuInfoDialog = false; + }, + handleEdit(row) { + //修改 + this.judge = true; + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(row)); + this.disabled = true; + }); + }, + handleDelete(dormRoomId) { + //删除 + request.delete("/room/delete/" + dormRoomId).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + calCurrentNum(info) { + this.havePeopleNum = 0; + // 获取房间人数 + let roomPeopleNum = 0; + if (info.firstBed != null) { + roomPeopleNum++; + } + if (info.secondBed != null) { + roomPeopleNum++; + } + if (info.thirdBed != null) { + roomPeopleNum++; + } + if (info.fourthBed != null) { + roomPeopleNum++; + } + this.havePeopleNum = roomPeopleNum; + }, + plusIcon(num, info) { + //添加图标 + this.judge = false; + //显示对应床位input + this.bedNum = num; + //获取当前房间人数 + this.calCurrentNum(info); + this.bedDialog = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(info)); + }); + }, + editIcon(num, info) { + //修改图标 + this.judge = true; + //显示对应床位input + this.bedNum = num; + //修改床位所住的学生 + this.bedDialog = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(info)); + }); + }, + detailIcon(num, info) { + //查看床位所住的学生 + let stu = ""; + // 删除 + if (num === 1) { + stu = info.firstBed; + } else if (num === 2) { + stu = info.secondBed; + } else if (num === 3) { + stu = info.thirdBed; + } else if (num === 4) { + stu = info.fourthBed; + } + request.get("/stu/exist/" + stu).then((res) => { + if (res.code === "0") { + this.stuInfoDialog = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(res.data)); + }); + } + }); + }, + addStuBed() { + this.$refs.form.validate((valid) => { + if (valid) { + // 为床位添加学生 + this.form.currentCapacity = this.havePeopleNum + 1; + request.put("/room/update", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.loading = true; + this.load(); + this.bedDialog = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }); + }, + editStuBed() { + //修改 + this.$refs.form.validate((valid) => { + if (valid) { + request.put("/room/update", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.loading = true; + this.load(); + this.bedDialog = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }); + }, + async deleteStuBed(bedNum, info) { + let bedName = ""; + // 删除 + if (bedNum === 1) { + bedName = "first_bed"; + } else if (bedNum === 2) { + bedName = "second_bed"; + } else if (bedNum === 3) { + bedName = "third_bed"; + } else if (bedNum === 4) { + bedName = "fourth_bed"; + } + //更新当前房间人数 + this.calCurrentNum(info); + request.delete( + "/room/delete/" + + bedName + + "/" + + info.dormRoomId + + "/" + + this.havePeopleNum + ).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.loading = true; + this.load(); + this.bedDialog = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/SelfInfo.js b/src/assets/js/SelfInfo.js new file mode 100644 index 0000000..22acbae --- /dev/null +++ b/src/assets/js/SelfInfo.js @@ -0,0 +1,238 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); +export default { + name: "selfInfo", + data() { + // 手机号验证 + const checkPhone = (rule, value, callback) => { + const phoneReg = /^1[3|4|5|6|7|8][0-9]{9}$/; + if (!value) { + return callback(new Error("电话号码不能为空")); + } + setTimeout(() => { + if (!Number.isInteger(+value)) { + callback(new Error("请输入数字值")); + } else { + if (phoneReg.test(value)) { + callback(); + } else { + callback(new Error("电话号码格式不正确")); + } + } + }, 100); + }; + const checkPass = (rule, value, callback) => { + if (!this.editJudge) { + console.log("验证"); + if (value == "") { + callback(new Error("请再次输入密码")); + } else if (value !== this.form.password) { + callback(new Error("两次输入密码不一致!")); + } else { + callback(); + } + } else { + console.log("不验证"); + callback(); + } + }; + return { + showpassword: true, + image: "", + editJudge: true, + disabled: true, + dialogVisible: false, + identity: "", + username: "", + name: "", + gender: "", + age: "", + phoneNum: "", + email: "", + targetURL: "", + avatar: "", + form: { + username: "", + name: "", + gender: "", + age: "", + phoneNum: "", + email: "", + }, + rules: { + username: [ + {required: true, message: "请输入账号", trigger: "blur"}, + { + pattern: /^[a-zA-Z0-9]{4,9}$/, + message: "必须由 4 到 9 个字母或数字组成", + trigger: "blur", + }, + ], + name: [ + {required: true, message: "请输入姓名", trigger: "blur"}, + { + pattern: /^(?:[\u4E00-\u9FA5·]{2,10})$/, + message: "必须由 2 到 10 个汉字组成", + trigger: "blur", + }, + ], + gender: [{required: true, message: "请选择性别", trigger: "change"}], + age: [ + {required: true, message: "请输入年龄", trigger: "blur"}, + {type: "number", message: "年龄必须为数字值", trigger: "blur"}, + { + pattern: /^(1|[1-9]\d?|100)$/, + message: "范围:1-100", + trigger: "blur", + }, + ], + phoneNum: [{required: true, validator: checkPhone, trigger: "blur"}], + email: [ + {type: "email", message: "请输入正确的邮箱地址", trigger: "blur"}, + ], + password: [ + {required: true, message: "请输入密码", trigger: "blur"}, + { + min: 6, + max: 32, + message: "长度在 6 到 16 个字符", + trigger: "blur", + }, + ], + checkPass: [{validator: checkPass, trigger: "blur"}], + }, + display: { + display: "none", + }, + imgDisplay: { + display: "none", + }, + }; + }, + created() { + this.load(); + this.find(); + this.init(this.avatar); + }, + methods: { + //获取个人信息页面信息 + load() { + this.form = JSON.parse(sessionStorage.getItem("user")); + this.identity = JSON.parse(sessionStorage.getItem("identity")); + this.username = this.form.username; + this.name = this.form.name; + this.gender = this.form.gender; + this.age = this.form.age; + this.phoneNum = this.form.phoneNum; + this.email = this.form.email; + this.avatar = this.form.avatar; + }, + //查询数据,更新session + find() { + this.form = JSON.parse(sessionStorage.getItem("user")); + request.post("/" + this.identity + "/login", this.form).then((res) => { + //更新sessionStorage + window.sessionStorage.setItem("user", JSON.stringify(res.data)); + //更新页面数据 + this.load(); + }); + }, + Edit() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(sessionStorage.getItem("user")); + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.display = {display: "none"}; + this.showpassword = true; + this.editJudge = true; + this.disabled = true; + this.dialogVisible = false; + }, + async save() { + this.$refs.form.validate(async (valid) => { + if (valid) { + //修改 + await request.put("/" + this.identity + "/update", this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + //更新sessionStorage + window.sessionStorage.setItem( + "user", + JSON.stringify(this.form) + ); + this.find(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }); + }, + EditPass() { + if (this.editJudge) { + this.display = {display: "flex"}; + this.showpassword = false; + this.disabled = false; + this.editJudge = false; + } else { + this.display = {display: "none"}; + this.showpassword = true; + this.editJudge = true; + this.disabled = true; + } + }, + //发送请求,获取头像 + async init(data) { + if (data === null || data === "") { + console.log("用户未设置头像"); + this.imgDisplay = {display: "none"}; + } else { + this.imgDisplay = {display: "block"}; + console.log("头像名称:" + data); + await request.get("/files/initAvatar/" + data).then((res) => { + if (res.code === "0") { + this.image = res.data.data; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + }, + async uploadSuccess() { + this.form = JSON.parse(sessionStorage.getItem("user")); + await request.post("/files/uploadAvatar/" + this.identity, this.form).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "设置成功", + type: "success", + }); + //获取头像文件名 + this.avatar = res.data; + console.log("上传成功:" + this.avatar); + this.find(); + this.init(this.avatar); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/StuInfo.js b/src/assets/js/StuInfo.js new file mode 100644 index 0000000..cafea13 --- /dev/null +++ b/src/assets/js/StuInfo.js @@ -0,0 +1,273 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "StuInfo", + data() { + // 手机号验证 + const checkPhone = (rule, value, callback) => { + const phoneReg = /^1[3|4|5|6|7|8][0-9]{9}$/; + if (!value) { + return callback(new Error("电话号码不能为空")); + } + setTimeout(() => { + if (!Number.isInteger(+value)) { + callback(new Error("请输入数字值")); + } else { + if (phoneReg.test(value)) { + callback(); + } else { + callback(new Error("电话号码格式不正确")); + } + } + }, 100); + }; + const checkPass = (rule, value, callback) => { + if (!this.editJudge) { + if (value == "") { + callback(new Error("请再次输入密码")); + } else if (value !== this.form.password) { + callback(new Error("两次输入密码不一致!")); + } else { + callback(); + } + } else { + callback(); + } + }; + return { + showpassword: true, + judgeAddOrEdit: true, + loading: true, + editJudge: true, + disabled: false, + judge: false, + dialogVisible: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + form: { + username: "", + name: "", + age: "", + gender: "", + phoneNum: "", + email: "", + }, + rules: { + username: [ + {required: true, message: "请输入学号", trigger: "blur"}, + { + pattern: /^[a-zA-Z0-9]{4,9}$/, + message: "必须由 2 到 5 个字母或数字组成", + trigger: "blur", + }, + ], + name: [ + {required: true, message: "请输入姓名", trigger: "blur"}, + { + pattern: /^(?:[\u4E00-\u9FA5·]{2,10})$/, + message: "必须由 2 到 10 个汉字组成", + trigger: "blur", + }, + ], + age: [ + {required: true, message: "请输入年龄", trigger: "blur"}, + {type: "number", message: "年龄必须为数字值", trigger: "blur"}, + { + pattern: /^(1|[1-9]\d?|100)$/, + message: "范围:1-100", + trigger: "blur", + }, + ], + gender: [{required: true, message: "请选择性别", trigger: "change"}], + phoneNum: [{required: true, validator: checkPhone, trigger: "blur"}], + email: [ + {type: "email", message: "请输入正确的邮箱地址", trigger: "blur"}, + ], + password: [ + {required: true, message: "请输入密码", trigger: "blur"}, + { + min: 6, + max: 32, + message: "长度在 6 到 16 个字符", + trigger: "blur", + }, + ], + checkPass: [{validator: checkPass, trigger: "blur"}], + }, + editDisplay: { + display: "block", + }, + display: { + display: "none", + }, + }; + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/stu/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/stu/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.gender === value; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.judgeAddOrEdit = false; + this.editDisplay = {display: "none"}; + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.$refs.form.validate((valid) => { + if (valid) { + if (this.judge === false) { + //新增 + request.post("/stu/add", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.loading = true; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + request.put("/stu/update", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.display = {display: "none"}; + this.editJudge = true; + this.disabled = true; + this.showpassword = true; + this.dialogVisible = false; + }, + EditPass() { + if (this.editJudge) { + this.showpassword = false; + this.display = {display: "flex"}; + this.disabled = false; + this.editJudge = false; + } else { + this.showpassword = true; + this.display = {display: "none"}; + this.editJudge = true; + this.disabled = true; + } + }, + handleEdit(row) { + //修改 + //判断操作类型 + this.judge = true; + // 生拷贝 + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.form = JSON.parse(JSON.stringify(row)); + this.judgeAddOrEdit = true; + this.editDisplay = {display: "block"}; + this.disabled = true; + }); + }, + async handleDelete(username) { + //删除 + console.log(username); + request.delete("/stu/delete/" + username).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/js/VisitorInfo.js b/src/assets/js/VisitorInfo.js new file mode 100644 index 0000000..bd7836a --- /dev/null +++ b/src/assets/js/VisitorInfo.js @@ -0,0 +1,207 @@ +import request from "@/utils/request"; + +const {ElMessage} = require("element-plus"); + +export default { + name: "VisitorInfo", + components: {}, + data() { + // 手机号验证 + const checkPhone = (rule, value, callback) => { + const phoneReg = /^1[3|4|5|6|7|8][0-9]{9}$/; + if (!value) { + return callback(new Error("电话号码不能为空")); + } + setTimeout(() => { + if (!Number.isInteger(+value)) { + callback(new Error("请输入数字值")); + } else { + if (phoneReg.test(value)) { + callback(); + } else { + callback(new Error("电话号码格式不正确")); + } + } + }, 100); + }; + return { + loading: true, + disabled: false, + judge: false, + dialogVisible: false, + search: "", + currentPage: 1, + pageSize: 10, + total: 0, + tableData: [], + detail: {}, + form: {}, + rules: { + visitorName: [ + {required: true, message: "请输入姓名", trigger: "blur"}, + { + pattern: /^(?:[\u4E00-\u9FA5·]{2,10})$/, + message: "必须由 2 到 10 个汉字组成", + trigger: "blur", + }, + ], + gender: [{required: true, message: "请选择性别", trigger: "change"}], + phoneNum: [{required: true, validator: checkPhone, trigger: "blur"}], + visitTime: [ + {required: true, message: "请选择时间", trigger: "change"}, + ], + content: [ + {required: true, message: "请输入来访信息", trigger: "change"}, + ], + }, + }; + }, + created() { + this.load(); + this.loading = true; + setTimeout(() => { + //设置延迟执行 + this.loading = false; + }, 1000); + }, + methods: { + async load() { + request.get("/visitor/find", { + params: { + pageNum: this.currentPage, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + reset() { + this.search = '' + request.get("/visitor/find", { + params: { + pageNum: 1, + pageSize: this.pageSize, + search: this.search, + }, + }).then((res) => { + console.log(res); + this.tableData = res.data.records; + this.total = res.data.total; + this.loading = false; + }); + }, + filterTag(value, row) { + return row.gender === value; + }, + showDetail(row) { + this.detailDialog = true; + this.$nextTick(() => { + this.detail = row; + }); + }, + closeDetailDialog() { + this.detailDialog = false; + }, + add() { + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + this.disabled = false; + this.form = {}; + this.judge = false; + }); + }, + save() { + this.$refs.form.validate(async (valid) => { + if (valid) { + if (this.judge === false) { + //新增 + await request.post("/visitor/add", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "新增成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } else { + //修改 + await request.put("/visitor/update", this.form).then((res) => { + console.log(res); + if (res.code === "0") { + ElMessage({ + message: "修改成功", + type: "success", + }); + this.search = ""; + this.load(); + this.dialogVisible = false; + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + } + } + }); + }, + cancel() { + this.$refs.form.resetFields(); + this.dialogVisible = false; + }, + handleEdit(row) { + //修改 + this.judge = true; + this.dialogVisible = true; + this.$nextTick(() => { + this.$refs.form.resetFields(); + // 生拷贝 + this.form = JSON.parse(JSON.stringify(row)); + this.disabled = true; + }); + }, + async handleDelete(id) { + console.log(id); + request.delete("/visitor/delete/" + id).then((res) => { + if (res.code === "0") { + ElMessage({ + message: "删除成功", + type: "success", + }); + this.search = ""; + this.load(); + } else { + ElMessage({ + message: res.msg, + type: "error", + }); + } + }); + }, + handleSizeChange(pageSize) { + //改变每页个数 + this.pageSize = pageSize; + this.load(); + }, + handleCurrentChange(pageNum) { + //改变页码 + this.currentPage = pageNum; + this.load(); + }, + }, +}; \ No newline at end of file diff --git a/src/assets/login_bg_phone.png b/src/assets/login_bg_phone.png new file mode 100644 index 0000000..addf1f2 Binary files /dev/null and b/src/assets/login_bg_phone.png differ diff --git a/src/assets/login_two.jpg b/src/assets/login_two.jpg new file mode 100644 index 0000000..221a99a Binary files /dev/null and b/src/assets/login_two.jpg differ diff --git a/src/assets/logo.png b/src/assets/logo.png new file mode 100644 index 0000000..2a0b264 Binary files /dev/null and b/src/assets/logo.png differ diff --git a/src/assets/sleep.png b/src/assets/sleep.png new file mode 100644 index 0000000..d2b9a17 Binary files /dev/null and b/src/assets/sleep.png differ diff --git a/src/assets/wake.png b/src/assets/wake.png new file mode 100644 index 0000000..ae7476e Binary files /dev/null and b/src/assets/wake.png differ diff --git a/src/components/Aside.vue b/src/components/Aside.vue new file mode 100644 index 0000000..e849a3a --- /dev/null +++ b/src/components/Aside.vue @@ -0,0 +1,161 @@ + + + + + \ No newline at end of file diff --git a/src/components/Calendar.vue b/src/components/Calendar.vue new file mode 100644 index 0000000..3773dda --- /dev/null +++ b/src/components/Calendar.vue @@ -0,0 +1,563 @@ + + + + + diff --git a/src/components/Clock.vue b/src/components/Clock.vue new file mode 100644 index 0000000..1e6ad6b --- /dev/null +++ b/src/components/Clock.vue @@ -0,0 +1,43 @@ + + + \ No newline at end of file diff --git a/src/components/Header.vue b/src/components/Header.vue new file mode 100644 index 0000000..3a1a4aa --- /dev/null +++ b/src/components/Header.vue @@ -0,0 +1,72 @@ + + + + + \ No newline at end of file diff --git a/src/components/home_echarts.vue b/src/components/home_echarts.vue new file mode 100644 index 0000000..94df127 --- /dev/null +++ b/src/components/home_echarts.vue @@ -0,0 +1,96 @@ + + + + + \ No newline at end of file diff --git a/src/components/weather.vue b/src/components/weather.vue new file mode 100644 index 0000000..616504b --- /dev/null +++ b/src/components/weather.vue @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/layout/Layout.vue b/src/layout/Layout.vue new file mode 100644 index 0000000..e57e6ad --- /dev/null +++ b/src/layout/Layout.vue @@ -0,0 +1,37 @@ + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..d2676f0 --- /dev/null +++ b/src/main.js @@ -0,0 +1,22 @@ +import {createApp} from 'vue' +import router from './router' +import store from './store' +import './assets/css/global.css' +import App from './App.vue' +// element-plus +import ElementPlus from 'element-plus' +import 'element-plus/dist/index.css' +import * as ELIcons from '@element-plus/icons-vue' +import zhCn from 'element-plus/es/locale/lang/zh-cn' + +const app = createApp(App) + .use(ElementPlus, { + locale: zhCn + }) +for (let iconName in ELIcons) { + app.component(iconName, ELIcons[iconName]) +} +app.use(router) +app.use(store) +app.mount('#app') + diff --git a/src/router/index.js b/src/router/index.js new file mode 100644 index 0000000..858a373 --- /dev/null +++ b/src/router/index.js @@ -0,0 +1,53 @@ +import Layout from '../layout/Layout.vue' +import {createRouter, createWebHistory} from "vue-router"; + + +export const constantRoutes = [ + {path: '/Login', name: 'Login', component: () => import("@/views/Login")}, + { + path: '/Layout', name: 'Layout', component: Layout, children: [ + // + {path: '/home', name: 'Home', component: () => import("@/views/Home")}, + {path: '/stuInfo', name: 'StuInfo', component: () => import("@/views/StuInfo")}, + {path: '/dormManagerInfo', name: 'DormManagerInfo', component: () => import("@/views/DormManagerInfo")}, + {path: '/buildingInfo', name: 'BuildingInfo', component: () => import("@/views/BuildingInfo")}, + {path: '/roomInfo', name: 'RoomInfo', component: () => import("@/views/RoomInfo")}, + {path: '/noticeInfo', name: 'NoticeInfo', component: () => import("@/views/NoticeInfo")}, + {path: '/adjustRoomInfo', name: 'AdjustRoomInfo', component: () => import("@/views/AdjustRoomInfo")}, + {path: '/repairInfo', name: 'RepairInfo', component: () => import("@/views/RepairInfo")}, + {path: '/visitorInfo', name: 'VisitorInfo', component: () => import("@/views/VisitorInfo")}, + // + {path: '/myRoomInfo', name: 'MyRoomInfo', component: () => import("@/views/MyRoomInfo")}, + {path: '/applyRepairInfo', name: 'ApplyRepairInfo', component: () => import("@/views/ApplyRepairInfo")}, + {path: '/applyChangeRoom', name: 'ApplyChangeRoom', component: () => import("@/views/ApplyChangeRoom")}, + + {path: '/selfInfo', name: 'SelfInfo', component: () => import("@/views/SelfInfo")}, + ] + }, + +] +const router = createRouter({ + routes: constantRoutes, + history: createWebHistory(process.env.BASE_URL) +}) +//路由守卫 +router.beforeEach((to, from, next) => { + //to 要访问的路径 + //from 代表从哪个路径跳转而来 + // next 是函数,表示放行 + // next() 放行 + // next('/*') 强制跳转 + const user = window.sessionStorage.getItem('user') + if (to.path === '/Login') { + return next(); + } + if (!user) { + return next('/Login') + } + if (to.path === '/' && user) { + return next('/home') + } + next() +}) + +export default router diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..eccff49 --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,15 @@ +import {createStore} from 'vuex' + +export default createStore({ + state: { + isLogin: false, + identity: '' + }, + mutations: { + login(state) { + state.isLogin = true + } + }, + actions: {}, + modules: {} +}) diff --git a/src/utils/request.js b/src/utils/request.js new file mode 100644 index 0000000..d64625b --- /dev/null +++ b/src/utils/request.js @@ -0,0 +1,50 @@ +import axios from 'axios' + +const request = axios.create({ + baseURL: '/api', // 注意!! 这里是全局统一加上了 '/api' 前缀,也就是说所有接口都会加上'/api'前缀在,页面里面写接口的时候就不要加 '/api'了,否则会出现2个'/api',类似 '/api/api/user'这样的报错,切记!!! + timeout: 5000 +}) +let token = ''; +// request 拦截器 +// 可以自请求发送前对请求做一些处理 +// 比如统一加token,对请求参数统一加密 +//添加一个请求拦截器 +axios.interceptors.request.use(function (config) { + let user = JSON.parse(window.sessionStorage.getItem('access-user')); + if (user) { + token = user.token; + } + config.headers.common['token'] = token; + //console.dir(config); + return config; +}, function (error) { + // Do something with request error + console.info("error: "); + console.info(error); + return Promise.reject(error); +}); + +// response 拦截器 +// 可以在接口响应后统一处理结果 +request.interceptors.response.use( + response => { + let res = response.data; + // 如果是返回的文件 + if (response.config.responseType === 'blob') { + return res + } + // 兼容服务端返回的字符串数据 + if (typeof res === 'string') { + res = res ? JSON.parse(res) : res + } + return res; + }, + error => { + console.log('err' + error) // for debug + return Promise.reject(error) + } +) + +// 以request暴露出去 +export default request + diff --git a/src/views/AdjustRoomInfo.vue b/src/views/AdjustRoomInfo.vue new file mode 100644 index 0000000..177fcb0 --- /dev/null +++ b/src/views/AdjustRoomInfo.vue @@ -0,0 +1,188 @@ + + \ No newline at end of file diff --git a/src/views/ApplyChangeRoom.vue b/src/views/ApplyChangeRoom.vue new file mode 100644 index 0000000..49cca46 --- /dev/null +++ b/src/views/ApplyChangeRoom.vue @@ -0,0 +1,172 @@ + + \ No newline at end of file diff --git a/src/views/ApplyRepairInfo.vue b/src/views/ApplyRepairInfo.vue new file mode 100644 index 0000000..bc6e46a --- /dev/null +++ b/src/views/ApplyRepairInfo.vue @@ -0,0 +1,128 @@ + + \ No newline at end of file diff --git a/src/views/BuildingInfo.vue b/src/views/BuildingInfo.vue new file mode 100644 index 0000000..694418d --- /dev/null +++ b/src/views/BuildingInfo.vue @@ -0,0 +1,98 @@ + + \ No newline at end of file diff --git a/src/views/DormManagerInfo.vue b/src/views/DormManagerInfo.vue new file mode 100644 index 0000000..655b8f6 --- /dev/null +++ b/src/views/DormManagerInfo.vue @@ -0,0 +1,120 @@ + + \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue new file mode 100644 index 0000000..a775d2c --- /dev/null +++ b/src/views/Home.vue @@ -0,0 +1,202 @@ + + + + \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue new file mode 100644 index 0000000..639e662 --- /dev/null +++ b/src/views/Login.vue @@ -0,0 +1,313 @@ + + + + \ No newline at end of file diff --git a/src/views/Login2.vue b/src/views/Login2.vue new file mode 100644 index 0000000..196651b --- /dev/null +++ b/src/views/Login2.vue @@ -0,0 +1,245 @@ + + + + + \ No newline at end of file diff --git a/src/views/MyRoomInfo.vue b/src/views/MyRoomInfo.vue new file mode 100644 index 0000000..7669288 --- /dev/null +++ b/src/views/MyRoomInfo.vue @@ -0,0 +1,148 @@ + + + \ No newline at end of file diff --git a/src/views/NoticeInfo.vue b/src/views/NoticeInfo.vue new file mode 100644 index 0000000..e1e4791 --- /dev/null +++ b/src/views/NoticeInfo.vue @@ -0,0 +1,99 @@ + + \ No newline at end of file diff --git a/src/views/RepairInfo.vue b/src/views/RepairInfo.vue new file mode 100644 index 0000000..7cafed4 --- /dev/null +++ b/src/views/RepairInfo.vue @@ -0,0 +1,155 @@ + + \ No newline at end of file diff --git a/src/views/RoomInfo.vue b/src/views/RoomInfo.vue new file mode 100644 index 0000000..7c05d84 --- /dev/null +++ b/src/views/RoomInfo.vue @@ -0,0 +1,287 @@ + + + \ No newline at end of file diff --git a/src/views/SelfInfo.vue b/src/views/SelfInfo.vue new file mode 100644 index 0000000..4eb4ae8 --- /dev/null +++ b/src/views/SelfInfo.vue @@ -0,0 +1,186 @@ + + + \ No newline at end of file diff --git a/src/views/StuInfo.vue b/src/views/StuInfo.vue new file mode 100644 index 0000000..ea804c0 --- /dev/null +++ b/src/views/StuInfo.vue @@ -0,0 +1,120 @@ + + \ No newline at end of file diff --git a/src/views/StudentHome.vue b/src/views/StudentHome.vue new file mode 100644 index 0000000..ec5fa14 --- /dev/null +++ b/src/views/StudentHome.vue @@ -0,0 +1,295 @@ + + + + \ No newline at end of file diff --git a/src/views/VisitorInfo.vue b/src/views/VisitorInfo.vue new file mode 100644 index 0000000..5681c0d --- /dev/null +++ b/src/views/VisitorInfo.vue @@ -0,0 +1,117 @@ + + \ No newline at end of file diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..ea30b8c --- /dev/null +++ b/vue.config.js @@ -0,0 +1,19 @@ +// 跨域配置 +module.exports = { + + publicPath: './',// vue-cli3.3+新版本使用 + + devServer: { //记住,别写错了devServer//设置本地默认端口 选填 + // port: 9876, + proxy: { //设置代理,必须填 + '/api': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定 + target: 'http://localhost:8083', //代理的目标地址 + changeOrigin: true, //是否设置同源,输入是的 + pathRewrite: { //路径重写 + '^/api': '' //选择忽略拦截器里面的内容 + } + } + } + } +} +