refactor(health): 前端适配后端API重构

- 新增 medicationTask.js 替代 medicationRecord.js
- 新增 medicationTask/index.vue 服药任务页面
- 更新 medicationAdherence.js 参数名 personId -> memberId
- 状态值适配:0-待服药 1-已服药 2-漏服 3-跳过
This commit is contained in:
bot5
2026-03-19 21:36:51 +08:00
parent f090aeb9b9
commit ffe1ed9e88
5 changed files with 312 additions and 466 deletions

View File

@@ -19,11 +19,11 @@ export function getDailyAdherence(query) {
}
// 获取日历视图数据
export function getCalendarData(personId, yearMonth) {
export function getCalendarData(memberId, yearMonth) {
return request({
url: '/health/adherence/calendar',
method: 'get',
params: { personId, yearMonth }
params: { memberId, yearMonth }
})
}
@@ -36,38 +36,11 @@ export function getTimeSlotAdherence(query) {
})
}
// 获取各药品依从性统计
export function getMedicineAdherence(query) {
return request({
url: '/health/adherence/medicine',
method: 'get',
params: query
})
}
// 获取各人员依从性统计
export function getPersonAdherence(query) {
return request({
url: '/health/adherence/person',
method: 'get',
params: query
})
}
// 获取漏服原因统计
export function getMissedReasonStats(query) {
return request({
url: '/health/adherence/missedReason',
method: 'get',
params: query
})
}
// 获取仪表盘概览数据
export function getDashboard(personId) {
export function getDashboard(memberId) {
return request({
url: '/health/adherence/dashboard',
method: 'get',
params: { personId }
params: { memberId }
})
}

View File

@@ -1,79 +0,0 @@
import request from '@/utils/request'
// 查询用药记录列表
export function listMedicationRecord(query) {
return request({
url: '/health/medicationRecord/list',
method: 'get',
params: query
})
}
// 查询今日用药记录
export function getTodayRecords(personId) {
return request({
url: '/health/medicationRecord/today',
method: 'get',
params: { personId }
})
}
// 查询某计划某天的用药记录
export function getRecordsByPlanAndDate(planId, date) {
return request({
url: '/health/medicationRecord/plan/' + planId + '/date/' + date,
method: 'get'
})
}
// 查询用药记录详细
export function getMedicationRecord(id) {
return request({
url: '/health/medicationRecord/' + id,
method: 'get'
})
}
// 新增用药记录
export function addMedicationRecord(data) {
return request({
url: '/health/medicationRecord',
method: 'post',
data
})
}
// 修改用药记录
export function updateMedicationRecord(data) {
return request({
url: '/health/medicationRecord',
method: 'put',
data
})
}
// 删除用药记录
export function delMedicationRecord(id) {
return request({
url: '/health/medicationRecord/' + id,
method: 'delete'
})
}
// 服药(标记为已服用)
export function takeMedication(id, dosage, remark) {
return request({
url: '/health/medicationRecord/take/' + id,
method: 'put',
params: { dosage, remark }
})
}
// 跳过服药
export function skipMedication(id, remark) {
return request({
url: '/health/medicationRecord/skip/' + id,
method: 'put',
params: { remark }
})
}

View 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) {
return request({
url: '/health/medicationTask/confirm/' + id,
method: 'put',
params: { confirmType }
})
}
// 跳过服药
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 }
})
}

View File

@@ -1,356 +0,0 @@
<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 personList" :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 || item.medicineDisplayName" :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_record_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 @click="handleAdd" icon="Plus" v-hasPermi="['health:medicationRecord:add']">手动记录</el-button>
<el-button :disabled="multiple" icon="Delete" @click="handleDelete" v-hasPermi="['health:medicationRecord:remove']">删除</el-button>
</div>
</div>
<div class="content-con" v-loading="loading">
<el-table v-loading="loading" :data="recordList" @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" width="180">
<template #default="scope">
{{ scope.row.shortName }}-{{ scope.row.brand }}
</template>
</el-table-column>
<el-table-column label="计划时间" align="center" width="160">
<template #default="scope">
{{ formatDateTime(scope.row.scheduledTime) }}
</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.dosage }}{{ scope.row.dosageUnit }}
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="status" width="90">
<template #default="scope">
<dict-tag :options="medication_record_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
<template v-slot="scope">
<div class="ctrl-btn d-flex">
<el-tooltip v-if="scope.row.status === '1'" class="item" effect="dark" content="服药" placement="top">
<el-button type="success" icon="Check" v-hasPermi="['health:medicationRecord:edit']" circle @click="handleTake(scope.row)"></el-button>
</el-tooltip>
<el-tooltip v-if="scope.row.status === '1'" class="item" effect="dark" content="跳过" placement="top">
<el-button type="warning" icon="Close" v-hasPermi="['health:medicationRecord:edit']" circle @click="handleSkip(scope.row)"></el-button>
</el-tooltip>
<el-tooltip class="item" effect="dark" content="修改" placement="top">
<el-button icon="Edit" v-hasPermi="['health:medicationRecord: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:medicationRecord: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="手动记录用药" v-model="open" width="600px" append-to-body>
<el-form ref="recordRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="计划" prop="planId">
<el-select v-model="form.planId" placeholder="请选择计划" filterable style="width: 100%" @change="handlePlanChange">
<el-option v-for="item in planList" :key="item.id" :label="item.planName || item.medicineDisplayName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="服药时间" prop="actualTime">
<el-date-picker v-model="form.actualTime" type="datetime" placeholder="选择服药时间" value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />
</el-form-item>
<el-form-item label="剂量" prop="dosage">
<el-input-number v-model="form.dosage" :min="0" :precision="2" style="width: 150px" />
<span style="margin-left: 10px">{{ form.dosageUnit }}</span>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" :rows="3" />
</el-form-item>
</el-form>
<template #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="MedicationRecord">
import { listMedicationRecord, getMedicationRecord, delMedicationRecord, addMedicationRecord, updateMedicationRecord, takeMedication, skipMedication } from '@/api/health/medicationRecord'
import { listMedicationPlan } from '@/api/health/medicationPlan'
import { listPerson } from '@/api/health/person'
const { proxy } = getCurrentInstance()
const { medication_record_status } = proxy.useDict('medication_record_status')
const recordList = ref([])
const personList = ref([])
const planList = 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 dateRange = ref([])
const data = reactive({
form: {},
queryParams: {
pageNum: 1,
pageSize: 10,
planId: null,
personId: null,
status: null
},
rules: {
planId: [{ required: true, message: '请选择计划', trigger: 'change' }],
actualTime: [{ required: true, message: '请选择服药时间', trigger: 'change' }]
}
})
const { queryParams, form, rules } = toRefs(data)
/** 查询用药记录列表 */
function getList() {
loading.value = true
const params = { ...queryParams.value }
if (dateRange.value && dateRange.value.length === 2) {
params.scheduledTimeBegin = dateRange.value[0] + ' 00:00:00'
params.scheduledTimeEnd = dateRange.value[1] + ' 23:59:59'
}
listMedicationRecord(params).then((response) => {
recordList.value = response.rows
total.value = response.total
loading.value = false
})
}
/** 查询人员列表 */
function getPersonList() {
listPerson({ pageNum: 1, pageSize: 100 }).then((response) => {
personList.value = response.rows || []
})
}
/** 查询计划列表 */
function getPlanList() {
listMedicationPlan({ pageNum: 1, pageSize: 100 }).then((response) => {
planList.value = response.rows || []
})
}
// 取消按钮
function cancel() {
open.value = false
reset()
}
// 表单重置
function reset() {
form.value = {
id: null,
planId: null,
personId: null,
medicineId: null,
scheduledTime: null,
actualTime: null,
dosage: null,
dosageUnit: '片',
status: '2',
remark: null
}
proxy.resetForm('recordRef')
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
function resetQuery() {
proxy.resetForm('queryRef')
dateRange.value = []
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 formatDateTime(datetime) {
if (!datetime) return ''
return datetime.substring(0, 16)
}
/** 新增按钮操作 */
function handleAdd() {
reset()
open.value = true
}
/** 修改按钮操作 */
function handleUpdate(row) {
reset()
getMedicationRecord(row.id).then((response) => {
form.value = response.data
open.value = true
})
}
/** 计划选择变化 */
function handlePlanChange(planId) {
const plan = planList.value.find(p => p.id === planId)
if (plan) {
form.value.personId = plan.personId
form.value.medicineId = plan.medicineId
form.value.dosage = plan.dosage
form.value.dosageUnit = plan.dosageUnit
}
}
/** 服药按钮操作 */
function handleTake(row) {
proxy.$modal.confirm('确认已服用该药物?').then(() => {
return takeMedication(row.id, row.dosage, null)
}).then(() => {
getList()
proxy.$modal.msgSuccess('已记录服药')
}).catch(() => {})
}
/** 跳过按钮操作 */
function handleSkip(row) {
proxy.$prompt('请输入跳过原因(可选)', '跳过服药', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPlaceholder: '如:忘记服药、药物不足等'
}).then(({ value }) => {
return skipMedication(row.id, value)
}).then(() => {
getList()
proxy.$modal.msgSuccess('已跳过')
}).catch(() => {})
}
/** 提交按钮 */
function submitForm() {
proxy.$refs.recordRef.validate((valid) => {
if (valid) {
form.value.status = '2' // 已服用
form.value.scheduledTime = form.value.actualTime
if (form.value.id != null) {
updateMedicationRecord(form.value).then(() => {
proxy.$modal.msgSuccess('修改成功')
open.value = false
getList()
})
} else {
addMedicationRecord(form.value).then(() => {
proxy.$modal.msgSuccess('记录成功')
open.value = false
getList()
})
}
}
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _ids = row.id || ids.value
proxy.$modal.confirm('是否确认删除选中的数据项?').then(function () {
return delMedicationRecord(_ids)
}).then(() => {
getList()
proxy.$modal.msgSuccess('删除成功')
}).catch(() => {})
}
getPersonList()
getPlanList()
getList()
</script>

View File

@@ -0,0 +1,255 @@
<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="memberName" 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" width="180">
<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="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 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 = async (row) => {
await proxy.$modal.confirm('确认已服药?')
await confirmMedication(row.id, 1)
proxy.$modal.msgSuccess('操作成功')
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 '--'
return date.substring(0, 10)
}
const formatTime = (time) => {
if (!time) return '--'
return time.substring(0, 5)
}
const formatDateTime = (datetime) => {
if (!datetime) return '--'
return datetime.replace('T', ' ').substring(0, 16)
}
onMounted(() => {
getList()
getPlanList()
getMemberList()
})
</script>
<style scoped lang="scss">
</style>