From 0f5cc526149da750f09e623724f0755cc349d63f Mon Sep 17 00:00:00 2001 From: bicey Date: Mon, 10 Jun 2024 12:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E5=B0=BE=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 +++++++++++++++++--- src/pages/data.vue | 12 +++++++----- src/utils/common.js | 40 +++++++++++++++++++++++----------------- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index a27098f..b6ad648 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# zoo-frontend +# zoo-frontend(大报告要求) 本次建设的动物信息分为以下功能: @@ -26,11 +26,25 @@ - ElementUI - axios -# 说明 +# 说明(给使用者看的) + +## 功能说明 + 首页统计面板没有对接后端,无法操作,只做观赏作用 + 其余界面均实现基本的增删改查,健康监测等复杂的功能没有实现 -# 需要后端提供的数据 +## 使用说明 + +前端方面:下载zip或通过git拉取文件运行 + +后端方面:同上,但是application.yml中的username和password需要改成你自己数据库的用户名和密码,一般只需要改密码就行,还有其他项目配置如jdk,maven需要你自己配置 + +数据库方面:先创建一个数据库(无需建表),数据库名字为zoo,然后运行sql文件导入表和数据 + +前端需要搞好数据库和运行后端程序,才能正常运行使用 + +# 需要后端提供的数据(给后端开发看的) 一切以最终实现的接口为准,你需要前端提供什么数据就什么数据 diff --git a/src/pages/data.vue b/src/pages/data.vue index 148486b..1c65eae 100644 --- a/src/pages/data.vue +++ b/src/pages/data.vue @@ -52,11 +52,13 @@ export default { diff --git a/src/utils/common.js b/src/utils/common.js index ec55318..d0ffd79 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -10,7 +10,7 @@ export function generateUsers() { for (let i = 0; i < n; i++) { const a = generateAuth() let user = { - id: i+2, + id: i + 2, username: 'user' + (i + 2), password: '123456', auth: a, @@ -48,7 +48,7 @@ export function generateAnimals() { const n = Math.floor(Math.random() * 20) + 40; for (let i = 0; i < n; i++) { let animal = { - id: i+3, + id: i + 3, name: 'animal' + (i + 1), sex: Math.floor(Math.random() * 2) === 0 ? '雌性' : '雄性', species: '种类' + Math.ceil(Math.random() * 20).toString(),//种类 @@ -176,11 +176,11 @@ function generatePhase() { } //生成档案 -export function generateArchives() { +export async function generateArchives() { const archives = [] - let aid=0 - store.state.animals.forEach(e => { + let aid = 0 + for (const e of store.state.animals) { //分为四个周期的档案 for (let i = 0; i < 4; i++) { let n; @@ -220,7 +220,7 @@ export function generateArchives() { animalName: archive.animalName,//字符 记录的动物名称 state: archive.state,//int 动物状态 0正常,1异常 temperature: Number((35 + Math.random() * 7).toFixed(1)),//double 体温 - breathRate: Math.floor(Math.random() * 90) + 10 ,//int 呼吸频率 + breathRate: Math.floor(Math.random() * 90) + 10,//int 呼吸频率 heartRate: Math.floor(Math.random() * 130) + 10,//int 心跳频率 bloodPressure: Math.floor(Math.random() * 110) + 70,//int // 血压 date: archive.date,//字符 记录日期 @@ -228,29 +228,35 @@ export function generateArchives() { description: 'test health' + i + '' + j + ' description',//字符 检测的描述,比如动物的症状 } //异常的记录要修改一下监测数据 - if (health.state===1){ - health.temperature += Math.random()*2>1? - Number((Math.random()*health.temperature*0.5).toFixed(1)): - -Number((Math.random()*health.temperature*0.5).toFixed(1)) + if (health.state === 1) { + health.temperature += Math.random() * 2 > 1 ? + Number((Math.random() * health.temperature * 0.5).toFixed(1)) : + -Number((Math.random() * health.temperature * 0.5).toFixed(1)) health.temperature = Number(health.temperature.toFixed(1)) - health.breathRate += Math.random()*2>1? - Math.floor(Math.random()*health.breathRate*0.5):-Math.floor(Math.random()*health.breathRate*0.5) - health.heartRate += health.heartRate += Math.random()*2>1? - Math.floor(Math.random()*health.heartRate*0.5):-Math.floor(Math.random()*health.heartRate*0.5) - health.bloodPressure += health.bloodPressure += Math.random()*2>1? - Math.floor(Math.random()*health.bloodPressure*0.5):-Math.floor(Math.random()*health.bloodPressure*0.5) + health.breathRate += Math.random() * 2 > 1 ? + Math.floor(Math.random() * health.breathRate * 0.5) : -Math.floor(Math.random() * health.breathRate * 0.5) + health.heartRate += health.heartRate += Math.random() * 2 > 1 ? + Math.floor(Math.random() * health.heartRate * 0.5) : -Math.floor(Math.random() * health.heartRate * 0.5) + health.bloodPressure += health.bloodPressure += Math.random() * 2 > 1 ? + Math.floor(Math.random() * health.bloodPressure * 0.5) : -Math.floor(Math.random() * health.bloodPressure * 0.5) } request.addHealthRequest(health) healths.push(health) aid++ + await sleep(50) } } - }) + } console.log('档案', archives) return archives } +function sleep(time){ + return new Promise((resolve) => setTimeout(resolve, time)); +} + + const healths = [] export function generateHealths() {