1.0最初版本

This commit is contained in:
zrh050423 2024-12-06 00:15:24 +08:00
commit fec022d549
22 changed files with 3707 additions and 0 deletions

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

3180
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

25
package.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "healthsystemvue",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"axios": "^1.7.8",
"element-plus": "^2.9.0",
"pinia": "^2.2.7",
"pinia-plugin-persistedstate": "^4.1.3",
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"vuex": "^4.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"vite": "^6.0.1"
}
}

1
public/vite.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

13
src/App.vue Normal file
View File

@ -0,0 +1,13 @@
<script setup>
</script>
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<style scoped>
</style>

11
src/api/request.js Normal file
View File

@ -0,0 +1,11 @@
import axios from "axios";
const axiosInstance = axios.create({
baseURL: 'http://localhost:8080',
timeout: 5000,
});
axiosInstance.interceptors.response.use(response => {
console.log(response);
const { status, data } = response;
})
export default axiosInstance;

BIN
src/assets/background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

1
src/assets/vue.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

15
src/main.js Normal file
View File

@ -0,0 +1,15 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import store from "./store/index.js"
import axios from "axios"
import 'element-plus/dist/index.css'
const app = createApp(App)
app.config.globalProperties.$axios = axios
app.use(ElementPlus)//将 ElementPlus 插件注册到 Vue 应用中//将Pinia实例注册到Vue应用中
app.use(router)//将Vue Router实例注册到Vue应用中
app.use(store)
app.mount('#app')

47
src/router/index.js Normal file
View File

@ -0,0 +1,47 @@
import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Home from '../views/Home.vue';
import BasicInfo from '../views/BasicInfo.vue';
import HealthBehaviorInfo from '../views/HealthBehaviorInfo.vue';
import RegularCheckupInfo from "../views/RegularCheckupInfo.vue";
import Main from "../views/Main.vue";
const routes = [
{
path: '/',
name: 'Login',
component: Login
},
{
path: '/home',
name: 'Home',
component: Home,
children: [
{
path: '',
name: 'Main',
component: Main
},
{
path: 'basic-info',
name: 'BasicInfo',
component: BasicInfo
},
{
path: 'regular-checkup-info',
name: 'RegularCheckupInfo',
component: RegularCheckupInfo
},
{
path: 'health-behavior-info',
name: 'HealthBehaviorInfo',
component: HealthBehaviorInfo
}
]
}
];
const router = createRouter({
history: createWebHistory(),
routes
});
export default router;

44
src/store/index.js Normal file
View File

@ -0,0 +1,44 @@
// src/store/index.js
import { createStore } from 'vuex';
export default createStore({
state() {
return {
// 初始化状态
user: {
isLoggedIn: false,
// 其他用户信息
},
// 其他状态
};
},
mutations: {
// 定义改变状态的函数
SET_LOGGED_IN(state, status) {
state.user.isLoggedIn = status;
},
// 其他 mutations
},
actions: {
// 定义提交 mutations 的函数
login({ commit }) {
// 执行登录逻辑
// 假设登录成功后
commit('SET_LOGGED_IN', true);
},
logout({ commit }) {
// 执行登出逻辑
commit('SET_LOGGED_IN', false);
},
// 其他 actions
},
getters: {
// 定义获取状态的函数
isLoggedIn: state => state.user.isLoggedIn,
// 其他 getters
},
modules: {
// 如果需要,可以定义模块
}
});

0
src/style.css Normal file
View File

91
src/views/BasicInfo.vue Normal file
View File

@ -0,0 +1,91 @@
<template>
<el-main>
基本信息表
<el-button type="primary" @click="fetchElderlyData">添加</el-button>
<div v-if="loading">Loading...</div>
<div v-else-if="error">{{ error }}</div>
<el-table v-else :data="elderlyData" style="width: 100%" height="450" >
<el-table-column prop="elderlyId" label="Elderly ID"></el-table-column>
<el-table-column prop="fullName" label="Full Name"></el-table-column>
<el-table-column prop="gender" label="Gender"></el-table-column>
<el-table-column
prop="dateOfBirth"
label="Date of Birth"
:formatter="formatDate"
></el-table-column>
<el-table-column prop="ethnicity" label="Ethnicity"></el-table-column>
<el-table-column prop="nativePlace" label="Native Place"></el-table-column>
<el-table-column prop="idNumber" label="ID Number"></el-table-column>
<el-table-column prop="permanentAddress" label="Permanent Address"></el-table-column>
<el-table-column prop="occupation" label="Occupation"></el-table-column>
<el-table-column prop="educationLevel" label="Education Level"></el-table-column>
<el-table-column prop="livingAlone" label="Living Alone"></el-table-column>
<el-table-column prop="maritalStatus" label="Marital Status"></el-table-column>
<el-table-column prop="phoneNumber" label="Phone Number"></el-table-column>
<el-table-column prop="contactName" label="Contact Name"></el-table-column>
<el-table-column prop="contactRelation" label="Contact Relation"></el-table-column>
<el-table-column prop="contactPhone" label="Contact Phone"></el-table-column>
<el-table-column prop="eatingHabits" label="Eating Habits"></el-table-column>
<el-table-column prop="exerciseFrequency" label="Exercise Frequency"></el-table-column>
<el-table-column fixed="right" label="Operations" min-width="120">
<template #default>
<el-button link type="primary" size="small" @click="handleClick">
查看
</el-button>
<el-button link type="primary" size="small">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-main>
</template>
<script setup lang="ts">
import { onMounted, ref } from "vue";
import axios from "axios";
import { ElTable, ElTableColumn } from 'element-plus';
const elderlyData = ref([]);
const loading = ref(false);
const error = ref(null);
const fetchElderlyData = async () => {
loading.value = true;
error.value = null;
try {
const response = await axios.get('http://10.10.10.44:8080/elderly/main');
if (response.data && response.data.data) {
elderlyData.value = response.data.data;
} else {
console.error('Unexpected response structure:', response.data);
error.value = 'Unexpected response structure';
}
} catch (error) {
console.error('Error fetching elderly data:', error);
error.value = 'Error fetching data';
} finally {
loading.value = false;
}
};
const formatDate = (row: any, column: any, cellValue: string) => {
return new Date(cellValue).toLocaleDateString();
};
onMounted(fetchElderlyData);
defineExpose({
elderlyData,
loading,
fetchElderlyData
});
const handleClick = () => {
console.log('click')
}
</script>
<style scoped>
/* 你可以在这里添加一些Element UI的样式覆盖 */
</style>

View File

@ -0,0 +1,12 @@
<template>
<div>
<h1>Page One</h1>
</div>
</template>
<script setup>
</script>
<style scoped>
</style>

115
src/views/Home.vue Normal file
View File

@ -0,0 +1,115 @@
<template>
<el-container>
<el-header>
<el-text>管理系统</el-text>
</el-header>
<el-container>
<el-aside width="isCollapse ? '64px' : '200px'">
<el-menu
default-active="2"
class="el-menu-vertical-demo"
:collapse="isCollapse"
router
>
<el-menu-item index="/home">
<el-icon><location /></el-icon>
<template #title>
<span>进入系统主页</span>
</template>
</el-menu-item>
<el-sub-menu index="2">
<template #title>
<el-icon><icon-menu /></el-icon>
<span>管理老人信息</span>
</template>
<el-menu-item-group>
<el-menu-item index="/home/basic-info">
<span>基本信息表</span>
</el-menu-item>
<el-menu-item index="/home/regular-checkup-info">
<span>定期体检表</span>
</el-menu-item>
<el-menu-item index="/home/health-history-info">
<span>行为档案表</span>
</el-menu-item>
</el-menu-item-group>
<el-sub-menu index="2-4">
<template #title>
<span>管理疾病表</span>
</template>
<el-menu-item index="2-4-1" disabled>既往史档案</el-menu-item>
<el-menu-item index="2-4-2" disabled>心理健康表</el-menu-item>
</el-sub-menu>
<el-sub-menu index="2-5">
<template #title>
<span>管理日程安排</span>
</template>
<el-menu-item index="2-5-1" disabled>打卡记录</el-menu-item>
<el-menu-item index="2-5-2" disabled>定时任务</el-menu-item>
</el-sub-menu>
</el-sub-menu>
<el-menu-item index="3" disabled>
<el-icon><document /></el-icon>
<template #title>查看对话记录</template>
</el-menu-item>
<el-menu-item index="4" disabled>
<el-icon><setting /></el-icon>
<template #title>推荐方案生成</template>
</el-menu-item>
<el-menu-item class="toggle-button" @click="toggleCollapse">
<el-icon v-if="isCollapse"><ArrowRight /></el-icon>
<el-icon v-else><ArrowLeft /></el-icon>
</el-menu-item>
</el-menu>
</el-aside>
<el-main class="main">
<router-view></router-view>
</el-main>
</el-container>
</el-container>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import {
Document,
Menu as IconMenu,
Location,
Setting, ArrowLeft, ArrowRight,
} from '@element-plus/icons-vue'
const isCollapse = ref(true)
const toggleCollapse = () => {
isCollapse.value = !isCollapse.value
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
width: 200px;
min-height: 400px;
}
</style>

60
src/views/Login.vue Normal file
View File

@ -0,0 +1,60 @@
<template>
<div>
<h1>Login</h1>
<form class="more-padding" autocomplete="off" @submit.prevent="login">
<input type="text" placeholder="username" id="userName" v-model="userName">
<input type="password" placeholder="password" id="userPassword" v-model="userPassword">
<div class="checkbox">
<input type="checkbox" id="remember" /><label for="remember">记住密码</label>
</div>
<button type="submit">登录</button>
<p v-if="message">{{ message }}</p>
</form>
</div>
</template>
<script>
import axios from 'axios';
import { useStore } from 'vuex';
export default {
data() {
return {
userName: '',
userPassword: '',
message: ''
};
},setup() {
const store = useStore();
return { store };
},
methods: {
login() {
axios.post('http://10.10.10.44:8080/login', {
userName: this.userName,
userPassword: this.userPassword
})
.then(response => {
if (response.data.status === 'success') {
this.message =response.data.data.message;
if (response.data.data.userId>0) {
this.store.commit('SET_LOGGED_IN', true);
this.$router.push({name: 'Home'});
}
}
else {
console.log('登录失败');
}
})
.catch(error => {
console.error('登录失败', error);
this.message = '登录失败';
});
}
}
};
</script>
<style scoped>
</style>

25
src/views/Main.vue Normal file
View File

@ -0,0 +1,25 @@
<template>
<div class="centered-h1">
<h1>欢迎来到健康养老管理系统</h1>
</div>
</template>
<script setup lang="ts">
</script>
<style scoped>
.centered-h1 {
display: flex; /* 使用Flexbox布局 */
justify-content: center; /* 水平居中 */
align-items: center;
height: 100%/* 垂直居中 */
}
.centered-h1 h1 {
font-size: 2.5em; /* 设置字体大小为最大 */
margin: 0; /* 移除默认的margin */
}
</style>

View File

@ -0,0 +1,15 @@
<template>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>

7
vite.config.js Normal file
View File

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
})