Merge branch 'develop' of https://gitea.gentronhealth.com/Yajentine/his into develop

This commit is contained in:
qk123
2025-12-02 16:44:57 +08:00
15 changed files with 927 additions and 62 deletions

76
.github/copilot-instructions.md vendored Normal file
View File

@@ -0,0 +1,76 @@
# OpenHIS — AI 编码助手 指南
目的:帮助自动化/AI 编码代理快速上手本仓库,包含架构要点、关键文件、常用构建/运行命令以及项目约定。请只按照仓库内真实可见的内容提出修改建议或补充说明。
- **代码组织**: 本项目是一个 Java 后端(多模块 Maven+ Vue3 前端Vite的大型应用。
- 后端主模块目录:`openhis-server-new/`(顶层为 `pom`,包含多个子模块)。关键子模块示例:`openhis-application`, `openhis-domain`, `openhis-common`, `core-*` 系列。
- 前端目录:`openhis-ui-vue3/`Vite + Vue 3使用 Pinia、Element Plus 等)。
- **大局观Big Picture**: 后端以 Spring BootJava 17实现使用多模块 Maven 管理公共库与业务模块;前端由单独仓库目录通过 Vite 构建并以环境变量(`VITE_APP_BASE_API`)与后端交互。后端扫描 `com.core``com.openhis` 包(见 `OpenHisApplication.java`),启动类位于:`openhis-server-new/openhis-application/src/main/java/com/openhis/OpenHisApplication.java`
- **运行/构建Windows PowerShell 示例)**:
- 构建后端(从仓库根执行):
```powershell
cd openhis-server-new
mvn clean package -DskipTests
```
- 仅运行后端模块(开发时常用):
```powershell
cd openhis-server-new/openhis-application
mvn spring-boot:run
# 或在 IDE 中运行 `com.openhis.OpenHisApplication` 的 main()
```
- 前端启动与构建(需要 Node.js v16.x仓库 README 建议 v16.15
```powershell
cd openhis-ui-vue3
npm install
npm run dev # 本地开发(热重载)
npm run build:prod # 生产构建
```
- **环境与配置**:
- 后端配置:`openhis-server-new/openhis-application/src/main/resources/application.yml`数据库、端口、profile 等。README 还提及 `application-druid.yml`(若存在请优先查看)。
- 前端配置:多个 `.env.*` 文件(例如 `.env.development`, `.env.staging`, `.env.production`),关键变量:`VITE_APP_BASE_API`(例如 `/dev-api`),前端通过 `import.meta.env.VITE_APP_BASE_API` 拼接后端 URL`src/utils/request.js`、多个视图与组件)。
- **重要约定 / 模式**:
- 后端采用 Java 17、Spring Boot 2.5.x 家族,父 POM在 `openhis-server-new/pom.xml` 定义。常用依赖版本在该 POM 的 `<properties>` 中集中维护。
- 模块间以 Maven 模块依赖与 `com.core` / `com.openhis` 包名分层(见 `pom.xml``<modules>``dependencyManagement`)。
- 前端通过 Vite 插件配置(`openhis-ui-vue3/vite/plugins`)管理 svg、自动导入等。UI 框架为 Element Plus状态管理为 Pinia。
- **集成点 & 外部依赖**:
- 数据库PostgreSQLREADME 建议 v16.2),仓库根含一个大型初始化 SQL`数据库初始话脚本请使用navicat16版本导入.sql`,用于初始化表与演示数据。
- 缓存/会话Redis需自行配置
- 其他Flowable工作流Druid连接池监控第三方服务通过特定配置类例如 `YbServiceConfig``OpenHisApplication` 中启用)。
- **调试与常见位置**:
- 启动类:`openhis-server-new/openhis-application/src/main/java/com/openhis/OpenHisApplication.java`
- 全局配置:`openhis-server-new/openhis-application/src/main/resources/``application.yml`、profile 文件等)。
- 前端入口:`openhis-ui-vue3/src/main.js`、路由在 `openhis-ui-vue3/src/router/index.js`
- API 文档与监控路径(通常由后端暴露并被前端访问):
- Swagger UI: `<VITE_APP_BASE_API>/swagger-ui/index.html`(前端视图在 `src/views/tool/swagger/index.vue`)。
- Druid: `<VITE_APP_BASE_API>/druid/login.html`(见前端相关视图引用)。
- **为 AI 代理的具体建议(如何安全、有效地修改代码)**:
- 修改后端时:优先在子模块(例如 `openhis-application`)本地运行 `mvn spring-boot:run` 验证启动与基础 API大量改动前先执行 `mvn -T1C -DskipTests clean package` 在 CI 环境上验证构建(本地机器也可用)。
- 修改前端时:检查/调整对应 `.env.*` 文件中的 `VITE_APP_BASE_API`,使用 `npm run dev` 本地联调后端接口(可通过代理或将 `VITE_APP_BASE_API` 指向后端地址)。
- 修改数据库结构或 seed请参考仓库根的 SQL 初始化脚本,任何 DDL/数据变更需同步该脚本并通知数据库管理员/运维。
- **举例(常见任务示例)**:
- 本地联调前端 + 后端PowerShell:
```powershell
# 启动后端
cd openhis-server-new/openhis-application
mvn spring-boot:run
# 启动前端(另开终端)
cd openhis-ui-vue3
npm run dev
```
如需我把这些内容合并为更短或更详细的版本,或把其中某部分(例如后端模块依赖关系图、关键 Java 包说明)展开,请告诉我要增强哪一节。

View File

@@ -59,6 +59,8 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
# redis 配置 # redis 配置
redis: redis:
# 地址 # 地址
@@ -85,3 +87,9 @@ spring:
messages: messages:
basename: i18n/general_message/messages basename: i18n/general_message/messages
encoding: utf-8 encoding: utf-8
server:
# 服务器的HTTP端口默认为18080
port: 18080
servlet:
# 应用的访问路径
context-path: /openhis

View File

@@ -6,7 +6,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=public&characterEncoding=UTF-8&client_encoding=UTF-8 url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=hisprd&characterEncoding=UTF-8&client_encoding=UTF-8
username: postgresql username: postgresql
password: Jchl1528 password: Jchl1528
# 从库数据源 # 从库数据源
@@ -85,3 +85,9 @@ spring:
messages: messages:
basename: i18n/general_message/messages basename: i18n/general_message/messages
encoding: utf-8 encoding: utf-8
server:
# 服务器的HTTP端口默认为18080
port: 18082
servlet:
# 应用的访问路径
context-path: /openhis

View File

@@ -0,0 +1,93 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: org.postgresql.Driver
druid:
# 主库数据源
master:
url: jdbc:postgresql://192.168.110.252:15432/postgresql?currentSchema=histest&characterEncoding=UTF-8&client_encoding=UTF-8
username: postgresql
password: Jchl1528
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled:
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 # FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: openhis
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# redis 配置
redis:
# 地址
host: 192.168.110.252
# 端口默认为6379
port: 6379
# 数据库索引
database: 1
# 密码
password: Jchl1528
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
# 文言
messages:
basename: i18n/general_message/messages
encoding: utf-8
server:
# 服务器的HTTP端口默认为18080
port: 18081
servlet:
# 应用的访问路径
context-path: /openhis

View File

@@ -15,11 +15,6 @@ core:
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口默认为18080
port: 18080
servlet:
# 应用的访问路径
context-path: /openhis
tomcat: tomcat:
# tomcat的URI编码 # tomcat的URI编码
uri-encoding: UTF-8 uri-encoding: UTF-8
@@ -54,7 +49,7 @@ spring:
# 国际化资源文件路径 # 国际化资源文件路径
basename: i18n/messages basename: i18n/messages
profiles: profiles:
active: local #本地local 生产prod (农大) active: dev
# 文件上传 # 文件上传
servlet: servlet:
multipart: multipart:

View File

@@ -2,7 +2,10 @@
VITE_APP_TITLE = 医院信息管理系统 VITE_APP_TITLE = 医院信息管理系统
# 开发环境配置 # 开发环境配置
VITE_APP_ENV = 'development' VITE_APP_ENV = 'dev'
# OpenHIS管理系统/开发环境 # OpenHIS管理系统/开发环境
VITE_APP_BASE_API = '/dev-api' VITE_APP_BASE_API = '/dev-api'
# 租户ID配置
VITE_APP_TENANT_ID = '1'

View File

@@ -2,10 +2,13 @@
VITE_APP_TITLE=医院信息管理系统 VITE_APP_TITLE=医院信息管理系统
# 生产环境配置 # 生产环境配置
VITE_APP_ENV=production VITE_APP_ENV= 'prod'
# OpenHIS管理系统/生产环境 # OpenHIS管理系统/生产环境
VITE_APP_BASE_API=/prod-api VITE_APP_BASE_API= '/prd-api'
# 租户ID配置
VITE_APP_TENANT_ID= '1'
# 是否在打包时开启压缩,支持 gzip 和 brotli # 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS=gzip VITE_BUILD_COMPRESS = gzip

View File

@@ -13,6 +13,9 @@ VITE_UPLOAD_TYPE=server
# OpenHIS管理系统/SPUG环境 # OpenHIS管理系统/SPUG环境
VITE_APP_BASE_API = '/admin-api' VITE_APP_BASE_API = '/admin-api'
# 租户ID配置
VITE_APP_TENANT_ID=1
# 是否删除debugger # 是否删除debugger
VITE_DROP_DEBUGGER=false VITE_DROP_DEBUGGER=false

View File

@@ -7,5 +7,8 @@ VITE_APP_ENV = 'staging'
# OpenHIS管理系统/生产环境 # OpenHIS管理系统/生产环境
VITE_APP_BASE_API = '/stage-api' VITE_APP_BASE_API = '/stage-api'
# 租户ID配置
VITE_APP_TENANT_ID=1
# 是否在打包时开启压缩,支持 gzip 和 brotli # 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip VITE_BUILD_COMPRESS = gzip

12
openhis-ui-vue3/.env.test Normal file
View File

@@ -0,0 +1,12 @@
# 页面标题
VITE_APP_TITLE = 医院信息管理系统
# 测试环境配置
VITE_APP_ENV = 'test'
# OpenHIS管理系统/测试环境
VITE_APP_BASE_API = '/test-api'
# 租户ID配置
VITE_APP_TENANT_ID = '1'

View File

@@ -910,6 +910,7 @@
"version": "4.17.12", "version": "4.17.12",
"resolved": "https://registry.npmmirror.com/@types/lodash-es/-/lodash-es-4.17.12.tgz", "resolved": "https://registry.npmmirror.com/@types/lodash-es/-/lodash-es-4.17.12.tgz",
"integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
"peer": true,
"dependencies": { "dependencies": {
"@types/lodash": "*" "@types/lodash": "*"
} }
@@ -919,6 +920,7 @@
"resolved": "https://registry.npmmirror.com/@types/node/-/node-22.13.10.tgz", "resolved": "https://registry.npmmirror.com/@types/node/-/node-22.13.10.tgz",
"integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==", "integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"undici-types": "~6.20.0" "undici-types": "~6.20.0"
} }
@@ -2324,6 +2326,7 @@
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmmirror.com/d3-selection/-/d3-selection-3.0.0.tgz", "resolved": "https://registry.npmmirror.com/d3-selection/-/d3-selection-3.0.0.tgz",
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
} }
@@ -4215,7 +4218,8 @@
"node_modules/jquery": { "node_modules/jquery": {
"version": "3.7.1", "version": "3.7.1",
"resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.1.tgz", "resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.1.tgz",
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==" "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
"peer": true
}, },
"node_modules/js-base64": { "node_modules/js-base64": {
"version": "2.6.4", "version": "2.6.4",
@@ -4345,12 +4349,14 @@
"node_modules/lodash": { "node_modules/lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"peer": true
}, },
"node_modules/lodash-es": { "node_modules/lodash-es": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmmirror.com/lodash-es/-/lodash-es-4.17.21.tgz", "resolved": "https://registry.npmmirror.com/lodash-es/-/lodash-es-4.17.21.tgz",
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
"peer": true
}, },
"node_modules/lodash-unified": { "node_modules/lodash-unified": {
"version": "1.0.3", "version": "1.0.3",
@@ -5079,6 +5085,7 @@
"url": "https://github.com/sponsors/ai" "url": "https://github.com/sponsors/ai"
} }
], ],
"peer": true,
"dependencies": { "dependencies": {
"nanoid": "^3.3.8", "nanoid": "^3.3.8",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@@ -5480,6 +5487,7 @@
"resolved": "https://registry.npmmirror.com/rollup/-/rollup-4.35.0.tgz", "resolved": "https://registry.npmmirror.com/rollup/-/rollup-4.35.0.tgz",
"integrity": "sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg==", "integrity": "sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"@types/estree": "1.0.6" "@types/estree": "1.0.6"
}, },
@@ -5644,6 +5652,7 @@
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.69.5.tgz", "resolved": "https://registry.npmmirror.com/sass/-/sass-1.69.5.tgz",
"integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"chokidar": ">=3.0.0 <4.0.0", "chokidar": ">=3.0.0 <4.0.0",
"immutable": "^4.0.0", "immutable": "^4.0.0",
@@ -5666,6 +5675,7 @@
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmmirror.com/segmentit/-/segmentit-2.0.3.tgz", "resolved": "https://registry.npmmirror.com/segmentit/-/segmentit-2.0.3.tgz",
"integrity": "sha512-7mn2XL3OdTUQ+AhHz7SbgyxLTaQRzTWQNVwiK+UlTO8aePGbSwvKUzTwE4238+OUY9MoR6ksAg35zl8sfTunQQ==", "integrity": "sha512-7mn2XL3OdTUQ+AhHz7SbgyxLTaQRzTWQNVwiK+UlTO8aePGbSwvKUzTwE4238+OUY9MoR6ksAg35zl8sfTunQQ==",
"peer": true,
"dependencies": { "dependencies": {
"preval.macro": "^4.0.0" "preval.macro": "^4.0.0"
} }
@@ -7023,6 +7033,7 @@
"resolved": "https://registry.npmjs.org/vite/-/vite-5.0.4.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.4.tgz",
"integrity": "sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==", "integrity": "sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==",
"dev": true, "dev": true,
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.19.3", "esbuild": "^0.19.3",
"postcss": "^8.4.31", "postcss": "^8.4.31",
@@ -7116,6 +7127,7 @@
"version": "3.5.13", "version": "3.5.13",
"resolved": "https://registry.npmmirror.com/vue/-/vue-3.5.13.tgz", "resolved": "https://registry.npmmirror.com/vue/-/vue-3.5.13.tgz",
"integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==",
"peer": true,
"dependencies": { "dependencies": {
"@vue/compiler-dom": "3.5.13", "@vue/compiler-dom": "3.5.13",
"@vue/compiler-sfc": "3.5.13", "@vue/compiler-sfc": "3.5.13",
@@ -7894,6 +7906,7 @@
"version": "4.17.12", "version": "4.17.12",
"resolved": "https://registry.npmmirror.com/@types/lodash-es/-/lodash-es-4.17.12.tgz", "resolved": "https://registry.npmmirror.com/@types/lodash-es/-/lodash-es-4.17.12.tgz",
"integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
"peer": true,
"requires": { "requires": {
"@types/lodash": "*" "@types/lodash": "*"
} }
@@ -7903,6 +7916,7 @@
"resolved": "https://registry.npmmirror.com/@types/node/-/node-22.13.10.tgz", "resolved": "https://registry.npmmirror.com/@types/node/-/node-22.13.10.tgz",
"integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==", "integrity": "sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"undici-types": "~6.20.0" "undici-types": "~6.20.0"
} }
@@ -8957,7 +8971,8 @@
"d3-selection": { "d3-selection": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmmirror.com/d3-selection/-/d3-selection-3.0.0.tgz", "resolved": "https://registry.npmmirror.com/d3-selection/-/d3-selection-3.0.0.tgz",
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==" "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
"peer": true
}, },
"d3-shape": { "d3-shape": {
"version": "3.2.0", "version": "3.2.0",
@@ -10316,7 +10331,8 @@
"jquery": { "jquery": {
"version": "3.7.1", "version": "3.7.1",
"resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.1.tgz", "resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.1.tgz",
"integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==" "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==",
"peer": true
}, },
"js-base64": { "js-base64": {
"version": "2.6.4", "version": "2.6.4",
@@ -10424,12 +10440,14 @@
"lodash": { "lodash": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz", "resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"peer": true
}, },
"lodash-es": { "lodash-es": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmmirror.com/lodash-es/-/lodash-es-4.17.21.tgz", "resolved": "https://registry.npmmirror.com/lodash-es/-/lodash-es-4.17.21.tgz",
"integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==",
"peer": true
}, },
"lodash-unified": { "lodash-unified": {
"version": "1.0.3", "version": "1.0.3",
@@ -10934,6 +10952,7 @@
"version": "8.5.3", "version": "8.5.3",
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.3.tgz", "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.5.3.tgz",
"integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==",
"peer": true,
"requires": { "requires": {
"nanoid": "^3.3.8", "nanoid": "^3.3.8",
"picocolors": "^1.1.1", "picocolors": "^1.1.1",
@@ -11238,6 +11257,7 @@
"resolved": "https://registry.npmmirror.com/rollup/-/rollup-4.35.0.tgz", "resolved": "https://registry.npmmirror.com/rollup/-/rollup-4.35.0.tgz",
"integrity": "sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg==", "integrity": "sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"@rollup/rollup-android-arm-eabi": "4.35.0", "@rollup/rollup-android-arm-eabi": "4.35.0",
"@rollup/rollup-android-arm64": "4.35.0", "@rollup/rollup-android-arm64": "4.35.0",
@@ -11351,6 +11371,7 @@
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.69.5.tgz", "resolved": "https://registry.npmmirror.com/sass/-/sass-1.69.5.tgz",
"integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==", "integrity": "sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"chokidar": ">=3.0.0 <4.0.0", "chokidar": ">=3.0.0 <4.0.0",
"immutable": "^4.0.0", "immutable": "^4.0.0",
@@ -11367,6 +11388,7 @@
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmmirror.com/segmentit/-/segmentit-2.0.3.tgz", "resolved": "https://registry.npmmirror.com/segmentit/-/segmentit-2.0.3.tgz",
"integrity": "sha512-7mn2XL3OdTUQ+AhHz7SbgyxLTaQRzTWQNVwiK+UlTO8aePGbSwvKUzTwE4238+OUY9MoR6ksAg35zl8sfTunQQ==", "integrity": "sha512-7mn2XL3OdTUQ+AhHz7SbgyxLTaQRzTWQNVwiK+UlTO8aePGbSwvKUzTwE4238+OUY9MoR6ksAg35zl8sfTunQQ==",
"peer": true,
"requires": { "requires": {
"preval.macro": "^4.0.0" "preval.macro": "^4.0.0"
} }
@@ -12422,6 +12444,7 @@
"resolved": "https://registry.npmjs.org/vite/-/vite-5.0.4.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.4.tgz",
"integrity": "sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==", "integrity": "sha512-RzAr8LSvM8lmhB4tQ5OPcBhpjOZRZjuxv9zO5UcxeoY2bd3kP3Ticd40Qma9/BqZ8JS96Ll/jeBX9u+LJZrhVg==",
"dev": true, "dev": true,
"peer": true,
"requires": { "requires": {
"esbuild": "^0.19.3", "esbuild": "^0.19.3",
"fsevents": "~2.3.3", "fsevents": "~2.3.3",
@@ -12468,6 +12491,7 @@
"version": "3.5.13", "version": "3.5.13",
"resolved": "https://registry.npmmirror.com/vue/-/vue-3.5.13.tgz", "resolved": "https://registry.npmmirror.com/vue/-/vue-3.5.13.tgz",
"integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==",
"peer": true,
"requires": { "requires": {
"@vue/compiler-dom": "3.5.13", "@vue/compiler-dom": "3.5.13",
"@vue/compiler-sfc": "3.5.13", "@vue/compiler-sfc": "3.5.13",

View File

@@ -7,8 +7,10 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build:prod": "vite build --mode production", "build:prod": "vite build --mode prod",
"build:stage": "vite build --mode staging", "build:stage": "vite build --mode staging",
"build:test": "vite build --mode test",
"build:dev": "vite build --mode dev",
"preview": "vite preview", "preview": "vite preview",
"build:spug": "vite build --mode spug" "build:spug": "vite build --mode spug"
}, },

View File

@@ -12,7 +12,8 @@ let downloadLoadingInstance;
export let isRelogin = { show: false }; export let isRelogin = { show: false };
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
axios.defaults.headers['X-Tenant-ID'] = '1' // 从环境变量读取租户ID如果没有则使用默认值'1'
axios.defaults.headers['X-Tenant-ID'] = import.meta.env.VITE_APP_TENANT_ID || '1'
axios.defaults.headers['Request-Method-Name'] = 'login' axios.defaults.headers['Request-Method-Name'] = 'login'
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({

View File

@@ -1,16 +1,16 @@
<template> <template>
<!-- <div class="app-container"> --> <!-- <div class="app-container"> -->
<!-- 添加或修改对话框 --> <!-- 添加或修改对话框 -->
<el-dialog :title="title" v-model="visible" width="1020px" append-to-body> <el-dialog :title="title" v-model="visible" width="1200px" append-to-body>
<el-form ref="patientRef" :model="form" :rules="rules" label-width="120px" label-position="left"> <el-form ref="patientRef" :model="form" :rules="rules" label-width="120px" label-position="left">
<!-- 第一行姓名民族性别 --> <!-- 第一行姓名民族文化程度性别 -->
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="8"> <el-col :span="6">
<el-form-item label="姓名" prop="name" label-width="80px"> <el-form-item label="姓名" prop="name" label-width="80px">
<el-input v-model="form.name" clearable :disabled="isViewMode" /> <el-input v-model="form.name" clearable :disabled="isViewMode" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="6">
<el-form-item label="民族" prop="nationalityCode" label-width="80px"> <el-form-item label="民族" prop="nationalityCode" label-width="80px">
<el-select v-model="form.nationalityCode" clearable filterable :disabled="isViewMode"> <el-select v-model="form.nationalityCode" clearable filterable :disabled="isViewMode">
<el-option <el-option
@@ -22,12 +22,28 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="6">
<el-form-item label="文化程度" prop="educationLevel" label-width="80px">
<el-select v-model="form.educationLevel" placeholder="请选择文化程度" clearable :disabled="isViewMode">
<el-option
v-for="item in educationLevelList"
:key="item.value"
:label="item.info"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="性别" prop="genderEnum" label-width="80px"> <el-form-item label="性别" prop="genderEnum" label-width="80px">
<el-radio-group v-model="form.genderEnum" :disabled="isViewMode"> <el-select v-model="form.genderEnum" placeholder="请选择性别" clearable :disabled="isViewMode">
<el-radio :label="0">男性</el-radio> <el-option
<el-radio :label="1">女性</el-radio> v-for="item in administrativegenderList"
</el-radio-group> :key="item.value"
:label="item.info"
:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -70,11 +86,18 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 第三行家编码*联系方式工作单位 --> <!-- 第三行*联系方式工作单位 -->
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="8"> <el-col :span="8">
<el-form-item label="国家编码" prop="countryCode" label-width="80px"> <el-form-item label="国" prop="countryCode" label-width="80px">
<el-input v-model="form.countryCode" clearable :disabled="isViewMode" /> <el-select v-model="form.countryCode" placeholder="请选择国籍" clearable filterable :disabled="isViewMode">
<el-option
v-for="item in countryCodeList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@@ -97,7 +120,7 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 第三行就诊卡号国家编码出生日期 --> <!-- 第三行就诊卡号职业邮政编码 -->
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="就诊卡号" prop="identifierNo"> <el-form-item label="就诊卡号" prop="identifierNo">
@@ -116,16 +139,29 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="邮政编码" prop="postalCode">
<el-input v-model="form.postalCode" clearable :disabled="isViewMode" placeholder="请输入邮政编码" />
</el-form-item>
</el-col>
</el-row>
<!-- 第四行工作单位 -->
<el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="工作单位" prop="workCompany"> <el-form-item label="工作单位" prop="workCompany">
<el-input v-model="form.workCompany" clearable :disabled="isViewMode" /> <el-input v-model="form.workCompany" clearable :disabled="isViewMode" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="16">
<el-form-item label="单位地址" prop="companyAddress">
<el-input v-model="form.companyAddress" clearable :disabled="isViewMode" />
</el-form-item>
</el-col>
</el-row> </el-row>
<!-- 址选择详细地址 --> <!-- 现住址选择详细地址 -->
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="地址选择" prop="addressSelect"> <el-form-item label="现住址" prop="addressSelect">
<el-cascader <el-cascader
:options="options" :options="options"
:props="{ checkStrictly: true, value: 'code', label: 'name' }" :props="{ checkStrictly: true, value: 'code', label: 'name' }"
@@ -147,6 +183,31 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 户籍地址选择详细地址 -->
<el-row>
<el-col :span="8">
<el-form-item label="户籍地址" prop="hukouAddressSelect">
<el-cascader
:options="options"
:props="{ checkStrictly: true, value: 'code', label: 'name' }"
v-model="selectedHukouOptions"
@change="handleHukouChange"
:disabled="isViewMode"
>
<template #default="{ node, data }">
<span>{{ data.name }}</span>
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
</template>
</el-cascader>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="详细地址" prop="hukouAddress">
<el-input v-model="form.hukouAddress" clearable :disabled="isViewMode" />
</el-form-item>
</el-col>
</el-row>
<!-- 第六行血型ABO血型RH --> <!-- 第六行血型ABO血型RH -->
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
@@ -178,6 +239,18 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-form-item label="患者来源" prop="patientDerived">
<el-select v-model="form.patientDerived" placeholder="患者来源" clearable :disabled="isViewMode">
<el-option
v-for="item in patientDerivedList"
:key="item.value"
:label="item.info"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
</el-row> </el-row>
<!-- 第七行婚姻状态死亡时间 --> <!-- 第七行婚姻状态死亡时间 -->
@@ -307,16 +380,146 @@ const {
); );
const selectedOptions = ref([]); // v-model 绑定的选中值 const selectedOptions = ref([]); // v-model 绑定的选中值
const selectedHukouOptions = ref([]); // 户籍地址v-model 绑定的选中值
const maritalstatusList = ref([]); //婚姻 const maritalstatusList = ref([]); //婚姻
const occupationtypeList = ref([]); //职业 const occupationtypeList = ref([]); //职业
const administrativegenderList = ref([]); //性别 const administrativegenderList = ref([]); //性别
const bloodtypeaboList = ref([]); //血型abo const bloodtypeaboList = ref([]); //血型abo
const bloodtypearhList = ref([]); //血型RH const bloodtypearhList = ref([]); //血型RH
const familyrelationshiptypeList = ref([]); //家庭关系 const familyrelationshiptypeList = ref([]); //家庭关系
const patientDerivedList = ref([]); //患者来源
// 使用 ref 定义查询所得用户信息数据 // 使用 ref 定义查询所得用户信息数据
const patientInfo = ref(undefined); const patientInfo = ref(undefined);
const addressCom = ref(''); //地址 const addressCom = ref(''); //地址
const educationLevelList = ref([]); //文化程度
const countryCodeList = ref([]); //国家地区代码
// 从字典管理获取患者来源数据
const getPatientDerivedOptions = async () => {
try {
console.log('开始获取患者来源字典数据...');
// 从字典管理获取患者来源数据字典类型为patient_derived
const patientDerivedDict = await proxy.getDictDataByType('patient_derived');
console.log('获取到的患者来源原始数据:', patientDerivedDict);
// 确保数据是数组
if (!Array.isArray(patientDerivedDict)) {
console.error('患者来源数据格式错误,不是数组:', patientDerivedDict);
return;
}
// 按字典排序字段sort字段升序排序
const sortedPatientDerived = patientDerivedDict.sort((a, b) => {
// 尝试获取排序字段可能的字段名sort, orderNum, dictSort等
const sortA = a.sort || a.orderNum || a.dictSort || 0;
const sortB = b.sort || b.orderNum || b.dictSort || 0;
return sortA - sortB;
});
console.log('按排序字段排序后的患者来源数据:', sortedPatientDerived);
// 转换为组件需要的格式,确保使用正确的字段名称
patientDerivedList.value = sortedPatientDerived.map(item => ({
value: item.value || item.dictValue || item.code || '', // 使用字典键值
info: item.label || item.dictLabel || item.name || '' // 使用info字段作为显示文本与模板中的:label="item.info"匹配)
}));
console.log('处理后的患者来源选项:', patientDerivedList.value);
} catch (error) {
console.error('获取患者来源字典数据失败:', error);
// 改进的降级方案:使用默认的患者来源选项
patientDerivedList.value = [
{ value: '1', info: '熟人介绍' },
{ value: '2', info: '电视广告' },
{ value: '3', info: '公交站牌' },
{ value: '99', info: '其他' }
];
console.warn('使用默认患者来源数据作为降级方案');
}
};
// 从字典管理获取性别数据
const getGenderOptions = async () => {
try {
// 从字典管理获取性别数据
const genderDict = await proxy.getDictDataByType('性别');
// 按字典排序字段排序
const sortedGenders = genderDict.sort((a, b) => {
return (a.sort || 0) - (b.sort || 0);
});
// 转换为组件需要的格式
administrativegenderList.value = sortedGenders.map(item => ({
value: item.value, // 使用字典键值
info: item.label // 使用字典标签
}));
} catch (error) {
console.error('获取性别字典数据失败:', error);
// 降级方案:使用默认的性别选项
administrativegenderList.value = [
{ value: '1', info: '男' },
{ value: '2', info: '女' },
{ value: '9', info: '未说明性别' },
{ value: '0', info: '未知的性别' }
];
}
};
// 从字典管理获取文化程度数据
const getEducationLevelOptions = async () => {
try {
// 从字典管理获取文化程度数据
const educationDict = await proxy.getDictDataByType('文化程度');
console.log('获取到的文化程度数据:', educationDict);
// 确保数据是数组
if (!Array.isArray(educationDict)) {
console.error('文化程度数据格式错误,不是数组:', educationDict);
return;
}
// 按字典编码顺序升序排列(根据截图显示,排序字段为字典编码)
const sortedEducation = educationDict.sort((a, b) => {
// 获取字典编码可能的字段名code, dictCode, 或 value
const codeA = a.code || a.dictCode || a.value || '';
const codeB = b.code || b.dictCode || b.value || '';
// 尝试将编码转换为数字进行升序排序
const numA = parseInt(codeA);
const numB = parseInt(codeB);
// 如果都是有效数字,则按数字排序,否则按字符串排序
if (!isNaN(numA) && !isNaN(numB)) {
return numA - numB;
} else {
return codeA.localeCompare(codeB);
}
});
console.log('按字典编码排序后的文化程度数据:', sortedEducation);
// 转换为组件需要的格式
educationLevelList.value = sortedEducation.map(item => ({
value: item.value || item.dictValue || item.code || '', // 使用字典键值或编码
info: item.label || item.dictLabel || item.name || '' // 使用字典标签
}));
console.log('处理后的文化程度选项:', educationLevelList.value);
} catch (error) {
console.error('获取文化程度字典数据失败:', error);
// 降级方案:使用默认的文化程度选项,按编码顺序排列
educationLevelList.value = [
{ value: '3912', info: '大学本科' },
{ value: '3913', info: '硕士研究生' },
{ value: '3914', info: '博士研究生' },
{ value: '3915', info: '初中毕业' },
{ value: '3916', info: '大学毕业' },
{ value: '3917', info: '技工学校毕业' },
{ value: '3918', info: '职业高中毕业' },
{ value: '3919', info: '小学毕业' },
{ value: '3920', info: '普通高中毕业' },
{ value: '3921', info: '中等专科毕业' }
].sort((a, b) => parseInt(a.value) - parseInt(b.value)); // 确保默认选项也按编码排序
}
};
const options = ref(pcas); // 地区数据 const options = ref(pcas); // 地区数据
const title = ref('新增患者'); const title = ref('新增患者');
@@ -406,11 +609,25 @@ const data = reactive({
typeCode: '08', typeCode: '08',
birthDate: undefined, birthDate: undefined,
age: undefined, age: undefined,
genderEnum: '1', // 默认设置为'男'
hukouAddressSelect: undefined,
hukouAddress: undefined,
postalCode: undefined,
companyAddress: undefined,
patientDerived: undefined,
}, },
rules: { rules: {
name: [{ required: true, message: '姓名不能为空', trigger: 'change' }, name: [{ required: true, message: '姓名不能为空', trigger: 'change' },
{ validator: validateUniquePatient, trigger: 'blur' } { validator: validateUniquePatient, trigger: 'blur' }
], ],
postalCode: [
{ required: false, message: '邮政编码非必填', trigger: 'change' },
{ pattern: /^\d{6}$/, message: '邮政编码格式应为6位数字', trigger: 'blur' }
],
hukouAddressSelect: [{ required: false, message: '户籍地址选择非必填', trigger: 'change' }],
hukouAddress: [{ required: false, message: '户籍详细地址非必填', trigger: 'change' }],
companyAddress: [{ required: false, message: '单位地址非必填', trigger: 'change' }],
patientDerived: [{ required: false, message: '患者来源非必填', trigger: 'change' }],
genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }], genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }],
age: [{ required: true, message: '年龄不能为空', trigger: 'change' }], age: [{ required: true, message: '年龄不能为空', trigger: 'change' }],
phone: [{ required: true, message: '联系方式不能为空', trigger: 'change' }], phone: [{ required: true, message: '联系方式不能为空', trigger: 'change' }],
@@ -516,7 +733,7 @@ function getList() {
patientlLists().then((response) => { patientlLists().then((response) => {
console.log(response); console.log(response);
occupationtypeList.value = response.data.occupationType; occupationtypeList.value = response.data.occupationType;
administrativegenderList.value = response.data.sex; // 移除直接从patientlLists设置性别的代码
bloodtypeaboList.value = response.data.bloodTypeABO; bloodtypeaboList.value = response.data.bloodTypeABO;
bloodtypearhList.value = response.data.bloodTypeRH; bloodtypearhList.value = response.data.bloodTypeRH;
familyrelationshiptypeList.value = response.data.familyRelationshipType; familyrelationshiptypeList.value = response.data.familyRelationshipType;
@@ -539,7 +756,7 @@ function getPatientInfo(idCard) {
} }
}); });
} }
//址选择 //现住址选择
const handleChange = () => { const handleChange = () => {
const checkedNodes = selectedOptions.value.map((code) => { const checkedNodes = selectedOptions.value.map((code) => {
const node = findNodeByCode(options.value, code); const node = findNodeByCode(options.value, code);
@@ -552,6 +769,19 @@ const handleChange = () => {
form.value.address = ''; form.value.address = '';
}; };
//户籍地址选择
const handleHukouChange = () => {
const checkedNodes = selectedHukouOptions.value.map((code) => {
const node = findNodeByCode(options.value, code);
return node ? node.name : null;
});
form.value.hukouAddressProvince = checkedNodes[0] || '';
form.value.hukouAddressCity = checkedNodes[1] || '';
form.value.hukouAddressDistrict = checkedNodes[2] || '';
form.value.hukouAddressStreet = checkedNodes[3] || '';
form.value.hukouAddress = '';
};
// 递归查找节点 // 递归查找节点
const findNodeByCode = (data, code) => { const findNodeByCode = (data, code) => {
for (const item of data) { for (const item of data) {
@@ -563,10 +793,415 @@ const findNodeByCode = (data, code) => {
} }
return null; return null;
}; };
// 从字典管理获取国家地区代码数据
const getCountryCodeOptions = async () => {
try {
console.log('开始获取国家地区代码数据...');
// 确保使用正确的字典名称获取完整数据
let countryDict = [];
// 定义多个可能的字典类型名称优先使用nat_regn_code
const dictTypes = ['nat_regn_code', 'country_code', 'COUNTRY_CODE', '国家地区代码'];
let success = false;
// 尝试使用useDict方法获取数据遍历不同的字典类型
if (proxy.useDict && typeof proxy.useDict === 'function') {
for (const dictType of dictTypes) {
try {
const dictResult = await proxy.useDict(dictType);
if (dictResult && dictResult[dictType] && Array.isArray(dictResult[dictType]) && dictResult[dictType].length > 0) {
countryDict = dictResult[dictType];
console.log(`通过useDict(${dictType})获取到的国家地区代码数据数量:`, countryDict.length);
success = true;
break;
}
} catch (err) {
console.warn(`useDict(${dictType})调用失败,尝试下一种方式:`, err.message);
}
}
}
// 如果useDict失败尝试直接调用API获取字典数据
if (!success && proxy.request && typeof proxy.request === 'function') {
try {
console.log('尝试直接调用API获取国家地区代码数据...');
// 直接调用字典数据API优先使用nat_regn_code接口路径
const response = await proxy.request({
url: '/system/dict/data/type/nat_regn_code',
method: 'get'
});
if (response && response.code === 200 && Array.isArray(response.data)) {
countryDict = response.data;
console.log('通过API直接调用获取到的国家地区代码数据数量:', countryDict.length);
success = true;
} else {
// 如果nat_regn_code接口失败尝试使用country_code
const fallbackResponse = await proxy.request({
url: '/system/dict/data/type/country_code',
method: 'get'
});
if (fallbackResponse && fallbackResponse.code === 200 && Array.isArray(fallbackResponse.data)) {
countryDict = fallbackResponse.data;
console.log('通过备用API获取到的国家地区代码数据数量:', countryDict.length);
success = true;
}
}
} catch (apiError) {
console.error('API直接调用失败:', apiError);
}
}
// 如果仍然未获取到数据使用与nat_regn_code字典一致的模拟数据
if (!Array.isArray(countryDict) || countryDict.length === 0) {
console.warn('未获取到国家地区代码数据或数据格式错误使用与nat_regn_code字典一致的模拟数据');
// 创建与nat_regn_code字典一致的模拟数据基于数据库中的数据格式
const mockCountries = [
{ dictValue: 'CHN', dictLabel: '中国' },
{ dictValue: 'HKG', dictLabel: '香港' },
{ dictValue: 'MAC', dictLabel: '澳门' },
{ dictValue: 'TWN', dictLabel: '台湾' },
{ dictValue: 'AFG', dictLabel: '阿富汗' },
{ dictValue: 'ALB', dictLabel: '阿尔巴尼亚' },
{ dictValue: 'DZA', dictLabel: '阿尔及利亚' },
{ dictValue: 'ASM', dictLabel: '美属萨摩亚' },
{ dictValue: 'AND', dictLabel: '安道尔' },
{ dictValue: 'AGO', dictLabel: '安哥拉' },
{ dictValue: 'AIA', dictLabel: '安圭拉' },
{ dictValue: 'ATA', dictLabel: '南极洲' },
{ dictValue: 'ATG', dictLabel: '安提瓜和巴布达' },
{ dictValue: 'ARG', dictLabel: '阿根廷' },
{ dictValue: 'ARM', dictLabel: '亚美尼亚' },
{ dictValue: 'ABW', dictLabel: '阿鲁巴' },
{ dictValue: 'AUS', dictLabel: '澳大利亚' },
{ dictValue: 'AUT', dictLabel: '奥地利' },
{ dictValue: 'AZE', dictLabel: '阿塞拜疆' },
{ dictValue: 'BHS', dictLabel: '巴哈马' },
{ dictValue: 'BHR', dictLabel: '巴林' },
{ dictValue: 'BGD', dictLabel: '孟加拉国' },
{ dictValue: 'BRB', dictLabel: '巴巴多斯' },
{ dictValue: 'BLR', dictLabel: '白俄罗斯' },
{ dictValue: 'BEL', dictLabel: '比利时' },
{ dictValue: 'BLZ', dictLabel: '伯利兹' },
{ dictValue: 'BEN', dictLabel: '贝宁' },
{ dictValue: 'BMU', dictLabel: '百慕大' },
{ dictValue: 'BTN', dictLabel: '不丹' },
{ dictValue: 'BOL', dictLabel: '玻利维亚' },
{ dictValue: 'BIH', dictLabel: '波黑' },
{ dictValue: 'BWA', dictLabel: '博茨瓦纳' },
{ dictValue: 'BVT', dictLabel: '布维岛' },
{ dictValue: 'BRA', dictLabel: '巴西' },
{ dictValue: 'IOT', dictLabel: '英属印度洋领土' },
{ dictValue: 'BRN', dictLabel: '文莱' },
{ dictValue: 'BGR', dictLabel: '保加利亚' },
{ dictValue: 'BFA', dictLabel: '布基纳法索' },
{ dictValue: 'BDI', dictLabel: '布隆迪' },
{ dictValue: 'KHM', dictLabel: '柬埔寨' },
{ dictValue: 'CMR', dictLabel: '喀麦隆' },
{ dictValue: 'CAN', dictLabel: '加拿大' },
{ dictValue: 'CPV', dictLabel: '佛得角' },
{ dictValue: 'CYM', dictLabel: '开曼群岛' },
{ dictValue: 'CAF', dictLabel: '中非' },
{ dictValue: 'TCD', dictLabel: '乍得' },
{ dictValue: 'CHL', dictLabel: '智利' },
{ dictValue: 'CXR', dictLabel: '圣诞岛' },
{ dictValue: 'CCK', dictLabel: '科科斯(基林)群岛' },
{ dictValue: 'COL', dictLabel: '哥伦比亚' },
{ dictValue: 'COM', dictLabel: '科摩罗' },
{ dictValue: 'COG', dictLabel: '刚果(布)' },
{ dictValue: 'COD', dictLabel: '刚果(金)' },
{ dictValue: 'COK', dictLabel: '库克群岛' },
{ dictValue: 'CRI', dictLabel: '哥斯达黎加' },
{ dictValue: 'CIV', dictLabel: '科特迪瓦' },
{ dictValue: 'HRV', dictLabel: '克罗地亚' },
{ dictValue: 'CUB', dictLabel: '古巴' },
{ dictValue: 'CYP', dictLabel: '塞浦路斯' },
{ dictValue: 'CZE', dictLabel: '捷克' },
{ dictValue: 'DNK', dictLabel: '丹麦' },
{ dictValue: 'DJI', dictLabel: '吉布提' },
{ dictValue: 'DMA', dictLabel: '多米尼克' },
{ dictValue: 'DOM', dictLabel: '多米尼加' },
{ dictValue: 'TLS', dictLabel: '东帝汶' },
{ dictValue: 'ECU', dictLabel: '厄瓜多尔' },
{ dictValue: 'EGY', dictLabel: '埃及' },
{ dictValue: 'SLV', dictLabel: '萨尔瓦多' },
{ dictValue: 'GNQ', dictLabel: '赤道几内亚' },
{ dictValue: 'ERI', dictLabel: '厄立特里亚' },
{ dictValue: 'EST', dictLabel: '爱沙尼亚' },
{ dictValue: 'ETH', dictLabel: '埃塞俄比亚' },
{ dictValue: 'FLK', dictLabel: '福克兰群岛' },
{ dictValue: 'FRO', dictLabel: '法罗群岛' },
{ dictValue: 'FJI', dictLabel: '斐济' },
{ dictValue: 'FIN', dictLabel: '芬兰' },
{ dictValue: 'FRA', dictLabel: '法国' },
{ dictValue: 'GUF', dictLabel: '法属圭亚那' },
{ dictValue: 'PYF', dictLabel: '法属波利尼西亚' },
{ dictValue: 'ATF', dictLabel: '法属南部领地' },
{ dictValue: 'GAB', dictLabel: '加蓬' },
{ dictValue: 'GMB', dictLabel: '冈比亚' },
{ dictValue: 'GEO', dictLabel: '格鲁吉亚' },
{ dictValue: 'DEU', dictLabel: '德国' },
{ dictValue: 'GHA', dictLabel: '加纳' },
{ dictValue: 'GIB', dictLabel: '直布罗陀' },
{ dictValue: 'GRC', dictLabel: '希腊' },
{ dictValue: 'GRL', dictLabel: '格陵兰' },
{ dictValue: 'GRD', dictLabel: '格林纳达' },
{ dictValue: 'GLP', dictLabel: '瓜德罗普' },
{ dictValue: 'GUM', dictLabel: '关岛' },
{ dictValue: 'GTM', dictLabel: '危地马拉' },
{ dictValue: 'GGY', dictLabel: '根西岛' },
{ dictValue: 'GIN', dictLabel: '几内亚' },
{ dictValue: 'GNB', dictLabel: '几内亚比绍' },
{ dictValue: 'GUY', dictLabel: '圭亚那' },
{ dictValue: 'HTI', dictLabel: '海地' },
{ dictValue: 'HMD', dictLabel: '赫德岛和麦克唐纳群岛' },
{ dictValue: 'VAT', dictLabel: '梵蒂冈' },
{ dictValue: 'HND', dictLabel: '洪都拉斯' },
{ dictValue: 'HUN', dictLabel: '匈牙利' },
{ dictValue: 'ISL', dictLabel: '冰岛' },
{ dictValue: 'IND', dictLabel: '印度' },
{ dictValue: 'IDN', dictLabel: '印度尼西亚' },
{ dictValue: 'IRN', dictLabel: '伊朗' },
{ dictValue: 'IRQ', dictLabel: '伊拉克' },
{ dictValue: 'IRL', dictLabel: '爱尔兰' },
{ dictValue: 'IMN', dictLabel: '马恩岛' },
{ dictValue: 'ISR', dictLabel: '以色列' },
{ dictValue: 'ITA', dictLabel: '意大利' },
{ dictValue: 'JAM', dictLabel: '牙买加' },
{ dictValue: 'JPN', dictLabel: '日本' },
{ dictValue: 'JEY', dictLabel: '泽西岛' },
{ dictValue: 'JOR', dictLabel: '约旦' },
{ dictValue: 'KAZ', dictLabel: '哈萨克斯坦' },
{ dictValue: 'KEN', dictLabel: '肯尼亚' },
{ dictValue: 'KIR', dictLabel: '基里巴斯' },
{ dictValue: 'PRK', dictLabel: '朝鲜' },
{ dictValue: 'KOR', dictLabel: '韩国' },
{ dictValue: 'KWT', dictLabel: '科威特' },
{ dictValue: 'KGZ', dictLabel: '吉尔吉斯斯坦' },
{ dictValue: 'LAO', dictLabel: '老挝' },
{ dictValue: 'LVA', dictLabel: '拉脱维亚' },
{ dictValue: 'LBN', dictLabel: '黎巴嫩' },
{ dictValue: 'LSO', dictLabel: '莱索托' },
{ dictValue: 'LBR', dictLabel: '利比里亚' },
{ dictValue: 'LBY', dictLabel: '利比亚' },
{ dictValue: 'LIE', dictLabel: '列支敦士登' },
{ dictValue: 'LTU', dictLabel: '立陶宛' },
{ dictValue: 'LUX', dictLabel: '卢森堡' },
{ dictValue: 'MKD', dictLabel: '前南马其顿' },
{ dictValue: 'MDG', dictLabel: '马达加斯加' },
{ dictValue: 'MWI', dictLabel: '马拉维' },
{ dictValue: 'MYS', dictLabel: '马来西亚' },
{ dictValue: 'MDV', dictLabel: '马尔代夫' },
{ dictValue: 'MLI', dictLabel: '马里' },
{ dictValue: 'MLT', dictLabel: '马耳他' },
{ dictValue: 'MHL', dictLabel: '马绍尔群岛' },
{ dictValue: 'MTQ', dictLabel: '马提尼克' },
{ dictValue: 'MRT', dictLabel: '毛里塔尼亚' },
{ dictValue: 'MUS', dictLabel: '毛里求斯' },
{ dictValue: 'MYT', dictLabel: '马约特' },
{ dictValue: 'MEX', dictLabel: '墨西哥' },
{ dictValue: 'FSM', dictLabel: '密克罗尼西亚联邦' },
{ dictValue: 'MDA', dictLabel: '摩尔多瓦' },
{ dictValue: 'MCO', dictLabel: '摩纳哥' },
{ dictValue: 'MNG', dictLabel: '蒙古' },
{ dictValue: 'MSR', dictLabel: '蒙特塞拉特' },
{ dictValue: 'MAR', dictLabel: '摩洛哥' },
{ dictValue: 'MOZ', dictLabel: '莫桑比克' },
{ dictValue: 'MMR', dictLabel: '缅甸' },
{ dictValue: 'NAM', dictLabel: '纳米比亚' },
{ dictValue: 'NRU', dictLabel: '瑙鲁' },
{ dictValue: 'NPL', dictLabel: '尼泊尔' },
{ dictValue: 'NLD', dictLabel: '荷兰' },
{ dictValue: 'ANT', dictLabel: '荷属安的列斯' },
{ dictValue: 'NCL', dictLabel: '新喀里多尼亚' },
{ dictValue: 'NZL', dictLabel: '新西兰' },
{ dictValue: 'NIC', dictLabel: '尼加拉瓜' },
{ dictValue: 'NER', dictLabel: '尼日尔' },
{ dictValue: 'NGA', dictLabel: '尼日利亚' },
{ dictValue: 'NIU', dictLabel: '纽埃' },
{ dictValue: 'NFK', dictLabel: '诺福克岛' },
{ dictValue: 'MNP', dictLabel: '北马里亚纳' },
{ dictValue: 'NOR', dictLabel: '挪威' },
{ dictValue: 'OMN', dictLabel: '阿曼' },
{ dictValue: 'PAK', dictLabel: '巴基斯坦' },
{ dictValue: 'PLW', dictLabel: '帕劳' },
{ dictValue: 'PSE', dictLabel: '巴勒斯坦' },
{ dictValue: 'PAN', dictLabel: '巴拿马' },
{ dictValue: 'PNG', dictLabel: '巴布亚新几内亚' },
{ dictValue: 'PRY', dictLabel: '巴拉圭' },
{ dictValue: 'PER', dictLabel: '秘鲁' },
{ dictValue: 'PHL', dictLabel: '菲律宾' },
{ dictValue: 'PCN', dictLabel: '皮特凯恩群岛' },
{ dictValue: 'POL', dictLabel: '波兰' },
{ dictValue: 'PRT', dictLabel: '葡萄牙' },
{ dictValue: 'PRI', dictLabel: '波多黎各' },
{ dictValue: 'QAT', dictLabel: '卡塔尔' },
{ dictValue: 'REU', dictLabel: '留尼汪' },
{ dictValue: 'ROM', dictLabel: '罗马尼亚' },
{ dictValue: 'RUS', dictLabel: '俄罗斯联邦' },
{ dictValue: 'RWA', dictLabel: '卢旺达' },
{ dictValue: 'SHN', dictLabel: '圣赫勒拿' },
{ dictValue: 'KNA', dictLabel: '圣基茨和尼维斯' },
{ dictValue: 'LCA', dictLabel: '圣卢西亚' },
{ dictValue: 'SPM', dictLabel: '圣皮埃尔和密克隆' },
{ dictValue: 'VCT', dictLabel: '圣文森特和格林纳丁斯' },
{ dictValue: 'WSM', dictLabel: '萨摩亚' },
{ dictValue: 'SMR', dictLabel: '圣马力诺' },
{ dictValue: 'STP', dictLabel: '圣多美和普林西比' },
{ dictValue: 'SAU', dictLabel: '沙特阿拉伯' },
{ dictValue: 'SEN', dictLabel: '塞内加尔' },
{ dictValue: 'SYC', dictLabel: '塞舌尔' },
{ dictValue: 'SLE', dictLabel: '塞拉利昂' },
{ dictValue: 'SGP', dictLabel: '新加坡' },
{ dictValue: 'SVK', dictLabel: '斯洛伐克' },
{ dictValue: 'SVN', dictLabel: '斯洛文尼亚' },
{ dictValue: 'SLB', dictLabel: '所罗门群岛' },
{ dictValue: 'SOM', dictLabel: '索马里' },
{ dictValue: 'ZAF', dictLabel: '南非' },
{ dictValue: 'SGS', dictLabel: '南乔治亚岛和南桑威奇群岛' },
{ dictValue: 'ESP', dictLabel: '西班牙' },
{ dictValue: 'LKA', dictLabel: '斯里兰卡' },
{ dictValue: 'SDN', dictLabel: '苏丹' },
{ dictValue: 'SUR', dictLabel: '苏里南' },
{ dictValue: 'SJM', dictLabel: '斯瓦尔巴群岛和扬马延岛' },
{ dictValue: 'SWZ', dictLabel: '斯威士兰' },
{ dictValue: 'SWE', dictLabel: '瑞典' },
{ dictValue: 'CHE', dictLabel: '瑞士' },
{ dictValue: 'SYR', dictLabel: '叙利亚' },
{ dictValue: 'TWN', dictLabel: '台湾' },
{ dictValue: 'TJK', dictLabel: '塔吉克斯坦' },
{ dictValue: 'TZA', dictLabel: '坦桑尼亚' },
{ dictValue: 'THA', dictLabel: '泰国' },
{ dictValue: 'TGO', dictLabel: '多哥' },
{ dictValue: 'TKL', dictLabel: '托克劳' },
{ dictValue: 'TON', dictLabel: '汤加' },
{ dictValue: 'TTO', dictLabel: '特立尼达和多巴哥' },
{ dictValue: 'TUN', dictLabel: '突尼斯' },
{ dictValue: 'TUR', dictLabel: '土耳其' },
{ dictValue: 'TKM', dictLabel: '土库曼斯坦' },
{ dictValue: 'TCA', dictLabel: '特克斯和凯科斯群岛' },
{ dictValue: 'TUV', dictLabel: '图瓦卢' },
{ dictValue: 'UGA', dictLabel: '乌干达' },
{ dictValue: 'UKR', dictLabel: '乌克兰' },
{ dictValue: 'ARE', dictLabel: '阿联酋' },
{ dictValue: 'GBR', dictLabel: '英国' },
{ dictValue: 'USA', dictLabel: '美国' },
{ dictValue: 'UMI', dictLabel: '美国本土外小岛屿' },
{ dictValue: 'URY', dictLabel: '乌拉圭' },
{ dictValue: 'UZB', dictLabel: '乌兹别克斯坦' },
{ dictValue: 'VUT', dictLabel: '瓦努阿图' },
{ dictValue: 'VEN', dictLabel: '委内瑞拉' },
{ dictValue: 'VNM', dictLabel: '越南' },
{ dictValue: 'VGB', dictLabel: '英属维尔京群岛' },
{ dictValue: 'VIR', dictLabel: '美属维尔京群岛' },
{ dictValue: 'WLF', dictLabel: '瓦利斯和富图纳' },
{ dictValue: 'ESH', dictLabel: '西撒哈拉' },
{ dictValue: 'YEM', dictLabel: '也门' },
{ dictValue: 'ZMB', dictLabel: '赞比亚' },
{ dictValue: 'ZWE', dictLabel: '津巴布韦' }
];
countryDict = mockCountries;
console.log('使用与nat_regn_code字典一致的模拟数据共生成:', countryDict.length, '条国家地区代码数据');
// 提示管理员检查数据库中的国家地区代码数据
console.warn('提示: 请检查数据库中的sys_dict_type和sys_dict_data表确保存在nat_regn_code类型的完整国家地区代码数据');
}
// 确保有足够的数据
console.log('最终获取到的国家地区代码数据数量:', countryDict.length);
// 转换为统一格式
const formattedCountries = countryDict.map(item => ({
value: item.value || item.dictValue || item.code || '', // 使用字典键值或编码
label: item.label || item.dictLabel || item.name || '' // 使用字典标签
}));
// 数据去重根据value字段去重
const uniqueCountries = [];
const valueSet = new Set();
formattedCountries.forEach(item => {
if (item.value && !valueSet.has(item.value)) {
valueSet.add(item.value);
uniqueCountries.push(item);
}
});
console.log('去重后的数据数量:', uniqueCountries.length);
// 按字典编码升序排序
const sortedCountries = uniqueCountries.sort((a, b) => {
// 获取字典编码
const codeA = a.value || '';
const codeB = b.value || '';
// 按字典编码字符串升序排序
return codeA.localeCompare(codeB);
});
countryCodeList.value = sortedCountries;
// 确保中国是第一个选项(如果存在)
const chinaIndex = countryCodeList.value.findIndex(item => item.label === '中国');
if (chinaIndex > 0) {
// 将中国选项移到数组开头
const chinaOption = countryCodeList.value.splice(chinaIndex, 1)[0];
countryCodeList.value.unshift(chinaOption);
}
// 设置中国为默认值(查找标签为'中国'的选项)
const chinaOption = countryCodeList.value.find(item => item.label === '中国');
if (chinaOption && !form.value.countryCode) {
form.value.countryCode = chinaOption.value;
}
console.log('最终处理后的国家地区代码选项数量:', countryCodeList.value.length);
console.log('前5个国家地区代码选项:', countryCodeList.value.slice(0, 5));
} catch (error) {
console.error('获取国家地区代码字典数据失败:', error);
// 改进的降级方案:提供更完整的默认选项
countryCodeList.value = [
{ value: 'CHN', label: '中国' },
{ value: 'USA', label: '美国' },
{ value: 'JPN', label: '日本' },
{ value: 'KOR', label: '韩国' },
{ value: 'GBR', label: '英国' },
{ value: 'FRA', label: '法国' },
{ value: 'DEU', label: '德国' },
{ value: 'CAN', label: '加拿大' },
{ value: 'AUS', label: '澳大利亚' },
{ value: 'RUS', label: '俄罗斯' }
];
// 设置中国为默认值
if (!form.value.countryCode) {
form.value.countryCode = 'CHN';
}
// 显示错误提示,提醒用户检查系统配置
if (proxy && proxy.modal && proxy.modal.msgError) {
proxy.modal.msgError('获取国家地区代码数据失败,请联系系统管理员');
}
}
};
// 显示弹框 // 显示弹框
function show() { function show() {
// queryParams.roleId = props.roleId; // queryParams.roleId = props.roleId;
getList(); getList();
// 调用从字典管理获取性别数据的函数
getGenderOptions();
// 调用从字典管理获取文化程度数据的函数
getEducationLevelOptions();
// 调用从字典管理获取国家地区代码数据的函数
getCountryCodeOptions();
// 调用从字典管理获取患者来源数据的函数
getPatientDerivedOptions();
visible.value = true; visible.value = true;
} }

View File

@@ -3,14 +3,14 @@
* @Date: 2025-04-09 09:33:35 * @Date: 2025-04-09 09:33:35
* @Description: * @Description:
*/ */
import {defineConfig, loadEnv} from 'vite'; import { defineConfig, loadEnv } from 'vite';
import path from 'path'; import path from 'path';
import createVitePlugins from './vite/plugins'; import createVitePlugins from './vite/plugins';
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig (({mode, command}) => { export default defineConfig(({ mode, command }) => {
const env = loadEnv (mode, process.cwd ()); const env = loadEnv(mode, process.cwd());
const {VITE_APP_ENV} = env; const { VITE_APP_ENV } = env;
return { return {
// define: { // define: {
// // enable hydration mismatch details in production build // // enable hydration mismatch details in production build
@@ -19,15 +19,15 @@ export default defineConfig (({mode, command}) => {
// 部署生产环境和开发环境下的URL。 // 部署生产环境和开发环境下的URL。
// 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上 // 默认情况下vite 会假设你的应用是被部署在一个域名的根路径上
// 例如 https://www.openHIS.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.openhis.vip/admin/,则设置 baseUrl 为 /admin/。 // 例如 https://www.openHIS.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.openhis.vip/admin/,则设置 baseUrl 为 /admin/。
base: VITE_APP_ENV === 'production' ? '/' : '/', base: VITE_APP_ENV === 'prod' ? '/' : '/',
plugins: createVitePlugins (env, command === 'build'), plugins: createVitePlugins(env, command === 'build'),
resolve: { resolve: {
// https://cn.vitejs.dev/config/#resolve-alias // https://cn.vitejs.dev/config/#resolve-alias
alias: { alias: {
// 设置路径 // 设置路径
'~': path.resolve (__dirname, './'), '~': path.resolve(__dirname, './'),
// 设置别名 // 设置别名
'@': path.resolve (__dirname, './src'), '@': path.resolve(__dirname, './src'),
}, },
// https://cn.vitejs.dev/config/#resolve-extensions // https://cn.vitejs.dev/config/#resolve-extensions
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
@@ -40,23 +40,24 @@ export default defineConfig (({mode, command}) => {
proxy: { proxy: {
// https://cn.vitejs.dev/config/#server-proxy // https://cn.vitejs.dev/config/#server-proxy
'/dev-api': { '/dev-api': {
target: 'http://localhost:18080/openhis', target: 'http://localhost:18080/openhis',
// target: 'http://192.168.31.30:18080/openhis', // zwh
// target: 'http://192.168.31.50:18080/openhis', // wh
// target: 'http://192.168.31.190:18080/openhis', // yangmo
// target: 'http://60.188.247.175:18080/openhis',// 公网
changeOrigin: true, changeOrigin: true,
rewrite: p => p.replace (/^\/dev-api/, ''), rewrite: p => p.replace(/^\/dev-api/, ''),
}, },
'/ybplugin':{ '/ybplugin': {
target: 'http://localhost:5000', target: 'http://localhost:5000',
changeOrigin: true, changeOrigin: true,
rewrite: p => p.replace (/^\/ybplugin/, ''), rewrite: p => p.replace(/^\/ybplugin/, ''),
}, },
'/prod-api': { '/prd-api': {
target: 'http://localhost:18080/openhis', target: 'http://localhost:18082/openhis',
changeOrigin: true, changeOrigin: true,
rewrite: p => p.replace (/^\/prod-api/, ''), rewrite: p => p.replace(/^\/prd-api/, ''),
},
'/test-api': {
target: 'http://localhost:18081/openhis',
changeOrigin: true,
rewrite: p => p.replace(/^\/test-api/, ''),
} }
}, },
}, },
@@ -69,7 +70,7 @@ export default defineConfig (({mode, command}) => {
AtRule: { AtRule: {
charset: atRule => { charset: atRule => {
if (atRule.name === 'charset') { if (atRule.name === 'charset') {
atRule.remove (); atRule.remove();
} }
}, },
}, },