Compare commits
10 Commits
7e2ae9e565
...
fdcb6479e7
Author | SHA1 | Date | |
---|---|---|---|
fdcb6479e7 | |||
|
b533c4205c | ||
|
353c99eca9 | ||
|
1ae3f8b035 | ||
|
0f5cc52614 | ||
|
3a1fac9100 | ||
|
f3e9ba083b | ||
|
fca50296df | ||
|
ff62e543ef | ||
|
a5de0b4987 |
1
.env.development
Normal file
1
.env.development
Normal file
@ -0,0 +1 @@
|
||||
VITE_BASE_URL='http://localhost:8888'
|
1
.env.production
Normal file
1
.env.production
Normal file
@ -0,0 +1 @@
|
||||
VITE_BASE_URL='http://zoo-backend:12321'
|
173
README.md
173
README.md
@ -1,23 +1,40 @@
|
||||
# zoo-frontend
|
||||
# 动物信息管理系统说明
|
||||
|
||||
## 简介
|
||||
|
||||
本人负责动物信息管理系统的前端部分,该项目为大作业所作,由于不擅长前端,所以很烂
|
||||
|
||||
加载数据很卡,没做优化,卡住的话耐心等待几秒吧
|
||||
|
||||
## 账户(密码都是123456)
|
||||
|
||||
管理员账户:admin
|
||||
|
||||
饲养员账户:user2
|
||||
|
||||
兽医账户:user4
|
||||
|
||||
|
||||
# zoo-frontend(大报告要求)
|
||||
|
||||
本次建设的动物信息分为以下功能:
|
||||
|
||||
1. 数据录入与管理(前端基本完成,未接入后端)
|
||||
1. 数据录入与管理(前端基本完成,已接入后端)
|
||||
系统应提供数据录入功能,允许用户输入动物的基本信息,如种类、年龄、性别、体重、健康状况等。同时,系统应具备数据管理功能,包括数据的查询、修改、删除等操作,以便用户能够方便地管理和维护动物信息。
|
||||
|
||||
2. 动物档案管理(前端基本完成,未接入后端)
|
||||
2. 动物档案管理(前端基本完成,已接入后端)
|
||||
系统应建立动物档案,记录动物的整个生命周期,包括出生日期、疫苗接种记录、疾病治疗记录、饲养记录等。这有助于跟踪动物的健康状况和饲养情况,为动物提供更好的管理和照顾。
|
||||
|
||||
3. 饲养管理(前端基本完成,未接入后端)
|
||||
3. 饲养管理(前端基本完成,已接入后端)
|
||||
系统应提供饲养管理功能,包括饲养计划的制定、饲养任务的分配、饲养记录的管理等。这有助于确保动物获得适当的饲料和营养,保持健康生长。
|
||||
|
||||
4. 健康监测与预警(前端基本完成,未接入后端)
|
||||
4. 健康监测与预警(前端基本完成,已接入后端)
|
||||
系统应具备健康监测功能,定期收集和分析动物的健康数据,如体温、心率、呼吸频率等。同时,系统应提供预警功能,当动物的健康数据出现异常时,及时提醒管理人员采取相应措施。
|
||||
|
||||
5. 统计分析(未开始)
|
||||
5. 统计分析(前端基本完成,无需后端)
|
||||
系统应提供统计分析功能,对动物信息、饲养记录、健康数据等进行统计分析,生成各类报表和图表。这有助于管理人员了解动物的整体状况和饲养效果,为决策提供支持。
|
||||
|
||||
6. 用户权限管理(前端基本完成,未接入后端)
|
||||
6. 用户权限管理(前端基本完成,已接入后端)
|
||||
系统应建立用户权限管理机制,对不同用户设置不同的权限,如管理员、饲养员、兽医等。这有助于确保系统的安全性和数据的保密性。
|
||||
|
||||
使用的技术/资源:
|
||||
@ -26,7 +43,25 @@
|
||||
- ElementUI
|
||||
- axios
|
||||
|
||||
# 需要后端提供的数据
|
||||
# 说明(给使用者看的)
|
||||
|
||||
## 功能说明
|
||||
|
||||
首页统计面板没有对接后端,无法操作,只做观赏作用
|
||||
|
||||
其余界面均实现基本的增删改查,健康监测等复杂的功能没有实现
|
||||
|
||||
## 使用说明
|
||||
|
||||
前端方面:下载zip或通过git拉取文件运行
|
||||
|
||||
后端方面:同上,但是application.yml中的username和password需要改成你自己数据库的用户名和密码,一般只需要改密码就行,还有其他项目配置如jdk,maven需要你自己配置
|
||||
|
||||
数据库方面:先创建一个数据库(无需建表),数据库名字为zoo,然后运行sql文件导入表和数据
|
||||
|
||||
前端需要搞好数据库和运行后端程序,才能正常运行使用
|
||||
|
||||
# 需要后端提供的数据(给后端开发看的)
|
||||
|
||||
一切以最终实现的接口为准,你需要前端提供什么数据就什么数据
|
||||
|
||||
@ -223,124 +258,4 @@ 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
91
package-lock.json
generated
@ -9,6 +9,7 @@
|
||||
"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",
|
||||
@ -991,6 +992,21 @@
|
||||
"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",
|
||||
@ -1070,6 +1086,17 @@
|
||||
"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",
|
||||
@ -1151,6 +1178,14 @@
|
||||
"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",
|
||||
@ -1327,6 +1362,38 @@
|
||||
"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",
|
||||
@ -1625,6 +1692,25 @@
|
||||
"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",
|
||||
@ -1857,6 +1943,11 @@
|
||||
"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",
|
||||
|
@ -10,6 +10,7 @@
|
||||
},
|
||||
"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",
|
||||
|
@ -3,6 +3,7 @@
|
||||
/*浏览器默认margin为8px,会出现滚动条的问题,因此此处设置为0*/
|
||||
body {
|
||||
margin: 0;
|
||||
background-color: aliceblue;
|
||||
}
|
||||
|
||||
/*相对定位*/
|
||||
@ -41,7 +42,7 @@ body {
|
||||
|
||||
/*与pages组件相关的所有样式*/
|
||||
.table {
|
||||
height: 506px;
|
||||
height: 516px;
|
||||
margin: 0 30px;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<script>
|
||||
import {copy} from "@/utils/common.js";
|
||||
import {mapGetters} from "vuex";
|
||||
|
||||
export default {
|
||||
name: "ZooAnimalFormDialog",
|
||||
@ -18,6 +19,102 @@ 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: {
|
||||
@ -33,6 +130,9 @@ export default {
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
...mapGetters(["getKeepers"])
|
||||
},
|
||||
mounted() {
|
||||
// 给表单填充传递的数据
|
||||
if (this.data) {
|
||||
@ -48,7 +148,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"/>
|
||||
<el-input v-model.number="form.id" placeholder="系统自动生成ID" type="number" :disabled="edit || detail || true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="动物名称">
|
||||
<el-input v-model="form.name" placeholder="动物名称" :disabled="detail"/>
|
||||
@ -60,7 +160,25 @@ export default {
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="动物种类">
|
||||
<el-input v-model="form.species" placeholder="动物种类" :disabled="detail"/>
|
||||
|
||||
<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"/>
|
||||
@ -75,7 +193,26 @@ 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-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-form-item>
|
||||
<el-form-item label="动物颜色">
|
||||
<el-color-picker v-model="form.color" :disabled="detail"/>
|
||||
@ -85,10 +222,10 @@ export default {
|
||||
</el-form-item>
|
||||
<el-form-item label="生命阶段">
|
||||
<el-select v-model="form.phase" placeholder="生命阶段" :disabled="detail">
|
||||
<el-option label="幼年期" :value="0"/>
|
||||
<el-option label="成长期" :value="1"/>
|
||||
<el-option label="成年期" :value="2"/>
|
||||
<el-option label="老年期" :value="3"/>
|
||||
<el-option label="幼年期" value="幼年期"/>
|
||||
<el-option label="成长期" value="成长期"/>
|
||||
<el-option label="成年期" value="成年期"/>
|
||||
<el-option label="老年期" value="老年期"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="right">
|
||||
|
@ -1,5 +1,6 @@
|
||||
<script>
|
||||
import {copy} from "@/utils/common.js";
|
||||
import {mapState, mapGetters} from "vuex";
|
||||
|
||||
export default {
|
||||
name: "ZooArchiveFormDialog",
|
||||
@ -16,6 +17,7 @@ export default {
|
||||
time: '',//字符,档案记录时间
|
||||
roleId: null,//负责录入档案的人的id,身份不限
|
||||
description: '',//字符 档案的描述
|
||||
breedingId: null
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -32,10 +34,27 @@ 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() {
|
||||
@ -47,20 +66,39 @@ 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"/>
|
||||
<el-input v-model.number="form.id" type="number" placeholder="系统自动生成记录号"
|
||||
:disabled="edit || detail || true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="动物ID">
|
||||
<el-input v-model.number="form.animalId" type="number" placeholder="动物ID" :disabled="detail"/>
|
||||
<!-- <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-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="0"/>
|
||||
<el-option label="成长期" :value="1"/>
|
||||
<el-option label="成年期" :value="2"/>
|
||||
<el-option label="老年期" :value="3"/>
|
||||
<el-option label="幼年期" value="幼年期"/>
|
||||
<el-option label="成长期" value="成长期"/>
|
||||
<el-option label="成年期" value="成年期"/>
|
||||
<el-option label="老年期" value="老年期"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="动物状态">
|
||||
@ -77,20 +115,68 @@ export default {
|
||||
</el-select>
|
||||
</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 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>
|
||||
<el-form-item label="记录人ID">
|
||||
<el-input v-model.number="form.roleId" type="number" placeholder="记录人ID" :disabled="detail"/>
|
||||
<!-- <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-form-item>
|
||||
<el-form-item label="记录描述">
|
||||
<el-input
|
||||
|
@ -9,6 +9,11 @@ export default {
|
||||
order:0
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
order(){
|
||||
this.timeSort()
|
||||
}
|
||||
},
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
@ -16,20 +21,24 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
sort(){
|
||||
//降序
|
||||
if (this.order===0){
|
||||
this.order++
|
||||
sortByDateTime(this.archives)
|
||||
//按时间排序
|
||||
timeSort() {
|
||||
//0降序
|
||||
if (this.order === 0) {
|
||||
this.archives = sortByDateTime(copy(this.archives))
|
||||
return
|
||||
}
|
||||
//升序
|
||||
if (this.order===1){
|
||||
this.order--
|
||||
sortByDateTime(this.archives)
|
||||
this.archives.reverse()
|
||||
//1升序
|
||||
if (this.order === 1) {
|
||||
this.archives = sortByDateTime(copy(this.archives)).reverse()
|
||||
return;
|
||||
}
|
||||
},
|
||||
changeOrder(){
|
||||
if (this.order===0)
|
||||
this.order++
|
||||
else this.order--
|
||||
},
|
||||
nodeType(type) {
|
||||
if (type === '日常饲养') {
|
||||
return 'success'
|
||||
@ -50,13 +59,19 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// 给表单填充传递的数据
|
||||
// 给填充传递的数据
|
||||
if (this.data) {
|
||||
this.archives = copy(this.data)
|
||||
//默认按照时间降序
|
||||
this.sort()
|
||||
this.timeSort()
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
if (this.data) {
|
||||
this.archives = copy(this.data)
|
||||
//默认按照时间降序
|
||||
this.timeSort()
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
@ -67,7 +82,7 @@ export default {
|
||||
|
||||
<template>
|
||||
<div class="relative" style="height: 40px">
|
||||
<el-button type="primary" class="right" @click="sort()">按时间升 / 降序</el-button>
|
||||
<el-button type="primary" class="right" @click="changeOrder()">按时间升 / 降序</el-button>
|
||||
</div>
|
||||
<el-scrollbar height="500px">
|
||||
<el-timeline style="max-width: 600px">
|
||||
@ -117,7 +132,10 @@ export default {
|
||||
{{ a.description }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="left">记录号:{{ a.id }}</div>
|
||||
<div class="left">
|
||||
记录号:{{ a.id }} |
|
||||
关联计划:{{ a.breedingId }}
|
||||
</div>
|
||||
<div class="right">{{ a.roleId }} 记录于 {{ a.date }} {{ a.time }}</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<script>
|
||||
import {mapState} from "vuex";
|
||||
import {Menu, User} from "@element-plus/icons-vue";
|
||||
|
||||
export default {
|
||||
name: "ZooAside",
|
||||
components: {User, Menu},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
@ -16,7 +18,9 @@ export default {
|
||||
this.$router.push(path)
|
||||
}
|
||||
},
|
||||
watch: {}
|
||||
mounted() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
@ -42,30 +46,14 @@ export default {
|
||||
<el-sub-menu index="1">
|
||||
<template #title="scope">
|
||||
<el-icon>
|
||||
<location/>
|
||||
<Menu/>
|
||||
</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')">用户管理</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/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>
|
||||
@ -75,6 +63,9 @@ export default {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
#aside{
|
||||
background-color: white;
|
||||
}
|
||||
.aside-icon {
|
||||
width: 200px;
|
||||
margin-top: 20px;
|
||||
|
@ -1,12 +1,13 @@
|
||||
<script>
|
||||
import {copy} from "@/utils/common.js";
|
||||
import {mapGetters} from "vuex";
|
||||
|
||||
export default {
|
||||
name: "ZooBreedingFormDialog",
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
id: '',//int 饲养计划id
|
||||
id: null,//int 饲养计划id
|
||||
name: '',//字符 饲养计划名称
|
||||
species: '',//字符 种类
|
||||
sex: '雄性',//字符 饲养动物性别
|
||||
@ -30,6 +31,9 @@ export default {
|
||||
default: false
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
...mapGetters(['getAllSpecies','getKeepers'])
|
||||
},
|
||||
mounted() {
|
||||
// 给表单填充传递的数据
|
||||
if (this.data) {
|
||||
@ -45,13 +49,21 @@ 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"/>
|
||||
<el-input v-model.number="form.id" type="number" placeholder="系统自动生成ID" :disabled="edit || detail || true"/>
|
||||
</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-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-form-item>
|
||||
<el-form-item label="性别">
|
||||
<el-radio-group v-model="form.sex" :disabled="detail">
|
||||
@ -61,10 +73,10 @@ export default {
|
||||
</el-form-item>
|
||||
<el-form-item label="生命阶段">
|
||||
<el-select v-model="form.phase" :disabled="detail">
|
||||
<el-option label="幼年期" :value="0"/>
|
||||
<el-option label="成长期" :value="1"/>
|
||||
<el-option label="成年期" :value="2"/>
|
||||
<el-option label="老年期" :value="3"/>
|
||||
<el-option label="幼年期" value="幼年期"/>
|
||||
<el-option label="成长期" value="成长期"/>
|
||||
<el-option label="成年期" value="成年期"/>
|
||||
<el-option label="老年期" value="老年期"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="动物状态">
|
||||
@ -74,7 +86,25 @@ 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-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-form-item>
|
||||
<el-form-item label="计划描述" >
|
||||
<el-input
|
||||
|
@ -1,5 +1,6 @@
|
||||
<script>
|
||||
import {copy} from "@/utils/common.js";
|
||||
import {mapState} from "vuex";
|
||||
|
||||
export default {
|
||||
name: "ZooHealthFormDialog",
|
||||
@ -33,10 +34,25 @@ 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() {
|
||||
@ -48,10 +64,28 @@ 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"/>
|
||||
<el-input v-model.number="form.id" type="number" placeholder="系统自动生成监测号" :disabled="edit || detail || true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="动物ID">
|
||||
<el-input v-model.number="form.animalId" type="number" placeholder="动物ID" :disabled="detail"/>
|
||||
<!-- <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-form-item>
|
||||
<el-form-item label="动物名称">
|
||||
<el-input v-model="form.animalName" placeholder="动物名称" :disabled="detail"/>
|
||||
@ -79,18 +113,35 @@ 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-form-item>
|
||||
<el-form-item label="记录时间">
|
||||
<el-time-picker v-model="form.time" type="time" placeholder="选择时间" value-format="HH:mm:ss"
|
||||
:disabled="detail"/>
|
||||
<!-- <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-input
|
||||
v-model="form.description"
|
||||
|
@ -9,6 +9,11 @@ export default {
|
||||
order: 0
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
order(){
|
||||
this.timeSort()
|
||||
}
|
||||
},
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
@ -16,20 +21,24 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
sort() {
|
||||
//降序
|
||||
//按时间排序
|
||||
timeSort() {
|
||||
//0降序
|
||||
if (this.order === 0) {
|
||||
this.order++
|
||||
sortByDateTime(this.healths)
|
||||
this.healths = sortByDateTime(copy(this.healths))
|
||||
return
|
||||
}
|
||||
//升序
|
||||
//1升序
|
||||
if (this.order === 1) {
|
||||
this.order--
|
||||
sortByDateTime(this.healths)
|
||||
this.healths.reverse()
|
||||
this.healths = sortByDateTime(copy(this.healths)).reverse()
|
||||
return;
|
||||
}
|
||||
},
|
||||
changeOrder(){
|
||||
if (this.order===0)
|
||||
this.order++
|
||||
else this.order--
|
||||
},
|
||||
nodeType(type) {
|
||||
if (type === 0) {
|
||||
return 'success'
|
||||
@ -45,7 +54,15 @@ export default {
|
||||
if (this.data) {
|
||||
this.healths = copy(this.data)
|
||||
//默认按照时间降序
|
||||
this.sort()
|
||||
this.timeSort()
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
// 给表单填充传递的数据
|
||||
if (this.data) {
|
||||
this.healths = copy(this.data)
|
||||
//默认按照时间降序
|
||||
this.timeSort()
|
||||
}
|
||||
},
|
||||
beforeUnmount() {
|
||||
@ -56,7 +73,7 @@ export default {
|
||||
|
||||
<template>
|
||||
<div class="relative" style="height: 40px">
|
||||
<el-button type="primary" class="right" @click="sort()">按时间升 / 降序</el-button>
|
||||
<el-button type="primary" class="right" @click="changeOrder()">按时间升 / 降序</el-button>
|
||||
</div>
|
||||
<el-scrollbar height="500px">
|
||||
<el-timeline style="max-width: 600px">
|
||||
|
@ -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"/>
|
||||
<el-input v-model.number="form.id" placeholder="系统自动生成ID" type="number"
|
||||
:disabled="edit || detail|| true"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户名">
|
||||
<el-input v-model="form.username" placeholder="请设置用户名" :disabled="detail"/>
|
||||
|
@ -1,9 +1,10 @@
|
||||
<script>
|
||||
import {copy, fuzzyMatching, splitKeyWords} from "@/utils/common.js";
|
||||
import {copy, fuzzyMatching, refreshData, splitKeyWords} from "@/utils/common.js";
|
||||
import {Delete, Document, DocumentAdd, Edit, Search, Tickets} from "@element-plus/icons-vue";
|
||||
import ZooAnimalFormDialog from "@/components/ZooAnimalFormDialog.vue";
|
||||
import {mapActions, mapMutations, mapState} from "vuex";
|
||||
import {mapMutations, mapState} from "vuex";
|
||||
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
|
||||
import request, {frontendAnimal, frontendAnimals, frontendArchives} from "@/utils/request.js";
|
||||
|
||||
export default {
|
||||
name: "ZooAnimal",
|
||||
@ -54,7 +55,10 @@ export default {
|
||||
return Tickets
|
||||
},
|
||||
//endregion
|
||||
...mapState(["animals", 'archives', 'animalsTableData'])
|
||||
...mapState(["animals", 'archives', 'animalsTableData','loginUser']),
|
||||
operateWidth() {
|
||||
return this.loginUser.auth===1?'250':'130'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 搜索框存在输入,自动调用搜索(刷新数据包含搜索)
|
||||
@ -66,19 +70,26 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["getAnimals"]),
|
||||
...mapMutations(['updateAnimalsTableData']),
|
||||
...mapMutations(['updateAnimals','updateAnimalsTableData']),
|
||||
|
||||
// 显示详情弹窗
|
||||
showDetail(data) {
|
||||
console.log('显示详情', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.detailDialogVisible = true
|
||||
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.detailDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//显示编辑弹窗
|
||||
@ -86,45 +97,61 @@ export default {
|
||||
console.log('显示编辑', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.editDialogVisible = true
|
||||
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.editDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
edit(data) {
|
||||
console.log('编辑', data)
|
||||
|
||||
//判断表单是否为空
|
||||
return this.isEmpty(data);
|
||||
//验证是否为空
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//这里将数据传给后端进行数据更新
|
||||
//编辑失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
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()
|
||||
|
||||
//编辑成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
this.dialog.editDialogVisible = false//关闭窗口
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getAnimals()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//关闭窗口
|
||||
this.dialog.editDialogVisible = false
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
delete_(data) {
|
||||
@ -139,19 +166,34 @@ 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.refresh()
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getAnimals()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
// 返回提示
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
// 返回提示
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
})
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除失败',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
@ -165,61 +207,62 @@ export default {
|
||||
console.log('添加', data)
|
||||
|
||||
//验证是否为空
|
||||
return this.isEmpty(data);
|
||||
|
||||
//先查询用户是否存在
|
||||
|
||||
//添加失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '该动物已存在',
|
||||
type: 'warning',
|
||||
})
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
//添加成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
// //从后端重新拉取数据
|
||||
// this.getAnimals()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
request.addAnimalRequest(data).then(response => {
|
||||
if (response.data.code===1){
|
||||
// 添加成功
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '添加失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//以时间线的形式查看该动物的所有档案记录
|
||||
showTimeline(data) {
|
||||
console.log('显示时间线记录', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.animals.find(e => e.id === data.id)
|
||||
this.dialog.dialogData = data
|
||||
|
||||
this.dialog.timelineData = []
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.archives.forEach(e => {
|
||||
if (e.animalId === data.id) {
|
||||
this.dialog.timelineData.push(copy(e))
|
||||
request.queryAnimalRequest(data.id).then(response => {
|
||||
if (response.data.data===null){
|
||||
this.refresh();
|
||||
return ElMessage({
|
||||
message: '该动物不存在,请刷新',
|
||||
type: 'warning',
|
||||
})
|
||||
} else {
|
||||
request.queryArchiveRequest(null,data.id).then(response => {
|
||||
if (response.data.code===1){
|
||||
this.dialog.timelineData = frontendArchives(response.data.data)
|
||||
//显示弹窗
|
||||
this.dialog.timelineDialogVisible = true
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.timelineDialogVisible = true
|
||||
},
|
||||
|
||||
// 判断表单是否为空
|
||||
isEmpty(form) {
|
||||
if (!form.name) {
|
||||
//返回提示
|
||||
return ElMessage({
|
||||
message: '动物名不能为空',
|
||||
message: '请输入动物名称',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
@ -278,18 +321,22 @@ export default {
|
||||
console.log('刷新数据')
|
||||
|
||||
//先拉取一遍数据
|
||||
this.getAnimals()
|
||||
request.queryAnimalRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
this.updateAnimals(frontendAnimals(response.data.data))
|
||||
}
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
})
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
// 加载完成后拉取数据
|
||||
this.refresh()
|
||||
refreshData()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -297,7 +344,7 @@ export default {
|
||||
<template>
|
||||
<div class="animal-root">
|
||||
<div class="select">
|
||||
<div class="left">
|
||||
<div class="left" v-if="loginUser.auth===1">
|
||||
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加动物</el-button>
|
||||
</div>
|
||||
<div class="right">
|
||||
@ -346,7 +393,7 @@ export default {
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="features" label="动物特征" width="300"/>
|
||||
<el-table-column fixed="right" label="操作" width="250">
|
||||
<el-table-column fixed="right" label="操作" :width="operateWidth" >
|
||||
<template #default="scope">
|
||||
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
|
||||
档案
|
||||
@ -354,10 +401,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)">
|
||||
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth===1">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth===1">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
@ -375,7 +422,8 @@ export default {
|
||||
</div>
|
||||
|
||||
<!-- 添加动物对话框-->
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加动物" width="500" align-center draggable overflow>
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加动物" width="500" align-center draggable overflow
|
||||
destroy-on-close>
|
||||
<ZooAnimalFormDialog>
|
||||
<template #default="scope">
|
||||
<el-button @click="dialog.addDialogVisible = false">
|
||||
@ -416,9 +464,8 @@ 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>-->
|
||||
|
@ -2,8 +2,9 @@
|
||||
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} from "@/utils/common.js";
|
||||
import {copy, splitKeyWords, fuzzyMatching, sortByDateTime, refreshData} from "@/utils/common.js";
|
||||
import ZooArchiveTimeline from "@/components/ZooArchiveTimeline.vue";
|
||||
import request, {frontendArchive, frontendArchives} from "@/utils/request.js";
|
||||
|
||||
export default {
|
||||
name: "ZooArchive",
|
||||
@ -58,7 +59,10 @@ export default {
|
||||
return Timer
|
||||
},
|
||||
//endregion
|
||||
...mapState(["archives", 'archivesTableData'])
|
||||
...mapState(["archives", 'archivesTableData','loginUser']),
|
||||
operateWidth() {
|
||||
return this.loginUser.auth!==0?'250':'130'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 搜索框存在输入,自动调用搜索(刷新数据包含搜索)
|
||||
@ -74,19 +78,26 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["getArchives"]),
|
||||
...mapMutations(['updateArchivesTableData']),
|
||||
...mapMutations(['updateArchives','updateArchivesTableData']),
|
||||
|
||||
// 显示详情弹窗
|
||||
showDetail(data) {
|
||||
console.log('显示详情', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.detailDialogVisible = true
|
||||
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.detailDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//显示编辑弹窗
|
||||
@ -94,45 +105,66 @@ export default {
|
||||
console.log('显示编辑', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.editDialogVisible = true
|
||||
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.editDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
edit(data) {
|
||||
console.log('编辑', data)
|
||||
|
||||
//判断表单是否为空
|
||||
return this.isEmpty(data);
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//这里将数据传给后端进行数据更新
|
||||
//编辑失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
//编辑成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
this.dialog.editDialogVisible = false//关闭窗口
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getArchives()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//关闭窗口
|
||||
this.dialog.editDialogVisible = false
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
delete_(data) {
|
||||
@ -147,19 +179,38 @@ 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.refresh()
|
||||
request.queryArchiveRequest(null,this.dialog.dialogData.animalId).then(response => {
|
||||
if (response.data.code===1){
|
||||
this.dialog.timelineData = frontendArchives(response.data.data)
|
||||
}
|
||||
})
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getArchives()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
// 返回提示
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
return ElMessage({
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '删除失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
@ -173,61 +224,53 @@ export default {
|
||||
console.log('添加', data)
|
||||
|
||||
//验证是否为空
|
||||
return this.isEmpty(data);
|
||||
|
||||
//先查询用户是否存在
|
||||
|
||||
//添加失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '该记录已存在',
|
||||
type: 'warning',
|
||||
})
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
//添加成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
// //从后端重新拉取数据
|
||||
// this.getArchives()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
request.addArchiveRequest(data).then(response => {
|
||||
if (response.data.code===1){
|
||||
// 添加成功
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
this.dialog.addDialogVisible = false//关闭窗口
|
||||
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '添加失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//以时间线的形式查看该动物的所有档案记录
|
||||
showTimeline(data) {
|
||||
console.log('显示时间线记录', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.archives.find(e => e.id === data.id)
|
||||
this.dialog.dialogData = data
|
||||
|
||||
this.dialog.timelineData = []
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.archives.forEach(e => {
|
||||
if (e.animalId === data.animalId) {
|
||||
this.dialog.timelineData.push(copy(e))
|
||||
//从后端获取需要查询的数据
|
||||
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.timelineDialogVisible = true
|
||||
},
|
||||
|
||||
// 判断表单是否为空
|
||||
isEmpty(form) {
|
||||
if (!form.animalId) {
|
||||
if (!form.animalId||!form.animalName) {
|
||||
//返回提示
|
||||
return ElMessage({
|
||||
message: '记录的动物ID不能为空',
|
||||
message: '动物ID或动物名称不能为空',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
@ -310,21 +353,25 @@ export default {
|
||||
console.log('刷新数据')
|
||||
|
||||
//先拉取一遍数据
|
||||
this.getArchives()
|
||||
request.queryArchiveRequest().then(response=>{
|
||||
if (response.data.code === 1){
|
||||
this.updateArchives(frontendArchives(response.data.data))
|
||||
}
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
//排序
|
||||
this.timeSort(this.order)
|
||||
|
||||
//排序
|
||||
this.timeSort(this.order)
|
||||
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 加载完成后拉取数据
|
||||
this.refresh()
|
||||
refreshData()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -332,7 +379,7 @@ export default {
|
||||
<template>
|
||||
<div class="archive-root">
|
||||
<div class="select">
|
||||
<div class="left">
|
||||
<div class="left" v-if="loginUser.auth!==0">
|
||||
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加记录</el-button>
|
||||
</div>
|
||||
<div class="right">
|
||||
@ -374,8 +421,9 @@ 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="250">
|
||||
<el-table-column fixed="right" label="操作" :width="operateWidth">
|
||||
<template #default="scope">
|
||||
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
|
||||
档案
|
||||
@ -383,10 +431,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)">
|
||||
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth!==0">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth!==0">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
@ -404,7 +452,8 @@ export default {
|
||||
</div>
|
||||
|
||||
<!-- 添加记录对话框-->
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow>
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow
|
||||
destroy-on-close>
|
||||
<ZooArchiveFormDialog>
|
||||
<template #default="scope">
|
||||
<el-button @click="dialog.addDialogVisible = false">
|
||||
@ -446,8 +495,7 @@ 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>
|
||||
|
@ -1,12 +1,14 @@
|
||||
<script>
|
||||
import ZooBreedingPlanFormDialog from "@/components/ZooBreedingPlanFormDialog.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";
|
||||
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";
|
||||
|
||||
export default {
|
||||
name: "ZooBreeding",
|
||||
components: {ZooBreedingPlanFormDialog},
|
||||
components: {ZooArchiveTimeline, ZooBreedingPlanFormDialog},
|
||||
data() {
|
||||
return {
|
||||
//表格分页显示的数据
|
||||
@ -25,11 +27,14 @@ export default {
|
||||
dialogData: {},
|
||||
addDialogVisible: false,//添加饲养计划对话框
|
||||
editDialogVisible: false,//编辑饲养计划对话框
|
||||
detailDialogVisible:false//查询饲养计划对话框
|
||||
detailDialogVisible: false,//查询饲养计划对话框
|
||||
timelineDialogVisible: false,//时间线对话框
|
||||
timelineData: []//时间线数据
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
//图标
|
||||
//region
|
||||
Search() {
|
||||
@ -47,33 +52,72 @@ export default {
|
||||
Document() {
|
||||
return Document
|
||||
},
|
||||
Tickets() {
|
||||
return Tickets
|
||||
},
|
||||
//endregion
|
||||
...mapState(["breedingPlans",'breedingPlansTableData'])
|
||||
...mapState(["breedingPlans", 'breedingPlansTableData','loginUser']),
|
||||
operateWidth() {
|
||||
return this.loginUser.auth===1?'250':'130'
|
||||
}
|
||||
|
||||
},
|
||||
watch: {
|
||||
// 搜索框存在输入,自动调用搜索(刷新数据包含搜索)
|
||||
searchInput: {
|
||||
deep: true,
|
||||
handler(val) {
|
||||
// this.search()
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["getBreedingPlans"]),
|
||||
...mapMutations(['updateBreedingPlansTableData']),
|
||||
...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
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//显示详情弹窗
|
||||
showDetail(data) {
|
||||
console.log('显示详情', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.breedingPlans.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.detailDialogVisible = true
|
||||
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.detailDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//显示编辑弹窗
|
||||
@ -81,45 +125,61 @@ export default {
|
||||
console.log('显示编辑', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.breedingPlans.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.editDialogVisible = true
|
||||
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.editDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
edit(data) {
|
||||
console.log('编辑', data)
|
||||
|
||||
//判断表单是否为空
|
||||
return this.isEmpty(data);
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//这里将数据传给后端进行数据更新
|
||||
//编辑失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
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()
|
||||
|
||||
//编辑成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
this.dialog.editDialogVisible = false//关闭窗口
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getBreedingPlans()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//关闭窗口
|
||||
this.dialog.editDialogVisible = false
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
delete_(data) {
|
||||
@ -127,26 +187,40 @@ 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.refresh()
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getBreedingPlans()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
// 返回提示
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
return ElMessage({
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
return ElMessage({
|
||||
message: '删除失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
@ -160,40 +234,37 @@ export default {
|
||||
console.log('添加', data)
|
||||
|
||||
//验证是否为空
|
||||
return this.isEmpty(data);
|
||||
|
||||
//先查询用户是否存在
|
||||
|
||||
//添加失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '该计划已存在',
|
||||
type: 'warning',
|
||||
})
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
//添加成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
// //从后端重新拉取数据
|
||||
// this.getBreedingPlans()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
request.addBreedingPlanRequest(data).then(response => {
|
||||
if (response.data.code===1){
|
||||
// 添加成功
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '添加失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 判断表单是否为空
|
||||
isEmpty(form) {
|
||||
if (!form.name) {
|
||||
if (!form.name || !form.species) {
|
||||
//返回提示
|
||||
return ElMessage({
|
||||
message: '计划名不能为空',
|
||||
message: '计划名称或物种不能为空',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
@ -236,7 +307,7 @@ export default {
|
||||
|
||||
//当前页切换时触发
|
||||
handleCurrentChange(val) {
|
||||
console.log('分页被切换',val)
|
||||
console.log('分页被切换', val)
|
||||
this.currentPage = val
|
||||
this.getPagesData()
|
||||
},
|
||||
@ -249,28 +320,26 @@ export default {
|
||||
},
|
||||
|
||||
//刷新数据的方法
|
||||
refresh(){
|
||||
refresh() {
|
||||
console.log('刷新数据')
|
||||
|
||||
//先拉取一遍数据
|
||||
this.getBreedingPlans()
|
||||
request.queryBreedingPlanRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
this.updateBreedingPlans(frontendBreedingPlans(response.data.data))
|
||||
}
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
mounted() {
|
||||
// // 加载完成后拉取数据
|
||||
// this.getBreedingPlans()
|
||||
//
|
||||
// //获取分页后显示的数据
|
||||
// this.getPagesData()
|
||||
|
||||
// 加载完成后拉取数据
|
||||
this.refresh()
|
||||
refreshData()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -278,7 +347,7 @@ export default {
|
||||
<template>
|
||||
<div class="breeding-root">
|
||||
<div class="select">
|
||||
<div class="left">
|
||||
<div class="left" v-if="loginUser.auth === 1">
|
||||
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加计划</el-button>
|
||||
</div>
|
||||
<div class="right">
|
||||
@ -302,7 +371,8 @@ 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"/>
|
||||
@ -317,15 +387,18 @@ export default {
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="description" label="计划描述" width="300"/>
|
||||
<el-table-column fixed="right" label="操作" width="190">
|
||||
<el-table-column fixed="right" label="操作" :width="operateWidth">
|
||||
<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)">
|
||||
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth===1">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth===1">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
@ -343,7 +416,8 @@ export default {
|
||||
</div>
|
||||
|
||||
<!-- 添加饲养计划对话框-->
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加饲养计划" width="500" align-center draggable overflow>
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加饲养计划" width="500" align-center draggable overflow
|
||||
destroy-on-close>
|
||||
<ZooBreedingPlanFormDialog>
|
||||
<template #default="scope">
|
||||
<el-button @click="dialog.addDialogVisible = false">
|
||||
@ -382,6 +456,25 @@ 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>
|
||||
|
@ -1,9 +1,10 @@
|
||||
<script>
|
||||
import {Delete, DocumentAdd, Document, Edit, Search, Tickets, Timer} from "@element-plus/icons-vue";
|
||||
import {mapActions, mapMutations, mapState} from "vuex";
|
||||
import {copy, fuzzyMatching, sortByDateTime, splitKeyWords} from "@/utils/common.js";
|
||||
import {copy, fuzzyMatching, refreshData, 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",
|
||||
@ -58,7 +59,10 @@ export default {
|
||||
return Timer
|
||||
},
|
||||
//endregion
|
||||
...mapState(["healths", 'healthsTableData'])
|
||||
...mapState(["healths", 'healthsTableData','loginUser']),
|
||||
operateWidth() {
|
||||
return this.loginUser.auth===2?'250':'130'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// 搜索框存在输入,自动调用搜索(刷新数据包含搜索)
|
||||
@ -75,19 +79,26 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["getHealths"]),
|
||||
...mapMutations(['updateHealthsTableData']),
|
||||
...mapMutations(['updateHealths','updateHealthsTableData']),
|
||||
|
||||
// 显示详情弹窗
|
||||
showDetail(data) {
|
||||
console.log('显示详情', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.healths.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.detailDialogVisible = true
|
||||
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.detailDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//显示编辑弹窗
|
||||
@ -95,45 +106,66 @@ export default {
|
||||
console.log('显示编辑', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.healths.find(e => e.id === data.id)
|
||||
|
||||
//显示弹窗
|
||||
this.dialog.editDialogVisible = true
|
||||
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.editDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
edit(data) {
|
||||
console.log('编辑', data)
|
||||
|
||||
//判断表单是否为空
|
||||
return this.isEmpty(data);
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//这里将数据传给后端进行数据更新
|
||||
//编辑失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
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)
|
||||
}
|
||||
})
|
||||
|
||||
//编辑成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
this.dialog.editDialogVisible = false//关闭窗口
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getHealths()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//关闭窗口
|
||||
this.dialog.editDialogVisible = false
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
delete_(data) {
|
||||
@ -149,18 +181,38 @@ 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)
|
||||
}
|
||||
})
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getHealths()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
// 返回提示
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
return ElMessage({
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
return ElMessage({
|
||||
message: '删除失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
@ -174,61 +226,53 @@ export default {
|
||||
console.log('添加', data)
|
||||
|
||||
//验证是否为空
|
||||
return this.isEmpty(data);
|
||||
|
||||
//先查询用户是否存在
|
||||
|
||||
//添加失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '该记录已存在',
|
||||
type: 'warning',
|
||||
})
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
//添加成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
// //从后端重新拉取数据
|
||||
// this.getHealths()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
request.addHealthRequest(data).then(response => {
|
||||
if (response.data.code === 1) {
|
||||
//添加成功
|
||||
//刷新数据
|
||||
this.refresh()
|
||||
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
this.dialog.addDialogVisible = false//关闭窗口
|
||||
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
return ElMessage({
|
||||
message: '添加失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//以时间线的形式查看该动物的所有档案记录
|
||||
showTimeline(data) {
|
||||
console.log('显示时间线记录', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.healths.find(e => e.id === data.id)
|
||||
this.dialog.dialogData = data
|
||||
|
||||
this.dialog.timelineData = []
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.healths.forEach(e => {
|
||||
if (e.animalId === data.animalId) {
|
||||
this.dialog.timelineData.push(copy(e))
|
||||
//从后端获取需要查询的数据
|
||||
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.timelineDialogVisible = true
|
||||
},
|
||||
|
||||
// 判断表单是否为空
|
||||
isEmpty(form) {
|
||||
if (!form.animalId) {
|
||||
if (!form.animalId||!form.animalName) {
|
||||
//返回提示
|
||||
return ElMessage({
|
||||
message: '记录的动物ID不能为空',
|
||||
message: '动物ID或动物名称不能为空',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
@ -311,21 +355,25 @@ export default {
|
||||
console.log('刷新数据')
|
||||
|
||||
//先拉取一遍数据
|
||||
this.getHealths()
|
||||
request.queryHealthRequest().then(response=>{
|
||||
if (response.data.code===1){
|
||||
this.updateHealths(frontendHealths(response.data.data))
|
||||
}
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
//排序
|
||||
this.timeSort(this.order)
|
||||
|
||||
//排序
|
||||
this.timeSort(this.order)
|
||||
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 加载完成后拉取数据
|
||||
this.refresh()
|
||||
refreshData()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -333,7 +381,7 @@ export default {
|
||||
<template>
|
||||
<div class="health-root">
|
||||
<div class="select">
|
||||
<div class="left">
|
||||
<div class="left" v-if="loginUser.auth===2">
|
||||
<el-button type="primary" :icon="DocumentAdd" @click="dialog.addDialogVisible = true">添加记录</el-button>
|
||||
</div>
|
||||
<div class="right">
|
||||
@ -401,7 +449,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="250">
|
||||
<el-table-column fixed="right" label="操作" :width="operateWidth">
|
||||
<template #default="scope">
|
||||
<el-button link type="success" size="small" :icon="Tickets" @click="showTimeline(scope.row)">
|
||||
追踪
|
||||
@ -409,10 +457,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)">
|
||||
<el-button link type="primary" size="small" :icon="Edit" @click="showEdit(scope.row)" v-if="loginUser.auth===2">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)">
|
||||
<el-button link type="danger" size="small" :icon="Delete" @click="delete_(scope.row)" v-if="loginUser.auth===2">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
@ -430,7 +478,8 @@ export default {
|
||||
</div>
|
||||
|
||||
<!-- 添加记录对话框-->
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow>
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加记录" width="500" align-center draggable overflow
|
||||
destroy-on-close>
|
||||
<ZooHealthFormDialog>
|
||||
<template #default="scope">
|
||||
<el-button @click="dialog.addDialogVisible = false">
|
||||
@ -471,7 +520,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">
|
||||
|
@ -1,24 +1,460 @@
|
||||
<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,//老年期
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
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>
|
||||
这是home界面
|
||||
<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>
|
||||
</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>
|
@ -1,6 +1,6 @@
|
||||
<script>
|
||||
|
||||
import {mapMutations,mapState,mapActions} from "vuex";
|
||||
import {mapMutations, mapState} from "vuex";
|
||||
import request, {frontendLoginUser} from "@/utils/request.js";
|
||||
|
||||
export default {
|
||||
name: "ZooContainer",
|
||||
@ -8,20 +8,25 @@ export default {
|
||||
return {
|
||||
// 登录表单数据
|
||||
form: {
|
||||
username: '',
|
||||
username: 'admin',
|
||||
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) {
|
||||
//返回提示
|
||||
@ -31,16 +36,25 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
//此处接入后端登录接口
|
||||
this.getLoginUser(this.form)//通过表单获取登录的用户
|
||||
|
||||
//能获取到登录后的数据,说明登录成功
|
||||
if (this.loginUser) {
|
||||
localStorage.setItem('username', this.loginUser.username);//本地存储登录用户名
|
||||
|
||||
// 跳转到面板首页
|
||||
this.$router.push('/panel/home')
|
||||
}
|
||||
//此处接入后端登录接口验证登录用户名和密码,验证通过方可通行
|
||||
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.$router.push('/panel/home')
|
||||
return ElMessage({
|
||||
message: '登录成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
return ElMessage({
|
||||
message: '用户名不存在或密码错误',
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//重置表单
|
||||
reset() {
|
||||
@ -49,29 +63,34 @@ 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">
|
||||
<!-- 背景图片-->
|
||||
<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>
|
||||
<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-item>
|
||||
</el-carousel>
|
||||
</div>
|
||||
|
||||
<!-- 登录表单-->
|
||||
<div class="center">
|
||||
<el-card style="width: 480px" shadow="always" header="登录">
|
||||
<el-form :model="form" label-width="auto" style="max-width: 600px">
|
||||
<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-form-item label="用户名">
|
||||
<el-input v-model="form.username" style="width: 240px" placeholder="请输入用户名"/>
|
||||
<el-input v-model="form.username" style="width: 240px" placeholder="请输入用户名" id="username"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input
|
||||
@ -80,10 +99,11 @@ export default {
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
show-password
|
||||
id="password"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="login">登录</el-button>
|
||||
<el-button type="primary" @click="login" id="login-button">登录</el-button>
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -97,6 +117,10 @@ export default {
|
||||
#login-root {
|
||||
width: 100%;
|
||||
height: 700px;
|
||||
background-color: skyblue;
|
||||
background-color: aliceblue;
|
||||
}
|
||||
|
||||
.center {
|
||||
opacity: 0.95;
|
||||
}
|
||||
</style>
|
@ -3,6 +3,8 @@ 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",
|
||||
@ -14,15 +16,24 @@ 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>
|
||||
|
||||
@ -50,15 +61,15 @@ export default {
|
||||
top: 0;
|
||||
}
|
||||
.footer {
|
||||
height: 30px;
|
||||
height: 20px;
|
||||
bottom: 0;
|
||||
text-align: center;
|
||||
line-height: 30px;
|
||||
line-height: 20px;
|
||||
background-color: lightgray;
|
||||
}
|
||||
.main {
|
||||
/*有footer*/
|
||||
height: 606px;
|
||||
height: 616px;
|
||||
|
||||
/*没footer*/
|
||||
/*height: 636px;*/
|
||||
|
@ -2,7 +2,8 @@
|
||||
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} from "@/utils/common.js";
|
||||
import {copy, fuzzyMatching, splitKeyWords, showPassword, hidePassword, refreshData} from "@/utils/common.js";
|
||||
import request, {frontendUser, frontendUsers} from "@/utils/request.js";
|
||||
|
||||
|
||||
export default {
|
||||
@ -27,7 +28,7 @@ export default {
|
||||
addDialogVisible: false,//添加弹窗
|
||||
editDialogVisible: false,//编辑弹窗
|
||||
detailDialogVisible: false,//详情弹窗
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -57,7 +58,6 @@ export default {
|
||||
searchInput: {
|
||||
deep: true,
|
||||
handler(val) {
|
||||
// this.search()
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
@ -66,18 +66,26 @@ export default {
|
||||
hidePassword,
|
||||
showPassword,
|
||||
...mapActions(['getUsers']),
|
||||
...mapMutations(['updateUsersTableData']),
|
||||
...mapMutations(['updateUsers','updateUsersTableData']),
|
||||
|
||||
//显示详情弹窗
|
||||
showDetail(data) {
|
||||
console.log('显示详情', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.users.find(e => e.username === data.username)
|
||||
|
||||
//显示详情弹窗
|
||||
this.dialog.detailDialogVisible = true
|
||||
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.detailDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 显示编辑弹窗
|
||||
@ -85,45 +93,61 @@ export default {
|
||||
console.log('编辑弹窗', data)
|
||||
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
//这里先用假数据代替一下
|
||||
this.dialog.dialogData = this.users.find(e => e.id === data.id)
|
||||
|
||||
// 显示编辑弹窗
|
||||
this.dialog.editDialogVisible = true
|
||||
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.editDialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
edit(data) {
|
||||
console.log('编辑', data)
|
||||
|
||||
//判断表单是否为空
|
||||
return this.isEmpty(data);
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//这里将数据传给后端进行数据更新
|
||||
//编辑失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
//从后端获取需要查询的数据,防止数据前后不一致
|
||||
request.queryUserRequest(data.username).then(response => {
|
||||
if (response.data.data === null) {
|
||||
this.refresh()
|
||||
this.dialog.editDialogVisible = false;
|
||||
return ElMessage({
|
||||
message: '该用户不存在,请刷新',
|
||||
type: 'warning',
|
||||
})
|
||||
}else {
|
||||
request.updateUserRequest(data).then(response => {
|
||||
if (response.data.code===1){
|
||||
// 编辑成功
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//编辑成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
this.dialog.editDialogVisible = false//关闭窗口
|
||||
|
||||
// //从后端重新拉取数据
|
||||
// this.getUsers()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//关闭窗口
|
||||
this.dialog.editDialogVisible = false
|
||||
return ElMessage({
|
||||
message: '编辑成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '编辑失败,无权限',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
delete_(data) {
|
||||
@ -138,19 +162,34 @@ 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.refresh()
|
||||
|
||||
// //重新拉取数据
|
||||
// this.getUsers()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
// 返回提示
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
//返回提示
|
||||
return ElMessage({
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '删除失败,无权限',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
@ -164,33 +203,39 @@ export default {
|
||||
console.log('添加', data)
|
||||
|
||||
//验证是否为空
|
||||
return this.isEmpty(data);
|
||||
if (this.isEmpty(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//先查询用户是否存在
|
||||
request.queryUserRequest(data.username).then(response => {
|
||||
if (response.data.data!==null){
|
||||
return ElMessage({
|
||||
message: '用户名重复',
|
||||
type: 'warning',
|
||||
})
|
||||
}else {
|
||||
//添加成功
|
||||
request.addUserRequest(data).then(response => {
|
||||
if (response.data.code===1){
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
//添加失败
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '该用户已存在',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
//添加成功
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
|
||||
// // 此处重新拉取数据
|
||||
// this.getUsers()
|
||||
// this.search()
|
||||
|
||||
// 刷新数据
|
||||
this.refresh()
|
||||
|
||||
this.dialog.addDialogVisible = false//添加成功关闭窗口
|
||||
return ElMessage({
|
||||
message: '添加成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else {
|
||||
return ElMessage({
|
||||
message: '添加失败',
|
||||
type: 'warning',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 判断表单是否为空
|
||||
@ -258,23 +303,21 @@ export default {
|
||||
console.log('刷新数据')
|
||||
|
||||
//先拉取一遍数据
|
||||
this.getUsers()
|
||||
request.queryUserRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
this.updateUsers(frontendUsers(response.data.data))
|
||||
}
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//可能输入了搜索关键字,故执行一次搜索
|
||||
this.search()
|
||||
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
//获取结果的分页
|
||||
this.getPagesData()
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// // 加载完成后拉取数据
|
||||
// this.getUsers()
|
||||
//
|
||||
// //获取分页后显示的数据
|
||||
// this.getPagesData()
|
||||
|
||||
this.refresh()
|
||||
refreshData();
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@ -341,7 +384,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"
|
||||
@ -353,7 +396,8 @@ export default {
|
||||
|
||||
|
||||
<!-- 添加用户对话框-->
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加用户" width="400" align-center draggable overflow>
|
||||
<el-dialog v-model="dialog.addDialogVisible" title="添加用户" width="400" align-center draggable overflow
|
||||
destroy-on-close>
|
||||
<ZooUserFormDialog>
|
||||
<template #default="scope">
|
||||
<el-button @click="dialog.addDialogVisible = false">
|
||||
|
@ -13,50 +13,52 @@ export default {
|
||||
methods: {
|
||||
...mapMutations(['updateUsers', 'updateAnimals', 'updateBreedingPlans', 'updateArchives','updateHealths']),
|
||||
usersData() {
|
||||
this.updateUsers(generateUsers())
|
||||
generateUsers()
|
||||
return ElMessage({
|
||||
message: '成功',
|
||||
type: 'success',
|
||||
})
|
||||
},
|
||||
animalsData() {
|
||||
this.updateAnimals(generateAnimals())
|
||||
generateAnimals()
|
||||
return ElMessage({
|
||||
message: '成功',
|
||||
type: 'success',
|
||||
})
|
||||
},
|
||||
breedingPlansData() {
|
||||
this.updateBreedingPlans(generateBreedingPlans())
|
||||
generateBreedingPlans()
|
||||
return ElMessage({
|
||||
message: '成功',
|
||||
type: 'success',
|
||||
})
|
||||
},
|
||||
archiveData() {
|
||||
this.updateArchives(generateArchives())
|
||||
generateArchives()
|
||||
return ElMessage({
|
||||
message: '成功',
|
||||
type: 'success',
|
||||
})
|
||||
},
|
||||
healthData() {
|
||||
this.updateHealths(generateHealths())
|
||||
generateHealths()
|
||||
return ElMessage({
|
||||
message: '成功',
|
||||
type: 'success',
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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>
|
||||
生成数据,最好先确保数据库中的各表没有数据再使用,使用方法:从左到右依次点击,每点击应该需等到弹出成功提示才继续点击下一个
|
||||
<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="$router.push('/login')">跳转登录</el-button>
|
||||
</template>
|
||||
|
||||
|
@ -76,7 +76,9 @@ router.beforeEach((to, from, next) => {
|
||||
//不是登录界面都需要权限。。。
|
||||
// console.log(to, from, next);
|
||||
if (to.path !== '/login') {
|
||||
if (!store.state.loginUser) {
|
||||
if (to.path==='/data'){
|
||||
next()
|
||||
}else if (!store.state.loginUser.username) {
|
||||
router.replace({
|
||||
path: '/login',
|
||||
})
|
||||
|
@ -1,55 +1,64 @@
|
||||
import {createStore} from "vuex";
|
||||
import {copy, generateAnimals, generateArchives, generateBreedingPlans, generateUsers} from "@/utils/common.js";
|
||||
import {copy} from "@/utils/common.js";
|
||||
import request, {
|
||||
frontendAnimals,
|
||||
frontendArchives,
|
||||
frontendBreedingPlans,
|
||||
frontendHealths,
|
||||
frontendUsers
|
||||
} from "@/utils/request.js";
|
||||
|
||||
const actions = {
|
||||
//获取登录用户
|
||||
getLoginUser(context, user) {
|
||||
//此处接入后端登录接口验证登录用户名和密码,验证通过方可通行
|
||||
//密码错误
|
||||
if (false) {
|
||||
return ElMessage({
|
||||
message: '用户名不存在或密码错误',
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
//登录成功
|
||||
context.commit('updateLoginUser', user);//存储登录用户,这里拉取远程登录的用户作为参数
|
||||
},
|
||||
//获取用户数据
|
||||
getUsers(context) {
|
||||
console.log('getUsers')
|
||||
//通过后端获取数据
|
||||
// context.commit('updateUsers', generateUsers())
|
||||
context.commit('updateUsers', context.state.users);
|
||||
request.queryUserRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
context.commit('updateUsers', frontendUsers(response.data.data));
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取动物数据
|
||||
getAnimals(context) {
|
||||
console.log('getAnimals')
|
||||
// 通过后端获取数据
|
||||
// context.commit('updateAnimals', generateAnimals())
|
||||
context.commit('updateAnimals', context.state.animals);
|
||||
request.queryAnimalRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
context.commit('updateAnimals', frontendAnimals(response.data.data));
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取饲养计划
|
||||
getBreedingPlans(context) {
|
||||
console.log('getBreedingPlans')
|
||||
// 通过后端获取数据
|
||||
// context.commit('updateBreedingPlans',generateBreedingPlans())
|
||||
context.commit('updateBreedingPlans',context.state.breedingPlans);
|
||||
request.queryBreedingPlanRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
context.commit('updateBreedingPlans',frontendBreedingPlans(response.data.data));
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取动物档案
|
||||
getArchives(context) {
|
||||
console.log('getArchives')
|
||||
// 通过后端获取数据
|
||||
// context.commit('updateArchives', generateArchives())
|
||||
context.commit('updateArchives',context.state.archives);
|
||||
request.queryArchiveRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
context.commit('updateArchives',frontendArchives(response.data.data));
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
//获取监控检测数据
|
||||
getHealths(context) {
|
||||
console.log('getHealths')
|
||||
// 通过后端获取数据
|
||||
// context.commit('updateHealths', generateHealths())
|
||||
context.commit('updateHealths',context.state.healths);
|
||||
request.queryHealthRequest().then(response => {
|
||||
if (response.data.code === 1) {
|
||||
context.commit('updateHealths',frontendHealths(response.data.data));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,17 +127,9 @@ const state = {
|
||||
//登录用户数据
|
||||
loginUser: {
|
||||
id:0,
|
||||
username: 'user1',
|
||||
username: '',
|
||||
auth: 0
|
||||
},
|
||||
// //用户数据
|
||||
// users: [],
|
||||
// //动物数据
|
||||
// animals: [],
|
||||
// //饲养计划
|
||||
// breedingPlans:[],
|
||||
// //动物档案
|
||||
// archives:[],
|
||||
//用户数据
|
||||
users: [],
|
||||
usersTableData:[],//用户表格数据
|
||||
@ -146,8 +147,37 @@ 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
|
||||
state,
|
||||
getters
|
||||
})
|
@ -1,20 +1,30 @@
|
||||
//生成用户数据
|
||||
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 = []
|
||||
// 随机生成40-100条用户数据
|
||||
const n = Math.floor(Math.random() * 60) + 40;
|
||||
// 随机生成20-40条用户数据
|
||||
const n = Math.floor(Math.random() * 20) + 20;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const a = generateAuth()
|
||||
let user = {
|
||||
id: i,
|
||||
username: 'user' + (i + 1),
|
||||
id: i + 2,
|
||||
username: 'user' + (i + 2),
|
||||
password: '123456',
|
||||
auth: a,
|
||||
}
|
||||
users.push(user)
|
||||
request.addUserRequest(user)
|
||||
if (a === 1) {
|
||||
keeper.push(user)
|
||||
} else if (a === 2) {
|
||||
@ -42,11 +52,11 @@ function generateAuth() {
|
||||
//生成动物数据
|
||||
export function generateAnimals() {
|
||||
const animals = []
|
||||
//随机生成100-200只动物
|
||||
const n = Math.floor(Math.random() * 100) + 100;
|
||||
//随机生成40-60只动物
|
||||
const n = Math.floor(Math.random() * 20) + 40;
|
||||
for (let i = 0; i < n; i++) {
|
||||
let animal = {
|
||||
id: i,
|
||||
id: i + 3,
|
||||
name: 'animal' + (i + 1),
|
||||
sex: Math.floor(Math.random() * 2) === 0 ? '雌性' : '雄性',
|
||||
species: '种类' + Math.ceil(Math.random() * 20).toString(),//种类
|
||||
@ -58,9 +68,11 @@ 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
|
||||
}
|
||||
|
||||
@ -129,8 +141,8 @@ function generateNewColor() {
|
||||
export function generateBreedingPlans() {
|
||||
const breedingPlans = []
|
||||
|
||||
//随机生成20种类动物的饲养计划
|
||||
const n = 20;
|
||||
//随机生成5种类动物的饲养计划
|
||||
const n = 5;
|
||||
for (let i = 0; i < n; i++) {
|
||||
//分别生成2种性别的
|
||||
for (let j = 0; j < 2; j++) {
|
||||
@ -139,7 +151,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 ? '雌性' : '雄性',
|
||||
@ -148,6 +160,7 @@ export function generateBreedingPlans() {
|
||||
roleId: generateKeeperId(),
|
||||
description: 'test breeding' + i + '' + j + '' + k + '' + l + ' description',
|
||||
}
|
||||
request.addBreedingPlanRequest(breedingPlan)
|
||||
breedingPlans.push(breedingPlan)
|
||||
}
|
||||
}
|
||||
@ -171,30 +184,30 @@ function generatePhase() {
|
||||
}
|
||||
|
||||
//生成档案
|
||||
export function generateArchives() {
|
||||
export async function generateArchives() {
|
||||
const archives = []
|
||||
|
||||
let aid=0
|
||||
store.state.animals.forEach(e => {
|
||||
let aid = 0
|
||||
for (const e of store.state.animals) {
|
||||
//分为四个周期的档案
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let n;
|
||||
if (i === 0) {
|
||||
//幼年期5-10条档案
|
||||
n = Math.floor(Math.random() * 5) + 5
|
||||
//幼年期5条档案
|
||||
n = 5
|
||||
} else if (i === 1) {
|
||||
//成长期10-20条档案
|
||||
n = Math.floor(Math.random() * 10) + 10
|
||||
//成长期10条档案
|
||||
n = 10
|
||||
} else if (i === 2) {
|
||||
//成年期30-60条档案
|
||||
n = Math.floor(Math.random() * 30) + 30
|
||||
//成年期30条档案
|
||||
n = 30
|
||||
} else {
|
||||
//老年期5-10条档案
|
||||
n = Math.floor(Math.random() * 5) + 5
|
||||
//老年期5条档案
|
||||
n = 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 ? '成年期' : '老年期',
|
||||
@ -205,16 +218,17 @@ export 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,//字符 记录日期
|
||||
@ -222,28 +236,35 @@ export function generateArchives() {
|
||||
description: 'test health' + i + '' + j + ' description',//字符 检测的描述,比如动物的症状
|
||||
}
|
||||
//异常的记录要修改一下监测数据
|
||||
if (health.state===1){
|
||||
health.temperature += Math.random()*2>1?
|
||||
Number((Math.random()*health.temperature*0.5).toFixed(1)):
|
||||
-Number((Math.random()*health.temperature*0.5).toFixed(1))
|
||||
if (health.state === 1) {
|
||||
health.temperature += Math.random() * 2 > 1 ?
|
||||
Number((Math.random() * health.temperature * 0.5).toFixed(1)) :
|
||||
-Number((Math.random() * health.temperature * 0.5).toFixed(1))
|
||||
health.temperature = Number(health.temperature.toFixed(1))
|
||||
health.breathRate += Math.random()*2>1?
|
||||
Math.floor(Math.random()*health.breathRate*0.5):-Math.floor(Math.random()*health.breathRate*0.5)
|
||||
health.heartRate += health.heartRate += Math.random()*2>1?
|
||||
Math.floor(Math.random()*health.heartRate*0.5):-Math.floor(Math.random()*health.heartRate*0.5)
|
||||
health.bloodPressure += health.bloodPressure += Math.random()*2>1?
|
||||
Math.floor(Math.random()*health.bloodPressure*0.5):-Math.floor(Math.random()*health.bloodPressure*0.5)
|
||||
health.breathRate += Math.random() * 2 > 1 ?
|
||||
Math.floor(Math.random() * health.breathRate * 0.5) : -Math.floor(Math.random() * health.breathRate * 0.5)
|
||||
health.heartRate += health.heartRate += Math.random() * 2 > 1 ?
|
||||
Math.floor(Math.random() * health.heartRate * 0.5) : -Math.floor(Math.random() * health.heartRate * 0.5)
|
||||
health.bloodPressure += health.bloodPressure += Math.random() * 2 > 1 ?
|
||||
Math.floor(Math.random() * health.bloodPressure * 0.5) : -Math.floor(Math.random() * health.bloodPressure * 0.5)
|
||||
|
||||
}
|
||||
request.addHealthRequest(health)
|
||||
healths.push(health)
|
||||
aid++
|
||||
await sleep(50)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log('档案', archives)
|
||||
return archives
|
||||
}
|
||||
|
||||
function sleep(time){
|
||||
return new Promise((resolve) => setTimeout(resolve, time));
|
||||
}
|
||||
|
||||
|
||||
const healths = []
|
||||
|
||||
export function generateHealths() {
|
||||
@ -290,7 +311,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;
|
||||
}
|
||||
@ -307,7 +328,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
|
||||
}
|
||||
//只要对象的任意属性能匹配一次关键字就返回true,some():遇到true就返回true,所有false就返回false
|
||||
|
@ -1,7 +1,278 @@
|
||||
import store from "@/store/index.js";
|
||||
import axios from "axios";
|
||||
|
||||
export function getUserById(id) {
|
||||
const data = store.state.users.find(e => e.id === id);
|
||||
const instance = axios.create({
|
||||
// baseURL : `${window.location.origin}/api/zoo`,
|
||||
baseURL : `${window.location.origin}/api/zoo`,
|
||||
})
|
||||
|
||||
return data;
|
||||
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
|
||||
}
|
||||
}
|
@ -1,26 +1,35 @@
|
||||
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({
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
}
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 5000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8888',
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user