Sfoglia il codice sorgente

医院管理、病区管理

chenying2100 2 mesi fa
parent
commit
0d899f4148

+ 209 - 0
.specstory/history/2025-06-24_02-08-调整表单label宽度以完全显示.md

@@ -429,3 +429,212 @@ const beforeSignatureUpload = (file: File) => {
 
 ---
 
+_**User**_
+
+为我生成建表sql语句
+
+---
+
+_**Assistant**_
+
+根据你提供的病区管理信息,我为你生成建表SQL语句:
+
+### MySQL 建表语句
+
+```sql
+CREATE TABLE sys_ward (
+    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
+    ward_name VARCHAR(100) NOT NULL COMMENT '病区名称',
+    dept_id BIGINT NOT NULL COMMENT '科室ID',
+    dept_name VARCHAR(100) COMMENT '科室名称',
+    status CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
+    create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
+    create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
+    update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
+    INDEX idx_dept_id (dept_id),
+    INDEX idx_status (status)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='病区管理表';
+```
+
+### 如果需要外键约束(可选)
+
+```sql
+-- 添加外键约束(确保科室存在)
+ALTER TABLE sys_ward 
+ADD CONSTRAINT fk_ward_dept 
+FOREIGN KEY (dept_id) REFERENCES sys_dept(dept_id);
+```
+
+### 字段说明
+
+| 字段名 | 类型 | 说明 |
+|--------|------|------|
+| id | BIGINT | 主键,自增 |
+| ward_name | VARCHAR(100) | 病区名称 |
+| dept_id | BIGINT | 科室ID(关联科室表) |
+| dept_name | VARCHAR(100) | 科室名称(冗余字段,便于查询) |
+| status | CHAR(1) | 状态(0正常 1停用) |
+| create_by | VARCHAR(64) | 创建者 |
+| create_time | DATETIME | 创建时间 |
+| update_by | VARCHAR(64) | 更新者 |
+| update_time | DATETIME | 更新时间 |
+| remark | VARCHAR(500) | 备注 |
+
+### 示例数据
+
+```sql
+INSERT INTO sys_ward (ward_name, dept_id, dept_name, status, create_by, remark) VALUES
+('内科一病区', 1, '内科', '0', 'admin', '内科一病区'),
+('外科一病区', 2, '外科', '0', 'admin', '外科一病区'),
+('儿科病区', 3, '儿科', '0', 'admin', '儿科病区');
+```
+
+这个表结构包含了基本的病区管理字段,支持与科室表的关联,并包含了常用的审计字段。你可以根据实际需求调整字段类型和长度。
+
+---
+
+_**User**_
+
+为我创建一个医院管理表,
+
+---
+
+_**Assistant**_
+
+好的,下面是一个通用的“医院管理表”建表SQL(MySQL语法),字段设计考虑了常见的医院信息管理需求:
+
+```sql
+CREATE TABLE sys_hospital (
+    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
+    hospital_code VARCHAR(50) NOT NULL COMMENT '医院编码',
+    hospital_name VARCHAR(200) NOT NULL COMMENT '医院名称',
+    hospital_type VARCHAR(50) COMMENT '医院类型',
+    level VARCHAR(50) COMMENT '医院等级',
+    address VARCHAR(300) COMMENT '医院地址',
+    phone VARCHAR(30) COMMENT '联系电话',
+    email VARCHAR(100) COMMENT '电子邮箱',
+    legal_person VARCHAR(50) COMMENT '法人代表',
+    status CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
+    create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
+    create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
+    update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
+    UNIQUE KEY uk_hospital_code (hospital_code)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院管理表';
+```
+
+### 字段说明
+
+| 字段名         | 类型         | 说明           |
+|----------------|--------------|----------------|
+| id             | BIGINT       | 主键,自增     |
+| hospital_code  | VARCHAR(50)  | 医院编码,唯一 |
+| hospital_name  | VARCHAR(200) | 医院名称       |
+| hospital_type  | VARCHAR(50)  | 医院类型       |
+| level          | VARCHAR(50)  | 医院等级       |
+| address        | VARCHAR(300) | 医院地址       |
+| phone          | VARCHAR(30)  | 联系电话       |
+| email          | VARCHAR(100) | 电子邮箱       |
+| legal_person   | VARCHAR(50)  | 法人代表       |
+| status         | CHAR(1)      | 状态(0正常 1停用)|
+| create_by      | VARCHAR(64)  | 创建者         |
+| create_time    | DATETIME     | 创建时间       |
+| update_by      | VARCHAR(64)  | 更新者         |
+| update_time    | DATETIME     | 更新时间       |
+| remark         | VARCHAR(500) | 备注           |
+
+如需增加/减少字段或有特殊业务需求,请补充说明!
+
+---
+
+_**User**_
+
+为我创建一个医院管理表,
+
+---
+
+_**Assistant**_
+
+根据你提供的字段,下面是一个适合“医院管理”功能的MySQL建表SQL语句,字段均带注释:
+
+```sql
+CREATE TABLE sys_hospital (
+    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
+    hospital_name VARCHAR(200) NOT NULL COMMENT '医院名称',
+    hospital_logo VARCHAR(300) COMMENT '医院logo',
+    hospital_level VARCHAR(50) COMMENT '医院等级',
+    phone VARCHAR(30) COMMENT '联系电话',
+    bed_count INT DEFAULT 0 COMMENT '住院床位数',
+    region VARCHAR(100) COMMENT '所属地区',
+    description VARCHAR(1000) COMMENT '医院描述',
+    status CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
+    create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
+    create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
+    update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    remark VARCHAR(500) DEFAULT NULL COMMENT '备注'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院管理表';
+```
+
+### 字段说明
+
+| 字段名         | 类型         | 说明           |
+|----------------|--------------|----------------|
+| id             | BIGINT       | 主键,自增     |
+| hospital_name  | VARCHAR(200) | 医院名称       |
+| hospital_logo  | VARCHAR(300) | 医院logo       |
+| hospital_level | VARCHAR(50)  | 医院等级       |
+| phone          | VARCHAR(30)  | 联系电话       |
+| bed_count      | INT          | 住院床位数     |
+| region         | VARCHAR(100) | 所属地区       |
+| description    | VARCHAR(1000)| 医院描述       |
+| status         | CHAR(1)      | 状态(0正常 1停用)|
+| create_by      | VARCHAR(64)  | 创建者         |
+| create_time    | DATETIME     | 创建时间       |
+| update_by      | VARCHAR(64)  | 更新者         |
+| update_time    | DATETIME     | 更新时间       |
+| remark         | VARCHAR(500) | 备注           |
+
+如需增加唯一约束、外键或有其他字段需求,请补充说明!
+
+---
+
+_**User**_
+
+为我创建一张  疾病/部位标签 表
+
+---
+
+_**Assistant**_
+
+根据你提供的信息,下面是“疾病/部位标签”表的MySQL建表SQL语句,字段均带注释:
+
+```sql
+CREATE TABLE sys_disease_label (
+    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
+    label_name VARCHAR(100) NOT NULL COMMENT '疾病/部位名称',
+    label_code VARCHAR(50) NOT NULL COMMENT '疾病/部位编码',
+    category VARCHAR(100) COMMENT '所属分类',
+    status CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
+    create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
+    create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
+    update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
+    UNIQUE KEY uk_label_code (label_code)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='疾病/部位标签表';
+```
+
+### 字段说明
+
+| 字段名      | 类型         | 说明             |
+|-------------|--------------|------------------|
+| id          | BIGINT       | 主键,自增       |
+| label_name  | VARCHAR(100) | 疾病/部位名称    |
+| label_code  | VARCHAR(50)  | 疾病/部位
+
+---
+

+ 20 - 25
info.txt

@@ -1,26 +1,21 @@
- 
-姓名:
-密码:
-别名:
-角色:
-性别: 
-所属科室:
-登录名:
-所属科室编码:
-工号:
-身份证号码:
-现住地址:
-出生日期:
-户籍地址:
-民族:
-政治面貌:
-婚姻状况:
-职称:
-学历:
-手机号码:
-电子邮箱:
-职工简介:
-擅长疾病:
-签名图片:
- 
+疾病/部位名称
+疾病/部位编码
+所属分类
 
+CREATE TABLE sys_hospital (
+    id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
+    hospital_name VARCHAR(200) NOT NULL COMMENT '医院名称',
+    hospital_logo VARCHAR(300) COMMENT '医院logo',
+    hospital_level char(2) COMMENT '医院等级',
+    phone VARCHAR(20) COMMENT '联系电话',
+    bed_space VARCHAR(100)  COMMENT '住院床位',
+    region VARCHAR(300) COMMENT '所属地区',
+    description VARCHAR(1000) COMMENT '医院描述',
+    status CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
+    del_flag char default '0' null comment '删除标志(0代表存在 1代表删除)',
+    create_dept  bigint null comment '创建部门',
+    create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
+    create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
+    update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医院管理表'; 

+ 71 - 0
src/api/system/hospital/index.ts

@@ -0,0 +1,71 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { HospitalVO, HospitalForm, HospitalQuery } from '@/api/system/hospital/types';
+
+/**
+ * 查询医院管理列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listHospital = (query?: HospitalQuery): AxiosPromise<HospitalVO[]> => {
+  return request({
+    url: '/system/hospital/list',
+    method: 'get',
+    params: query
+  });
+};
+
+
+export const getHospitalData = (): AxiosPromise<HospitalVO> => {
+  return request({
+    url: '/system/hospital/getHospitalData',
+    method: 'get',
+  });
+};
+
+/**
+ * 查询医院管理详细
+ * @param hospitalId
+ */
+export const getHospital = (hospitalId: string | number): AxiosPromise<HospitalVO> => {
+  return request({
+    url: '/system/hospital/' + hospitalId,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增医院管理
+ * @param data
+ */
+export const addHospital = (data: HospitalForm) => {
+  return request({
+    url: '/system/hospital',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改医院管理
+ * @param data
+ */
+export const updateHospital = (data: HospitalForm) => {
+  return request({
+    url: '/system/hospital',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除医院管理
+ * @param hospitalId
+ */
+export const delHospital = (hospitalId: string | number | Array<string | number>) => {
+  return request({
+    url: '/system/hospital/' + hospitalId,
+    method: 'delete'
+  });
+};

+ 146 - 0
src/api/system/hospital/types.ts

@@ -0,0 +1,146 @@
+export interface HospitalVO {
+  /**
+   * 主键ID
+   */
+  hospitalId: string | number;
+
+  /**
+   * 医院名称
+   */
+  hospitalName: string;
+
+  /**
+   * 医院logo
+   */
+  hospitalLogo: string;
+
+  /**
+   * 医院等级
+   */
+  hospitalLevel: string;
+
+  /**
+   * 联系电话
+   */
+  phone: string;
+
+  /**
+   * 住院床位
+   */
+  bedSpace: string;
+
+  /**
+   * 所属地区
+   */
+  region: string;
+
+  /**
+   * 医院描述
+   */
+  description: string;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status: string;
+
+}
+
+export interface HospitalForm extends BaseEntity {
+  /**
+   * 主键ID
+   */
+  hospitalId?: string | number;
+
+  /**
+   * 医院名称
+   */
+  hospitalName?: string;
+
+  /**
+   * 医院logo
+   */
+  hospitalLogo?: string;
+
+  /**
+   * 医院等级
+   */
+  hospitalLevel?: string;
+
+  /**
+   * 联系电话
+   */
+  phone?: string;
+
+  /**
+   * 住院床位
+   */
+  bedSpace?: string;
+
+  /**
+   * 所属地区
+   */
+  region?: string;
+
+  /**
+   * 医院描述
+   */
+  description?: string;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status?: string;
+
+}
+
+export interface HospitalQuery extends PageQuery {
+
+  /**
+   * 医院名称
+   */
+  hospitalName?: string;
+
+  /**
+   * 医院logo
+   */
+  hospitalLogo?: string;
+
+  /**
+   * 医院等级
+   */
+  hospitalLevel?: string;
+
+  /**
+   * 联系电话
+   */
+  phone?: string;
+
+  /**
+   * 住院床位
+   */
+  bedSpace?: string;
+
+  /**
+   * 所属地区
+   */
+  region?: string;
+
+  /**
+   * 医院描述
+   */
+  description?: string;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status?: string;
+
+    /**
+     * 日期范围参数
+     */
+    params?: any;
+}
+
+
+

+ 7 - 0
src/api/system/role/index.ts

@@ -12,6 +12,13 @@ export const listRole = (query: RoleQuery): AxiosPromise<RoleVO[]> => {
   });
 };
 
+export const listAllRole = (): AxiosPromise<RoleVO[]> => {
+  return request({
+    url: '/system/role/listAll',
+    method: 'get'
+  });
+};
+
 /**
  * 通过roleIds查询角色
  * @param roleIds

+ 0 - 1
src/api/system/user/types.ts

@@ -60,7 +60,6 @@ export interface UserForm {
   userName: string;
   name?: string;
   deptCode?: string;
-
   jobNumber?: string;
   idCard?: string;
   address?: string;

+ 70 - 0
src/api/system/ward/index.ts

@@ -0,0 +1,70 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { WardVO, WardForm, WardQuery } from '@/api/system/ward/types';
+
+/**
+ * 查询病区管理列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listWard = (query?: WardQuery): AxiosPromise<WardVO[]> => {
+  return request({
+    url: '/system/ward/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询病区管理详细
+ * @param wardId
+ */
+export const getWard = (wardId: string | number): AxiosPromise<WardVO> => {
+  return request({
+    url: '/system/ward/' + wardId,
+    method: 'get'
+  });
+};
+
+export const listUsed = (): AxiosPromise<WardVO> => {
+  return request({
+    url: '/system//ward/listUsed',
+    method: 'get'
+  });
+};
+
+/**
+ * 新增病区管理
+ * @param data
+ */
+export const addWard = (data: WardForm) => {
+  return request({
+    url: '/system/ward',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改病区管理
+ * @param data
+ */
+export const updateWard = (data: WardForm) => {
+  return request({
+    url: '/system/ward',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除病区管理
+ * @param wardId
+ */
+export const delWard = (wardId: string | number | Array<string | number>) => {
+  return request({
+    url: '/system/ward/' + wardId,
+    method: 'delete'
+  });
+};

+ 76 - 0
src/api/system/ward/types.ts

@@ -0,0 +1,76 @@
+export interface WardVO {
+  /**
+   * 主键ID
+   */
+  wardId: string | number;
+
+  /**
+   * 病区名称
+   */
+  wardName: string;
+
+  /**
+   * 科室ID
+   */
+  deptId: string | number;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status: string;
+
+}
+
+export interface WardForm extends BaseEntity {
+  /**
+   * 主键ID
+   */
+  wardId?: string | number;
+
+  /**
+   * 病区名称
+   */
+  wardName?: string;
+
+  /**
+   * 科室ID
+   */
+  deptId?: string | number;
+
+  /**
+   * 科室ID
+   */
+  deptIds?: string[] | number[];
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status?: string;
+
+}
+
+export interface WardQuery extends PageQuery {
+
+  /**
+   * 病区名称
+   */
+  wardName?: string;
+
+  /**
+   * 科室ID
+   */
+  deptId?: string | number;
+
+  /**
+   * 状态(0正常 1停用)
+   */
+  status?: string;
+
+    /**
+     * 日期范围参数
+     */
+    params?: any;
+}
+
+
+

+ 219 - 0
src/views/system/hospital/index.vue

@@ -0,0 +1,219 @@
+<template>
+  <el-card style="overflow-y: scroll;">
+    <div :style=divStyle>
+    <div>
+      <h4 style="margin-left: 70px;">基本信息</h4>
+    </div>
+    <el-divider />
+    <div class="p-2" style="width: 800px;margin-left: 100px;">
+      <el-form ref="hospitalFormRef" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="医院名称" prop="hospitalName">
+          <el-input v-model="form.hospitalName" placeholder="请输入" size="large"  :disabled="editBtn"/>
+        </el-form-item>
+        <el-form-item label="医院logo" prop="hospitalLogo">
+          <imageUpload v-model="form.hospitalLogo" :limit="1" :isShowTip="false" :disabled="editBtn" />
+        </el-form-item>
+        <el-form-item label="医院等级" prop="hospitalLevel">
+          <el-select v-model="form.hospitalLevel" placeholder="请选择" :disabled="editBtn" size="large">
+                <el-option v-for="dict in hospital_level" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="联系电话" prop="phone">
+          <el-input v-model="form.phone" placeholder="请输入" size="large" maxlength="11" :disabled="editBtn"/>
+        </el-form-item>
+        <el-form-item label="住院床位" prop="bedSpace">
+          <el-input v-model="form.bedSpace" placeholder="请输入" size="large" :disabled="editBtn"/>
+        </el-form-item>
+        <el-form-item label="所属地区" prop="region">
+          <el-input v-model="form.region" placeholder="请输入" size="large" :disabled="editBtn"/>
+        </el-form-item>
+        <el-form-item label="医院描述" prop="description">
+          <el-input v-model="form.description" type="textarea" placeholder="请输入" :rows="10" :disabled="editBtn" />
+        </el-form-item>
+      </el-form>
+    </div>
+  </div>
+  </el-card>  
+  <el-card shadow="always" class="card-footer">
+    <div>
+        <el-button type="primary" size="large" @click="submitForm" v-hasPermi="['system:hospital:add']" v-if="!editBtn">
+          &nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;&nbsp;
+        </el-button>
+        <el-button type="primary" size="large" @click="editBtn=false" v-hasPermi="['system:hospital:add']" v-if="editBtn">
+          &nbsp;&nbsp;&nbsp;编辑&nbsp;&nbsp;&nbsp;
+        </el-button>
+      </div>
+  </el-card>
+</template>
+
+<script setup name="Hospital" lang="ts">
+import { listHospital, getHospital, delHospital, addHospital, updateHospital,getHospitalData } from '@/api/system/hospital';
+import { HospitalVO, HospitalQuery, HospitalForm } from '@/api/system/hospital/types';
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+const { hospital_level } = toRefs<any>(proxy?.useDict('hospital_level'));
+ 
+
+const editBtn = ref<boolean>(true);
+const buttonLoading = ref(false);
+const loading = ref(true);
+const showSearch = ref(true);
+const ids = ref<Array<string | number>>([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+const divStyle = ref({
+  height: '700px'
+});
+ 
+
+const queryFormRef = ref<ElFormInstance>();
+const hospitalFormRef = ref<ElFormInstance>();
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const initFormData: HospitalForm = {
+  hospitalId: undefined,
+  hospitalName: undefined,
+  hospitalLogo: undefined,
+  hospitalLevel: undefined,
+  phone: undefined,
+  bedSpace: undefined,
+  region: undefined,
+  description: undefined,
+  status: undefined,
+}
+const data = reactive<PageData<HospitalForm, HospitalQuery>>({
+  form: {...initFormData},
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    hospitalName: undefined,
+    hospitalLogo: undefined,
+    hospitalLevel: undefined,
+    phone: undefined,
+    bedSpace: undefined,
+    region: undefined,
+    description: undefined,
+    status: undefined,
+    params: {
+    }
+  },
+  rules: {    
+    hospitalName: [
+      { required: true, message: "医院名称不能为空", trigger: "blur" }
+    ],
+  }
+});
+
+const { queryParams, form, rules } = toRefs(data);
+
+/** 查询医院管理列表 */
+const getList = async () => {
+  loading.value = true;
+  const res = await getHospitalData();
+  console.log(res.data);
+  if(res.data){    
+    form.value=res.data;  
+  }  
+}
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+}
+
+/** 表单重置 */
+const reset = () => {
+  form.value = {...initFormData};
+  hospitalFormRef.value?.resetFields();
+}
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  getList();
+}
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+}
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: HospitalVO[]) => {
+  ids.value = selection.map(item => item.hospitalId);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+}
+
+/** 新增按钮操作 */
+const handleAdd = () => {
+  reset();
+  dialog.visible = true;
+  dialog.title = "添加医院管理";
+}
+
+/** 修改按钮操作 */
+const handleUpdate = async (row?: HospitalVO) => {
+  reset();
+  const _hospitalId = row?.hospitalId || ids.value[0]
+  const res = await getHospital(_hospitalId);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = "修改医院管理";
+}
+
+/** 提交按钮 */
+const submitForm = () => {
+  hospitalFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {       
+      buttonLoading.value = true;
+      if (form.value.hospitalId) {
+        await updateHospital(form.value).finally(() =>  buttonLoading.value = false);
+      } else {
+        await addHospital(form.value).finally(() =>  buttonLoading.value = false);
+      }
+      proxy?.$modal.msgSuccess("操作成功");
+      dialog.visible = false;
+      await getList();
+    }
+  });
+}
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: HospitalVO) => {
+  const _hospitalIds = row?.hospitalId || ids.value;
+  await proxy?.$modal.confirm('是否确认删除医院管理编号为"' + _hospitalIds + '"的数据项?').finally(() => loading.value = false);
+  await delHospital(_hospitalIds);
+  proxy?.$modal.msgSuccess("删除成功");
+  await getList();
+}
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download('system/hospital/export', {
+    ...queryParams.value
+  }, `hospital_${new Date().getTime()}.xlsx`)
+}
+
+onMounted(() => {
+  getList();
+});
+</script>
+<style lang="scss" scoped>
+.card-footer{  
+    z-index: 99;
+    bottom: 0px;
+    left: calc(var(--left-menu-max-width) + var(--app-content-padding));
+    right: 0px;
+    height: 90px;
+    display: flex;
+    justify-content: center;
+    align-items: center;     
+}
+</style>

+ 31 - 9
src/views/system/user/index.vue

@@ -24,9 +24,9 @@
           <div v-show="showSearch" class="mb-[10px]">
             <el-card shadow="hover">
               <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="150px">
-                <el-form-item label="角色" prop="status">
-                  <el-select v-model="queryParams.status" placeholder="请选择" clearable>
-                    <el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
+                <el-form-item label="角色" prop="roleId">
+                  <el-select v-model="queryParams.roleId" placeholder="请选择" clearable>
+                    <el-option v-for="dict in roleList" :key="dict.roleId" :label="dict.roleName" :value="dict.roleId" />
                   </el-select>
                 </el-form-item>
 
@@ -221,7 +221,7 @@
           </el-col>
           <el-col :span="12">
             <el-form-item label="所属科室编码" prop="deptCode">
-              <el-input v-model="form.deptCode" placeholder="请输入"  :disabled="dialog.disabled" />
+              <el-input v-model="form.deptCode" placeholder="请输入"  :disabled="true" />
             </el-form-item>             
           </el-col>
         </el-row>
@@ -241,7 +241,7 @@
         <el-row>
           <el-col :span="12">
             <el-form-item label="身份证号码" prop="idCard">
-              <el-input v-model="form.idCard" placeholder="请输入身份证号码" :disabled="dialog.disabled" />
+              <el-input v-model="form.idCard" placeholder="请输入身份证号码" :disabled="dialog.disabled" @input="handleIdCardChange"/>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -253,7 +253,7 @@
         <el-row>
           <el-col :span="12">
             <el-form-item  label="出生日期" prop="birthDate">
-              <el-input v-model="form.birthDate" placeholder="请输入出生日期" :disabled="dialog.disabled"/>
+              <el-input v-model="form.birthDate" placeholder="请输入出生日期" :disabled="true"/>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -374,7 +374,7 @@
 import api from '@/api/system/user';
 import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
 import { DeptTreeVO, DeptVO } from '@/api/system/dept/types';
-import { RoleVO } from '@/api/system/role/types';
+import { RoleVO ,RoleQuery} from '@/api/system/role/types';
 import { PostQuery, PostVO } from '@/api/system/post/types';
 import { treeselect } from '@/api/system/dept';
 import { globalHeaders } from '@/utils/request';
@@ -382,7 +382,9 @@ import { to } from 'await-to-js';
 import { optionselect } from '@/api/system/post';
 import { hasPermi } from '@/directive/permission';
 import { checkPermi } from '@/utils/permission';
+import {listAllRole } from '@/api/system/role';
 
+const roleList=ref();
 const router = useRouter();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 const { sys_normal_disable, sys_user_sex } = toRefs<any>(proxy?.useDict('sys_normal_disable', 'sys_user_sex'));
@@ -564,6 +566,22 @@ const handleQuery = () => {
   queryParams.value.pageNum = 1;
   getList();
 };
+
+
+const handleIdCardChange=(val:string)=>{
+  if(val&&val.length>6){
+    let birth=val.substring(6,6+Math.min(val.length,8))
+    if(birth.length>=4){
+      birth=birth.substring(0,4)+'-'+birth.substring(4,val.length);
+    }
+    if(birth.length>=6){
+      birth=birth.substring(0,7)+'-'+birth.substring(7,val.length);
+    }    
+    form.value.birthDate=birth; 
+  }
+}
+
+
 /** 重置按钮操作 */
 const resetQuery = () => {
   dateRange.value = ['', ''];
@@ -689,6 +707,7 @@ const handleAdd = async () => {
   dialog.visible = true;
   dialog.title = '新增用户';
   postOptions.value = data.posts;
+  dialog.disabled = false;
   roleOptions.value = data.roles;
   form.value.password = initPassword.value.toString();
 };
@@ -744,12 +763,15 @@ onMounted(() => {
   getList(); // 初始化列表数据
   proxy?.getConfigKey('sys.user.initPassword').then((response) => {
     initPassword.value = response.data;
+  }); 
+  
+  listAllRole().then((res) => {
+    roleList.value = res.rows;     
   });
 });
 
 async function handleDeptChange(value: number | string) {
   let dept=deptJson.value[value.toString()]
-  form.value.deptCode=dept.deptCategory;
-  console.log(dept,'+++++++++++++++++',value.toString() );
+  form.value.deptCode=dept.deptCategory;  
 }
 </script>

+ 281 - 0
src/views/system/ward/index.vue

@@ -0,0 +1,281 @@
+<template>
+  <div class="p-2">
+    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
+      <div v-show="showSearch" class="mb-[10px]">
+        <el-card shadow="hover">
+          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
+            <el-form-item label="病区名称" prop="wardName">
+              <el-input v-model="queryParams.wardName" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+            <!-- <el-form-item label="科室ID" prop="deptId">
+              <el-input v-model="queryParams.deptId" placeholder="请输入科室ID" clearable @keyup.enter="handleQuery" />
+            </el-form-item> -->
+            <el-form-item>
+              <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
+              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
+            </el-form-item>
+          </el-form>
+        </el-card>
+      </div>
+    </transition>
+
+    <el-card shadow="never">
+      <template #header>
+        <el-row :gutter="10" class="mb8">
+          <el-col :span="1.5">
+            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:ward:add']">新增病区</el-button>
+          </el-col>
+          <!-- <el-col :span="1.5">
+            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:ward:edit']">修改</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:ward:remove']">删除</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:ward:export']">导出</el-button>
+          </el-col> -->
+          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+        </el-row>
+      </template>
+
+      <el-table v-loading="loading" border :data="wardList" @selection-change="handleSelectionChange">
+        <el-table-column type="selection" width="55" align="center" />
+        <!-- <el-table-column label="主键ID" align="center" prop="wardId" v-if="true" /> -->
+        <el-table-column label="病区名称" align="center" prop="wardName"/>
+        <el-table-column label="所属科室" align="center" prop="deptName" />         
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+          <template #default="scope">
+            <el-tooltip content="编辑" placement="top">
+              <el-button link type="primary" icon="Edit" @click="handleUpdate(false,scope.row)" v-hasPermi="['system:ward:edit']">编辑</el-button>
+            </el-tooltip>
+            <el-tooltip content="详情" placement="详情">
+              <el-button link type="primary" icon="View" @click="handleUpdate(true,scope.row)" v-hasPermi="['system:ward:edit']">详情</el-button>
+            </el-tooltip>
+            <el-tooltip content="删除" placement="top">
+              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:ward:remove']">删除</el-button>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+    </el-card>
+    <!-- 添加或修改病区管理对话框 -->
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
+      <el-form ref="wardFormRef" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="病区名称" prop="wardName">
+          <el-input v-model="form.wardName" placeholder="请输入" :disabled="dialog.disabled" />
+        </el-form-item>
+        <el-form-item label="科室" prop="deptIds">          
+          <el-tree-select :disabled="dialog.disabled"
+                v-model="form.deptIds"
+                show-checkbox                 
+                multiple
+                :render-after-expand="false"
+                :data="enabledDeptOptions"
+                :props="{ value: 'id', label: 'label', children: 'children' } as any"
+                value-key="id"
+                placeholder="请选择"                
+              />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup name="Ward" lang="ts">
+import api from '@/api/system/user';
+import { listWard, getWard, delWard, addWard, updateWard,listUsed} from '@/api/system/ward';
+import { WardVO, WardQuery, WardForm } from '@/api/system/ward/types';
+import { DeptTreeVO } from '@/api/system/dept/types';
+import { object } from 'vue-types';
+
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+
+const enabledDeptOptions = ref<DeptTreeVO[]>([]);
+const wardList = ref<WardVO[]>([]);
+const buttonLoading = ref(false);
+const loading = ref(true);
+const showSearch = ref(true);
+const ids = ref<Array<string | number>>([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+
+const queryFormRef = ref<ElFormInstance>();
+const wardFormRef = ref<ElFormInstance>();
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: '',
+  disabled:false
+});
+
+const initFormData: WardForm = {
+  wardId: undefined,
+  wardName: undefined,
+  deptId: undefined,
+  deptIds: undefined,
+  status: undefined,
+}
+const data = reactive<PageData<WardForm, WardQuery>>({
+  form: {...initFormData},
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    wardName: undefined,
+    deptId: undefined,
+    status: undefined,
+    params: {
+    }
+  },
+  rules: {    
+    wardName: [
+      { required: true, message: "病区名称不能为空", trigger: "blur" }
+    ],     
+  }
+});
+
+const { queryParams, form, rules } = toRefs(data);
+
+/** 查询科室下拉树结构 */
+const getDeptTree = async (isshow:boolean) => {
+  let usedDept={};
+  if (!isshow){
+    const response = await listUsed();
+    usedDept=response.data;
+  }
+  const res = await api.deptTreeSelect();  
+  enabledDeptOptions.value = filterDisabledDept(res.data,usedDept);
+};
+
+ 
+/** 过滤禁用的科室 */
+const filterDisabledDept = (deptList: DeptTreeVO[],usedDept:any) => {
+  return deptList.filter((dept) => {    
+    dept.disabled=usedDept[dept.id.toString()]==true;
+    if (dept.disabled) {
+      return false;
+    }
+    if (dept.children && dept.children.length) {
+      dept.children = filterDisabledDept(dept.children,usedDept);
+    }
+    return true;
+  });
+};
+
+/** 查询病区管理列表 */
+const getList = async () => {
+  loading.value = true;
+  const res = await listWard(queryParams.value);
+  wardList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
+}
+
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+}
+
+/** 表单重置 */
+const reset = () => {
+  form.value = {...initFormData};
+  wardFormRef.value?.resetFields();
+}
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  getList();
+}
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+}
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: WardVO[]) => {
+  ids.value = selection.map(item => item.wardId);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+}
+
+/** 新增按钮操作 */
+const handleAdd = () => {
+  getDeptTree(false);
+  reset();
+  dialog.visible = true;
+  dialog.disabled = false;
+  dialog.title = "添加病区管理";
+}
+
+/** 修改按钮操作 */
+const handleUpdate = async (disabled:boolean,row?: WardVO) => {
+  await getDeptTree(true);
+  reset();
+  const _wardId = row?.wardId || ids.value[0]
+  const res = await getWard(_wardId);
+  Object.assign(form.value, res.data);  
+  if (res.data.deptId) {
+    let deptId:string =res.data.deptId.toString();
+    form.value.deptIds =deptId.length>0?deptId.split(","):[];
+  }else{
+    form.value.deptIds = [];
+  }
+  dialog.visible = true;
+  dialog.disabled = disabled;
+  dialog.title = "修改病区管理";
+}
+
+/** 提交按钮 */
+const submitForm = () => {
+  wardFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      buttonLoading.value = true;
+      let params = ref<WardForm>({});
+      Object.assign(params.value, form.value); 
+      params.value.deptId = params.value.deptIds.join(","); 
+      params.value.deptIds=undefined;    
+      if (form.value.wardId) {
+        await updateWard(params.value).finally(() =>  buttonLoading.value = false);
+      } else {
+        await addWard(params.value).finally(() =>  buttonLoading.value = false);
+      }
+      proxy?.$modal.msgSuccess("操作成功");
+      dialog.visible = false;
+      await getList();
+    }
+  });
+}
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: WardVO) => {
+  const _wardIds = row?.wardId || ids.value;
+  await proxy?.$modal.confirm('是否确认删除病区管理编号为"' + _wardIds + '"的数据项?').finally(() => loading.value = false);
+  await delWard(_wardIds);
+  proxy?.$modal.msgSuccess("删除成功");
+  await getList();
+}
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download('system/ward/export', {
+    ...queryParams.value
+  }, `ward_${new Date().getTime()}.xlsx`)
+}
+
+onMounted(() => {    
+  getList();
+});
+</script>