Merge branch 'refs/heads/dev'
# Conflicts: # src/api/invest/iitem.js # src/api/invest/ilog.js # src/api/invest/ishop.js # src/api/invest/iuser.js # src/views/collect/CommemorativeBanknote/index.vue # src/views/collect/commemorativeCoin/index.vue # src/views/collect/preciousMetalCoin/index.vue # src/views/invest/creditCardBill/index.vue # vite.config.js
This commit is contained in:
52
src/api/health/chronicDisease.js
Normal file
52
src/api/health/chronicDisease.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询慢性疾病档案列表
|
||||
export function listChronicDisease(query) {
|
||||
return request({
|
||||
url: '/health/chronicDisease/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 根据成员ID查询慢性疾病档案列表
|
||||
export function listChronicDiseaseByMember(personId) {
|
||||
return request({
|
||||
url: '/health/chronicDisease/listByPerson/' + personId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询慢性疾病档案详细
|
||||
export function getChronicDisease(id) {
|
||||
return request({
|
||||
url: '/health/chronicDisease/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增慢性疾病档案
|
||||
export function addChronicDisease(data) {
|
||||
return request({
|
||||
url: '/health/chronicDisease',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改慢性疾病档案
|
||||
export function updateChronicDisease(data) {
|
||||
return request({
|
||||
url: '/health/chronicDisease',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除慢性疾病档案
|
||||
export function delChronicDisease(id) {
|
||||
return request({
|
||||
url: '/health/chronicDisease/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
46
src/api/health/medicationAdherence.js
Normal file
46
src/api/health/medicationAdherence.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 获取总体依从性统计
|
||||
export function getOverallAdherence(query) {
|
||||
return request({
|
||||
url: '/health/adherence/overall',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 获取每日依从性统计列表
|
||||
export function getDailyAdherence(query) {
|
||||
return request({
|
||||
url: '/health/adherence/daily',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 获取日历视图数据
|
||||
export function getCalendarData(memberId, yearMonth) {
|
||||
return request({
|
||||
url: '/health/adherence/calendar',
|
||||
method: 'get',
|
||||
params: { memberId, yearMonth }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取各时段服药统计
|
||||
export function getTimeSlotAdherence(query) {
|
||||
return request({
|
||||
url: '/health/adherence/timeSlot',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 获取仪表盘概览数据
|
||||
export function getDashboard(memberId) {
|
||||
return request({
|
||||
url: '/health/adherence/dashboard',
|
||||
method: 'get',
|
||||
params: { memberId }
|
||||
})
|
||||
}
|
||||
68
src/api/health/medicationPlan.js
Normal file
68
src/api/health/medicationPlan.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询用药计划列表
|
||||
export function listMedicationPlan(query) {
|
||||
return request({
|
||||
url: '/health/medicationPlan/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询用药计划详细
|
||||
export function getMedicationPlan(id) {
|
||||
return request({
|
||||
url: '/health/medicationPlan/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增用药计划
|
||||
export function addMedicationPlan(data) {
|
||||
return request({
|
||||
url: '/health/medicationPlan',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改用药计划
|
||||
export function updateMedicationPlan(data) {
|
||||
return request({
|
||||
url: '/health/medicationPlan',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除用药计划
|
||||
export function delMedicationPlan(id) {
|
||||
return request({
|
||||
url: '/health/medicationPlan/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 暂停用药计划
|
||||
export function pauseMedicationPlan(id) {
|
||||
return request({
|
||||
url: '/health/medicationPlan/pause/' + id,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
|
||||
// 恢复用药计划
|
||||
export function resumeMedicationPlan(id) {
|
||||
return request({
|
||||
url: '/health/medicationPlan/resume/' + id,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
|
||||
// 结束用药计划
|
||||
export function endMedicationPlan(id) {
|
||||
return request({
|
||||
url: '/health/medicationPlan/end/' + id,
|
||||
method: 'put'
|
||||
})
|
||||
}
|
||||
53
src/api/health/medicationTask.js
Normal file
53
src/api/health/medicationTask.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询服药任务列表
|
||||
export function listMedicationTask(query) {
|
||||
return request({
|
||||
url: '/health/medicationTask/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询服药任务详细
|
||||
export function getMedicationTask(id) {
|
||||
return request({
|
||||
url: '/health/medicationTask/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 删除服药任务
|
||||
export function delMedicationTask(id) {
|
||||
return request({
|
||||
url: '/health/medicationTask/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 确认服药
|
||||
export function confirmMedication(id, confirmType, confirmTime) {
|
||||
return request({
|
||||
url: '/health/medicationTask/confirm/' + id,
|
||||
method: 'put',
|
||||
params: { confirmType, confirmTime }
|
||||
})
|
||||
}
|
||||
|
||||
// 跳过服药
|
||||
export function skipMedication(id, notes) {
|
||||
return request({
|
||||
url: '/health/medicationTask/skip/' + id,
|
||||
method: 'put',
|
||||
params: { notes }
|
||||
})
|
||||
}
|
||||
|
||||
// 标记漏服
|
||||
export function markMissed(id, notes) {
|
||||
return request({
|
||||
url: '/health/medicationTask/missed/' + id,
|
||||
method: 'put',
|
||||
params: { notes }
|
||||
})
|
||||
}
|
||||
403
src/views/health/chronicDisease/index.vue
Normal file
403
src/views/health/chronicDisease/index.vue
Normal file
@@ -0,0 +1,403 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="search-con">
|
||||
<div class="title">查询条件</div>
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
|
||||
<el-form-item label="成员" prop="personId">
|
||||
<el-select v-model="queryParams.personId" placeholder="请选择成员" clearable filterable>
|
||||
<el-option v-for="item in memberList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="疾病名称" prop="diseaseName">
|
||||
<el-input v-model="queryParams.diseaseName" placeholder="请输入疾病名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="diseaseStatus">
|
||||
<el-select v-model="queryParams.diseaseStatus" placeholder="请选择状态" clearable>
|
||||
<el-option v-for="dict in disease_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否启用" prop="isActive">
|
||||
<el-select v-model="queryParams.isActive" placeholder="请选择" clearable>
|
||||
<el-option v-for="dict in is_active" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="search-btn-con">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button type="info" icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main-con">
|
||||
<div class="title-con">
|
||||
<div class="title">慢性疾病档案</div>
|
||||
<div class="operate-btn-con">
|
||||
<el-button @click="handleAdd" icon="Plus" v-hasPermi="['health:chronicDisease:add']">新增</el-button>
|
||||
<el-button :disabled="multiple" icon="Delete" @click="handleDelete" v-hasPermi="['health:chronicDisease:remove']">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-con" v-loading="loading" height="calc(100% - 0.65rem)">
|
||||
<el-table v-loading="loading" :data="chronicDiseaseList" @selection-change="handleSelectionChange" height="calc(100% - 0.65rem)">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column type="index" label="序号" :index="indexMethod" width="50"></el-table-column>
|
||||
<el-table-column label="成员" align="center" prop="personName" width="100" />
|
||||
<el-table-column label="疾病名称" align="center" prop="diseaseName" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="疾病编码" align="center" prop="diseaseCode" width="100" />
|
||||
<el-table-column label="确诊日期" align="center" prop="diagnosisDate" width="110">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.diagnosisDate, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="diseaseStatus" width="80">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStatusType(scope.row.diseaseStatus)">
|
||||
{{ getStatusLabel(scope.row.diseaseStatus) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="主治医生" align="center" prop="mainDoctor" width="100" />
|
||||
<el-table-column label="就诊医院" align="center" prop="hospital" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="科室" align="center" prop="department" width="100" />
|
||||
<el-table-column label="是否启用" align="center" prop="isActive" width="80">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.isActive"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
v-hasPermi="['health:chronicDisease:edit']"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
|
||||
<template v-slot="scope">
|
||||
<div class="ctrl-btn d-flex">
|
||||
<el-tooltip v-for="item in operateList" :key="item.id" class="item" effect="dark" :content="item.title" placement="top">
|
||||
<el-button :icon="item.icon" :v-hasPermi="item.hasPermi" circle @click="handleOperate(item.id, scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
small
|
||||
background
|
||||
layout="total,sizes, prev, pager, next"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 添加或修改慢性疾病档案对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="880px" append-to-body>
|
||||
<el-form ref="chronicDiseaseRef" :model="form" :inline="true" :rules="rules" label-width="120px">
|
||||
<el-form-item label="成员" prop="personId">
|
||||
<el-select v-model="form.personId" placeholder="请选择成员" filterable @change="handleMemberChange">
|
||||
<el-option v-for="item in memberList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联疾病" prop="diseaseId">
|
||||
<el-select v-model="form.diseaseId" placeholder="请选择疾病(可选)" clearable filterable @change="handleDiseaseChange">
|
||||
<el-option v-for="item in diseaseList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="疾病名称" prop="diseaseName">
|
||||
<el-input v-model="form.diseaseName" placeholder="请输入疾病名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="疾病编码" prop="diseaseCode">
|
||||
<el-input v-model="form.diseaseCode" placeholder="ICD-10编码(可选)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="确诊日期" prop="diagnosisDate">
|
||||
<el-date-picker v-model="form.diagnosisDate" type="date" placeholder="选择确诊日期" value-format="YYYY-MM-DD" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="diseaseStatus">
|
||||
<el-select v-model="form.diseaseStatus" placeholder="请选择状态">
|
||||
<el-option v-for="dict in disease_status" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="主治医生" prop="mainDoctor">
|
||||
<el-input v-model="form.mainDoctor" placeholder="请输入主治医生" />
|
||||
</el-form-item>
|
||||
<el-form-item label="就诊医院" prop="hospital">
|
||||
<el-input v-model="form.hospital" placeholder="请输入就诊医院" />
|
||||
</el-form-item>
|
||||
<el-form-item label="科室" prop="department">
|
||||
<el-input v-model="form.department" placeholder="请输入科室" />
|
||||
</el-form-item>
|
||||
<el-form-item label="诊断结果" style="width: 792px" prop="notes">
|
||||
<el-input v-model="form.notes" type="textarea" :rows="3" placeholder="请输入说明" />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" style="width: 792px" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template v-if="title !== '查看慢性疾病档案'" #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="ChronicDisease">
|
||||
import { listChronicDisease, getChronicDisease, delChronicDisease, addChronicDisease, updateChronicDisease } from '@/api/health/chronicDisease'
|
||||
import { listHealthDiseases } from '@/api/health/healthDiseases'
|
||||
import { listPerson } from '@/api/health/person'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { disease_status, is_active } = proxy.useDict('disease_status', 'is_active')
|
||||
|
||||
const chronicDiseaseList = ref([])
|
||||
const memberList = ref([])
|
||||
const diseaseList = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const ids = ref([])
|
||||
const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref('')
|
||||
const operateList = ref([
|
||||
{ id: 'view', icon: 'View', title: '查看', hasPermi: ['health:chronicDisease:query'] },
|
||||
{ id: 'edit', icon: 'Edit', title: '修改', hasPermi: ['health:chronicDisease:edit'] },
|
||||
{ id: 'delete', icon: 'Delete', title: '删除', hasPermi: ['health:chronicDisease:remove'] }
|
||||
])
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
personId: null,
|
||||
diseaseName: null,
|
||||
diseaseStatus: null,
|
||||
isActive: null
|
||||
},
|
||||
rules: {
|
||||
personId: [{ required: true, message: '成员不能为空', trigger: 'change' }],
|
||||
diseaseName: [{ required: true, message: '疾病名称不能为空', trigger: 'blur' }],
|
||||
diseaseStatus: [{ required: true, message: '状态不能为空', trigger: 'change' }]
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 获取状态类型 */
|
||||
function getStatusType(status) {
|
||||
const types = { 1: 'success', 2: 'warning', 3: 'danger' }
|
||||
return types[status] || 'info'
|
||||
}
|
||||
|
||||
/** 获取状态标签 */
|
||||
function getStatusLabel(status) {
|
||||
const labels = { 1: '稳定', 2: '需关注', 3: '急性期' }
|
||||
return labels[status] || '未知'
|
||||
}
|
||||
|
||||
/** 操作按钮 */
|
||||
const handleOperate = (operate, row) => {
|
||||
switch (operate) {
|
||||
case 'view':
|
||||
handleView(row)
|
||||
break
|
||||
case 'edit':
|
||||
handleUpdate(row)
|
||||
break
|
||||
case 'delete':
|
||||
handleDelete(row)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询成员列表 */
|
||||
function getMemberList() {
|
||||
listPerson({ pageNum: 1, pageSize: 1000 }).then((response) => {
|
||||
memberList.value = response.rows || []
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询疾病列表 */
|
||||
function getDiseaseList() {
|
||||
listHealthDiseases({ pageNum: 1, pageSize: 1000 }).then((response) => {
|
||||
diseaseList.value = response.rows || []
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询慢性疾病档案列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listChronicDisease(queryParams.value).then((response) => {
|
||||
chronicDiseaseList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
personId: null,
|
||||
diseaseId: null,
|
||||
diseaseName: null,
|
||||
diseaseCode: null,
|
||||
diagnosisDate: null,
|
||||
diseaseStatus: 1,
|
||||
mainDoctor: null,
|
||||
hospital: null,
|
||||
department: null,
|
||||
notes: null,
|
||||
isActive: 1,
|
||||
remark: null
|
||||
}
|
||||
proxy.resetForm('chronicDiseaseRef')
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm('queryRef')
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 分页
|
||||
const handleCurrentChange = (val) => {
|
||||
queryParams.value.pageNum = val
|
||||
getList()
|
||||
}
|
||||
|
||||
// 每页显示条数改变
|
||||
const handleSizeChange = (val) => {
|
||||
queryParams.value.pageSize = val
|
||||
getList()
|
||||
}
|
||||
|
||||
// 序号翻页递增
|
||||
const indexMethod = (index) => {
|
||||
const nowPage = queryParams.value.pageNum
|
||||
const nowLimit = queryParams.value.pageSize
|
||||
return index + 1 + (nowPage - 1) * nowLimit
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map((item) => item.id)
|
||||
single.value = selection.length !== 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
// 查看
|
||||
const handleView = (row) => {
|
||||
title.value = '查看慢性疾病档案'
|
||||
form.value = { ...row }
|
||||
open.value = true
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '添加慢性疾病档案'
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _id = row.id || ids.value
|
||||
getChronicDisease(_id).then((response) => {
|
||||
form.value = response.data
|
||||
open.value = true
|
||||
title.value = '修改慢性疾病档案'
|
||||
})
|
||||
}
|
||||
|
||||
/** 状态修改 */
|
||||
function handleStatusChange(row) {
|
||||
const text = row.isActive === 1 ? '启用' : '停用'
|
||||
proxy.$modal
|
||||
.confirm('确认要"' + text + '"该慢性疾病档案吗?')
|
||||
.then(() => {
|
||||
return updateChronicDisease({ id: row.id, isActive: row.isActive })
|
||||
})
|
||||
.then(() => {
|
||||
proxy.$modal.msgSuccess(text + '成功')
|
||||
})
|
||||
.catch(() => {
|
||||
row.isActive = row.isActive === 0 ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
/** 选择疾病时自动填充疾病名称 */
|
||||
function handleDiseaseChange(diseaseId) {
|
||||
if (diseaseId) {
|
||||
const disease = diseaseList.value.find((item) => item.id === diseaseId)
|
||||
if (disease) {
|
||||
form.value.diseaseName = disease.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 选择成员时清空疾病选择 */
|
||||
function handleMemberChange() {
|
||||
// 可以在这里添加其他逻辑
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs.chronicDiseaseRef.validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.id != null) {
|
||||
updateChronicDisease(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addChronicDisease(form.value).then((response) => {
|
||||
proxy.$modal.msgSuccess('新增成功')
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _ids = row.id || ids.value
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除选中的数据项?')
|
||||
.then(function () {
|
||||
return delChronicDisease(_ids)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
// 初始化
|
||||
getMemberList()
|
||||
getDiseaseList()
|
||||
getList()
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
679
src/views/health/medicationPlan/index.vue
Normal file
679
src/views/health/medicationPlan/index.vue
Normal file
@@ -0,0 +1,679 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="search-con">
|
||||
<div class="title">查询条件</div>
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
|
||||
<el-form-item label="计划名称" prop="planName">
|
||||
<el-input v-model="queryParams.planName" placeholder="请输入计划名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="人员" prop="personId">
|
||||
<el-select v-model="queryParams.personId" placeholder="请选择人员" clearable filterable>
|
||||
<el-option v-for="item in personList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="频率类型" prop="frequencyType">
|
||||
<el-select v-model="queryParams.frequencyType" placeholder="请选择频率类型" clearable>
|
||||
<el-option v-for="dict in medication_frequency_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option v-for="dict in medication_plan_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键字" prop="keys">
|
||||
<el-input v-model="queryParams.keys" placeholder="计划名称/药品名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="search-btn-con">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button type="info" icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main-con">
|
||||
<div class="title-con">
|
||||
<div class="title">用药计划</div>
|
||||
<div class="operate-btn-con">
|
||||
<el-button @click="handleAdd" icon="Plus" v-hasPermi="['health:medicationPlan:add']">新增</el-button>
|
||||
<el-button :disabled="multiple" icon="Delete" @click="handleDelete" v-hasPermi="['health:medicationPlan:remove']">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-con" v-loading="loading" height="calc(100% - 0.65rem)">
|
||||
<el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange" height="calc(100% - 0.65rem)">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column type="index" label="序号" :index="indexMethod" width="50"></el-table-column>
|
||||
<el-table-column label="计划名称" align="center" prop="planName" width="150" />
|
||||
<el-table-column label="人员" align="center" prop="personName" width="100" />
|
||||
<el-table-column label="药品" align="center" prop="medicineName" width="200" />
|
||||
<el-table-column label="剂量" align="center" width="100">
|
||||
<template #default="scope">
|
||||
<span style="display: inline-flex; align-items: center; gap: 4px">
|
||||
{{ scope.row.dosagePerTime }}
|
||||
<dict-tag :options="medical_unit" :value="scope.row.dosageUnit" style="display: inline-flex" />
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="频次类型" align="center" prop="frequencyType" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="medication_frequency_type" :value="scope.row.frequencyType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="服药时间" align="center" width="180">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.timeSlots" class="time-slots-list">
|
||||
<el-tag v-for="(time, idx) in parseTimeSlots(scope.row.timeSlots)" :key="idx" size="small" type="info" class="time-tag">
|
||||
{{ time }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="开始日期" align="center" prop="startDate" width="110">
|
||||
<template #default="scope">
|
||||
{{ formatDate(scope.row.startDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束日期" align="center" prop="endDate" width="110">
|
||||
<template #default="scope">
|
||||
{{ scope.row.endDate ? formatDate(scope.row.endDate) : '长期' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="今日进度" align="center" width="100">
|
||||
<template #default="scope">
|
||||
<span v-if="scope.row.status === 1"> {{ scope.row.todayCompleted || 0 }}/{{ scope.row.todayTotal || 0 }} </span>
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="提醒" align="center" prop="remindEnabled" width="80">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.remindEnabled === 1" type="success">开</el-tag>
|
||||
<el-tag v-else type="info">关</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="status" width="90">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="medication_plan_status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding">
|
||||
<template v-slot="scope">
|
||||
<div class="ctrl-btn d-flex">
|
||||
<el-tooltip class="item" effect="dark" content="查看" placement="top">
|
||||
<el-button icon="View" v-hasPermi="['health:medicationPlan:query']" circle @click="handleView(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="scope.row.status === 1" class="item" effect="dark" content="暂停" placement="top">
|
||||
<el-button icon="VideoPause" v-hasPermi="['health:medicationPlan:edit']" circle @click="handlePause(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="scope.row.status === 2 || scope.row.status === 3" class="item" effect="dark" content="恢复" placement="top">
|
||||
<el-button icon="VideoPlay" v-hasPermi="['health:medicationPlan:edit']" circle @click="handleResume(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="scope.row.status !== 2" class="item" effect="dark" content="结束" placement="top">
|
||||
<el-button icon="Finished" v-hasPermi="['health:medicationPlan:edit']" circle @click="handleEnd(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="修改" placement="top">
|
||||
<el-button icon="Edit" v-hasPermi="['health:medicationPlan:edit']" circle @click="handleUpdate(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="删除" placement="top">
|
||||
<el-button icon="Delete" v-hasPermi="['health:medicationPlan:remove']" circle @click="handleDelete(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
small
|
||||
background
|
||||
layout="total,sizes, prev, pager, next"
|
||||
:total="total"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 添加或修改用药计划对话框 -->
|
||||
<el-dialog :title="title" v-model="open" width="900px" append-to-body>
|
||||
<el-form ref="planRef" :model="form" :inline="true" :rules="rules" label-width="120px">
|
||||
<el-form-item label="计划名称" prop="planName">
|
||||
<el-input v-model="form.planName" placeholder="请输入计划名称(可选)" />
|
||||
</el-form-item>
|
||||
<el-form-item label="人员" prop="personId">
|
||||
<el-select v-model="form.personId" placeholder="请选择人员" filterable @change="handlePersonChange">
|
||||
<el-option v-for="item in personList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="慢性疾病" prop="chronicDiseaseId">
|
||||
<el-select v-model="form.chronicDiseaseId" placeholder="请选择慢性疾病(可选)" filterable clearable>
|
||||
<el-option v-for="item in chronicDiseaseList" :key="item.id" :label="item.diseaseName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="药品" prop="medicineId">
|
||||
<el-select v-model="form.medicineId" placeholder="请选择药品" filterable @change="handleMedicineChange">
|
||||
<el-option v-for="item in medicineList" :key="item.id" :label="item.shortName + '-' + item.brand" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="每次剂量" prop="dosagePerTime">
|
||||
<el-input-number v-model="form.dosagePerTime" :min="0" :precision="2" style="width: 150px" />
|
||||
<el-select v-model="form.dosageUnit" placeholder="单位" style="width: 100px; margin-left: 10px">
|
||||
<el-option v-for="dict in medical_unit" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="频次类型" prop="frequencyType">
|
||||
<el-select v-model="form.frequencyType" placeholder="请选择频次类型">
|
||||
<el-option label="每天" :value="1" />
|
||||
<el-option label="每周" :value="2" />
|
||||
<el-option label="隔天" :value="3" />
|
||||
<el-option label="自定义" :value="4" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="服药时间点" prop="timeSlots" style="width: 100%">
|
||||
<div class="time-slots-wrapper">
|
||||
<div v-for="(time, index) in form.timePointList" :key="index" class="time-slot-item">
|
||||
<span class="time-text">{{ time }}</span>
|
||||
<el-icon class="close-icon" @click="removeTimePoint(index)"><Close /></el-icon>
|
||||
</div>
|
||||
<el-time-picker
|
||||
v-model="newTimePoint"
|
||||
placeholder="添加时间"
|
||||
format="HH:mm"
|
||||
value-format="HH:mm"
|
||||
@change="addTimePoint"
|
||||
style="width: 110px"
|
||||
size="small"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始日期" prop="startDate">
|
||||
<el-date-picker v-model="form.startDate" type="date" placeholder="选择开始日期" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item label="结束日期" prop="endDate">
|
||||
<el-date-picker v-model="form.endDate" type="date" placeholder="选择结束日期(可选)" value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
<el-form-item label="启用提醒" prop="remindEnabled">
|
||||
<el-switch v-model="form.remindEnabled" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.remindEnabled === 1" label="提前提醒" prop="remindAdvanceMin">
|
||||
<el-input-number v-model="form.remindAdvanceMin" :min="0" :max="60" />
|
||||
<span style="margin-left: 10px">分钟</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="通知家属" prop="notifyFamily">
|
||||
<el-switch v-model="form.notifyFamily" :active-value="1" :inactive-value="0" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.notifyFamily === 1" label="家属成员" prop="familyMemberIds">
|
||||
<el-select v-model="form.familyMemberIdList" multiple placeholder="请选择家属成员" filterable style="width: 300px">
|
||||
<el-option v-for="item in personList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" style="width: 100%">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" :rows="3" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template v-if="title !== '查看用药计划'" #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="MedicationPlan">
|
||||
import {
|
||||
listMedicationPlan,
|
||||
getMedicationPlan,
|
||||
delMedicationPlan,
|
||||
addMedicationPlan,
|
||||
updateMedicationPlan,
|
||||
pauseMedicationPlan,
|
||||
resumeMedicationPlan,
|
||||
endMedicationPlan
|
||||
} from '@/api/health/medicationPlan'
|
||||
import { listMedicineBasic } from '@/api/health/medicineBasic'
|
||||
import { listPerson } from '@/api/health/person'
|
||||
import { listChronicDiseaseByMember } from '@/api/health/chronicDisease'
|
||||
import { Close } from '@element-plus/icons-vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { medication_frequency_type, medication_plan_status, medical_unit } = proxy.useDict('medication_frequency_type', 'medication_plan_status', 'medical_unit')
|
||||
|
||||
const planList = ref([])
|
||||
const personList = ref([])
|
||||
const medicineList = ref([])
|
||||
const chronicDiseaseList = ref([])
|
||||
const open = ref(false)
|
||||
const loading = ref(true)
|
||||
const showSearch = ref(true)
|
||||
const ids = ref([])
|
||||
const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const title = ref('')
|
||||
const newTimePoint = ref(null)
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
planName: null,
|
||||
personId: null,
|
||||
frequencyType: null,
|
||||
status: null,
|
||||
keys: null
|
||||
},
|
||||
rules: {
|
||||
personId: [{ required: true, message: '请选择人员', trigger: 'change' }],
|
||||
medicineId: [{ required: true, message: '请选择药品', trigger: 'change' }],
|
||||
dosagePerTime: [{ required: true, message: '请输入剂量', trigger: 'blur' }],
|
||||
startDate: [{ required: true, message: '请选择开始日期', trigger: 'change' }]
|
||||
}
|
||||
})
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data)
|
||||
|
||||
/** 查询用药计划列表 */
|
||||
function getList() {
|
||||
loading.value = true
|
||||
listMedicationPlan(queryParams.value).then((response) => {
|
||||
planList.value = response.rows
|
||||
total.value = response.total
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询人员列表 */
|
||||
function getPersonList() {
|
||||
listPerson({ pageNum: 1, pageSize: 100 }).then((response) => {
|
||||
personList.value = response.rows || []
|
||||
})
|
||||
}
|
||||
|
||||
/** 查询药品列表 */
|
||||
function getMedicineList() {
|
||||
listMedicineBasic({ pageNum: 1, pageSize: 1000 }).then((response) => {
|
||||
medicineList.value = response.rows || []
|
||||
})
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
open.value = false
|
||||
reset()
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
personId: null,
|
||||
chronicDiseaseId: null,
|
||||
medicineId: null,
|
||||
planName: null,
|
||||
medicineName: null,
|
||||
specification: null,
|
||||
dosagePerTime: 1,
|
||||
dosageUnit: '片',
|
||||
frequencyType: 1,
|
||||
frequencyConfig: null,
|
||||
timeSlots: null,
|
||||
timePointList: ['08:00', '12:00', '18:00'],
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
remindEnabled: 0,
|
||||
remindAdvanceMin: 15,
|
||||
notifyFamily: 0,
|
||||
familyMemberIds: null,
|
||||
familyMemberIdList: [],
|
||||
status: 1,
|
||||
remark: null
|
||||
}
|
||||
chronicDiseaseList.value = []
|
||||
proxy.resetForm('planRef')
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm('queryRef')
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
// 分页
|
||||
const handleCurrentChange = (val) => {
|
||||
queryParams.value.pageNum = val
|
||||
getList()
|
||||
}
|
||||
|
||||
const handleSizeChange = (val) => {
|
||||
queryParams.value.pageSize = val
|
||||
getList()
|
||||
}
|
||||
|
||||
// 序号翻页递增
|
||||
const indexMethod = (index) => {
|
||||
const nowPage = queryParams.value.pageNum
|
||||
const nowLimit = queryParams.value.pageSize
|
||||
return index + 1 + (nowPage - 1) * nowLimit
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map((item) => item.id)
|
||||
single.value = selection.length !== 1
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
function formatDate(date) {
|
||||
if (!date) return ''
|
||||
// 处理数组格式 [2026, 3, 21]
|
||||
if (Array.isArray(date)) {
|
||||
return `${date[0]}-${String(date[1]).padStart(2, '0')}-${String(date[2]).padStart(2, '0')}`
|
||||
}
|
||||
// 处理字符串格式
|
||||
if (typeof date === 'string') {
|
||||
return date.substring(0, 10)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
// 解析服药时间点 JSON
|
||||
function parseTimeSlots(timeSlots) {
|
||||
if (!timeSlots) return []
|
||||
try {
|
||||
return typeof timeSlots === 'string' ? JSON.parse(timeSlots) : timeSlots
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
// 将数组日期转换为字符串日期
|
||||
function convertArrayDateToString(dateArray) {
|
||||
if (!dateArray) return null
|
||||
if (Array.isArray(dateArray)) {
|
||||
return `${dateArray[0]}-${String(dateArray[1]).padStart(2, '0')}-${String(dateArray[2]).padStart(2, '0')}`
|
||||
}
|
||||
if (typeof dateArray === 'string') {
|
||||
return dateArray.substring(0, 10)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 查看
|
||||
const handleView = (row) => {
|
||||
getMedicationPlan(row.id).then((response) => {
|
||||
form.value = response.data
|
||||
// 转换日期格式
|
||||
form.value.startDate = convertArrayDateToString(form.value.startDate)
|
||||
form.value.endDate = convertArrayDateToString(form.value.endDate)
|
||||
// 解析 timeSlots JSON
|
||||
if (form.value.timeSlots) {
|
||||
try {
|
||||
form.value.timePointList = typeof form.value.timeSlots === 'string' ? JSON.parse(form.value.timeSlots) : form.value.timeSlots
|
||||
} catch (e) {
|
||||
form.value.timePointList = []
|
||||
}
|
||||
} else {
|
||||
form.value.timePointList = []
|
||||
}
|
||||
// 解析 familyMemberIds JSON
|
||||
if (form.value.familyMemberIds) {
|
||||
try {
|
||||
form.value.familyMemberIdList = typeof form.value.familyMemberIds === 'string' ? JSON.parse(form.value.familyMemberIds) : form.value.familyMemberIds
|
||||
} catch (e) {
|
||||
form.value.familyMemberIdList = []
|
||||
}
|
||||
} else {
|
||||
form.value.familyMemberIdList = []
|
||||
}
|
||||
title.value = '查看用药计划'
|
||||
open.value = true
|
||||
// 加载该人员的慢性疾病列表
|
||||
if (form.value.personId) {
|
||||
listChronicDiseaseByMember(form.value.personId).then((res) => {
|
||||
chronicDiseaseList.value = res.data || []
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '添加用药计划'
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
const _id = row.id || ids.value
|
||||
getMedicationPlan(_id).then((response) => {
|
||||
form.value = response.data
|
||||
// 转换日期格式
|
||||
form.value.startDate = convertArrayDateToString(form.value.startDate)
|
||||
form.value.endDate = convertArrayDateToString(form.value.endDate)
|
||||
// 解析 timeSlots JSON
|
||||
if (form.value.timeSlots) {
|
||||
try {
|
||||
form.value.timePointList = typeof form.value.timeSlots === 'string' ? JSON.parse(form.value.timeSlots) : form.value.timeSlots
|
||||
} catch (e) {
|
||||
form.value.timePointList = []
|
||||
}
|
||||
} else {
|
||||
form.value.timePointList = []
|
||||
}
|
||||
// 解析 familyMemberIds JSON
|
||||
if (form.value.familyMemberIds) {
|
||||
try {
|
||||
form.value.familyMemberIdList = typeof form.value.familyMemberIds === 'string' ? JSON.parse(form.value.familyMemberIds) : form.value.familyMemberIds
|
||||
} catch (e) {
|
||||
form.value.familyMemberIdList = []
|
||||
}
|
||||
} else {
|
||||
form.value.familyMemberIdList = []
|
||||
}
|
||||
open.value = true
|
||||
title.value = '修改用药计划'
|
||||
// 加载该人员的慢性疾病列表
|
||||
if (form.value.personId) {
|
||||
listChronicDiseaseByMember(form.value.personId).then((res) => {
|
||||
chronicDiseaseList.value = res.data || []
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 暂停按钮操作 */
|
||||
function handlePause(row) {
|
||||
proxy.$modal
|
||||
.confirm('确认暂停该用药计划?')
|
||||
.then(() => {
|
||||
return pauseMedicationPlan(row.id)
|
||||
})
|
||||
.then((response) => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess('暂停成功')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
/** 恢复按钮操作 */
|
||||
function handleResume(row) {
|
||||
resumeMedicationPlan(row.id).then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess('恢复成功')
|
||||
})
|
||||
}
|
||||
|
||||
/** 结束按钮操作 */
|
||||
function handleEnd(row) {
|
||||
proxy.$modal
|
||||
.confirm('确认结束该用药计划?结束后将不再生成用药记录。')
|
||||
.then(() => {
|
||||
return endMedicationPlan(row.id)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess('已结束')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs.planRef.validate((valid) => {
|
||||
if (valid) {
|
||||
// 构建提交数据,排除后端自动生成的字段
|
||||
const submitData = { ...form.value }
|
||||
// 将时间点列表转为 JSON 字符串
|
||||
submitData.timeSlots = JSON.stringify(form.value.timePointList)
|
||||
// 将家属成员ID列表转为 JSON 字符串
|
||||
if (form.value.familyMemberIdList && form.value.familyMemberIdList.length > 0) {
|
||||
submitData.familyMemberIds = JSON.stringify(form.value.familyMemberIdList)
|
||||
} else {
|
||||
submitData.familyMemberIds = null
|
||||
}
|
||||
// 根据药品ID获取药品名称和规格
|
||||
const medicine = medicineList.value.find((m) => m.id === submitData.medicineId)
|
||||
if (medicine) {
|
||||
submitData.medicineName = medicine.shortName + '-' + medicine.brand
|
||||
submitData.specification = medicine.specification || ''
|
||||
}
|
||||
// 移除后端自动管理的字段
|
||||
delete submitData.createTime
|
||||
delete submitData.updateTime
|
||||
delete submitData.familyMemberIdList
|
||||
if (submitData.id != null) {
|
||||
updateMedicationPlan(submitData).then((response) => {
|
||||
proxy.$modal.msgSuccess('修改成功')
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
} else {
|
||||
addMedicationPlan(submitData).then((response) => {
|
||||
proxy.$modal.msgSuccess('新增成功')
|
||||
open.value = false
|
||||
getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _ids = row.id || ids.value
|
||||
proxy.$modal
|
||||
.confirm('是否确认删除选中的数据项?')
|
||||
.then(function () {
|
||||
return delMedicationPlan(_ids)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
/** 添加服药时间点 */
|
||||
function addTimePoint(val) {
|
||||
if (val && !form.value.timePointList.includes(val)) {
|
||||
form.value.timePointList.push(val)
|
||||
}
|
||||
newTimePoint.value = null
|
||||
}
|
||||
|
||||
/** 移除服药时间点 */
|
||||
function removeTimePoint(index) {
|
||||
form.value.timePointList.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 药品选择变化 */
|
||||
function handleMedicineChange(medicineId) {
|
||||
const medicine = medicineList.value.find((m) => m.id === medicineId)
|
||||
if (medicine) {
|
||||
form.value.dosageUnit = medicine.unit || '片'
|
||||
}
|
||||
}
|
||||
|
||||
/** 人员选择变化 */
|
||||
function handlePersonChange(personId) {
|
||||
form.value.chronicDiseaseId = null
|
||||
chronicDiseaseList.value = []
|
||||
if (personId) {
|
||||
listChronicDiseaseByMember(personId).then((response) => {
|
||||
chronicDiseaseList.value = response.data || []
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
getPersonList()
|
||||
getMedicineList()
|
||||
getList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.time-slots-wrapper {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
background: #fafbfc;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 6px;
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.time-slot-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 10px;
|
||||
background: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.time-slot-item:hover {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.time-text {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.close-icon {
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
transition: all 0.2s;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.close-icon:hover {
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
.time-slots-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.time-tag {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
</style>
|
||||
555
src/views/health/medicationStatistic/index.vue
Normal file
555
src/views/health/medicationStatistic/index.vue
Normal file
@@ -0,0 +1,555 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 查询条件 -->
|
||||
<div class="search-con">
|
||||
<div class="title">查询条件</div>
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" label-width="80px">
|
||||
<el-form-item label="人员" prop="personId">
|
||||
<el-select v-model="queryParams.personId" placeholder="请选择人员" clearable filterable>
|
||||
<el-option v-for="item in personList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="统计周期">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="search-btn-con">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button type="info" icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 概览卡片 -->
|
||||
<div class="overview-cards" v-loading="loading">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background: #409eff">
|
||||
<el-icon><Calendar /></el-icon>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ overview.totalTasks || 0 }}</div>
|
||||
<div class="stat-label">总任务数</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background: #67c23a">
|
||||
<el-icon><Check /></el-icon>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ overview.completedTasks || 0 }}</div>
|
||||
<div class="stat-label">已服药</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background: #f56c6c">
|
||||
<el-icon><Close /></el-icon>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ overview.missedTasks || 0 }}</div>
|
||||
<div class="stat-label">漏服</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background: #e6a23c">
|
||||
<el-icon><Timer /></el-icon>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ overview.adherenceRate || 0 }}%</div>
|
||||
<div class="stat-label">服药率</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background: #909399">
|
||||
<el-icon><Clock /></el-icon>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ overview.ontimeRate || 0 }}%</div>
|
||||
<div class="stat-label">准时率</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 图表区域 -->
|
||||
<div class="charts-row">
|
||||
<!-- 趋势图 -->
|
||||
<div class="chart-card">
|
||||
<div class="chart-title">服药趋势(最近7天)</div>
|
||||
<div ref="trendChartRef" class="chart-container"></div>
|
||||
</div>
|
||||
<!-- 时段统计 -->
|
||||
<div class="chart-card">
|
||||
<div class="chart-title">时段分布</div>
|
||||
<div ref="timeSlotChartRef" class="chart-container"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 日历视图 -->
|
||||
<div class="calendar-section">
|
||||
<div class="calendar-header">
|
||||
<span class="calendar-title">日历视图</span>
|
||||
<div class="calendar-nav">
|
||||
<el-button-group>
|
||||
<el-button @click="changeMonth(-1)" icon="ArrowLeft">上月</el-button>
|
||||
<el-button>{{ currentMonth }}</el-button>
|
||||
<el-button @click="changeMonth(1)"
|
||||
>下月<el-icon class="el-icon--right"><ArrowRight /></el-icon
|
||||
></el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
</div>
|
||||
<div class="calendar-grid" v-loading="calendarLoading">
|
||||
<div class="calendar-weekdays">
|
||||
<div v-for="day in weekdays" :key="day" class="weekday">{{ day }}</div>
|
||||
</div>
|
||||
<div class="calendar-days">
|
||||
<div v-for="(day, index) in calendarDays" :key="index" class="calendar-day" :class="{ 'other-month': day.otherMonth, today: day.isToday }">
|
||||
<div class="day-number">{{ day.day }}</div>
|
||||
<div class="day-stats" v-if="day.data && day.data.totalTasks > 0">
|
||||
<span class="stat-dot completed" :title="`已服药: ${day.data.completedTasks}`"></span>
|
||||
<span class="stat-dot missed" v-if="day.data.missedTasks > 0" :title="`漏服: ${day.data.missedTasks}`"></span>
|
||||
<span class="stat-rate">{{ day.data.adherenceRate }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="MedicationStatistic">
|
||||
import { ref, reactive, onMounted, watch, computed, nextTick } from 'vue'
|
||||
import { getOverallAdherence, getDailyAdherence, getCalendarData, getTimeSlotAdherence } from '@/api/health/medicationAdherence'
|
||||
import { listPerson } from '@/api/health/person'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const loading = ref(false)
|
||||
const calendarLoading = ref(false)
|
||||
const personList = ref([])
|
||||
const queryParams = reactive({
|
||||
personId: null
|
||||
})
|
||||
const dateRange = ref([])
|
||||
const overview = ref({})
|
||||
|
||||
// 日历相关
|
||||
const currentMonth = ref('')
|
||||
const currentYearMonth = ref('')
|
||||
const calendarData = ref([])
|
||||
const weekdays = ['一', '二', '三', '四', '五', '六', '日']
|
||||
|
||||
// 图表
|
||||
const trendChartRef = ref(null)
|
||||
const timeSlotChartRef = ref(null)
|
||||
let trendChart = null
|
||||
let timeSlotChart = null
|
||||
|
||||
// 计算日历天数
|
||||
const calendarDays = computed(() => {
|
||||
const days = []
|
||||
if (!currentYearMonth.value) return days
|
||||
|
||||
const [year, month] = currentYearMonth.value.split('-').map(Number)
|
||||
const firstDay = new Date(year, month - 1, 1)
|
||||
const lastDay = new Date(year, month, 0)
|
||||
const startWeekday = (firstDay.getDay() + 6) % 7 // 周一为0
|
||||
|
||||
// 上月填充
|
||||
const prevMonthLastDay = new Date(year, month - 1, 0).getDate()
|
||||
for (let i = startWeekday - 1; i >= 0; i--) {
|
||||
days.push({
|
||||
day: prevMonthLastDay - i,
|
||||
otherMonth: true,
|
||||
isToday: false,
|
||||
data: null
|
||||
})
|
||||
}
|
||||
|
||||
// 当月
|
||||
const today = new Date()
|
||||
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`
|
||||
|
||||
const dataMap = {}
|
||||
calendarData.value.forEach((d) => {
|
||||
dataMap[d.date] = d
|
||||
})
|
||||
|
||||
for (let i = 1; i <= lastDay.getDate(); i++) {
|
||||
const dateStr = `${year}-${String(month).padStart(2, '0')}-${String(i).padStart(2, '0')}`
|
||||
days.push({
|
||||
day: i,
|
||||
otherMonth: false,
|
||||
isToday: dateStr === todayStr,
|
||||
data: dataMap[dateStr] || null
|
||||
})
|
||||
}
|
||||
|
||||
// 下月填充
|
||||
const remaining = 42 - days.length
|
||||
for (let i = 1; i <= remaining; i++) {
|
||||
days.push({
|
||||
day: i,
|
||||
otherMonth: true,
|
||||
isToday: false,
|
||||
data: null
|
||||
})
|
||||
}
|
||||
|
||||
return days
|
||||
})
|
||||
|
||||
// 获取人员列表
|
||||
const getPersonList = async () => {
|
||||
try {
|
||||
const res = await listPerson({})
|
||||
personList.value = res.rows || []
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
// 查询统计数据
|
||||
const getStatistics = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = { ...queryParams }
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
params.startDate = dateRange.value[0]
|
||||
params.endDate = dateRange.value[1]
|
||||
} else {
|
||||
// 默认最近7天
|
||||
const today = new Date()
|
||||
const weekAgo = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000)
|
||||
params.startDate = weekAgo.toISOString().split('T')[0]
|
||||
params.endDate = today.toISOString().split('T')[0]
|
||||
}
|
||||
|
||||
// 获取总体统计
|
||||
const overviewRes = await getOverallAdherence(params)
|
||||
overview.value = overviewRes.data || {}
|
||||
|
||||
// 获取每日趋势
|
||||
const dailyRes = await getDailyAdherence(params)
|
||||
renderTrendChart(dailyRes.data || [])
|
||||
|
||||
// 获取时段统计
|
||||
const timeSlotRes = await getTimeSlotAdherence(params)
|
||||
renderTimeSlotChart(timeSlotRes.data || {})
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染趋势图
|
||||
const renderTrendChart = (data) => {
|
||||
nextTick(() => {
|
||||
if (!trendChartRef.value) return
|
||||
if (!trendChart) {
|
||||
trendChart = echarts.init(trendChartRef.value)
|
||||
}
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: ['服药率', '准时率']
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: data.map((d) => d.date?.substring(5) || '')
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
max: 100
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '服药率',
|
||||
type: 'line',
|
||||
data: data.map((d) => d.adherenceRate || 0),
|
||||
smooth: true,
|
||||
itemStyle: { color: '#409EFF' }
|
||||
},
|
||||
{
|
||||
name: '准时率',
|
||||
type: 'line',
|
||||
data: data.map((d) => d.ontimeRate || 0),
|
||||
smooth: true,
|
||||
itemStyle: { color: '#67C23A' }
|
||||
}
|
||||
]
|
||||
}
|
||||
trendChart.setOption(option)
|
||||
})
|
||||
}
|
||||
|
||||
// 渲染时段统计图
|
||||
const renderTimeSlotChart = (data) => {
|
||||
nextTick(() => {
|
||||
if (!timeSlotChartRef.value) return
|
||||
if (!timeSlotChart) {
|
||||
timeSlotChart = echarts.init(timeSlotChartRef.value)
|
||||
}
|
||||
|
||||
const slotNames = {
|
||||
morning: '上午(6-12)',
|
||||
afternoon: '下午(12-18)',
|
||||
evening: '晚间(18-24)',
|
||||
night: '凌晨(0-6)'
|
||||
}
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: '{b}: {c}%'
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: ['40%', '70%'],
|
||||
data: Object.entries(data).map(([key, value]) => ({
|
||||
name: slotNames[key] || key,
|
||||
value: value.adherenceRate || 0
|
||||
})),
|
||||
emphasis: {
|
||||
itemStyle: {
|
||||
shadowBlur: 10,
|
||||
shadowOffsetX: 0,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
timeSlotChart.setOption(option)
|
||||
})
|
||||
}
|
||||
|
||||
// 获取日历数据
|
||||
const getCalendar = async () => {
|
||||
calendarLoading.value = true
|
||||
try {
|
||||
const res = await getCalendarData(queryParams.personId, currentYearMonth.value)
|
||||
calendarData.value = res.data || []
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
calendarLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 切换月份
|
||||
const changeMonth = (delta) => {
|
||||
const [year, month] = currentYearMonth.value.split('-').map(Number)
|
||||
const newDate = new Date(year, month - 1 + delta, 1)
|
||||
currentYearMonth.value = `${newDate.getFullYear()}-${String(newDate.getMonth() + 1).padStart(2, '0')}`
|
||||
currentMonth.value = `${newDate.getFullYear()}年${newDate.getMonth() + 1}月`
|
||||
getCalendar()
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
getStatistics()
|
||||
getCalendar()
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
queryParams.personId = null
|
||||
dateRange.value = []
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 初始化日期
|
||||
const today = new Date()
|
||||
currentYearMonth.value = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}`
|
||||
currentMonth.value = `${today.getFullYear()}年${today.getMonth() + 1}月`
|
||||
|
||||
getPersonList()
|
||||
getStatistics()
|
||||
getCalendar()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.app-container {
|
||||
height: calc(100vh - 84px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.overview-cards {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
min-width: 180px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
|
||||
.stat-icon {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
color: #fff;
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
.stat-content {
|
||||
.stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.charts-row {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.chart-card {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
|
||||
.chart-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 12px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
height: 300px;
|
||||
}
|
||||
}
|
||||
|
||||
.calendar-section {
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
|
||||
.calendar-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.calendar-title {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
.calendar-grid {
|
||||
.calendar-weekdays {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.weekday {
|
||||
padding: 8px;
|
||||
color: #909399;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.calendar-days {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 4px;
|
||||
|
||||
.calendar-day {
|
||||
min-height: 80px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
|
||||
&.other-month {
|
||||
background: #f5f7fa;
|
||||
.day-number {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
}
|
||||
|
||||
&.today {
|
||||
border-color: #409eff;
|
||||
.day-number {
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.day-number {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.day-stats {
|
||||
margin-top: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
.stat-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
|
||||
&.completed {
|
||||
background: #67c23a;
|
||||
}
|
||||
&.missed {
|
||||
background: #f56c6c;
|
||||
}
|
||||
}
|
||||
|
||||
.stat-rate {
|
||||
font-size: 12px;
|
||||
color: #606266;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
298
src/views/health/medicationTask/index.vue
Normal file
298
src/views/health/medicationTask/index.vue
Normal file
@@ -0,0 +1,298 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<div class="search-con">
|
||||
<div class="title">查询条件</div>
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
|
||||
<el-form-item label="人员" prop="memberId">
|
||||
<el-select v-model="queryParams.memberId" placeholder="请选择人员" clearable filterable>
|
||||
<el-option v-for="item in memberList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划" prop="planId">
|
||||
<el-select v-model="queryParams.planId" placeholder="请选择计划" clearable filterable style="width: 250px">
|
||||
<el-option v-for="item in planList" :key="item.id" :label="item.planName" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
|
||||
<el-option v-for="dict in medication_task_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划日期">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="search-btn-con">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button type="info" icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main-con">
|
||||
<div class="title-con">
|
||||
<div class="title">服药任务</div>
|
||||
<div class="operate-btn-con">
|
||||
<el-button :disabled="multiple" icon="Delete" @click="handleDelete" v-hasPermi="['health:medicationTask:remove']">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-con" v-loading="loading">
|
||||
<el-table v-loading="loading" :data="taskList" @selection-change="handleSelectionChange" height="calc(100% - 0.65rem)">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column type="index" label="序号" :index="indexMethod" width="50"></el-table-column>
|
||||
<el-table-column label="计划名称" align="center" prop="planName" width="150" />
|
||||
<el-table-column label="人员" align="center" prop="personName" width="80" />
|
||||
<el-table-column label="药品" align="center" prop="medicineName" width="180" />
|
||||
<el-table-column label="计划日期" align="center" prop="plannedDate" width="110">
|
||||
<template #default="scope">
|
||||
{{ formatDate(scope.row.plannedDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计划时间" align="center" prop="plannedTime" width="100">
|
||||
<template #default="scope">
|
||||
{{ formatTime(scope.row.plannedTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实际时间" align="center" width="160">
|
||||
<template #default="scope">
|
||||
{{ scope.row.actualTime ? formatDateTime(scope.row.actualTime) : '--' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="剂量" align="center" width="100">
|
||||
<template #default="scope">
|
||||
{{ scope.row.plannedDosage }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" prop="status" width="90">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="medication_task_status" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="notes" show-overflow-tooltip />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template v-slot="scope">
|
||||
<div class="ctrl-btn d-flex">
|
||||
<el-tooltip v-if="scope.row.status === 0" class="item" effect="dark" content="确认服药" placement="top">
|
||||
<el-button type="success" icon="Check" v-hasPermi="['health:medicationTask:edit']" circle @click="handleConfirm(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="scope.row.status === 0" class="item" effect="dark" content="跳过" placement="top">
|
||||
<el-button type="warning" icon="Close" v-hasPermi="['health:medicationTask:edit']" circle @click="handleSkip(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip class="item" effect="dark" content="删除" placement="top">
|
||||
<el-button icon="Delete" v-hasPermi="['health:medicationTask:remove']" circle @click="handleDelete(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
small
|
||||
background
|
||||
layout="total,sizes, prev, pager, next"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
:total="total"
|
||||
v-model:current-page="queryParams.pageNum"
|
||||
v-model:page-size="queryParams.pageSize"
|
||||
@size-change="getList"
|
||||
@current-change="getList"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 确认服药对话框 -->
|
||||
<el-dialog title="确认服药" v-model="confirmDialogVisible" width="400px">
|
||||
<el-form>
|
||||
<el-form-item label="实际服药时间">
|
||||
<el-time-picker v-model="actualTime" placeholder="选择实际服药时间" format="HH:mm" value-format="HH:mm" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="confirmDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitConfirm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 跳过对话框 -->
|
||||
<el-dialog title="跳过服药" v-model="skipDialogVisible" width="400px">
|
||||
<el-form>
|
||||
<el-form-item label="跳过原因">
|
||||
<el-input v-model="skipNotes" type="textarea" placeholder="请输入跳过原因(选填)" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="skipDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitSkip">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="MedicationTask">
|
||||
import { listMedicationTask, delMedicationTask, confirmMedication, skipMedication } from '@/api/health/medicationTask'
|
||||
import { listMedicationPlan } from '@/api/health/medicationPlan'
|
||||
import { listPerson } from '@/api/health/person'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { medication_task_status } = proxy.useDict('medication_task_status')
|
||||
|
||||
const taskList = ref([])
|
||||
const planList = ref([])
|
||||
const memberList = ref([])
|
||||
const loading = ref(false)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
const dateRange = ref([])
|
||||
const ids = ref([])
|
||||
|
||||
const queryParams = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
memberId: null,
|
||||
planId: null,
|
||||
status: null,
|
||||
plannedDateBegin: null,
|
||||
plannedDateEnd: null
|
||||
})
|
||||
|
||||
const confirmDialogVisible = ref(false)
|
||||
const actualTime = ref('')
|
||||
const skipDialogVisible = ref(false)
|
||||
const skipNotes = ref('')
|
||||
const currentRow = ref(null)
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
queryParams.plannedDateBegin = dateRange.value[0]
|
||||
queryParams.plannedDateEnd = dateRange.value[1]
|
||||
} else {
|
||||
queryParams.plannedDateBegin = null
|
||||
queryParams.plannedDateEnd = null
|
||||
}
|
||||
try {
|
||||
const res = await listMedicationTask(queryParams)
|
||||
taskList.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const getPlanList = async () => {
|
||||
const res = await listMedicationPlan({})
|
||||
planList.value = res.rows || []
|
||||
}
|
||||
|
||||
const getMemberList = async () => {
|
||||
const res = await listPerson({})
|
||||
memberList.value = res.rows || []
|
||||
}
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNum = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
dateRange.value = []
|
||||
queryParams.memberId = null
|
||||
queryParams.planId = null
|
||||
queryParams.status = null
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
const handleSelectionChange = (selection) => {
|
||||
ids.value = selection.map((item) => item.id)
|
||||
multiple.value = !selection.length
|
||||
}
|
||||
|
||||
const handleConfirm = (row) => {
|
||||
currentRow.value = row
|
||||
// 默认当前时间
|
||||
const now = new Date()
|
||||
actualTime.value = `${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
|
||||
confirmDialogVisible.value = true
|
||||
}
|
||||
|
||||
const submitConfirm = async () => {
|
||||
if (!actualTime.value) {
|
||||
proxy.$modal.msgError('请选择实际服药时间')
|
||||
return
|
||||
}
|
||||
// confirmType=1 表示确认服药,confirmTime 传递时间字符串
|
||||
await confirmMedication(currentRow.value.id, 1, actualTime.value)
|
||||
proxy.$modal.msgSuccess('操作成功')
|
||||
confirmDialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
|
||||
const handleSkip = (row) => {
|
||||
currentRow.value = row
|
||||
skipNotes.value = ''
|
||||
skipDialogVisible.value = true
|
||||
}
|
||||
|
||||
const submitSkip = async () => {
|
||||
await skipMedication(currentRow.value.id, skipNotes.value)
|
||||
proxy.$modal.msgSuccess('操作成功')
|
||||
skipDialogVisible.value = false
|
||||
getList()
|
||||
}
|
||||
|
||||
const handleDelete = async (row) => {
|
||||
const idList = row.id ? [row.id] : ids.value
|
||||
await proxy.$modal.confirm('确认删除选中的记录?')
|
||||
await delMedicationTask(idList.join(','))
|
||||
proxy.$modal.msgSuccess('删除成功')
|
||||
getList()
|
||||
}
|
||||
|
||||
const indexMethod = (index) => {
|
||||
return (queryParams.pageNum - 1) * queryParams.pageSize + index + 1
|
||||
}
|
||||
|
||||
const formatDate = (date) => {
|
||||
if (!date) return '--'
|
||||
// 处理数组格式 [2026, 3, 21]
|
||||
if (Array.isArray(date)) {
|
||||
return `${date[0]}-${String(date[1]).padStart(2, '0')}-${String(date[2]).padStart(2, '0')}`
|
||||
}
|
||||
// 处理字符串格式
|
||||
if (typeof date === 'string') {
|
||||
return date.substring(0, 10)
|
||||
}
|
||||
return '--'
|
||||
}
|
||||
|
||||
const formatTime = (time) => {
|
||||
if (!time) return '--'
|
||||
// 处理数组格式 [8, 0] 或 [14, 30]
|
||||
if (Array.isArray(time)) {
|
||||
return `${String(time[0]).padStart(2, '0')}:${String(time[1]).padStart(2, '0')}`
|
||||
}
|
||||
// 处理字符串格式
|
||||
if (typeof time === 'string') {
|
||||
return time.substring(0, 5)
|
||||
}
|
||||
return '--'
|
||||
}
|
||||
|
||||
const formatDateTime = (datetime) => {
|
||||
if (!datetime) return '--'
|
||||
return datetime.replace('T', ' ').substring(0, 16)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList()
|
||||
getPlanList()
|
||||
getMemberList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
Reference in New Issue
Block a user