Compare commits

..

No commits in common. "fdcb6479e7d1be91579b9d6181a26984dfd8169c" and "7e2ae9e56555d8b2a6b5a209a955f22aed9f736b" have entirely different histories.

28 changed files with 860 additions and 2287 deletions

View File

@ -1 +0,0 @@
VITE_BASE_URL='http://localhost:8888'

View File

@ -1 +0,0 @@
VITE_BASE_URL='http://zoo-backend:12321'

173
README.md
View File

@ -1,40 +1,23 @@
# 动物信息管理系统说明
## 简介
本人负责动物信息管理系统的前端部分,该项目为大作业所作,由于不擅长前端,所以很烂
加载数据很卡,没做优化,卡住的话耐心等待几秒吧
## 账户密码都是123456
管理员账户admin
饲养员账户user2
兽医账户user4
# zoo-frontend大报告要求
# zoo-frontend
本次建设的动物信息分为以下功能:
1. 数据录入与管理(前端基本完成,接入后端)
1. 数据录入与管理(前端基本完成,未接入后端)
系统应提供数据录入功能,允许用户输入动物的基本信息,如种类、年龄、性别、体重、健康状况等。同时,系统应具备数据管理功能,包括数据的查询、修改、删除等操作,以便用户能够方便地管理和维护动物信息。
2. 动物档案管理(前端基本完成,接入后端)
2. 动物档案管理(前端基本完成,未接入后端)
系统应建立动物档案,记录动物的整个生命周期,包括出生日期、疫苗接种记录、疾病治疗记录、饲养记录等。这有助于跟踪动物的健康状况和饲养情况,为动物提供更好的管理和照顾。
3. 饲养管理(前端基本完成,接入后端)
3. 饲养管理(前端基本完成,未接入后端)
系统应提供饲养管理功能,包括饲养计划的制定、饲养任务的分配、饲养记录的管理等。这有助于确保动物获得适当的饲料和营养,保持健康生长。
4. 健康监测与预警(前端基本完成,接入后端)
4. 健康监测与预警(前端基本完成,未接入后端)
系统应具备健康监测功能,定期收集和分析动物的健康数据,如体温、心率、呼吸频率等。同时,系统应提供预警功能,当动物的健康数据出现异常时,及时提醒管理人员采取相应措施。
5. 统计分析(前端基本完成,无需后端
5. 统计分析(未开始)
系统应提供统计分析功能,对动物信息、饲养记录、健康数据等进行统计分析,生成各类报表和图表。这有助于管理人员了解动物的整体状况和饲养效果,为决策提供支持。
6. 用户权限管理(前端基本完成,接入后端)
6. 用户权限管理(前端基本完成,接入后端)
系统应建立用户权限管理机制,对不同用户设置不同的权限,如管理员、饲养员、兽医等。这有助于确保系统的安全性和数据的保密性。
使用的技术/资源:
@ -43,25 +26,7 @@
- ElementUI
- axios
# 说明(给使用者看的)
## 功能说明
首页统计面板没有对接后端,无法操作,只做观赏作用
其余界面均实现基本的增删改查,健康监测等复杂的功能没有实现
## 使用说明
前端方面下载zip或通过git拉取文件运行
后端方面同上但是application.yml中的username和password需要改成你自己数据库的用户名和密码一般只需要改密码就行还有其他项目配置如jdkmaven需要你自己配置
数据库方面先创建一个数据库无需建表数据库名字为zoo然后运行sql文件导入表和数据
前端需要搞好数据库和运行后端程序,才能正常运行使用
# 需要后端提供的数据(给后端开发看的)
# 需要后端提供的数据
一切以最终实现的接口为准,你需要前端提供什么数据就什么数据
@ -258,4 +223,124 @@ health: {
## 统计分析
---
无需后端
## 需求分析
一、引言
动物园信息管理系统旨在为动物园内部人员(如系统管理员、饲养员、兽医等)提供一个便捷、高效的管理工具,以记录动物数据、提高管理效率、保障动物健康和福利。通过该系统,可以实时监控动物的各项体征数据,判断动物是否健康,并根据数据优化动物的生活环境,确保动物处于相对健康的状态。
二、系统用户
1. 系统管理员
- 用户与权限管理:负责创建、修改和删除用户账户,分配不同角色的权限,确保系统数据的安全性和完整性。(用户管理,重要)
- 系统设置与维护:进行系统参数配置,如数据备份策略、系统日志管理等,确保系统的稳定运行。(不重要)
- 数据监控与报告:实时监控动物数据异常情况,生成各类统计报告,为动物园管理层提供决策支持。(统计分析,一般)
3. 饲养员
- 动物日常饲养记录:录入动物的饮食、行为、活动等日常饲养信息,确保数据的准确性和完整性。(饲养管理,重要)
- 饲养计划制定与执行:根据动物种类、年龄、健康状况等因素,制定合理的饲养计划,并监控计划的执行情况。(饲养管理,一般)
- 食物库存管理:预估食物库存情况,及时补充库存,避免食物短缺或浪费。(不重要)
- 报警系统响应:接收系统发出的异常报警,及时处理异常情况,保障动物健康与安全。(不重要)
5. 兽医
- 动物体检数据录入与分析:录入动物的体重、体温、心跳等体征数据,进行健康评估,并生成诊断报告。(动物档案、健康检测,重要)
- 疾病治疗与记录:制定治疗方案,记录治疗过程及效果,为动物健康提供有力保障。(动物档案,重要)
- 报警系统响应:根据系统发出的异常报警,及时对患病动物进行诊断和治疗。(不重要)
三、功能需求
1. 数据管理(重要)
- 信息录入:动物基本信息的录入和管理,包括种类、年龄、性别、体重、健康状况等。(重要)
- 动物日常记录:饲养员可以记录动物的饮食、行为、活动等情况。
- 动物体检数据录入:兽医可以实时更新动物的体重、体温、心跳、呼吸等体征数据,并上传相关诊断报告。
- 动物档案管理:系统应该能够完整记录动物的生命周期信息,如出生日期、疫苗接种记录、疾病治疗记录、饲养记录等,确保数据的完整性和准确性。
3. 数据查询与统计(重要)
- 提供多种查询方式,如按动物种类、年龄、性别等条件查询动物信息。
- 统计动物数量、饲养成本、疾病发生率等数据,为动物园管理提供决策支持。
5. 健康与福利管理(一般)
- 实时监控动物体征数据,设置异常数据阈值,当数据超过阈值时自动报警。
- 提供动物健康评估功能,根据体征数据判断动物健康状态,并给出相应建议。
- 记录动物福利措施实施情况,如改善动物生活环境、增加娱乐设施等。
7. 权限管理(重要)
- 为不同用户角色分配不同的权限,只有授权的用户能够访问系统的特定功能和数据确保系统数据的安全性和完整性。
- 实现用户登录、注销功能,记录用户操作日志,便于追踪和审计。
9. 系统维护与优化(不重要)
- 提供数据备份与恢复功能,确保系统数据的安全可靠。定期备份系统数据,以防止数据丢失或系统故障。
- 支持系统升级和扩展,以适应动物园管理需求的变化。
四、报警系统分级(不一定来得及开发)
报警系统应采用分级制度,根据紧急程度逐级递增决定响应策略。例如,可以设置以下报警级别:
1. 一级报警:涉及动物生命安全或重大疾病的紧急情况,需立即处理。系统可根据预留手机号拨打电话提醒相关人员。
2. 二级报警:动物体征数据异常但未造成严重危害或饲养计划执行不到位等情况,需尽快处理。系统可发送邮件或短信提醒相关人员。
3. 三级报警:日常饲养记录缺失或数据录入错误等较小问题,可安排定期处理。
报警系统闭环管理的流程:
1.**报警触发:**报警系统根据预设的规则和条件,监测动物的健康状况、饲养记录等信息,当发现异常情况符合报警规则时,自动触发相应级别的报警。
2.**通知相关人员:**报警系统根据报警级别选择适的通知方式,通知相关责任人员,如饲养管理员、兽医等。通知方式可以包括电话呼叫、短信、邮件等。
3.**接收报警信息:**相关责任人员接收到报警信息后,需要及时查看并了解报警的具体内容和情况。系统应提供清晰明了的报警信息,包括动物种类、具体问题、位置等。
4.**处理报警:**相关责任人员根据报警信息采取相应的处理措施,针对不同级别的报警,制定相应的应对策略。一级报警需要立即处理,二级报警需要尽快处理,三级报警可以安排定期处理。
5.**解决问题:**相关责任人员在处理报警过程中,需要确保问题得到有效解决。对于一级报警和二级报警,需及时采取措施保障动物的健康和安全;对于三级报警,需要及时查明原因并采取相应措施,避免问题的再次发生。
6.**反馈和记录:**处理报警后,相关责任人员需要向系统反馈处理结果,并在系统中记录处理过程和结果。系统应提供相应的反馈和记录功能,方便责任人员进行操作。
7.**系统优化:**管理人员定期对报警系统的性能进行评估和分析,根据实际情况和反馈信息,对系统进行优化和改进。可以针对报警规则、通知方式、处理流程等方面进行调整,提高报警系统的准确性和效率。
五、饲养计划闭环系统(不一定来得及开发)
饲养计划的闭环是指在动物园信息管理系统中,通过制定、执行、监控和反馈的过程,实现对动物饲养的全面管理和持续优化。以下是饲养计划的闭环流程:
1. **计划制定:**饲养管理员根据动物的种类、年龄、健康状况等因素,制定饲养计划。计划包括每日、每周或每月的饲养任务安排,确定每种动物的饲料类型、数量和喂养时间等。
如果动物患有疾病或健康问题,兽医可以在饲养计划中考虑到这些特殊情况,对饲养计划和管理流程进行调整和优化
2. **任务分配:**系统根据制定的饲养计划,自动将任务分配给相应的饲养员。任务分配考虑到饲养员的工作时间、技能水平和工作负荷等因素,确保任务合理分配。
3. **执行监控:**饲养员执行任务时,实时记录饲养过程中的关键信息,如喂养时间、饲料用量、动物反应等。同时,系统监控饲养过程中的异常情况,如动物健康状况异常、饲料不足等。
4. **数据采集与分析:**系统定期采集和分析动物的健康数据和饲养记录,包括体重变化、食欲情况、疾病发生率等。通过数据分析,及时发现饲养过程中存在的问题和改进空间。
5. **问题反馈与调整:**根据数据分析结果,系统生成饲养效果报告和健康预警信息。管理人员和饲养员根据报告和预警信息,及时调整饲养计划和执行策略,解决存在的问题,并优化饲养过程。
六、饲料库存自动化管理系统(不一定来得及开发)
针对动物园饲料库存管理,建立自动化管理系统同样能够提高效率、降低成本并确保饲料供应的及时性。以下是动物园饲料库存自动化管理的主要内容和流程:
1. **自动化库存登记:**建立自动化系统,对动物园所有饲料进行自动化登记和识别,包括名称、规格、数量、购买日期、供应商信息等,实现饲料信息的自动采集和录入。
2. **库存监控:**实时监测饲料库存的数量、质量和保质期等信息。如有即将过期的饲料,系统会自动发送通知提醒相关人员。通过自动化系统,管理人员可以随时查看库存情况,并及时采取补货或调拨等措施。
3. **智能化补货策略:**根据库存监控数据和需求预测模型,制定智能化的补货策略。系统可以自动分析库存变化趋势和消耗情况,智能生成补货计划,并自动向供应商下订单,实现自动化补货流程。
4. **库存记录和报告:**系统可以自动生成库存记录和报告,包括库存量、成本、动物饲养需求等数据。管理人员可以通过系统查看和分析库存数据,优化饲料库存结构和管理策略。
七、非功能需求(略)
1. 易用性:系统界面简洁明了,操作流程简单易懂,方便用户快速上手。
2. 稳定性:系统应具有高可靠性,能够长时间稳定运行,减少故障率。
3. 安全性:系统应采取必要的安全措施,保护用户数据和系统免受攻击和破坏。
4. 可扩展性:系统应具备良好的可扩展性,以便在未来添加新的功能模块或集成其他系统。
八、总结(略)
动物园信息管理系统旨在提高动物园内部人员的管理效率,保障动物健康和福利。通过实现动物数据管理、数据查询与统计、健康与福利管理等功能,可以优化动物园管理流程,提升动物生活质量。同时,系统还应满足易用性、稳定性、安全性和可扩展性等非功能需求,确保系统的稳定运行和持续发展。

91
package-lock.json generated
View File

@ -9,7 +9,6 @@
"version": "0.0.0",
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"axios": "^1.7.2",
"element-plus": "^2.7.3",
"unplugin-icons": "^0.19.0",
"vite-plugin-inspect": "^0.8.4",
@ -992,21 +991,6 @@
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
"integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/axios": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz",
"integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@ -1086,17 +1070,6 @@
"fsevents": "~2.3.2"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/confbox": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.7.tgz",
@ -1178,14 +1151,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/element-plus": {
"version": "2.7.3",
"resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.7.3.tgz",
@ -1362,38 +1327,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/follow-redirects": {
"version": "1.15.6",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fs-extra": {
"version": "11.2.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
@ -1692,25 +1625,6 @@
"node": ">=8.6"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mimic-fn": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz",
@ -1943,11 +1857,6 @@
"node": "^10 || ^12 || >=14"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",

View File

@ -10,7 +10,6 @@
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"axios": "^1.7.2",
"element-plus": "^2.7.3",
"unplugin-icons": "^0.19.0",
"vite-plugin-inspect": "^0.8.4",

View File

@ -3,7 +3,6 @@
/*浏览器默认margin为8px会出现滚动条的问题因此此处设置为0*/
body {
margin: 0;
background-color: aliceblue;
}
/*相对定位*/
@ -42,7 +41,7 @@ body {
/*与pages组件相关的所有样式*/
.table {
height: 516px;
height: 506px;
margin: 0 30px;
}

View File

@ -1,6 +1,5 @@
<script>
import {copy} from "@/utils/common.js";
import {mapGetters} from "vuex";
export default {
name: "ZooAnimalFormDialog",
@ -19,102 +18,6 @@ export default {
features: '',//
phase: '幼年期'//
},
selectSpecies:true,
speciesData:[
{
value: '哺乳动物',
label: '哺乳动物',
children: [
{ value: '老虎', label: '老虎' },
{ value: '狮子', label: '狮子' },
{ value: '熊', label: '熊' },
{ value: '大象', label: '大象' },
{ value: '猴子', label: '猴子' },
{ value: '长颈鹿', label: '长颈鹿' },
{ value: '斑马', label: '斑马' },
{ value: '河马', label: '河马' },
{ value: '袋鼠', label: '袋鼠' },
{ value: '狼', label: '狼' },
{ value: '狐猴', label: '狐猴' },
],
},
{
value: '鸟类',
label: '鸟类',
children: [
{ value: '鸵鸟', label: '鸵鸟' },
{ value: '鹦鹉', label: '鹦鹉' },
{ value: '企鹅', label: '企鹅' },
{ value: '孔雀', label: '孔雀' },
{ value: '鹰', label: '鹰' },
{ value: '猫头鹰', label: '猫头鹰' },
{ value: '火烈鸟', label: '火烈鸟' },
{ value: '鹈鹕', label: '鹈鹕' },
],
},
{
value: '爬行动物',
label: '爬行动物',
children: [
{ value: '龟', label: '龟' },
{ value: '蜥蜴', label: '蜥蜴' },
{ value: '蛇', label: '蛇' },
{ value: '鳄鱼', label: '鳄鱼' },
{ value: '变色龙', label: '变色龙' },
{ value: '科莫多龙', label: '科莫多龙' },
],
},
{
value: '两栖动物',
label: '两栖动物',
children: [
{ value: '青蛙', label: '青蛙' },
{ value: '蟾蜍', label: '蟾蜍' },
{ value: '蝾螈', label: '蝾螈' },
{ value: '牛蛙', label: '牛蛙' },
{ value: '树蛙', label: '树蛙' },
],
},
{
value: '鱼类',
label: '鱼类',
children: [
{ value: '鲨鱼', label: '鲨鱼' },
{ value: '鳗鱼', label: '鳗鱼' },
{ value: '热带鱼', label: '热带鱼' },
{ value: '鲸鱼', label: '鲸鱼' },
{ value: '海豚', label: '海豚' },
{ value: '海马', label: '海马' },
{ value: '魔鬼鱼', label: '魔鬼鱼' },
],
},
{
value: '昆虫',
label: '昆虫',
children: [
{ value: '蝴蝶', label: '蝴蝶' },
{ value: '甲虫', label: '甲虫' },
{ value: '蜻蜓', label: '蜻蜓' },
],
},
{
value: '甲壳类',
label: '甲壳类',
children: [
{ value: '螃蟹', label: '螃蟹' },
{ value: '龙虾', label: '龙虾' },
{ value: '虾', label: '虾' },
],
},
{
value: '软体动物',
label: '软体动物',
children: [
{ value: '章鱼', label: '章鱼' },
{ value: '乌贼', label: '乌贼' },
],
},
],
}
},
props: {
@ -130,9 +33,6 @@ export default {
default: false
}
},
computed:{
...mapGetters(["getKeepers"])
},
mounted() {
//
if (this.data) {
@ -148,7 +48,7 @@ export default {
<template>
<el-form label-width="auto">
<el-form-item label="动物ID">
<el-input v-model.number="form.id" placeholder="系统自动生成ID" type="number" :disabled="edit || detail || true"/>
<el-input v-model.number="form.id" placeholder="请设置动物ID" type="number" :disabled="edit || detail"/>
</el-form-item>
<el-form-item label="动物名称">
<el-input v-model="form.name" placeholder="动物名称" :disabled="detail"/>
@ -160,25 +60,7 @@ export default {
</el-radio-group>
</el-form-item>
<el-form-item label="动物种类">
<el-col :span="16" v-if="selectSpecies">
<el-tree-select
v-model="form.species"
:data="speciesData"
:render-after-expand="false"
clearable :disabled="detail"
/>
</el-col>
<el-col :span="16" v-else>
<el-input v-model="form.species" placeholder="动物种类" :disabled="detail"/>
</el-col>
<el-col :span="1">
</el-col>
<el-col :span="6" justify="end">
<el-button @click="selectSpecies = !selectSpecies" :disabled="detail">自定义种类</el-button>
</el-col>
</el-form-item>
<el-form-item label="体重KG">
<el-input-number v-model.number="form.weight" :precision="2" :step="0.1" :min="0" :disabled="detail"/>
@ -193,26 +75,7 @@ export default {
</el-radio-group>
</el-form-item>
<el-form-item label="饲养员ID">
<!-- <el-input v-model="form.roleId" type="number" placeholder="饲养员ID" :disabled="detail"/>-->
<el-select v-model="form.roleId" placeholder="饲养员" clearable :disabled="detail">
<el-option
v-for="item in getKeepers"
:key="item.id"
:value="item.id"
>
<span style="float: left">{{ item.username }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>
用户ID {{ item.id }}
</span>
</el-option>
</el-select>
<el-input v-model="form.roleId" type="number" placeholder="饲养员ID" :disabled="detail"/>
</el-form-item>
<el-form-item label="动物颜色">
<el-color-picker v-model="form.color" :disabled="detail"/>
@ -222,10 +85,10 @@ export default {
</el-form-item>
<el-form-item label="生命阶段">
<el-select v-model="form.phase" placeholder="生命阶段" :disabled="detail">
<el-option label="幼年期" value="幼年期"/>
<el-option label="成长期" value="成长期"/>
<el-option label="成年期" value="成年期"/>
<el-option label="老年期" value="老年期"/>
<el-option label="幼年期" :value="0"/>
<el-option label="成长期" :value="1"/>
<el-option label="成年期" :value="2"/>
<el-option label="老年期" :value="3"/>
</el-select>
</el-form-item>
<div class="right">

View File

@ -1,6 +1,5 @@
<script>
import {copy} from "@/utils/common.js";
import {mapState, mapGetters} from "vuex";
export default {
name: "ZooArchiveFormDialog",
@ -17,7 +16,6 @@ export default {
time: '',//
roleId: null,//id
description: '',//
breedingId: null
},
}
},
@ -34,27 +32,10 @@ export default {
default: false
}
},
watch: {
'form.animalId': {
handler(newValue) {
// console.log(newValue)
this.form.animalName = this.animals.find(e => e.id === this.form.animalId).name
}
}
},
computed: {
...mapState(['loginUser', 'animals','breedingPlans']),
...mapGetters(['getKeepersAndVeterinary'])
},
mounted() {
//
if (this.data) {
this.form = copy(this.data)
} else {
const newDate = new Date();
this.form.date = newDate.getFullYear() + '-' + (newDate.getMonth() + 1).toString().padStart(2, '0') + '-' + newDate.getDate().toString().padStart(2, '0')
this.form.time = newDate.getHours().toString().padStart(2, '0') + ':' + newDate.getMinutes().toString().padStart(2, '0') + ':' + newDate.getSeconds().toString().padStart(2, '0')
this.form.roleId = this.loginUser.id
}
},
beforeUnmount() {
@ -66,39 +47,20 @@ export default {
<template>
<el-form label-width="auto">
<el-form-item label="记录号">
<el-input v-model.number="form.id" type="number" placeholder="系统自动生成记录号"
:disabled="edit || detail || true"/>
<el-input v-model.number="form.id" type="number" placeholder="记录号" :disabled="edit || detail"/>
</el-form-item>
<el-form-item label="动物ID">
<!-- <el-input v-model.number="form.animalId" type="number" placeholder="动物ID" :disabled="detail"/>-->
<el-select v-model="form.animalId" placeholder="动物ID" clearable :disabled="detail">
<el-option
v-for="item in animals"
:key="item.id"
:value="item.id"
>
<span style="float: left">{{ item.name }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>
动物ID {{ item.id }}
</span>
</el-option>
</el-select>
<el-input v-model.number="form.animalId" type="number" placeholder="动物ID" :disabled="detail"/>
</el-form-item>
<el-form-item label="动物名称">
<el-input v-model="form.animalName" placeholder="动物名称" :disabled="detail"/>
</el-form-item>
<el-form-item label="生命阶段">
<el-select v-model="form.phase" placeholder="生命阶段" :disabled="detail">
<el-option label="幼年期" value="幼年期"/>
<el-option label="成长期" value="成长期"/>
<el-option label="成年期" value="成年期"/>
<el-option label="老年期" value="老年期"/>
<el-option label="幼年期" :value="0"/>
<el-option label="成长期" :value="1"/>
<el-option label="成年期" :value="2"/>
<el-option label="老年期" :value="3"/>
</el-select>
</el-form-item>
<el-form-item label="动物状态">
@ -115,68 +77,20 @@ export default {
</el-select>
</el-form-item>
<el-form-item label="记录日期">
<el-col :span="11">
<el-date-picker
v-model="form.date"
type="date"
placeholder="选择日期"
value-format="YYYY-MM-DD"
:disabled="detail"
style="width: 100%"
/>
</el-col>
<el-col :span="2">
</el-col>
<el-col :span="11">
<el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"
:disabled="detail" style="width: 100%"/>
</el-col>
</el-form-item>
<!-- <el-form-item label="记录时间">-->
<!-- -->
<!-- </el-form-item>-->
<el-form-item label="关联计划">
<el-select v-model="form.breedingId" placeholder="选择关联计划" clearable :disabled="detail">
<el-option
v-for="item in breedingPlans"
:key="item.id"
:value="item.id"
>
<span style="float: left">{{ item.name }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>
计划ID {{ item.id }}
</span>
</el-option>
</el-select>
<el-form-item label="记录时间">
<el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"
:disabled="detail"/>
</el-form-item>
<el-form-item label="记录人ID">
<!-- <el-input v-model.number="form.roleId" type="number" placeholder="记录人ID" :disabled="detail"/>-->
<el-select v-model="form.roleId" placeholder="记录人ID" clearable :disabled="detail">
<el-option
v-for="item in getKeepersAndVeterinary"
:key="item.id"
:value="item.id"
>
<span style="float: left">{{ item.username }} {{ item.auth === 1 ? '饲养员' : '兽医' }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>
用户ID {{ item.id }}
</span>
</el-option>
</el-select>
<el-input v-model.number="form.roleId" type="number" placeholder="记录人ID" :disabled="detail"/>
</el-form-item>
<el-form-item label="记录描述">
<el-input

View File

@ -9,11 +9,6 @@ export default {
order:0
}
},
watch:{
order(){
this.timeSort()
}
},
props: {
data: {
type: Object,
@ -21,24 +16,20 @@ export default {
},
},
methods: {
//
timeSort() {
//0
if (this.order === 0) {
this.archives = sortByDateTime(copy(this.archives))
sort(){
//
if (this.order===0){
this.order++
sortByDateTime(this.archives)
return
}
//1
if (this.order === 1) {
this.archives = sortByDateTime(copy(this.archives)).reverse()
return;
//
if (this.order===1){
this.order--
sortByDateTime(this.archives)
this.archives.reverse()
}
},
changeOrder(){
if (this.order===0)
this.order++
else this.order--
},
nodeType(type) {
if (type === '日常饲养') {
return 'success'
@ -59,19 +50,13 @@ export default {
}
}
},
mounted() {
//
//
if (this.data) {
this.archives = copy(this.data)
//
this.timeSort()
}
},
updated() {
if (this.data) {
this.archives = copy(this.data)
//
this.timeSort()
this.sort()
}
},
beforeUnmount() {
@ -82,7 +67,7 @@ export default {
<template>
<div class="relative" style="height: 40px">
<el-button type="primary" class="right" @click="changeOrder()">按时间升 / 降序</el-button>
<el-button type="primary" class="right" @click="sort()">按时间升 / 降序</el-button>
</div>
<el-scrollbar height="500px">
<el-timeline style="max-width: 600px">
@ -132,10 +117,7 @@ export default {
{{ a.description }}
</el-descriptions-item>
</el-descriptions>
<div class="left">
记录号{{ a.id }} |
关联计划{{ a.breedingId }}
</div>
<div class="left">记录号{{ a.id }}</div>
<div class="right">{{ a.roleId }} 记录于 {{ a.date }} {{ a.time }}</div>
</el-timeline-item>
</el-timeline>

View File

@ -1,10 +1,8 @@
<script>
import {mapState} from "vuex";
import {Menu, User} from "@element-plus/icons-vue";
export default {
name: "ZooAside",
components: {User, Menu},
data() {
return {}
},
@ -18,9 +16,7 @@ export default {
this.$router.push(path)
}
},
mounted() {
}
watch: {}
}
</script>
@ -46,14 +42,30 @@ export default {
<el-sub-menu index="1">
<template #title="scope">
<el-icon>
<Menu/>
<location/>
</el-icon>
<span>用户功能</span>
<span>管理员</span>
</template>
<el-menu-item index="/panel/home" @click="toPath('/panel/home')">首页</el-menu-item>
<el-menu-item index="/panel/user" @click="toPath('/panel/user')" v-if="loginUser.auth===0">用户管理</el-menu-item>
<el-menu-item index="/panel/user" @click="toPath('/panel/user')">用户管理</el-menu-item>
<el-menu-item index="/panel/animal" @click="toPath('/panel/animal')">动物基本数据</el-menu-item>
</el-sub-menu>
<el-sub-menu index="2">
<template #title>
<el-icon>
<location/>
</el-icon>
<span>饲养员</span>
</template>
<el-menu-item index="/panel/breeding" @click="toPath('/panel/breeding')">饲养计划</el-menu-item>
</el-sub-menu>
<el-sub-menu index="3">
<template #title>
<el-icon>
<location/>
</el-icon>
<span>兽医</span>
</template>
<el-menu-item index="/panel/archive" @click="toPath('/panel/archive')">动物档案</el-menu-item>
<el-menu-item index="/panel/health" @click="toPath('/panel/health')">健康检测</el-menu-item>
</el-sub-menu>
@ -63,9 +75,6 @@ export default {
</template>
<style scoped>
#aside{
background-color: white;
}
.aside-icon {
width: 200px;
margin-top: 20px;

View File

@ -1,13 +1,12 @@
<script>
import {copy} from "@/utils/common.js";
import {mapGetters} from "vuex";
export default {
name: "ZooBreedingFormDialog",
data() {
return {
form: {
id: null,//int id
id: '',//int id
name: '',//
species: '',//
sex: '雄性',//
@ -31,9 +30,6 @@ export default {
default: false
}
},
computed:{
...mapGetters(['getAllSpecies','getKeepers'])
},
mounted() {
//
if (this.data) {
@ -49,21 +45,13 @@ export default {
<template>
<el-form label-width="auto">
<el-form-item label="计划ID">
<el-input v-model.number="form.id" type="number" placeholder="系统自动生成ID" :disabled="edit || detail || true"/>
<el-input v-model.number="form.id" type="number" placeholder="饲养计划ID" :disabled="edit || detail"/>
</el-form-item>
<el-form-item label="计划名称">
<el-input v-model="form.name" placeholder="计划名称" :disabled="detail"/>
</el-form-item>
<el-form-item label="动物种类">
<!-- <el-input v-model="form.species" placeholder="动物种类" :disabled="detail"/>-->
<el-select v-model="form.species" placeholder="动物种类" clearable :disabled="detail">
<el-option
v-for="(item,index) in getAllSpecies"
:key="index"
:value="item"
>
</el-option>
</el-select>
<el-input v-model="form.species" placeholder="动物种类" :disabled="detail"/>
</el-form-item>
<el-form-item label="性别">
<el-radio-group v-model="form.sex" :disabled="detail">
@ -73,10 +61,10 @@ export default {
</el-form-item>
<el-form-item label="生命阶段">
<el-select v-model="form.phase" :disabled="detail">
<el-option label="幼年期" value="幼年期"/>
<el-option label="成长期" value="成长期"/>
<el-option label="成年期" value="成年期"/>
<el-option label="老年期" value="老年期"/>
<el-option label="幼年期" :value="0"/>
<el-option label="成长期" :value="1"/>
<el-option label="成年期" :value="2"/>
<el-option label="老年期" :value="3"/>
</el-select>
</el-form-item>
<el-form-item label="动物状态">
@ -86,25 +74,7 @@ export default {
</el-radio-group>
</el-form-item>
<el-form-item label="执行饲养员">
<!-- <el-input v-model.number="form.roleId" type="number" placeholder="执行饲养员" :disabled="detail"/>-->
<el-select v-model="form.roleId" placeholder="执行饲养员" clearable :disabled="detail">
<el-option
v-for="item in getKeepers"
:key="item.id"
:value="item.id"
>
<span style="float: left">{{ item.username }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>
用户ID {{ item.id }}
</span>
</el-option>
</el-select>
<el-input v-model.number="form.roleId" type="number" placeholder="执行饲养员" :disabled="detail"/>
</el-form-item>
<el-form-item label="计划描述" >
<el-input

View File

@ -1,6 +1,5 @@
<script>
import {copy} from "@/utils/common.js";
import {mapState} from "vuex";
export default {
name: "ZooHealthFormDialog",
@ -34,25 +33,10 @@ export default {
default: false
}
},
computed:{
...mapState(['animals'])
},
watch:{
'form.animalId':{
handler(newValue){
// console.log(newValue)
this.form.animalName = this.animals.find(e=>e.id===this.form.animalId).name
}
}
},
mounted() {
//
if (this.data) {
this.form = copy(this.data)
}else {
const newDate = new Date();
this.form.date = newDate.getFullYear() + '-' + (newDate.getMonth()+1).toString().padStart(2, '0') + '-' + newDate.getDate().toString().padStart(2, '0')
this.form.time = newDate.getHours().toString().padStart(2, '0') + ':' + newDate.getMinutes().toString().padStart(2, '0') + ':' + newDate.getSeconds().toString().padStart(2, '0')
}
},
beforeUnmount() {
@ -64,28 +48,10 @@ export default {
<template>
<el-form label-width="auto">
<el-form-item label="监测号">
<el-input v-model.number="form.id" type="number" placeholder="系统自动生成监测号" :disabled="edit || detail || true"/>
<el-input v-model.number="form.id" type="number" placeholder="监测号" :disabled="edit || detail"/>
</el-form-item>
<el-form-item label="动物ID">
<!-- <el-input v-model.number="form.animalId" type="number" placeholder="动物ID" :disabled="detail"/>-->
<el-select v-model="form.animalId" placeholder="动物ID" clearable :disabled="detail">
<el-option
v-for="item in animals"
:key="item.id"
:value="item.id"
>
<span style="float: left">{{ item.name }}</span>
<span
style="
float: right;
color: var(--el-text-color-secondary);
font-size: 13px;
"
>
动物ID {{ item.id }}
</span>
</el-option>
</el-select>
<el-input v-model.number="form.animalId" type="number" placeholder="动物ID" :disabled="detail"/>
</el-form-item>
<el-form-item label="动物名称">
<el-input v-model="form.animalName" placeholder="动物名称" :disabled="detail"/>
@ -113,35 +79,18 @@ export default {
</el-radio-group>
</el-form-item>
<el-form-item label="记录日期">
<!-- <el-date-picker-->
<!-- v-model="form.date"-->
<!-- type="date"-->
<!-- placeholder="选择日期"-->
<!-- value-format="YYYY-MM-DD"-->
<!-- :disabled="detail"-->
<!-- />-->
<el-col :span="11">
<el-date-picker
v-model="form.date"
type="date"
placeholder="选择日期"
value-format="YYYY-MM-DD"
:disabled="detail"
style="width: 100%"
/>
</el-col>
<el-col :span="2">
</el-col>
<el-col :span="11">
<el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"
:disabled="detail" style="width: 100%"/>
</el-col>
</el-form-item>
<!-- <el-form-item label="记录时间">-->
<!-- <el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"-->
<!-- :disabled="detail"/>-->
<!-- </el-form-item>-->
<el-form-item label="记录时间">
<el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"
:disabled="detail"/>
</el-form-item>
<el-form-item label="记录描述">
<el-input
v-model="form.description"

View File

@ -9,11 +9,6 @@ export default {
order: 0
}
},
watch:{
order(){
this.timeSort()
}
},
props: {
data: {
type: Object,
@ -21,24 +16,20 @@ export default {
},
},
methods: {
//
timeSort() {
//0
sort() {
//
if (this.order === 0) {
this.healths = sortByDateTime(copy(this.healths))
this.order++
sortByDateTime(this.healths)
return
}
//1
//
if (this.order === 1) {
this.healths = sortByDateTime(copy(this.healths)).reverse()
return;
this.order--
sortByDateTime(this.healths)
this.healths.reverse()
}
},
changeOrder(){
if (this.order===0)
this.order++
else this.order--
},
nodeType(type) {
if (type === 0) {
return 'success'
@ -54,15 +45,7 @@ export default {
if (this.data) {
this.healths = copy(this.data)
//
this.timeSort()
}
},
updated() {
//
if (this.data) {
this.healths = copy(this.data)
//
this.timeSort()
this.sort()
}
},
beforeUnmount() {
@ -73,7 +56,7 @@ export default {
<template>
<div class="relative" style="height: 40px">
<el-button type="primary" class="right" @click="changeOrder()">按时间升 / 降序</el-button>
<el-button type="primary" class="right" @click="sort()">按时间升 / 降序</el-button>
</div>
<el-scrollbar height="500px">
<el-timeline style="max-width: 600px">

View File

@ -22,7 +22,7 @@ export default {
type: Boolean,
default: false
},
edit: {
edit:{
type: Boolean,
default: false
}
@ -42,8 +42,8 @@ export default {
<template>
<el-form label-width="auto">
<el-form-item label="用户ID">
<el-input v-model.number="form.id" placeholder="系统自动生成ID" type="number"
:disabled="edit || detail|| true"/>
<el-input v-model.number="form.id" placeholder="请设置用户ID" type="number"
:disabled="edit || detail"/>
</el-form-item>
<el-form-item label="用户名">
<el-input v-model="form.username" placeholder="请设置用户名" :disabled="detail"/>

View File

@ -1,10 +1,9 @@
<script>
import {copy, fuzzyMatching, refreshData, splitKeyWords} from "@/utils/common.js";
import {copy, fuzzyMatching, splitKeyWords} from "@/utils/common.js";
import {Delete, Document, DocumentAdd, Edit, Search, Tickets} from "@element-plus/icons-vue";
import ZooAnimalFormDialog from "@/components/ZooAnimalFormDialog.vue";
import {mapMutations, mapState} from "vuex";
import {mapActions, mapMutations, mapState} from "vuex";
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
import request, {frontendAnimal, frontendAnimals, frontendArchives} from "@/utils/request.js";
export default {
name: "ZooAnimal",
@ -55,10 +54,7 @@ export default {
return Tickets
},
//endregion
...mapState(["animals", 'archives', 'animalsTableData','loginUser']),
operateWidth() {
return this.loginUser.auth===1?'250':'130'
}
...mapState(["animals", 'archives', 'animalsTableData'])
},
watch: {
// ()
@ -70,26 +66,19 @@ export default {
}
},
methods: {
...mapMutations(['updateAnimals','updateAnimalsTableData']),
...mapActions(["getAnimals"]),
...mapMutations(['updateAnimalsTableData']),
//
showDetail(data) {
console.log('显示详情', data)
//
request.queryAnimalRequest(data.id).then(response => {
if (response.data.data===null){
this.refresh();
return ElMessage({
message: '该动物不存在,请刷新',
type: 'warning',
})
} else {
this.dialog.dialogData = frontendAnimal(response.data.data)
//
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true
}
})
},
//
@ -97,61 +86,45 @@ export default {
console.log('显示编辑', data)
//
request.queryAnimalRequest(data.id).then(response => {
if (response.data.data===null){
this.refresh();
return ElMessage({
message: '该动物不存在,请刷新',
type: 'warning',
})
} else {
this.dialog.dialogData = frontendAnimal(response.data.data)
//
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true
}
})
},
edit(data) {
console.log('编辑', data)
//
if (this.isEmpty(data)) {
return;
}
//
return this.isEmpty(data);
//
//
request.queryAnimalRequest(data.id).then(response => {
if (response.data.data===null){
this.refresh();
this.dialog.editDialogVisible = false;
return ElMessage({
message: '该动物不存在,请刷新',
type: 'warning',
})
} else {
request.updateAnimalRequest(data).then(response => {
if (response.data.code===1){
//
//
this.refresh()
this.dialog.editDialogVisible = false//
return ElMessage({
message: '编辑成功',
type: 'success',
})
}else {
//
if (false) {
return ElMessage({
message: '编辑失败',
type: 'warning',
})
}
//
if (false) {
return ElMessage({
message: '编辑成功',
type: 'success',
})
}
})
// //
// this.getAnimals()
// this.search()
//
this.refresh()
//
this.dialog.editDialogVisible = false
},
delete_(data) {
@ -166,18 +139,12 @@ export default {
type: 'warning',
}
).then(() => {
//
request.queryAnimalRequest(data.id).then(response => {
if (response.data.data===null){
this.refresh();
return ElMessage({
message: '该动物不存在,请刷新',
type: 'warning',
})
} else {
//
request.deleteAnimalRequest(data.id).then(response => {
if (response.data.code===1){
// //
// this.getAnimals()
// this.search()
//
this.refresh()
@ -186,15 +153,6 @@ export default {
type: 'success',
message: '删除成功',
})
} else {
ElMessage({
type: 'success',
message: '删除失败',
})
}
})
}
})
}).catch(() => {
ElMessage({
type: 'info',
@ -207,62 +165,61 @@ export default {
console.log('添加', data)
//
if (this.isEmpty(data)) {
return;
return this.isEmpty(data);
//
//
if (false) {
return ElMessage({
message: '该动物已存在',
type: 'warning',
})
}
request.addAnimalRequest(data).then(response => {
if (response.data.code===1){
//
//
this.refresh()
this.dialog.addDialogVisible = false//
//
if (false) {
return ElMessage({
message: '添加成功',
type: 'success',
})
}else {
return ElMessage({
message: '添加失败',
type: 'warning',
})
}
})
// //
// this.getAnimals()
// this.search()
//
this.refresh()
this.dialog.addDialogVisible = false//
},
//线
showTimeline(data) {
console.log('显示时间线记录', data)
this.dialog.dialogData = data
//
request.queryAnimalRequest(data.id).then(response => {
if (response.data.data===null){
this.refresh();
return ElMessage({
message: '该动物不存在,请刷新',
type: 'warning',
//
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
this.dialog.timelineData = []
//
//
this.archives.forEach(e => {
if (e.animalId === data.id) {
this.dialog.timelineData.push(copy(e))
}
})
} else {
request.queryArchiveRequest(null,data.id).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendArchives(response.data.data)
//
this.dialog.timelineDialogVisible = true
}
})
}
})
},
//
isEmpty(form) {
if (!form.name) {
//
return ElMessage({
message: '请输入动物名称',
message: '动物名不能为空',
type: 'warning',
})
}
@ -321,22 +278,18 @@ export default {
console.log('刷新数据')
//
request.queryAnimalRequest().then(response => {
if (response.data.code === 1) {
this.updateAnimals(frontendAnimals(response.data.data))
}
this.getAnimals()
//
this.search()
//
this.getPagesData()
})
},
},
mounted() {
//
this.refresh()
refreshData()
}
}
</script>
@ -344,7 +297,7 @@ export default {
<template>
<div class="animal-root">
<div class="select">
<div class="left" v-if="loginUser.auth===1">
<div class="left">
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加动物</el-button>
</div>
<div class="right">
@ -393,7 +346,7 @@ export default {
</template>
</el-table-column>
<el-table-column prop="features" label="动物特征" width="300"/>
<el-table-column fixed="right" label="操作" :width="operateWidth" >
<el-table-column fixed="right" label="操作" width="250">
<template #default="scope">
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
档案
@ -401,10 +354,10 @@ export default {
<el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情
</el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth===1">
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑
</el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth===1">
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除
</el-button>
</template>
@ -422,8 +375,7 @@ export default {
</div>
<!-- 添加动物对话框-->
<el-dialog v-model="dialog.addDialogVisible" title="添加动物" width="500" align-center draggable overflow
destroy-on-close>
<el-dialog v-model="dialog.addDialogVisible" title="添加动物" width="500" align-center draggable overflow>
<ZooAnimalFormDialog>
<template #default="scope">
<el-button @click="dialog.addDialogVisible = false">
@ -464,8 +416,9 @@ export default {
</el-dialog>
<!--查看动物所有记录-->
<el-dialog v-model="dialog.timelineDialogVisible" :title="'生命周期档案:'+dialog.dialogData.id" width="600" align-center
draggable overflow destroy-on-close>
<el-dialog v-model="dialog.timelineDialogVisible" :title="'动物档案:'+dialog.dialogData.id" width="600" align-center
draggable overflow
destroy-on-close>
<ZooArchiveTimeline :data="dialog.timelineData">
<!-- <template #operate="scope">-->
<!-- <el-button type="primary" link @click="showEdit(scope.archive)">编辑</el-button>-->

View File

@ -2,9 +2,8 @@
import ZooArchiveFormDialog from "@/components/ZooArchiveFormDialog.vue";
import {Delete, DocumentAdd, Document, Edit, Search, Tickets, Timer} from "@element-plus/icons-vue";
import {mapState, mapActions, mapMutations} from "vuex";
import {copy, splitKeyWords, fuzzyMatching, sortByDateTime, refreshData} from "@/utils/common.js";
import {copy, splitKeyWords, fuzzyMatching, sortByDateTime} from "@/utils/common.js";
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
import request, {frontendArchive, frontendArchives} from "@/utils/request.js";
export default {
name: "ZooArchive",
@ -59,10 +58,7 @@ export default {
return Timer
},
//endregion
...mapState(["archives", 'archivesTableData','loginUser']),
operateWidth() {
return this.loginUser.auth!==0?'250':'130'
}
...mapState(["archives", 'archivesTableData'])
},
watch: {
// ()
@ -78,26 +74,19 @@ export default {
}
},
methods: {
...mapMutations(['updateArchives','updateArchivesTableData']),
...mapActions(["getArchives"]),
...mapMutations(['updateArchivesTableData']),
//
showDetail(data) {
console.log('显示详情', data)
//
request.queryArchiveRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh()
return ElMessage({
message: '该档案记录不存在,请刷新',
type: 'warning',
})
}else {
this.dialog.dialogData = frontendArchive(response.data.data)
//
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true
}
})
},
//
@ -105,66 +94,45 @@ export default {
console.log('显示编辑', data)
//
request.queryArchiveRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh()
return ElMessage({
message: '该记录不存在,请刷新',
type: 'warning',
})
}else {
this.dialog.dialogData = frontendArchive(response.data.data)
//
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true
}
})
},
edit(data) {
console.log('编辑', data)
//
if (this.isEmpty(data)) {
return;
}
return this.isEmpty(data);
//
//
request.queryArchiveRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh()
this.dialog.editDialogVisible = false;
return ElMessage({
message: '该档案记录不存在,请刷新',
type: 'warning',
})
}else {
request.updateArchiveRequest(data).then(response => {
if (response.data.code===1){
//
//
this.refresh()
request.queryArchiveRequest(null,this.dialog.dialogData.animalId).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendArchives(response.data.data)
}
})
this.dialog.editDialogVisible = false//
return ElMessage({
message: '编辑成功',
type: 'success',
})
}else {
//
if (false) {
return ElMessage({
message: '编辑失败',
type: 'warning',
})
}
//
if (false) {
return ElMessage({
message: '编辑成功',
type: 'success',
})
}
})
// //
// this.getArchives()
// this.search()
//
this.refresh()
//
this.dialog.editDialogVisible = false
},
delete_(data) {
@ -179,38 +147,19 @@ export default {
type: 'warning',
}
).then(() => {
//
request.queryArchiveRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh()
return ElMessage({
message: '该档案记录不存在,请刷新',
type: 'warning',
})
}else {
//
request.deleteArchiveRequest(data.id).then(response => {
if (response.data.code===1){
// //
// this.getArchives()
// this.search()
//
this.refresh()
request.queryArchiveRequest(null,this.dialog.dialogData.animalId).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendArchives(response.data.data)
}
})
return ElMessage({
message: '删除成功',
//
ElMessage({
type: 'success',
})
}else {
return ElMessage({
message: '删除失败',
type: 'warning',
})
}
})
}
message: '删除成功',
})
}).catch(() => {
ElMessage({
@ -224,53 +173,61 @@ export default {
console.log('添加', data)
//
if (this.isEmpty(data)) {
return;
return this.isEmpty(data);
//
//
if (false) {
return ElMessage({
message: '该记录已存在',
type: 'warning',
})
}
request.addArchiveRequest(data).then(response => {
if (response.data.code===1){
//
//
this.refresh()
this.dialog.addDialogVisible = false//
//
if (false) {
return ElMessage({
message: '添加成功',
type: 'success',
})
}else {
return ElMessage({
message: '添加失败',
type: 'warning',
})
}
})
// //
// this.getArchives()
// this.search()
//
this.refresh()
this.dialog.addDialogVisible = false//
},
//线
showTimeline(data) {
console.log('显示时间线记录', data)
this.dialog.dialogData = data
//
//
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
//
request.queryArchiveRequest(null,data.animalId).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendArchives(response.data.data)
//
this.dialog.timelineDialogVisible = true
this.dialog.timelineData = []
//
//
this.archives.forEach(e => {
if (e.animalId === data.animalId) {
this.dialog.timelineData.push(copy(e))
}
})
//
this.dialog.timelineDialogVisible = true
},
//
isEmpty(form) {
if (!form.animalId||!form.animalName) {
if (!form.animalId) {
//
return ElMessage({
message: '动物ID或动物名称不能为空',
message: '记录的动物ID不能为空',
type: 'warning',
})
}
@ -353,10 +310,8 @@ export default {
console.log('刷新数据')
//
request.queryArchiveRequest().then(response=>{
if (response.data.code === 1){
this.updateArchives(frontendArchives(response.data.data))
}
this.getArchives()
//
this.search()
@ -365,13 +320,11 @@ export default {
//
this.getPagesData()
})
}
},
mounted() {
//
this.refresh()
refreshData()
},
}
</script>
@ -379,7 +332,7 @@ export default {
<template>
<div class="archive-root">
<div class="select">
<div class="left" v-if="loginUser.auth!==0">
<div class="left">
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加记录</el-button>
</div>
<div class="right">
@ -421,9 +374,8 @@ export default {
<el-table-column prop="date" label="记录日期" width="110"/>
<el-table-column prop="time" label="记录时间" width="90"/>
<el-table-column prop="roleId" label="记录人ID" width="90"/>
<el-table-column prop="breedingId" label="关联计划" width="90"/>
<el-table-column prop="description" label="记录描述" width="300"/>
<el-table-column fixed="right" label="操作" :width="operateWidth">
<el-table-column fixed="right" label="操作" width="250">
<template #default="scope">
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
档案
@ -431,10 +383,10 @@ export default {
<el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情
</el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth!==0">
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑
</el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth!==0">
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除
</el-button>
</template>
@ -452,8 +404,7 @@ export default {
</div>
<!-- 添加记录对话框-->
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow
destroy-on-close>
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow>
<ZooArchiveFormDialog>
<template #default="scope">
<el-button @click="dialog.addDialogVisible = false">
@ -495,7 +446,8 @@ export default {
<!--查看动物所有记录-->
<el-dialog v-model="dialog.timelineDialogVisible" :title="'生命周期档案:'+dialog.dialogData.animalId" width="600"
align-center draggable overflow destroy-on-close>
align-center draggable overflow
destroy-on-close>
<ZooArchiveTimeline :data="dialog.timelineData">
<template #operate="scope">
<el-button type="primary" link @click="showEdit(scope.archive)">编辑</el-button>

View File

@ -1,14 +1,12 @@
<script>
import ZooBreedingPlanFormDialog from "@/components/ZooBreedingPlanFormDialog.vue";
import {mapState, mapActions, mapMutations, mapGetters} from "vuex";
import {Delete, DocumentAdd, Document, Edit, Search, Tickets} from "@element-plus/icons-vue";
import {copy, splitKeyWords, fuzzyMatching, refreshData} from "@/utils/common.js";
import request, {frontendArchives, frontendBreeding, frontendBreedingPlans} from "@/utils/request.js";
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
import {mapState, mapActions, mapMutations} from "vuex";
import {Delete, DocumentAdd, Document,Edit, Search} from "@element-plus/icons-vue";
import {copy, splitKeyWords,fuzzyMatching} from "@/utils/common.js";
export default {
name: "ZooBreeding",
components: {ZooArchiveTimeline, ZooBreedingPlanFormDialog},
components: {ZooBreedingPlanFormDialog},
data() {
return {
//
@ -27,14 +25,11 @@ export default {
dialogData: {},
addDialogVisible: false,//
editDialogVisible: false,//
detailDialogVisible: false,//
timelineDialogVisible: false,//线
timelineData: []//线
detailDialogVisible:false//
}
}
},
computed: {
//
//region
Search() {
@ -52,72 +47,33 @@ export default {
Document() {
return Document
},
Tickets() {
return Tickets
},
//endregion
...mapState(["breedingPlans", 'breedingPlansTableData','loginUser']),
operateWidth() {
return this.loginUser.auth===1?'250':'130'
}
...mapState(["breedingPlans",'breedingPlansTableData'])
},
watch: {
// ()
searchInput: {
deep: true,
handler(val) {
// this.search()
this.refresh();
}
}
},
methods: {
...mapMutations(['updateBreedingPlans','updateBreedingPlansTableData']),
//线
showTimeline(data) {
console.log('显示时间线记录', data)
this.dialog.dialogData = data
//
request.queryBreedingPlanRequest(data.id).then(response => {
if (response.data.data===null){
this.refresh();
return ElMessage({
message: '该计划不存在,请刷新',
type: 'warning',
})
} else {
request.queryArchiveByBreedingId(data.id).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendArchives(response.data.data)
//
this.dialog.timelineDialogVisible = true
}
})
}
})
},
...mapActions(["getBreedingPlans"]),
...mapMutations(['updateBreedingPlansTableData']),
//
showDetail(data) {
console.log('显示详情', data)
//
request.queryBreedingPlanRequest(data.id).then(response => {
if (response.data.data === null) {
this.refresh();
return ElMessage({
message: '该计划不存在,请刷新',
type: 'warning',
})
} else {
this.dialog.dialogData = frontendBreeding(response.data.data)
//
this.dialog.dialogData = this.breedingPlans.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true
}
})
},
//
@ -125,61 +81,45 @@ export default {
console.log('显示编辑', data)
//
request.queryBreedingPlanRequest(data.id).then(response => {
if (response.data.data === null) {
this.refresh();
return ElMessage({
message: '该计划不存在,请刷新',
type: 'warning',
})
} else {
this.dialog.dialogData = frontendBreeding(response.data.data)
//
this.dialog.dialogData = this.breedingPlans.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true
}
})
},
edit(data) {
console.log('编辑', data)
//
if (this.isEmpty(data)) {
return;
}
return this.isEmpty(data);
//
//
request.queryBreedingPlanRequest(data.id).then(response => {
if (response.data.data === null) {
this.refresh();
this.dialog.editDialogVisible = false;
return ElMessage({
message: '该计划不存在,请刷新',
type: 'warning',
})
} else {
request.updateBreedingPlanRequest(data).then(response => {
if (response.data.code === 1) {
//
//
this.refresh()
this.dialog.editDialogVisible = false//
return ElMessage({
message: '编辑成功',
type: 'success',
})
} else {
//
if (false) {
return ElMessage({
message: '编辑失败',
type: 'warning',
})
}
//
if (false) {
return ElMessage({
message: '编辑成功',
type: 'success',
})
}
})
// //
// this.getBreedingPlans()
// this.search()
//
this.refresh()
//
this.dialog.editDialogVisible = false
},
delete_(data) {
@ -187,40 +127,26 @@ export default {
return ElMessageBox.confirm(
'该操作不可撤销,是否继续?',
'删除计划:' + data.name + '' + data.id + '',
'删除计划:' + data.name + ''+data.id+'',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
//
request.queryBreedingPlanRequest(data.id).then(response => {
if (response.data.data === null) {
this.refresh();
return ElMessage({
message: '该计划不存在,请刷新',
type: 'warning',
})
} else {
//
request.deleteBreedingPlanRequest(data.id).then(response => {
if (response.data.code === 1) {
// //
// this.getBreedingPlans()
// this.search()
//
this.refresh()
return ElMessage({
message: '删除成功',
//
ElMessage({
type: 'success',
})
} else {
return ElMessage({
message: '删除失败',
type: 'warning',
})
}
})
}
message: '删除成功',
})
}).catch(() => {
ElMessage({
@ -234,37 +160,40 @@ export default {
console.log('添加', data)
//
if (this.isEmpty(data)) {
return;
return this.isEmpty(data);
//
//
if (false) {
return ElMessage({
message: '该计划已存在',
type: 'warning',
})
}
request.addBreedingPlanRequest(data).then(response => {
if (response.data.code===1){
//
//
this.refresh()
this.dialog.addDialogVisible = false//
//
if (false) {
return ElMessage({
message: '添加成功',
type: 'success',
})
}else {
return ElMessage({
message: '添加失败',
type: 'warning',
})
}
})
// //
// this.getBreedingPlans()
// this.search()
//
this.refresh()
this.dialog.addDialogVisible = false//
},
//
isEmpty(form) {
if (!form.name || !form.species) {
if (!form.name) {
//
return ElMessage({
message: '计划名称或物种不能为空',
message: '计划名不能为空',
type: 'warning',
})
}
@ -307,7 +236,7 @@ export default {
//
handleCurrentChange(val) {
console.log('分页被切换', val)
console.log('分页被切换',val)
this.currentPage = val
this.getPagesData()
},
@ -320,26 +249,28 @@ export default {
},
//
refresh() {
refresh(){
console.log('刷新数据')
//
request.queryBreedingPlanRequest().then(response => {
if (response.data.code === 1) {
this.updateBreedingPlans(frontendBreedingPlans(response.data.data))
}
this.getBreedingPlans()
//
this.search()
//
this.getPagesData()
})
}
},
mounted() {
//
// //
// this.getBreedingPlans()
//
// //
// this.getPagesData()
this.refresh()
refreshData()
}
}
</script>
@ -347,7 +278,7 @@ export default {
<template>
<div class="breeding-root">
<div class="select">
<div class="left" v-if="loginUser.auth === 1">
<div class="left">
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加计划</el-button>
</div>
<div class="right">
@ -371,8 +302,7 @@ export default {
</div>
<div class="table">
<el-table :data="pagesData" style="width: 100%;height: 100%" border stripe :row-style="{height: '40px'}"
:cell-style="{padding:'0'}">
<el-table :data="pagesData" style="width: 100%;height: 100%" border stripe :row-style="{height: '40px'}" :cell-style="{padding:'0'}">
<el-table-column fixed prop="id" label="计划ID" width="70"/>
<el-table-column fixed prop="name" label="计划名称" width="150"/>
<el-table-column prop="roleId" label="执行饲养员" width="100"/>
@ -387,18 +317,15 @@ export default {
</template>
</el-table-column>
<el-table-column prop="description" label="计划描述" width="300"/>
<el-table-column fixed="right" label="操作" :width="operateWidth">
<el-table-column fixed="right" label="操作" width="190">
<template #default="scope">
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
档案
</el-button>
<el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情
</el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth===1">
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑
</el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth===1">
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除
</el-button>
</template>
@ -416,8 +343,7 @@ export default {
</div>
<!-- 添加饲养计划对话框-->
<el-dialog v-model="dialog.addDialogVisible" title="添加饲养计划" width="500" align-center draggable overflow
destroy-on-close>
<el-dialog v-model="dialog.addDialogVisible" title="添加饲养计划" width="500" align-center draggable overflow>
<ZooBreedingPlanFormDialog>
<template #default="scope">
<el-button @click="dialog.addDialogVisible = false">
@ -456,25 +382,6 @@ export default {
</template>
</ZooBreedingPlanFormDialog>
</el-dialog>
<!--查看动物所有记录-->
<el-dialog v-model="dialog.timelineDialogVisible" :title="'计划相关档案:'+dialog.dialogData.id" width="600" align-center
draggable overflow destroy-on-close>
<ZooArchiveTimeline :data="dialog.timelineData">
<!-- <template #operate="scope">-->
<!-- <el-button type="primary" link @click="showEdit(scope.archive)">编辑</el-button>-->
<!-- <el-button type="danger" link @click="delete_(scope.archive)">删除</el-button>-->
<!-- </template>-->
<template #footer>
<el-button type="primary" @click="$router.push('/panel/archive')">
跳转至动物档案
</el-button>
<el-button @click="dialog.timelineDialogVisible = false">
关闭
</el-button>
</template>
</ZooArchiveTimeline>
</el-dialog>
</template>
<style scoped>

View File

@ -1,10 +1,9 @@
<script>
import {Delete, DocumentAdd, Document, Edit, Search, Tickets, Timer} from "@element-plus/icons-vue";
import {mapActions, mapMutations, mapState} from "vuex";
import {copy, fuzzyMatching, refreshData, sortByDateTime, splitKeyWords} from "@/utils/common.js";
import {copy, fuzzyMatching, sortByDateTime, splitKeyWords} from "@/utils/common.js";
import ZooHealthFormDialog from "@/components/ZooHealthFormDialog.vue";
import ZooHealthTimeline from "@/components/ZooHealthTimeline.vue";
import request, {frontendHealth, frontendHealths} from "@/utils/request.js";
export default {
name: "ZooHealth",
@ -59,10 +58,7 @@ export default {
return Timer
},
//endregion
...mapState(["healths", 'healthsTableData','loginUser']),
operateWidth() {
return this.loginUser.auth===2?'250':'130'
}
...mapState(["healths", 'healthsTableData'])
},
watch: {
// ()
@ -79,26 +75,19 @@ export default {
}
},
methods: {
...mapMutations(['updateHealths','updateHealthsTableData']),
...mapActions(["getHealths"]),
...mapMutations(['updateHealthsTableData']),
//
showDetail(data) {
console.log('显示详情', data)
//
request.queryHealthRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh();
return ElMessage({
message: '该监测记录不存在,请刷新',
type: 'warning',
})
}else {
this.dialog.dialogData = frontendHealth(response.data.data)
//
this.dialog.dialogData = this.healths.find(e => e.id === data.id)
//
this.dialog.detailDialogVisible = true
}
})
},
//
@ -106,66 +95,45 @@ export default {
console.log('显示编辑', data)
//
request.queryHealthRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh();
return ElMessage({
message: '该监测记录不存在,请刷新',
type: 'warning',
})
}else {
this.dialog.dialogData = frontendHealth(response.data.data)
//
this.dialog.dialogData = this.healths.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true
}
})
},
edit(data) {
console.log('编辑', data)
//
if (this.isEmpty(data)) {
return;
}
return this.isEmpty(data);
//
//
request.queryHealthRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh();
this.dialog.editDialogVisible = false;
return ElMessage({
message: '该监测记录不存在,请刷新',
type: 'warning',
})
}else {
request.updateHealthRequest(data).then(response => {
if (response.data.code === 1) {
//
//
this.refresh()
request.queryHealthRequest(null,this.dialog.dialogData.animalId).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendHealths(response.data.data)
}
})
this.dialog.editDialogVisible = false//
return ElMessage({
message: '编辑成功',
type: 'success',
})
} else {
//
if (false) {
return ElMessage({
message: '编辑失败',
type: 'warning',
})
}
//
if (false) {
return ElMessage({
message: '编辑成功',
type: 'success',
})
}
})
// //
// this.getHealths()
// this.search()
//
this.refresh()
//
this.dialog.editDialogVisible = false
},
delete_(data) {
@ -181,38 +149,18 @@ export default {
}
).then(() => {
//
//
request.queryHealthRequest(data.id,null).then(response => {
if (response.data.data === null) {
this.refresh();
return ElMessage({
message: '该监测记录不存在,请刷新',
type: 'warning',
})
}else {
request.deleteHealthRequest(data.id).then(response => {
if (response.data.code === 1) {
//
//
this.refresh()
request.queryHealthRequest(null,this.dialog.dialogData.animalId).then(response => {
if (response.data.code===1){
this.dialog.timelineData = frontendHealths(response.data.data)
}
})
return ElMessage({
message: '删除成功',
// //
// this.getHealths()
// this.search()
//
this.refresh()
//
ElMessage({
type: 'success',
})
} else {
return ElMessage({
message: '删除失败',
type: 'warning',
})
}
})
}
message: '删除成功',
})
}).catch(() => {
ElMessage({
@ -226,53 +174,61 @@ export default {
console.log('添加', data)
//
if (this.isEmpty(data)) {
return;
return this.isEmpty(data);
//
//
if (false) {
return ElMessage({
message: '该记录已存在',
type: 'warning',
})
}
request.addHealthRequest(data).then(response => {
if (response.data.code === 1) {
//
//
this.refresh()
this.dialog.addDialogVisible = false//
if (false) {
return ElMessage({
message: '添加成功',
type: 'success',
})
} else {
return ElMessage({
message: '添加失败',
type: 'warning',
})
}
})
// //
// this.getHealths()
// this.search()
//
this.refresh()
this.dialog.addDialogVisible = false//
},
//线
showTimeline(data) {
console.log('显示时间线记录', data)
this.dialog.dialogData = data
//
//
this.dialog.dialogData = this.healths.find(e => e.id === data.id)
//
request.queryHealthRequest(null,data.animalId).then(response=>{
if (response.data.code === 1) {
this.dialog.timelineData = frontendHealths(response.data.data)
//
this.dialog.timelineDialogVisible = true
this.dialog.timelineData = []
//
//
this.healths.forEach(e => {
if (e.animalId === data.animalId) {
this.dialog.timelineData.push(copy(e))
}
})
//
this.dialog.timelineDialogVisible = true
},
//
isEmpty(form) {
if (!form.animalId||!form.animalName) {
if (!form.animalId) {
//
return ElMessage({
message: '动物ID或动物名称不能为空',
message: '记录的动物ID不能为空',
type: 'warning',
})
}
@ -355,10 +311,8 @@ export default {
console.log('刷新数据')
//
request.queryHealthRequest().then(response=>{
if (response.data.code===1){
this.updateHealths(frontendHealths(response.data.data))
}
this.getHealths()
//
this.search()
@ -367,13 +321,11 @@ export default {
//
this.getPagesData()
})
}
},
mounted() {
//
this.refresh()
refreshData()
},
}
</script>
@ -381,7 +333,7 @@ export default {
<template>
<div class="health-root">
<div class="select">
<div class="left" v-if="loginUser.auth===2">
<div class="left">
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加记录</el-button>
</div>
<div class="right">
@ -449,7 +401,7 @@ export default {
<el-table-column prop="date" label="记录日期" width="110"/>
<el-table-column prop="time" label="记录时间" width="90"/>
<el-table-column prop="description" label="记录描述" width="300"/>
<el-table-column fixed="right" label="操作" :width="operateWidth">
<el-table-column fixed="right" label="操作" width="250">
<template #default="scope">
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
追踪
@ -457,10 +409,10 @@ export default {
<el-button link type="primary" size="small" :icon="Document" @click="showDetail(scope.row)">
详情
</el-button>
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth===2">
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)">
编辑
</el-button>
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth===2">
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
删除
</el-button>
</template>
@ -478,8 +430,7 @@ export default {
</div>
<!-- 添加记录对话框-->
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow
destroy-on-close>
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow>
<ZooHealthFormDialog>
<template #default="scope">
<el-button @click="dialog.addDialogVisible = false">
@ -520,7 +471,7 @@ export default {
</el-dialog>
<!-- 查看动物所有记录-->
<el-dialog v-model="dialog.timelineDialogVisible" :title="'健康监测追踪'+dialog.dialogData.animalId" width="600" align-center draggable overflow
<el-dialog v-model="dialog.timelineDialogVisible" :title="'健康监测档案'+dialog.dialogData.animalId" width="600" align-center draggable overflow
destroy-on-close>
<ZooHealthTimeline :data="dialog.timelineData">
<template #operate="scope">

View File

@ -1,460 +1,24 @@
<script>
import {mapState} from "vuex";
import {Bell, Minus, Plus} from "@element-plus/icons-vue";
import {refreshData} from "@/utils/common.js";
export default {
name: "ZooHome",
data() {
return {
adminCount: 0,
keeperCount: 0,
veterinaryCount: 0,
speciesCount: 0,
normalCount: 0,
abnormalCount: 0,
foodCount: Math.floor((Math.random() * 201)),//
foodCapacity: 200,//
// breedingAnimalCount: 0,//
// healthAnimalCount: 0,//
// handleAnimalCount: 0,//
percentageColors: [
{color: '#f56c6c', percentage: 30},
{color: '#e6a23c', percentage: 60},
{color: '#5cb87a', percentage: 90},
],
childhoodCount: 0,//
adolescenceCount: 0,//
adulthoodCount: 0,//
oldCount: 0,//
}
},
watch: {
users: {
immediate: true,
handler(value) {
this.adminCount = 0
this.keeperCount = 0
this.veterinaryCount = 0
this.users.forEach(e => {
if (e.auth === 0) {
this.adminCount++
} else if (e.auth === 1) {
this.keeperCount++
} else if (e.auth === 2) {
this.veterinaryCount++
}
})
}
},
animals: {
immediate: true,
handler(value) {
this.speciesCount = 0
const speciesSet = new Set()
this.normalCount = 0
this.abnormalCount = 0
this.childhoodCount = 0
this.adolescenceCount = 0
this.adulthoodCount = 0
this.oldCount = 0
this.animals.forEach(e => {
speciesSet.add(e.species)
if (e.state === 0) {
this.normalCount++
} else if (e.state === 1) {
this.abnormalCount++
}
if (e.phase === '幼年期') {
this.childhoodCount++
} else if (e.phase === '成长期') {
this.adolescenceCount++
} else if (e.phase === '成年期') {
this.adulthoodCount++
} else if (e.phase === '老年期') {
this.oldCount++
}
})
this.speciesCount = speciesSet.size
this.breedingAnimalCount = Number((Math.random() * this.animals.length).toFixed(0))
}
}
},
computed: {
Bell() {
return Bell
},
Plus() {
return Plus
},
Minus() {
return Minus
},
breedingAnimalCount(){//
let count = 0;
const newDate = new Date()
this.archives.forEach(e => {
if (e.type === '日常饲养' && e.date === (newDate.getFullYear() + '-' + (newDate.getMonth()+1).toString().padStart(2, '0') + '-' + newDate.getDate().toString().padStart(2, '0'))) {
count++
}
})
return count;
},
healthAnimalCount(){
let count = 0;
const newDate = new Date()
this.healths.forEach(e => {
if (e.date === (newDate.getFullYear() + '-' + (newDate.getMonth()+1).toString().padStart(2, '0') + '-' + newDate.getDate().toString().padStart(2, '0'))) {
count++
}
})
return count;
},
handleAnimalCount(){
let count = 0;
const newDate = new Date()
this.archives.forEach(e => {
if (e.type === '疾病治疗' && e.date === (newDate.getFullYear() + '-' + (newDate.getMonth()+1).toString().padStart(2, '0') + '-' + newDate.getDate().toString().padStart(2, '0'))) {
count++
}
})
return count;
},
...mapState(["users", 'animals', 'loginUser', 'archives','healths']),
},
methods: {
decreaseFood() {
if (this.foodCount > 0) {
this.foodCount--
}
},
increaseFood() {
if (this.foodCount < this.foodCapacity) {
this.foodCount++
}
},
decreaseBreeding(){
if (this.breedingAnimalCount > 0) {
this.breedingAnimalCount--
}
},
increaseBreeding(){
if (this.breedingAnimalCount < this.animals.length) {
this.breedingAnimalCount++
}
},
decreaseHealth(){
if (this.healthAnimalCount > 0) {
this.healthAnimalCount--
}
},
increaseHealth(){
if (this.healthAnimalCount < this.animals.length) {
this.healthAnimalCount++
}
},
decreaseHandle(){
if (this.handleAnimalCount > 0) {
this.handleAnimalCount--
}
},
increaseHandle(){
if (this.handleAnimalCount < this.abnormalCount) {
this.handleAnimalCount++
}
},
notify(msg){
return ElMessage({
message: '已通知'+msg,
type: 'success',
})
}
},
mounted() {
refreshData()
}
}
</script>
<template>
<div id="home-root">
<div class="statistics" style="padding-bottom: 20px">
<el-row>
<el-col :span="24">
<div class="title">用户统计</div>
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<el-statistic title="系统用户总数" :value="users.length"/>
</el-col>
<el-col :span="6">
<el-statistic :value="adminCount" :value-style="{color:'#409EFF'}">
<template #title>
<span style="color: #409EFF">管理员数量</span>
</template>
<template #suffix>
<span style="color: #409EFF" v-if="users.length===0">(0%)</span>
<span style="color: #409EFF" v-else>
({{ (adminCount / users.length * 100).toFixed(1) }}%)
</span>
</template>
</el-statistic>
</el-col>
<el-col :span="6">
<el-statistic :value="keeperCount" :value-style="{color:'#67C23A'}">
<template #title>
<span style="color: #67C23A">饲养员数量</span>
</template>
<template #suffix>
<span style="color: #67C23A" v-if="users.length===0">(0%)</span>
<span style="color: #67C23A" v-else>
({{ (keeperCount / users.length * 100).toFixed(1) }}%)
</span>
</template>
</el-statistic>
</el-col>
<el-col :span="6">
<el-statistic :value="veterinaryCount" :value-style="{color:'#E6A23C'}">
<template #title>
<span style="color: #E6A23C">兽医数量</span>
</template>
<template #suffix>
<span style="color: #E6A23C" v-if="users.length===0">(0%)</span>
<span style="color: #E6A23C" v-else>
({{ (veterinaryCount / users.length * 100).toFixed(1) }}%)
</span>
</template>
</el-statistic>
</el-col>
</el-row>
</div>
<div class="statistics" style="margin-bottom: 0">
<el-row>
<el-col :span="24">
<div class="title">动物统计</div>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-row>
<el-col :span="6">
<el-statistic title="动物总数" :value="animals.length"/>
</el-col>
<el-col :span="6">
<el-statistic :value="speciesCount" title="动物种类"/>
</el-col>
<el-col :span="6">
<el-statistic :value="normalCount" :value-style="{color:'#67C23A'}">
<template #title>
<span style="color: #67C23A">健康动物</span>
</template>
<template #suffix>
<span style="color: #67C23A" v-if="animals.length===0">(0%)</span>
<span style="color: #67C23A" v-else>({{ (normalCount / animals.length * 100).toFixed(1) }}%)</span>
</template>
</el-statistic>
</el-col>
<el-col :span="6">
<el-statistic :value="abnormalCount" :value-style="{color:'#f56c6c'}">
<template #title>
<span style="color: #f56c6c">异常动物</span>
</template>
<template #suffix>
<span style="color: #f56c6c" v-if="animals.length===0">(0%)</span>
<span style="color: #f56c6c" v-else>({{ (abnormalCount / animals.length * 100).toFixed(1) }}%)</span>
</template>
</el-statistic>
</el-col>
</el-row>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<div class="statistics">
<el-row>
<el-col :span="24">
<div class="title">日常统计</div>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-progress type="dashboard" :percentage="Number((breedingAnimalCount/animals.length*100).toFixed(1))"
:color="percentageColors">
<template #default="{ percentage }">
<span class="percentage-label">今日饲养进度</span>
<span class="percentage-value" v-if="!percentage">0%</span>
<span class="percentage-value" v-else>{{ percentage }}%</span>
<span class="percentage-label">{{ breedingAnimalCount }}/{{ animals.length }}</span>
<span v-if="percentage>=0 && (loginUser.auth === 0 || loginUser.auth === 1)">
<!-- <el-button :icon="Minus" @click="decreaseBreeding" size="small" style="width: 10px"/>-->
<!-- <el-button :icon="Plus" @click="increaseBreeding" size="small" style="width: 10px"/>-->
<el-button :icon="Bell" @click="notify('饲养员')" size="small" style="width: 80px">通知饲养员</el-button>
</span>
</template>
</el-progress>
</el-col>
<el-col :span="12">
<el-progress type="dashboard" :percentage="Number((foodCount/foodCapacity*100).toFixed(1))"
:color="percentageColors">
<template #default="{ percentage }">
<span class="percentage-label">食物库存</span>
<span class="percentage-value">{{ percentage }}%</span>
<span class="percentage-label">{{ foodCount }}/{{ foodCapacity }}</span>
<span v-if="percentage>=0 && (loginUser.auth === 0 || loginUser.auth === 1)">
<!-- <el-button :icon="Minus" @click="decreaseFood" size="small" style="width: 10px"/>-->
<!-- <el-button :icon="Plus" @click="increaseFood" size="small" style="width: 10px"/>-->
<el-button :icon="Bell" @click="notify('饲养员')" size="small" style="width: 80px">通知饲养员</el-button>
</span>
</template>
</el-progress>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-progress type="dashboard" :percentage="Number((healthAnimalCount/animals.length*100).toFixed(1))"
:color="percentageColors">
<template #default="{ percentage }">
<span class="percentage-label">今日监测进度</span>
<span class="percentage-value" v-if="!percentage">0%</span>
<span class="percentage-value" v-else>{{ percentage }}%</span>
<span class="percentage-label">{{ healthAnimalCount }}/{{ animals.length }}</span>
<span v-if="percentage>=0 && (loginUser.auth === 0 || loginUser.auth === 2)">
<!-- <el-button :icon="Minus" @click="decreaseHealth" size="small" style="width: 10px"/>-->
<!-- <el-button :icon="Plus" @click="increaseHealth" size="small" style="width: 10px"/>-->
<el-button :icon="Bell" @click="notify('兽医')" size="small" style="width: 80px">通知兽医</el-button>
</span>
</template>
</el-progress>
</el-col>
<el-col :span="12">
<el-progress type="dashboard" :percentage="Number((handleAnimalCount/abnormalCount*100).toFixed(1))"
:color="percentageColors">
<template #default="{ percentage }">
<span class="percentage-label">异常处理进度</span>
<span class="percentage-value" v-if="!percentage">0%</span>
<span class="percentage-value" v-else>{{ percentage }}%</span>
<span class="percentage-label">{{ handleAnimalCount }}/{{ abnormalCount }}</span>
<span v-if="percentage>=0 && (loginUser.auth === 0 || loginUser.auth === 2)">
<!-- <el-button :icon="Minus" @click="decreaseHandle" size="small" style="width: 10px"/>-->
<!-- <el-button :icon="Plus" @click="increaseHandle" size="small" style="width: 10px"/>-->
<el-button :icon="Bell" @click="notify('兽医')" size="small" style="width: 80px">通知兽医</el-button>
</span>
</template>
</el-progress>
</el-col>
</el-row>
</div>
</el-col>
<el-col :span="12">
<div class="statistics">
<el-row>
<el-col :span="24">
<div class="title">生命阶段统计</div>
</el-col>
</el-row>
<el-row style="padding: 40px 0">
<el-col :span="12">
<el-statistic :value="childhoodCount" :value-style="{color:'#67C23A'}">
<template #title>
<span style="color: #67C23A">幼年期</span>
</template>
<template #suffix>
<span style="color: #67C23A" v-if="animals.length===0">(0%)</span>
<span style="color: #67C23A" v-else>({{ (childhoodCount / animals.length * 100).toFixed(1) }}%)</span>
</template>
</el-statistic>
</el-col>
<el-col :span="12">
<el-statistic :value="adolescenceCount" :value-style="{color:'#409EFF'}">
<template #title>
<span style="color: #409EFF">成长期</span>
</template>
<template #suffix>
<span style="color: #409EFF" v-if="animals.length===0">(0%)</span>
<span style="color: #409EFF" v-else>({{ (adolescenceCount / animals.length * 100).toFixed(1) }}%)</span>
</template>
</el-statistic>
</el-col>
</el-row>
<el-row style="padding: 40px 0">
<el-col :span="12">
<el-statistic :value="adulthoodCount" :value-style="{color:'#E6A23C'}">
<template #title>
<span style="color: #E6A23C">成年期</span>
</template>
<template #suffix>
<span style="color: #E6A23C" v-if="animals.length===0">(0%)</span>
<span style="color: #E6A23C" v-else>({{ (adulthoodCount / animals.length * 100).toFixed(1) }}%)</span>
</template>
</el-statistic>
</el-col>
<el-col :span="12">
<el-statistic :value="oldCount" :value-style="{color:'#909399'}">
<template #title>
<span style="color: #909399">老年期</span>
</template>
<template #suffix>
<span style="color: #909399" v-if="animals.length===0">(0%)</span>
<span style="color: #909399" v-else>({{ (oldCount / animals.length * 100).toFixed(1) }}%)</span>
</template>
</el-statistic>
</el-col>
</el-row>
</div>
</el-col>
</el-row>
</div>
<div>
这是home界面
</div>
</template>
<style scoped>
#home-root {
margin: 20px;
background-color: white;
border: gray 1px solid;
}
.statistics {
border: darkgray 1px solid;
margin: 20px;
}
.title {
margin-top: 10px;
font-size: 20px;
}
.statistics, .title {
text-align: center;
}
.percentage-value {
display: block;
margin-top: 10px;
font-size: 28px;
}
.percentage-label {
display: block;
margin-top: 10px;
font-size: 12px;
}
.clear::after {
content: "";
clear: both;
display: block;
}
</style>

View File

@ -1,6 +1,6 @@
<script>
import {mapMutations, mapState} from "vuex";
import request, {frontendLoginUser} from "@/utils/request.js";
import {mapMutations,mapState,mapActions} from "vuex";
export default {
name: "ZooContainer",
@ -8,25 +8,20 @@ export default {
return {
//
form: {
username: 'admin',
username: '',
password: '123456',
},
picture: [
'https://www4.bing.com//th?id=OHR.BambooPanda_ZH-CN8455481760_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp',
'https://www4.bing.com//th?id=OHR.PolarBearCubs_ZH-CN2913942257_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp',
'https://www4.bing.com//th?id=OHR.WhiteEyes_ZH-CN1130380430_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp',
'https://www4.bing.com//th?id=OHR.ZebraCousins_ZH-CN8159888859_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp'
]
}
}
},
computed: {
...mapState(['loginUser'])
},
methods: {
...mapActions(['getLoginUser']),
...mapMutations(['updateLoginUser']),
//
login() {
console.log('点击登录', this.form)
console.log('登录',this.form)
//
if (!this.form.username || !this.form.password) {
//
@ -36,25 +31,16 @@ export default {
})
}
//
request.login(this.form).then(response => {
if (response.data.code === 1) {
//
this.updateLoginUser(frontendLoginUser(response.data.data))
localStorage.setItem('username', response.data.data.username);//
//
this.getLoginUser(this.form)//
//
if (this.loginUser) {
localStorage.setItem('username', this.loginUser.username);//
//
this.$router.push('/panel/home')
return ElMessage({
message: '登录成功',
type: 'success',
})
} else {
return ElMessage({
message: '用户名不存在或密码错误',
type: 'error',
})
}
})
},
//
reset() {
@ -63,34 +49,29 @@ export default {
},
mounted() {
//退
// this.updateLoginUser('');
this.updateLoginUser('');
// //
// this.form.username = localStorage.getItem('username');
//
this.form.username = localStorage.getItem('username');
}
}
</script>
<template>
<div id="login-root">
<!-- 背景图片-->
<div>
<el-carousel motion-blur height="700px" style="width: auto;">
<el-carousel-item v-for="(item,index) in picture" :key="index" style="text-align: center">
<img :src="item" width="auto" height="100%"/>
<!-- 背景图片-->
<el-carousel height="400px" motion-blur>
<el-carousel-item v-for="item in 4" :key="item">
<h3 class="small justify-center" text="2xl">{{ item }}</h3>
</el-carousel-item>
</el-carousel>
</div>
<!-- 登录表单-->
<!-- 登录表单-->
<div class="center">
<el-card style="width: 350px" shadow="always">
<template #header>
<div style="text-align: center;font-size: 25px">登录</div>
</template>
<el-form :model="form" label-width="auto" style="width: 400px">
<el-card style="width: 480px" shadow="always" header="登录">
<el-form :model="form" label-width="auto" style="max-width: 600px">
<el-form-item label="用户名">
<el-input v-model="form.username" style="width: 240px" placeholder="请输入用户名" id="username"/>
<el-input v-model="form.username" style="width: 240px" placeholder="请输入用户名"/>
</el-form-item>
<el-form-item label="密码">
<el-input
@ -99,11 +80,10 @@ export default {
type="password"
placeholder="请输入密码"
show-password
id="password"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="login" id="login-button">登录</el-button>
<el-button type="primary" @click="login">登录</el-button>
<el-button @click="reset">重置</el-button>
</el-form-item>
</el-form>
@ -117,10 +97,6 @@ export default {
#login-root {
width: 100%;
height: 700px;
background-color: aliceblue;
}
.center {
opacity: 0.95;
background-color: skyblue;
}
</style>

View File

@ -3,8 +3,6 @@ import ZooHeader from "@/components/ZooHeader.vue";
import ZooAside from "@/components/ZooAside.vue";
import ZooMain from "@/components/ZooMain.vue";
import ZooFooter from "@/components/ZooFooter.vue";
import {mapActions} from "vuex";
import {refreshData} from "@/utils/common.js";
export default {
name: "ZooPanel",
@ -16,24 +14,15 @@ export default {
}
},
methods: {
...mapActions(['getUsers','getAnimals','getArchives','getBreedingPlans','getHealths'])
},
components: {
ZooHeader,
ZooAside,
ZooMain,
ZooFooter
},
mounted() {
console.log("登录用户",this.$store.state.loginUser)
//
// this.getUsers();
// this.getAnimals();
// this.getBreedingPlans();
// this.getArchives();
// this.getHealths();
refreshData()
}
}
</script>
@ -61,15 +50,15 @@ export default {
top: 0;
}
.footer {
height: 20px;
height: 30px;
bottom: 0;
text-align: center;
line-height: 20px;
line-height: 30px;
background-color: lightgray;
}
.main {
/*有footer*/
height: 616px;
height: 606px;
/*没footer*/
/*height: 636px;*/

View File

@ -2,8 +2,7 @@
import {Delete, Edit, Search, User, Document} from "@element-plus/icons-vue";
import {mapState, mapActions, mapMutations} from "vuex";
import ZooUserFormDialog from "@/components/ZooUserFormDialog.vue";
import {copy, fuzzyMatching, splitKeyWords, showPassword, hidePassword, refreshData} from "@/utils/common.js";
import request, {frontendUser, frontendUsers} from "@/utils/request.js";
import {copy, fuzzyMatching, splitKeyWords, showPassword, hidePassword} from "@/utils/common.js";
export default {
@ -28,7 +27,7 @@ export default {
addDialogVisible: false,//
editDialogVisible: false,//
detailDialogVisible: false,//
},
}
}
},
computed: {
@ -58,6 +57,7 @@ export default {
searchInput: {
deep: true,
handler(val) {
// this.search()
this.refresh();
}
}
@ -66,26 +66,18 @@ export default {
hidePassword,
showPassword,
...mapActions(['getUsers']),
...mapMutations(['updateUsers','updateUsersTableData']),
...mapMutations(['updateUsersTableData']),
//
showDetail(data) {
console.log('显示详情', data)
//
request.queryUserRequest(data.username).then(response => {
if (response.data.data === null) {
this.refresh()
return ElMessage({
message: '该用户不存在,请刷新',
type: 'warning',
})
}else {
this.dialog.dialogData = frontendUser(response.data.data)
//
//
this.dialog.dialogData = this.users.find(e => e.username === data.username)
//
this.dialog.detailDialogVisible = true
}
})
},
//
@ -93,61 +85,45 @@ export default {
console.log('编辑弹窗', data)
//
request.queryUserRequest(data.username).then(response => {
if (response.data.data === null) {
this.refresh()
return ElMessage({
message: '该用户不存在,请刷新',
type: 'warning',
})
}else {
this.dialog.dialogData = frontendUser(response.data.data)
//
this.dialog.dialogData = this.users.find(e => e.id === data.id)
//
this.dialog.editDialogVisible = true
}
})
},
edit(data) {
console.log('编辑', data)
//
if (this.isEmpty(data)) {
return;
}
return this.isEmpty(data);
//
//
request.queryUserRequest(data.username).then(response => {
if (response.data.data === null) {
this.refresh()
this.dialog.editDialogVisible = false;
//
if (false) {
return ElMessage({
message: '该用户不存在,请刷新',
message: '编辑失败',
type: 'warning',
})
}else {
request.updateUserRequest(data).then(response => {
if (response.data.code===1){
//
//
this.refresh()
this.dialog.editDialogVisible = false//
}
//
if (false) {
return ElMessage({
message: '编辑成功',
type: 'success',
})
}else {
return ElMessage({
message: '编辑失败,无权限',
type: 'warning',
})
}
})
}
})
// //
// this.getUsers()
// this.search()
//
this.refresh()
//
this.dialog.editDialogVisible = false
},
delete_(data) {
@ -162,34 +138,19 @@ export default {
type: 'warning',
}
).then(() => {
//
request.queryUserRequest(data.username).then(response => {
if (response.data.data===null){
this.refresh();
return ElMessage({
message: '该用户不存在,请刷新',
type: 'warning',
})
}else {
//
request.deleteUserRequest(data.id).then(response => {
if (response.data.code===1){
// //
// this.getUsers()
// this.search()
//
this.refresh()
//
return ElMessage({
message: '删除成功',
//
ElMessage({
type: 'success',
})
}else {
return ElMessage({
message: '删除失败,无权限',
type: 'warning',
})
}
})
}
message: '删除成功',
})
}).catch(() => {
ElMessage({
@ -203,39 +164,33 @@ export default {
console.log('添加', data)
//
if (this.isEmpty(data)) {
return;
}
return this.isEmpty(data);
//
request.queryUserRequest(data.username).then(response => {
if (response.data.data!==null){
//
if (false) {
return ElMessage({
message: '用户名重复',
message: '该用户已存在',
type: 'warning',
})
}else {
}
//
request.addUserRequest(data).then(response => {
if (response.data.code===1){
//
this.refresh()
this.dialog.addDialogVisible = false//
if (false) {
return ElMessage({
message: '添加成功',
type: 'success',
})
}else {
return ElMessage({
message: '添加失败',
type: 'warning',
})
}
})
}
})
// //
// this.getUsers()
// this.search()
//
this.refresh()
this.dialog.addDialogVisible = false//
},
//
@ -303,21 +258,23 @@ export default {
console.log('刷新数据')
//
request.queryUserRequest().then(response => {
if (response.data.code === 1) {
this.updateUsers(frontendUsers(response.data.data))
}
this.getUsers()
//
this.search()
//
this.getPagesData()
})
}
},
mounted() {
// //
// this.getUsers()
//
// //
// this.getPagesData()
this.refresh()
refreshData();
},
}
</script>
@ -384,7 +341,7 @@ export default {
</el-table>
</div>
<!-- 分页-->
<!-- 分页-->
<div class="pager relative">
<div class="center">
<el-pagination background layout="total, prev, pager, next, jumper" :total="usersTableData.length"
@ -396,8 +353,7 @@ export default {
<!-- 添加用户对话框-->
<el-dialog v-model="dialog.addDialogVisible" title="添加用户" width="400" align-center draggable overflow
destroy-on-close>
<el-dialog v-model="dialog.addDialogVisible" title="添加用户" width="400" align-center draggable overflow>
<ZooUserFormDialog>
<template #default="scope">
<el-button @click="dialog.addDialogVisible = false">

View File

@ -13,52 +13,50 @@ export default {
methods: {
...mapMutations(['updateUsers', 'updateAnimals', 'updateBreedingPlans', 'updateArchives','updateHealths']),
usersData() {
generateUsers()
this.updateUsers(generateUsers())
return ElMessage({
message: '成功',
type: 'success',
})
},
animalsData() {
generateAnimals()
this.updateAnimals(generateAnimals())
return ElMessage({
message: '成功',
type: 'success',
})
},
breedingPlansData() {
generateBreedingPlans()
this.updateBreedingPlans(generateBreedingPlans())
return ElMessage({
message: '成功',
type: 'success',
})
},
archiveData() {
generateArchives()
this.updateArchives(generateArchives())
return ElMessage({
message: '成功',
type: 'success',
})
},
healthData() {
generateHealths()
this.updateHealths(generateHealths())
return ElMessage({
message: '成功',
type: 'success',
})
},
}
}
}
</script>
<template>
生成数据最好先确保数据库中的各表没有数据再使用使用方法从左到右依次点击每点击应该需等到弹出成功提示才继续点击下一个
<hr />
<el-button type="primary" @click="usersData">生成用户信息预计需要5秒左右</el-button>
<el-button type="primary" @click="animalsData">生成动物信息预计需要5秒左右</el-button>
<el-button type="primary" @click="breedingPlansData">生成饲养计划信息预计需要10秒左右</el-button>
<el-button type="primary" @click="archiveData">生成档案信息预计需要5分钟左右</el-button>
<el-button type="primary" @click="healthData">生成健康监测信息预计需要5分钟左右</el-button>
<el-button type="primary" @click="usersData">生成用户信息</el-button>
<el-button type="primary" @click="animalsData">生成动物信息</el-button>
<el-button type="primary" @click="breedingPlansData">生成饲养计划信息</el-button>
<el-button type="primary" @click="archiveData">生成档案信息</el-button>
<el-button type="primary" @click="healthData">生成健康监测信息</el-button>
<el-button type="primary" @click="$router.push('/login')">跳转登录</el-button>
</template>

View File

@ -76,9 +76,7 @@ router.beforeEach((to, from, next) => {
//不是登录界面都需要权限。。。
// console.log(to, from, next);
if (to.path !== '/login') {
if (to.path==='/data'){
next()
}else if (!store.state.loginUser.username) {
if (!store.state.loginUser) {
router.replace({
path: '/login',
})

View File

@ -1,64 +1,55 @@
import {createStore} from "vuex";
import {copy} from "@/utils/common.js";
import request, {
frontendAnimals,
frontendArchives,
frontendBreedingPlans,
frontendHealths,
frontendUsers
} from "@/utils/request.js";
import {copy, generateAnimals, generateArchives, generateBreedingPlans, generateUsers} from "@/utils/common.js";
const actions = {
//获取登录用户
getLoginUser(context, user) {
//此处接入后端登录接口验证登录用户名和密码,验证通过方可通行
//密码错误
if (false) {
return ElMessage({
message: '用户名不存在或密码错误',
type: 'error',
})
}
//登录成功
context.commit('updateLoginUser', user);//存储登录用户,这里拉取远程登录的用户作为参数
},
//获取用户数据
getUsers(context) {
console.log('getUsers')
//通过后端获取数据
request.queryUserRequest().then(response => {
if (response.data.code === 1) {
context.commit('updateUsers', frontendUsers(response.data.data));
}
})
// context.commit('updateUsers', generateUsers())
context.commit('updateUsers', context.state.users);
},
//获取动物数据
getAnimals(context) {
console.log('getAnimals')
// 通过后端获取数据
request.queryAnimalRequest().then(response => {
if (response.data.code === 1) {
context.commit('updateAnimals', frontendAnimals(response.data.data));
}
})
// context.commit('updateAnimals', generateAnimals())
context.commit('updateAnimals', context.state.animals);
},
//获取饲养计划
getBreedingPlans(context) {
console.log('getBreedingPlans')
// 通过后端获取数据
request.queryBreedingPlanRequest().then(response => {
if (response.data.code === 1) {
context.commit('updateBreedingPlans',frontendBreedingPlans(response.data.data));
}
})
// context.commit('updateBreedingPlans',generateBreedingPlans())
context.commit('updateBreedingPlans',context.state.breedingPlans);
},
//获取动物档案
getArchives(context) {
console.log('getArchives')
// 通过后端获取数据
request.queryArchiveRequest().then(response => {
if (response.data.code === 1) {
context.commit('updateArchives',frontendArchives(response.data.data));
}
})
// context.commit('updateArchives', generateArchives())
context.commit('updateArchives',context.state.archives);
},
//获取监控检测数据
getHealths(context) {
console.log('getHealths')
// 通过后端获取数据
request.queryHealthRequest().then(response => {
if (response.data.code === 1) {
context.commit('updateHealths',frontendHealths(response.data.data));
}
})
// context.commit('updateHealths', generateHealths())
context.commit('updateHealths',context.state.healths);
}
}
@ -127,9 +118,17 @@ const state = {
//登录用户数据
loginUser: {
id:0,
username: '',
username: 'user1',
auth: 0
},
// //用户数据
// users: [],
// //动物数据
// animals: [],
// //饲养计划
// breedingPlans:[],
// //动物档案
// archives:[],
//用户数据
users: [],
usersTableData:[],//用户表格数据
@ -147,37 +146,8 @@ const state = {
healthsTableData:[],//健康检测表格数据
}
const getters = {
getKeepers() {
const k = []
state.users.forEach(user => {
if (user.auth === 1){
k.push(copy(user))
}
})
return k;
},
getAllSpecies() {
const set = new Set
state.animals.forEach(e => {
set.add(e.species)
})
return set
},
getKeepersAndVeterinary() {
const ka = []
state.users.forEach(user => {
if (user.auth === 1 || user.auth === 2){
ka.push(copy(user))
}
})
return ka
}
}
export default createStore({
actions,
mutations,
state,
getters
state
})

View File

@ -1,30 +1,20 @@
//生成用户数据
import store from "@/store/index.js";
import request from "@/utils/request.js";
export function refreshData() {
store.dispatch('getUsers');
store.dispatch('getAnimals');
store.dispatch('getBreedingPlans');
store.dispatch('getArchives');
store.dispatch('getHealths');
}
// 生成用户数据
export function generateUsers() {
const users = []
// 随机生成20-40条用户数据
const n = Math.floor(Math.random() * 20) + 20;
// 随机生成40-100条用户数据
const n = Math.floor(Math.random() * 60) + 40;
for (let i = 0; i < n; i++) {
const a = generateAuth()
let user = {
id: i + 2,
username: 'user' + (i + 2),
id: i,
username: 'user' + (i + 1),
password: '123456',
auth: a,
}
users.push(user)
request.addUserRequest(user)
if (a === 1) {
keeper.push(user)
} else if (a === 2) {
@ -52,11 +42,11 @@ function generateAuth() {
//生成动物数据
export function generateAnimals() {
const animals = []
//随机生成40-60只动物
const n = Math.floor(Math.random() * 20) + 40;
//随机生成100-200只动物
const n = Math.floor(Math.random() * 100) + 100;
for (let i = 0; i < n; i++) {
let animal = {
id: i + 3,
id: i,
name: 'animal' + (i + 1),
sex: Math.floor(Math.random() * 2) === 0 ? '雌性' : '雄性',
species: '种类' + Math.ceil(Math.random() * 20).toString(),//种类
@ -68,11 +58,9 @@ export function generateAnimals() {
features: 'test animal' + (i + 1) + ' features',//特征
phase: generatePhase()
}
request.addAnimalRequest(animal)
animals.push(animal)
}
console.log('动物', animals)
store.state.animals = animals
return animals
}
@ -141,8 +129,8 @@ function generateNewColor() {
export function generateBreedingPlans() {
const breedingPlans = []
//随机生成5种类动物的饲养计划
const n = 5;
//随机生成20种类动物的饲养计划
const n = 20;
for (let i = 0; i < n; i++) {
//分别生成2种性别的
for (let j = 0; j < 2; j++) {
@ -151,7 +139,7 @@ export function generateBreedingPlans() {
//分别生成2种状态的
for (let l = 0; l < 2; l++) {
let breedingPlan = {
// id: i + '' + j + '' + k + '' + l,
id: i + '' + j + '' + k + '' + l,
name: 'breeding' + (i + 1),
species: '种类' + i.toString(),
sex: j === 0 ? '雌性' : '雄性',
@ -160,7 +148,6 @@ export function generateBreedingPlans() {
roleId: generateKeeperId(),
description: 'test breeding' + i + '' + j + '' + k + '' + l + ' description',
}
request.addBreedingPlanRequest(breedingPlan)
breedingPlans.push(breedingPlan)
}
}
@ -184,30 +171,30 @@ function generatePhase() {
}
//生成档案
export async function generateArchives() {
export function generateArchives() {
const archives = []
let aid = 0
for (const e of store.state.animals) {
let aid=0
store.state.animals.forEach(e => {
//分为四个周期的档案
for (let i = 0; i < 4; i++) {
let n;
if (i === 0) {
//幼年期5条档案
n = 5
//幼年期5-10条档案
n = Math.floor(Math.random() * 5) + 5
} else if (i === 1) {
//成长期10条档案
n = 10
//成长期10-20条档案
n = Math.floor(Math.random() * 10) + 10
} else if (i === 2) {
//成年期30条档案
n = 30
//成年期30-60条档案
n = Math.floor(Math.random() * 30) + 30
} else {
//老年期5条档案
n = 5
//老年期5-10条档案
n = Math.floor(Math.random() * 5) + 5
}
for (let j = 0; j < n; j++) {
let archive = {
// id: aid,//档案号
id: aid,//档案号
animalId: e.id,//该档案记录的动物id
animalName: e.name,//该档案记录的动物名称
phase: i === 0 ? '幼年期' : i === 1 ? '成长期' : i === 2 ? '成年期' : '老年期',
@ -218,17 +205,16 @@ export async function generateArchives() {
roleId: generateVeterinaryId(),//负责录入档案的人的id身份不限
description: 'test archive' + i + '' + j + ' description',
}
request.addArchiveRequest(archive)
archives.push(archive)
//同时获取一条健康记录
let health = {
// id: aid,//int 健康检测数据号
id: aid,//int 健康检测数据号
animalId: archive.animalId,//int 记录的动物id
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,//字符 记录日期
@ -236,35 +222,28 @@ export async 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() {
@ -311,7 +290,7 @@ export function hidePassword(event) {
export function splitKeyWords(keyword) {
let keyset = keyword.split(' ')//提取关键字
keyset = Array.from(new Set(keyset))//关键字去重
// console.log('切割去重好的关键字', keyset)
console.log('切割去重好的关键字', keyset)
return keyset;
}
@ -328,7 +307,7 @@ export function fuzzyMatching(object, keyset) {
function keywordMatching(object, keyword) {
//该关键字为空,肯定能匹配上
if (keyword === '') {
// console.log('keywordMatching关键字为空', object, keyword, true)
console.log('keywordMatching关键字为空', object, keyword, true)
return true
}
//只要对象的任意属性能匹配一次关键字就返回truesome():遇到true就返回true所有false就返回false

View File

@ -1,278 +1,7 @@
import axios from "axios";
import store from "@/store/index.js";
const instance = axios.create({
// baseURL : `${window.location.origin}/api/zoo`,
baseURL : `${window.location.origin}/api/zoo`,
})
export function getUserById(id) {
const data = store.state.users.find(e => e.id === id);
export default {
login(form) {
const formData = new FormData();
formData.append('username', form.username);
formData.append('password', form.password);
return instance.post("/login/login", formData);
},
//用户请求
addUserRequest(user) {
return instance.post("/account/save", backendUser(user));
},
deleteUserRequest(id) {
return instance.get("/account/delete", {params: {id}});
},
updateUserRequest(user) {
return instance.post("/account/update", backendUser(user));
},
queryUserRequest(username) {
return instance.get("/account/info", {params: {username}})
},
//动物请求
addAnimalRequest(animal) {
return instance.post("/animal/add", backendAnimal(animal));
},
deleteAnimalRequest(aid) {
return instance.get("/animal/delete", {params: {aid}});
},
updateAnimalRequest(animal) {
return instance.post("/animal/update", backendAnimal(animal));
},
queryAnimalRequest(aid) {
return instance.get("/animal/info", {params: {aid}})
},
//饲养计划请求
addBreedingPlanRequest(breedingPlan) {
return instance.post("/plan/add", backendBreeding(breedingPlan));
},
deleteBreedingPlanRequest(id) {
return instance.get("/plan/delete", {params: {id}})
},
updateBreedingPlanRequest(breedingPlan) {
return instance.post("/plan/update", backendBreeding(breedingPlan));
},
queryBreedingPlanRequest(id) {
return instance.get("/plan/info", {params: {id}})
},
//档案请求
addArchiveRequest(archive) {
return instance.post("/archive/add", backendArchive(archive));
},
deleteArchiveRequest(id) {
return instance.get("/archive/delete", {params: {id}})
},
updateArchiveRequest(archive) {
return instance.post("/archive/update", backendArchive(archive));
},
queryArchiveRequest(id, animallId) {
return instance.get("/archive/info", {params: {id, animallId}})
},
queryArchiveByBreedingId(breedingId) {
return instance.get("/archive/selectByBreedingId", {params: {breedingId}})
},
//健康记录请求
addHealthRequest(health) {
return instance.post("/health/add", backendHealth(health));
},
deleteHealthRequest(id) {
return instance.get("/health/delete", {params: {id}})
},
updateHealthRequest(health) {
return instance.post("/health/update", backendHealth(health));
},
queryHealthRequest(id,animalId) {
return instance.get("/health/info", {params: {id,animalId}})
}
}
// 将后端对象转化为符合前端需求的对象
export function frontendLoginUser(data) {
return {
id: data.id,
username: data.username,
auth: data.permissions
};
}
export function frontendUsers(users) {
const newUsers = []
users.forEach(user => {
newUsers.push(frontendUser(user));
})
return newUsers
}
export function frontendUser(user) {
return {
id: user.id,
username: user.username,
password: user.password,
auth: user.permissions
}
}
export function frontendAnimals(animals) {
const newAnimals = []
animals.forEach((element) => {
newAnimals.push(frontendAnimal(element))
})
return newAnimals
}
export function frontendAnimal(animal) {
return {
id: animal.aId,
name: animal.name,
sex: animal.sex,
species: animal.species,//种类
weight: animal.weight,
height: animal.height,
state: animal.state,//状态0正常 1异常
roleId: animal.roleid,//饲养员id
color: animal.color,//颜色
features: animal.features,//特征
phase: animal.phase//生长阶段
}
}
export function frontendBreedingPlans(breedings) {
const newBreedingPlans = []
breedings.forEach(breedingPlan => {
newBreedingPlans.push(frontendBreeding(breedingPlan))
})
return newBreedingPlans
}
export function frontendBreeding(breeding) {
return {
id: breeding.id,
name: breeding.name,
species: breeding.species,
sex: breeding.sex,
phase: breeding.phase,
state: breeding.state,
roleId: breeding.roleid,
description: breeding.describe1,
}
}
export function frontendArchives(archives) {
const newArchives = []
archives.forEach(a => {
newArchives.push(frontendArchive(a))
})
return newArchives
}
export function frontendArchive(archive) {
return {
id: archive.id,
animalId: archive.animallId,
animalName: archive.animalName,
phase: archive.phase,
state: archive.state,
type: archive.type,
date: archive.date,
time: archive.time,
roleId: archive.roleId,
description: archive.description,
breedingId:archive.breedingId
}
}
export function frontendHealths(healths) {
const newHealths = []
healths.forEach(h => {
newHealths.push(frontendHealth(h))
})
return newHealths
}
export function frontendHealth(health) {
return {
id: health.id,
animalId: health.animalId,
animalName: health.animalName,
state: health.state,
temperature: health.temperature,
breathRate: health.breathRete,
heartRate: health.heartRete,
bloodPressure: health.bloodPressure,
date: health.date,
time: health.time,
description: health.description
}
}
// 将前端对象的属性转为能和后端对应上属性的对象
export function backendUser(user) {
return {
id: user.id,
username: user.username,
password: user.password,
permissions: user.auth
}
}
export function backendAnimal(animal) {
return {
aId: animal.id,
name: animal.name,
sex: animal.sex,
species: animal.species,
weight: animal.weight,
height: animal.height,
state: animal.state,
roleid: animal.roleId,
color: animal.color,
features: animal.features,
phase: animal.phase
}
}
export function backendBreeding(breeding) {
return {
id: breeding.id,
name: breeding.name,
species: breeding.species,
sex: breeding.sex,
phase: breeding.phase,
state: breeding.state,
roleid: breeding.roleId,
describe1: breeding.description,
}
}
export function backendArchive(archive) {
return {
id: archive.id,
animallId: archive.animalId,
animalName: archive.animalName,
phase: archive.phase,
state: archive.state,
type: archive.type,
date: archive.date,
time: archive.time,
roleId: archive.roleId,
description: archive.description,
breedingId:archive.breedingId
}
}
export function backendHealth(health) {
return {
id: health.id,
animalId: health.animalId,
animalName: health.animalName,
state: health.state,
temperature: health.temperature,
breathRete: health.breathRate,
heartRete: health.heartRate,
bloodPressure: health.bloodPressure,
date: health.date,
time: health.time,
description: health.description
}
return data;
}

View File

@ -1,11 +1,11 @@
import {fileURLToPath, URL} from 'node:url'
import { fileURLToPath, URL } from 'node:url'
import {defineConfig} from 'vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
@ -22,14 +22,5 @@ export default defineConfig({
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 5000,
proxy: {
'/api': {
target: 'http://localhost:8888',
rewrite: (path) => path.replace(/^\/api/, '')
}
}
},
})