feat(health): 新增用药计划模块H5/小程序页面
- 新增用药计划和用药记录API接口 - 新增用药计划列表/详情/新增编辑页面 - 新增用药记录列表页面(含今日待服药快捷卡片) - 支持服药/跳过操作 - 更新pages.json路由配置
This commit is contained in:
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'
|
||||||
|
})
|
||||||
|
}
|
||||||
79
src/api/health/medicationRecord.js
Normal file
79
src/api/health/medicationRecord.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
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 }
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -266,6 +266,30 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "吃奶量统计"
|
"navigationBarTitleText": "吃奶量统计"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/health/medicationPlan/list",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "用药计划"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/health/medicationPlan/details",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "用药计划详情"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/health/medicationPlan/addEdit",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "用药计划"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/health/medicationRecord/index",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "用药记录"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"subPackages": [
|
"subPackages": [
|
||||||
|
|||||||
456
src/pages/health/medicationPlan/addEdit.vue
Normal file
456
src/pages/health/medicationPlan/addEdit.vue
Normal file
@@ -0,0 +1,456 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container" style="paddingBottom: 120rpx;">
|
||||||
|
<view class="section">
|
||||||
|
<view class="section-title">{{ title }}</view>
|
||||||
|
<view class="form-view">
|
||||||
|
<u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" label-width="180rpx"
|
||||||
|
:labelStyle="{ color: '#333333', fontSize: '30rpx', marginRight: '24rpx' }">
|
||||||
|
|
||||||
|
<u-form-item label="计划名称" prop="planName">
|
||||||
|
<u--input v-model="form.planName" placeholder="请填写计划名称(可选)" inputAlign="left"
|
||||||
|
:customStyle="inputBaseStyle"></u--input>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="人员" prop="personName" required @click="handlePerson">
|
||||||
|
<view class="input-with-arrow">
|
||||||
|
<u--input v-model="form.personName" disabled disabledColor="#ffffff" placeholder="请选择人员"
|
||||||
|
inputAlign="left" :customStyle="inputBaseStyle"></u--input>
|
||||||
|
<text class="arrow-icon">▼</text>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="药品" prop="medicineName" required @click="handleMedicine">
|
||||||
|
<view class="input-with-arrow">
|
||||||
|
<u--input v-model="form.medicineName" disabled disabledColor="#ffffff" placeholder="请选择药品"
|
||||||
|
inputAlign="left" :customStyle="inputBaseStyle"></u--input>
|
||||||
|
<text class="arrow-icon">▼</text>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="每次剂量" prop="dosage" required>
|
||||||
|
<view class="dosage-input">
|
||||||
|
<u--input v-model="form.dosage" type="digit" placeholder="剂量" inputAlign="left"
|
||||||
|
:customStyle="inputBaseStyle" style="flex: 1"></u--input>
|
||||||
|
<u--input v-model="form.dosageUnit" disabled disabledColor="#ffffff" placeholder="单位"
|
||||||
|
inputAlign="left" :customStyle="inputBaseStyle" style="width: 160rpx; margin-left: 16rpx"></u--input>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="每日次数" prop="frequency" required>
|
||||||
|
<view class="stepper">
|
||||||
|
<view class="stepper-btn" @click="decreaseFrequency">-</view>
|
||||||
|
<text class="stepper-value">{{ form.frequency }}</text>
|
||||||
|
<view class="stepper-btn" @click="increaseFrequency">+</view>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="频率类型" prop="frequencyTypeName" @click="handleFrequencyType">
|
||||||
|
<view class="input-with-arrow">
|
||||||
|
<u--input v-model="form.frequencyTypeName" disabled disabledColor="#ffffff" placeholder="请选择频率类型"
|
||||||
|
inputAlign="left" :customStyle="inputBaseStyle"></u--input>
|
||||||
|
<text class="arrow-icon">▼</text>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="服药时间点" prop="timePointsText">
|
||||||
|
<view class="time-points-box">
|
||||||
|
<view v-for="(time, idx) in form.timePointList" :key="idx" class="time-tag">
|
||||||
|
<text>{{ time }}</text>
|
||||||
|
<uni-icons type="closeempty" size="14" color="#909399" @click="removeTimePoint(idx)"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="time-add" @click="showTimePicker = true">
|
||||||
|
<uni-icons type="plusempty" size="16" color="#667eea"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="开始日期" prop="startDate" required @click="showStartDate = true">
|
||||||
|
<view class="input-with-arrow">
|
||||||
|
<u--input v-model="form.startDate" disabled disabledColor="#ffffff" placeholder="请选择开始日期"
|
||||||
|
inputAlign="left" :customStyle="inputBaseStyle"></u--input>
|
||||||
|
<text class="arrow-icon">▼</text>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="结束日期" prop="endDate" @click="showEndDate = true">
|
||||||
|
<view class="input-with-arrow">
|
||||||
|
<u--input v-model="form.endDate" disabled disabledColor="#ffffff" placeholder="可选,不填则长期"
|
||||||
|
inputAlign="left" :customStyle="inputBaseStyle"></u--input>
|
||||||
|
<text class="arrow-icon">▼</text>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="启用提醒">
|
||||||
|
<u-switch v-model="form.reminderEnabled" activeValue="1" inactiveValue="0"
|
||||||
|
activeColor="#667eea" inactiveColor="#dcdfe6"></u-switch>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="提前提醒" v-if="form.reminderEnabled === '1'">
|
||||||
|
<view class="stepper">
|
||||||
|
<view class="stepper-btn" @click="form.reminderMinutes = Math.max(0, form.reminderMinutes - 5)">-</view>
|
||||||
|
<text class="stepper-value">{{ form.reminderMinutes }}分钟</text>
|
||||||
|
<view class="stepper-btn" @click="form.reminderMinutes += 5">+</view>
|
||||||
|
</view>
|
||||||
|
</u-form-item>
|
||||||
|
|
||||||
|
<u-form-item label="备注" prop="remark" labelPosition="top">
|
||||||
|
<u--textarea v-model="form.remark" placeholder="请填写备注" inputAlign="left"
|
||||||
|
style="border: 2rpx solid #dcdfe6 !important; height: 160rpx;"></u--textarea>
|
||||||
|
</u-form-item>
|
||||||
|
</u--form>
|
||||||
|
|
||||||
|
<view class="form-btn">
|
||||||
|
<u-button type="primary" text="提交" @click="submit"></u-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<u-toast ref="uToast"></u-toast>
|
||||||
|
|
||||||
|
<!-- 选择器 -->
|
||||||
|
<u-picker :show="showPersonPicker" :columns="personPickerList" keyName="name" @cancel="showPersonPicker = false"
|
||||||
|
@confirm="onPersonConfirm"></u-picker>
|
||||||
|
<u-picker :show="showMedicinePicker" :columns="medicinePickerList" keyName="shortNameBrand" @cancel="showMedicinePicker = false"
|
||||||
|
@confirm="onMedicineConfirm"></u-picker>
|
||||||
|
<u-picker :show="showFrequencyTypePicker" :columns="frequencyTypeList" keyName="label" @cancel="showFrequencyTypePicker = false"
|
||||||
|
@confirm="onFrequencyTypeConfirm"></u-picker>
|
||||||
|
<u-datetime-picker :show="showStartDate" mode="date" @cancel="showStartDate = false"
|
||||||
|
@confirm="onStartDateConfirm" :maxDate="maxDate"></u-datetime-picker>
|
||||||
|
<u-datetime-picker :show="showEndDate" mode="date" @cancel="showEndDate = false"
|
||||||
|
@confirm="onEndDateConfirm"></u-datetime-picker>
|
||||||
|
<u-datetime-picker :show="showTimePicker" mode="time" @cancel="showTimePicker = false"
|
||||||
|
@confirm="onTimeConfirm"></u-datetime-picker>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { getMedicationPlan, addMedicationPlan, updateMedicationPlan } from '@/api/health/medicationPlan'
|
||||||
|
import { listMedicineBasic } from '@/api/health/medicineBasic'
|
||||||
|
import { listPerson } from '@/api/health/person'
|
||||||
|
import { onLoad, onReady } from "@dcloudio/uni-app"
|
||||||
|
import { reactive, toRefs, ref, computed, getCurrentInstance } from "vue"
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance()
|
||||||
|
const title = ref("新增用药计划")
|
||||||
|
const planId = ref(null)
|
||||||
|
const copyFlag = ref(false)
|
||||||
|
|
||||||
|
const inputBaseStyle = {
|
||||||
|
background: '#ffffff',
|
||||||
|
border: '2rpx solid #dcdfe6',
|
||||||
|
borderRadius: '8rpx',
|
||||||
|
padding: '0 24rpx',
|
||||||
|
height: '68rpx',
|
||||||
|
width: '100%',
|
||||||
|
boxSizing: 'border-box'
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {
|
||||||
|
id: null,
|
||||||
|
personId: null,
|
||||||
|
personName: null,
|
||||||
|
medicineId: null,
|
||||||
|
medicineName: null,
|
||||||
|
dosage: 1,
|
||||||
|
dosageUnit: '片',
|
||||||
|
frequency: 3,
|
||||||
|
frequencyType: '1',
|
||||||
|
frequencyTypeName: '每日',
|
||||||
|
timePointList: ['08:00', '12:00', '18:00'],
|
||||||
|
startDate: null,
|
||||||
|
endDate: null,
|
||||||
|
reminderEnabled: '0',
|
||||||
|
reminderMinutes: 15,
|
||||||
|
remark: null
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
personName: [{ required: true, message: '请选择人员', trigger: 'change' }],
|
||||||
|
medicineName: [{ required: true, message: '请选择药品', trigger: 'change' }],
|
||||||
|
dosage: [{ required: true, message: '请输入剂量', trigger: 'blur' }],
|
||||||
|
frequency: [{ required: true, message: '请设置每日次数', trigger: 'change' }],
|
||||||
|
startDate: [{ required: true, message: '请选择开始日期', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const { form, rules } = toRefs(data)
|
||||||
|
|
||||||
|
// 选择器相关
|
||||||
|
const showPersonPicker = ref(false)
|
||||||
|
const showMedicinePicker = ref(false)
|
||||||
|
const showFrequencyTypePicker = ref(false)
|
||||||
|
const showStartDate = ref(false)
|
||||||
|
const showEndDate = ref(false)
|
||||||
|
const showTimePicker = ref(false)
|
||||||
|
|
||||||
|
const personList = ref([])
|
||||||
|
const medicineList = ref([])
|
||||||
|
const frequencyTypeList = ref([
|
||||||
|
[{ value: '1', label: '每日' }],
|
||||||
|
[{ value: '2', label: '隔日' }],
|
||||||
|
[{ value: '3', label: '每周' }],
|
||||||
|
[{ value: '4', label: '自定义' }]
|
||||||
|
])
|
||||||
|
|
||||||
|
const maxDate = ref(Date.now() + 365 * 24 * 60 * 60 * 1000)
|
||||||
|
|
||||||
|
const personPickerList = computed(() => [personList.value])
|
||||||
|
const medicinePickerList = computed(() => [medicineList.value])
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
if (options.id) {
|
||||||
|
planId.value = options.id
|
||||||
|
if (options.flag === 'copy') {
|
||||||
|
copyFlag.value = true
|
||||||
|
title.value = "复制用药计划"
|
||||||
|
} else {
|
||||||
|
title.value = "编辑用药计划"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getPersonList()
|
||||||
|
getMedicineList()
|
||||||
|
})
|
||||||
|
|
||||||
|
onReady(() => {
|
||||||
|
if (planId.value) {
|
||||||
|
getDetail()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function getPersonList() {
|
||||||
|
listPerson({ pageNum: 1, pageSize: 100 }).then(res => {
|
||||||
|
personList.value = res.rows || []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMedicineList() {
|
||||||
|
listMedicineBasic({ pageNum: 1, pageSize: 1000 }).then(res => {
|
||||||
|
medicineList.value = (res.rows || []).map(item => ({
|
||||||
|
...item,
|
||||||
|
shortNameBrand: `${item.shortName}-${item.brand}`
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDetail() {
|
||||||
|
getMedicationPlan(planId.value).then(res => {
|
||||||
|
form.value = {
|
||||||
|
...res.data,
|
||||||
|
personName: res.data.personName,
|
||||||
|
medicineName: res.data.shortName ? `${res.data.shortName}-${res.data.brand}` : null,
|
||||||
|
frequencyTypeName: getFrequencyTypeName(res.data.frequencyType),
|
||||||
|
timePointList: res.data.timePoints ? JSON.parse(res.data.timePoints) : [],
|
||||||
|
startDate: res.data.startDate ? res.data.startDate.substring(0, 10) : null,
|
||||||
|
endDate: res.data.endDate ? res.data.endDate.substring(0, 10) : null
|
||||||
|
}
|
||||||
|
if (copyFlag.value) {
|
||||||
|
form.value.id = null
|
||||||
|
title.value = "复制用药计划"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFrequencyTypeName(type) {
|
||||||
|
const map = { '1': '每日', '2': '隔日', '3': '每周', '4': '自定义' }
|
||||||
|
return map[type] || '每日'
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePerson() { showPersonPicker.value = true }
|
||||||
|
function handleMedicine() { showMedicinePicker.value = true }
|
||||||
|
function handleFrequencyType() { showFrequencyTypePicker.value = true }
|
||||||
|
|
||||||
|
function onPersonConfirm(e) {
|
||||||
|
const selected = e.value[0]
|
||||||
|
form.value.personId = selected.id
|
||||||
|
form.value.personName = selected.name
|
||||||
|
showPersonPicker.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMedicineConfirm(e) {
|
||||||
|
const selected = e.value[0]
|
||||||
|
form.value.medicineId = selected.id
|
||||||
|
form.value.medicineName = selected.shortNameBrand
|
||||||
|
form.value.dosageUnit = selected.unit || '片'
|
||||||
|
showMedicinePicker.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFrequencyTypeConfirm(e) {
|
||||||
|
const selected = e.value[0]
|
||||||
|
form.value.frequencyType = selected.value
|
||||||
|
form.value.frequencyTypeName = selected.label
|
||||||
|
showFrequencyTypePicker.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function onStartDateConfirm(e) {
|
||||||
|
form.value.startDate = dayjs(e.value).format('YYYY-MM-DD')
|
||||||
|
showStartDate.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEndDateConfirm(e) {
|
||||||
|
form.value.endDate = dayjs(e.value).format('YYYY-MM-DD')
|
||||||
|
showEndDate.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function onTimeConfirm(e) {
|
||||||
|
const time = dayjs(e.value).format('HH:mm')
|
||||||
|
if (!form.value.timePointList.includes(time)) {
|
||||||
|
form.value.timePointList.push(time)
|
||||||
|
form.value.timePointList.sort()
|
||||||
|
}
|
||||||
|
showTimePicker.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeTimePoint(idx) {
|
||||||
|
form.value.timePointList.splice(idx, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
function decreaseFrequency() {
|
||||||
|
if (form.value.frequency > 1) form.value.frequency--
|
||||||
|
}
|
||||||
|
|
||||||
|
function increaseFrequency() {
|
||||||
|
if (form.value.frequency < 10) form.value.frequency++
|
||||||
|
}
|
||||||
|
|
||||||
|
function submit() {
|
||||||
|
proxy.$refs.uForm.validate().then(() => {
|
||||||
|
const data = {
|
||||||
|
...form.value,
|
||||||
|
timePoints: JSON.stringify(form.value.timePointList)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.value.id && !copyFlag.value) {
|
||||||
|
updateMedicationPlan(data).then(() => {
|
||||||
|
proxy.$refs.uToast.show({ message: '修改成功', type: 'success' })
|
||||||
|
setTimeout(() => uni.navigateBack(), 1000)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
addMedicationPlan(data).then(() => {
|
||||||
|
proxy.$refs.uToast.show({ message: '新增成功', type: 'success' })
|
||||||
|
setTimeout(() => uni.navigateBack(), 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
console.log('验证失败', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.container {
|
||||||
|
background: #f5f7fa;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
background: #fff;
|
||||||
|
margin: 24rpx;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
padding: 32rpx 24rpx 16rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 1rpx solid #f0f2f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-view {
|
||||||
|
padding: 24rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-with-arrow {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.arrow-icon {
|
||||||
|
position: absolute;
|
||||||
|
right: 24rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: #909399;
|
||||||
|
font-size: 24rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dosage-input {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stepper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.stepper-btn {
|
||||||
|
width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 36rpx;
|
||||||
|
color: #667eea;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
&:active { background: #e8edf3; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.stepper-value {
|
||||||
|
min-width: 120rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-points-box {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx;
|
||||||
|
|
||||||
|
.time-tag {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 12rpx 20rpx;
|
||||||
|
background: rgba(102, 126, 234, 0.1);
|
||||||
|
border-radius: 8rpx;
|
||||||
|
border: 1rpx solid rgba(102, 126, 234, 0.3);
|
||||||
|
|
||||||
|
text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #667eea;
|
||||||
|
margin-right: 8rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-add {
|
||||||
|
width: 64rpx;
|
||||||
|
height: 64rpx;
|
||||||
|
background: rgba(102, 126, 234, 0.08);
|
||||||
|
border: 2rpx dashed #667eea;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-btn {
|
||||||
|
margin-top: 40rpx;
|
||||||
|
padding: 24rpx;
|
||||||
|
|
||||||
|
:deep(.u-button) {
|
||||||
|
height: 88rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
357
src/pages/health/medicationPlan/details.vue
Normal file
357
src/pages/health/medicationPlan/details.vue
Normal file
@@ -0,0 +1,357 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<view class="detail-card">
|
||||||
|
<view class="card-header">
|
||||||
|
<view class="header-left">
|
||||||
|
<view class="icon-box">
|
||||||
|
<uni-icons type="calendar" size="24" color="#667eea"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="header-info">
|
||||||
|
<text class="plan-name">{{ detail.planName || '用药计划' }}</text>
|
||||||
|
<view class="status-tag" :class="getStatusClass(detail.status)">
|
||||||
|
{{ getStatusText(detail.status) }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="info-section">
|
||||||
|
<view class="section-title">基本信息</view>
|
||||||
|
<view class="info-grid">
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">人员</text>
|
||||||
|
<text class="value">{{ detail.personName || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">药品</text>
|
||||||
|
<text class="value">{{ detail.medicineDisplayName || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">每次剂量</text>
|
||||||
|
<text class="value">{{ detail.dosage }}{{ detail.dosageUnit }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">每日次数</text>
|
||||||
|
<text class="value">{{ detail.frequency }}次</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">频率类型</text>
|
||||||
|
<text class="value">{{ getFrequencyText(detail.frequencyType) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">开始日期</text>
|
||||||
|
<text class="value">{{ formatDate(detail.startDate) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">结束日期</text>
|
||||||
|
<text class="value">{{ detail.endDate ? formatDate(detail.endDate) : '长期' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="label">提醒</text>
|
||||||
|
<text class="value">{{ detail.reminderEnabled === '1' ? '开启 (提前' + detail.reminderMinutes + '分钟)' : '关闭' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="info-section" v-if="detail.status === '1'">
|
||||||
|
<view class="section-title">今日进度</view>
|
||||||
|
<view class="progress-box">
|
||||||
|
<view class="progress-bar">
|
||||||
|
<view class="progress-fill" :style="{ width: progressPercent + '%' }"></view>
|
||||||
|
</view>
|
||||||
|
<text class="progress-text">{{ detail.todayTakenCount || 0 }}/{{ detail.todayTotalCount || 0 }} 次</text>
|
||||||
|
</view>
|
||||||
|
<view class="time-points">
|
||||||
|
<view v-for="(time, idx) in timePointList" :key="idx" class="time-item"
|
||||||
|
:class="takenTimes.includes(idx) ? 'taken' : ''">
|
||||||
|
<text class="time">{{ time }}</text>
|
||||||
|
<text class="status">{{ takenTimes.includes(idx) ? '已服' : '待服' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="info-section" v-if="detail.remark">
|
||||||
|
<view class="section-title">备注</view>
|
||||||
|
<text class="remark-text">{{ detail.remark }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="action-btns">
|
||||||
|
<view class="btn-primary" v-if="detail.status === '1'" @click="handleTodayRecords">
|
||||||
|
<uni-icons type="checkmarkempty" size="18" color="#fff"></uni-icons>
|
||||||
|
<text>今日记录</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-default" v-show="auth.hasPermi('health:medicationPlan:edit')" @click="handleEdit">
|
||||||
|
<uni-icons type="compose" size="18" color="#667eea"></uni-icons>
|
||||||
|
<text>修改计划</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { getMedicationPlan } from '@/api/health/medicationPlan'
|
||||||
|
import { getRecordsByPlanAndDate } from '@/api/health/medicationRecord'
|
||||||
|
import { onLoad } from "@dcloudio/uni-app"
|
||||||
|
import auth from "@/plugins/auth"
|
||||||
|
import { ref, computed } from "vue"
|
||||||
|
|
||||||
|
const detail = ref({})
|
||||||
|
const timePointList = ref([])
|
||||||
|
const takenTimes = ref([])
|
||||||
|
|
||||||
|
onLoad((options) => {
|
||||||
|
if (options.id) {
|
||||||
|
getDetail(options.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function getDetail(id) {
|
||||||
|
getMedicationPlan(id).then(res => {
|
||||||
|
detail.value = res.data
|
||||||
|
if (res.data.timePoints) {
|
||||||
|
try {
|
||||||
|
timePointList.value = JSON.parse(res.data.timePoints)
|
||||||
|
} catch (e) {
|
||||||
|
timePointList.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 获取今日记录
|
||||||
|
if (res.data.status === '1') {
|
||||||
|
const today = new Date().toISOString().substring(0, 10)
|
||||||
|
getRecordsByPlanAndDate(id, today).then(records => {
|
||||||
|
// 标记已服用的时间点
|
||||||
|
takenTimes.value = (records.data || []).map((r, idx) => r.status === '2' ? idx : -1).filter(i => i >= 0)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const progressPercent = computed(() => {
|
||||||
|
if (!detail.value.todayTotalCount) return 0
|
||||||
|
return Math.round((detail.value.todayTakenCount || 0) / detail.value.todayTotalCount * 100)
|
||||||
|
})
|
||||||
|
|
||||||
|
function formatDate(date) {
|
||||||
|
if (!date) return '--'
|
||||||
|
return date.substring(0, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusClass(status) {
|
||||||
|
const map = { '1': 'status-active', '2': 'status-ended', '3': 'status-paused' }
|
||||||
|
return map[status] || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusText(status) {
|
||||||
|
const map = { '1': '进行中', '2': '已结束', '3': '已暂停' }
|
||||||
|
return map[status] || '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFrequencyText(type) {
|
||||||
|
const map = { '1': '每日', '2': '隔日', '3': '每周', '4': '自定义' }
|
||||||
|
return map[type] || '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTodayRecords() {
|
||||||
|
uni.navigateTo({ url: `/pages/health/medicationRecord/index?planId=${detail.value.id}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit() {
|
||||||
|
uni.navigateTo({ url: `/pages/health/medicationPlan/addEdit?id=${detail.value.id}` })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.container {
|
||||||
|
padding: 24rpx;
|
||||||
|
background: #f5f7fa;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
padding: 32rpx 24rpx;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
|
||||||
|
.header-left {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.icon-box {
|
||||||
|
width: 72rpx;
|
||||||
|
height: 72rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-right: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-info {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
.plan-name {
|
||||||
|
font-size: 36rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag {
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
padding: 6rpx 16rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
&.status-active { background: rgba(82, 196, 26, 0.3); }
|
||||||
|
&.status-ended { background: rgba(140, 140, 140, 0.3); }
|
||||||
|
&.status-paused { background: rgba(250, 173, 20, 0.3); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-section {
|
||||||
|
padding: 24rpx;
|
||||||
|
border-bottom: 1rpx solid #f0f2f5;
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
padding-left: 16rpx;
|
||||||
|
border-left: 6rpx solid #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.info-item {
|
||||||
|
width: 50%;
|
||||||
|
padding: 12rpx 0;
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #909399;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-top: 6rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.remark-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-box {
|
||||||
|
margin-bottom: 24rpx;
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
height: 16rpx;
|
||||||
|
background: #f0f2f5;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.progress-fill {
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
|
||||||
|
border-radius: 8rpx;
|
||||||
|
transition: width 0.3s ease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-text {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #666;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-points {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx;
|
||||||
|
|
||||||
|
.time-item {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 140rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
background: #f5f7fa;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
text-align: center;
|
||||||
|
border: 2rpx solid #e8edf3;
|
||||||
|
|
||||||
|
&.taken {
|
||||||
|
background: rgba(82, 196, 26, 0.1);
|
||||||
|
border-color: #52c41a;
|
||||||
|
|
||||||
|
.time, .status { color: #52c41a; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #909399;
|
||||||
|
margin-top: 6rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-btns {
|
||||||
|
margin-top: 32rpx;
|
||||||
|
display: flex;
|
||||||
|
gap: 20rpx;
|
||||||
|
|
||||||
|
.btn-primary, .btn-default {
|
||||||
|
flex: 1;
|
||||||
|
height: 88rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-default {
|
||||||
|
background: #fff;
|
||||||
|
border: 2rpx solid #667eea;
|
||||||
|
color: #667eea;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
359
src/pages/health/medicationPlan/list.vue
Normal file
359
src/pages/health/medicationPlan/list.vue
Normal file
@@ -0,0 +1,359 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<u-sticky offsetTop="0rpx" customNavHeight="0rpx">
|
||||||
|
<view class="search-view">
|
||||||
|
<u--input
|
||||||
|
v-model="queryParams.keys"
|
||||||
|
border="surround"
|
||||||
|
@click="searchBlur"
|
||||||
|
placeholder="搜索计划/药品名称"
|
||||||
|
placeholderStyle="color: #909399"
|
||||||
|
color="#333333"
|
||||||
|
customStyle="background: rgba(102, 126, 234, 0.08); border: 2rpx solid rgba(102, 126, 234, 0.3); border-radius: 24rpx; height: 66rpx"
|
||||||
|
class="search-input"
|
||||||
|
suffixIcon="search"
|
||||||
|
suffixIconStyle="color: #667eea">
|
||||||
|
</u--input>
|
||||||
|
<view class="filter-btn" @click="filterPanel = !filterPanel">
|
||||||
|
<uni-icons type="list" size="18" color="#667eea"></uni-icons>
|
||||||
|
<text>筛选</text>
|
||||||
|
</view>
|
||||||
|
<view class="add-btn" v-show="auth.hasPermi('health:medicationPlan:add')" @click="handleAdd()">
|
||||||
|
<uni-icons type="plusempty" size="18" color="#667eea"></uni-icons>
|
||||||
|
<text>新增</text>
|
||||||
|
</view>
|
||||||
|
<u-transition :show="filterPanel" mode="fade">
|
||||||
|
<view class="filter-panel" :style="{ height: `${windowHeight - 42}px` }">
|
||||||
|
<view class="filter-panel-content">
|
||||||
|
<view class="filter-title">人员</view>
|
||||||
|
<view class="state-list">
|
||||||
|
<view v-for="item in personList" :key="item.id" class="state-item"
|
||||||
|
:class="queryParams.personId === item.id ? 'active' : ''" @click="selectPerson(item)">{{ item.name }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="filter-title">状态</view>
|
||||||
|
<view class="state-list">
|
||||||
|
<view v-for="item in statusList" :key="item.value" class="state-item"
|
||||||
|
:class="queryParams.status === item.value ? 'active' : ''" @click="selectStatus(item)">{{ item.label }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="btn-box">
|
||||||
|
<view class="btn-reset" @click="resetQuery()">
|
||||||
|
<uni-icons type="reload" size="16" color="#909399"></uni-icons>
|
||||||
|
<text>重置</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-confirm" @click="searchSubmit()">
|
||||||
|
<uni-icons type="checkmarkempty" size="16" color="#ffffff"></uni-icons>
|
||||||
|
<text>确定</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-transition>
|
||||||
|
</view>
|
||||||
|
</u-sticky>
|
||||||
|
<u-list @scrolltolower="loadmore" :spaceHeight="116" lowerThreshold="100">
|
||||||
|
<u-list-item v-for="(item, index) in listData" :key="index">
|
||||||
|
<view class="list-item" @click="enterDetails(item)">
|
||||||
|
<view class="item-header">
|
||||||
|
<view class="card-name-section">
|
||||||
|
<view class="card-icon">
|
||||||
|
<uni-icons type="calendar" size="20" color="#ffffff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="card-info">
|
||||||
|
<text class="card-name">{{ item.planName || item.medicineDisplayName || '用药计划' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="status-tag" :class="getStatusClass(item.status)">
|
||||||
|
{{ getStatusText(item.status) }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="card-body">
|
||||||
|
<view class="info-row">
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">人员</text>
|
||||||
|
<text class="info-value">{{ item.personName || '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">药品</text>
|
||||||
|
<text class="info-value">{{ item.shortName }}-{{ item.brand }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">剂量</text>
|
||||||
|
<text class="info-value">{{ item.dosage }}{{ item.dosageUnit }} × {{ item.frequency }}次/日</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">今日进度</text>
|
||||||
|
<text class="info-value" v-if="item.status === '1'">{{ item.todayTakenCount || 0 }}/{{ item.todayTotalCount || 0 }}</text>
|
||||||
|
<text class="info-value" v-else>--</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">开始日期</text>
|
||||||
|
<text class="info-value">{{ formatDate(item.startDate) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">结束日期</text>
|
||||||
|
<text class="info-value">{{ item.endDate ? formatDate(item.endDate) : '长期' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="operate" @click.stop>
|
||||||
|
<view class="btn-take" v-if="item.status === '1'" @click="handleTodayRecords(item)">
|
||||||
|
<uni-icons type="checkmarkempty" size="16" color="#52c41a"></uni-icons>
|
||||||
|
<text>今日记录</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-pause" v-if="item.status === '1'" @click="handlePause(item)">
|
||||||
|
<uni-icons type="hand-up" size="16" color="#faad14"></uni-icons>
|
||||||
|
<text>暂停</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-resume" v-if="item.status === '3'" @click="handleResume(item)">
|
||||||
|
<uni-icons type="play-filled" size="16" color="#667eea"></uni-icons>
|
||||||
|
<text>恢复</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-end" v-if="item.status !== '2'" @click="handleEnd(item)">
|
||||||
|
<uni-icons type="flag" size="16" color="#f5222d"></uni-icons>
|
||||||
|
<text>结束</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-edit" v-show="auth.hasPermi('health:medicationPlan:edit')" @click="handleEdit(item)">
|
||||||
|
<uni-icons type="compose" size="16" color="#667eea"></uni-icons>
|
||||||
|
<text>修改</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-delete" v-show="auth.hasPermi('health:medicationPlan:remove')" @click="handleDelete(item)">
|
||||||
|
<uni-icons type="trash" size="16" color="#f5576c"></uni-icons>
|
||||||
|
<text>删除</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-list-item>
|
||||||
|
<u-loadmore :status="status" loadingIcon="semicircle" height="88" fontSize="32rpx" @loadmore="loadmore" />
|
||||||
|
</u-list>
|
||||||
|
<suspend></suspend>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { listMedicationPlan, delMedicationPlan, pauseMedicationPlan, resumeMedicationPlan, endMedicationPlan } from '@/api/health/medicationPlan'
|
||||||
|
import { listPerson } from '@/api/health/person'
|
||||||
|
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||||
|
import auth from "@/plugins/auth"
|
||||||
|
import { reactive, toRefs, ref, computed } from "vue"
|
||||||
|
|
||||||
|
const pageNum = ref(1)
|
||||||
|
const listData = ref([])
|
||||||
|
const isShow = ref(false)
|
||||||
|
const status = ref('loadmore')
|
||||||
|
const filterPanel = ref(false)
|
||||||
|
const personList = ref([])
|
||||||
|
const statusList = ref([
|
||||||
|
{ value: '', label: '全部' },
|
||||||
|
{ value: '1', label: '进行中' },
|
||||||
|
{ value: '2', label: '已结束' },
|
||||||
|
{ value: '3', label: '已暂停' }
|
||||||
|
])
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
queryParams: {
|
||||||
|
keys: null,
|
||||||
|
personId: null,
|
||||||
|
status: null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const { queryParams } = toRefs(data)
|
||||||
|
const windowHeight = computed(() => uni.getSystemInfoSync().windowHeight - 50)
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
getPersonList()
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (isShow.value) {
|
||||||
|
listData.value = []
|
||||||
|
pageNum.value = 1
|
||||||
|
getList()
|
||||||
|
isShow.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function getPersonList() {
|
||||||
|
listPerson({ pageNum: 1, pageSize: 100 }).then(res => {
|
||||||
|
personList.value = res.rows || []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadmore() {
|
||||||
|
pageNum.value += 1
|
||||||
|
if (status.value == 'loadmore') {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getList() {
|
||||||
|
status.value = 'loading'
|
||||||
|
listMedicationPlan({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
|
||||||
|
listData.value = listData.value.concat(res.rows)
|
||||||
|
if (listData.value.length < res.total) {
|
||||||
|
status.value = 'loadmore'
|
||||||
|
} else {
|
||||||
|
status.value = 'nomore'
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
status.value = 'nomore'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectPerson(item) {
|
||||||
|
queryParams.value.personId = item.id
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectStatus(item) {
|
||||||
|
queryParams.value.status = item.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchSubmit() {
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
filterPanel.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchBlur() {
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetQuery() {
|
||||||
|
queryParams.value.keys = ''
|
||||||
|
queryParams.value.personId = null
|
||||||
|
queryParams.value.status = null
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(date) {
|
||||||
|
if (!date) return '--'
|
||||||
|
return date.substring(0, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusClass(status) {
|
||||||
|
const map = { '1': 'status-active', '2': 'status-ended', '3': 'status-paused' }
|
||||||
|
return map[status] || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusText(status) {
|
||||||
|
const map = { '1': '进行中', '2': '已结束', '3': '已暂停' }
|
||||||
|
return map[status] || '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
function enterDetails(item) {
|
||||||
|
uni.navigateTo({ url: `/pages/health/medicationPlan/details?id=${item.id}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTodayRecords(item) {
|
||||||
|
uni.navigateTo({ url: `/pages/health/medicationRecord/index?planId=${item.id}` })
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEdit(item) {
|
||||||
|
uni.navigateTo({ url: `/pages/health/medicationPlan/addEdit?id=${item.id}` })
|
||||||
|
isShow.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleAdd() {
|
||||||
|
uni.navigateTo({ url: `/pages/health/medicationPlan/addEdit` })
|
||||||
|
isShow.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePause(item) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '确认暂停',
|
||||||
|
content: '确定暂停该用药计划?',
|
||||||
|
confirmText: '暂停',
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmColor: '#faad14',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
pauseMedicationPlan(item.id).then(() => {
|
||||||
|
uni.showToast({ title: '已暂停', icon: 'success' })
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResume(item) {
|
||||||
|
resumeMedicationPlan(item.id).then(() => {
|
||||||
|
uni.showToast({ title: '已恢复', icon: 'success' })
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEnd(item) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '确认结束',
|
||||||
|
content: '结束后将不再生成用药记录,确定结束?',
|
||||||
|
confirmText: '结束',
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmColor: '#f5222d',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
endMedicationPlan(item.id).then(() => {
|
||||||
|
uni.showToast({ title: '已结束', icon: 'success' })
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDelete(item) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '确认删除',
|
||||||
|
content: '确定要删除这条记录吗?',
|
||||||
|
confirmText: '删除',
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmColor: '#f5576c',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
delMedicationPlan(item.id).then(() => {
|
||||||
|
uni.showToast({ title: '删除成功', icon: 'success' })
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import '@/styles/health-common.scss';
|
||||||
|
|
||||||
|
.status-tag {
|
||||||
|
padding: 6rpx 16rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
&.status-active {
|
||||||
|
background: rgba(82, 196, 26, 0.15);
|
||||||
|
color: #52c41a;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-ended {
|
||||||
|
background: rgba(140, 140, 140, 0.15);
|
||||||
|
color: #8c8c8c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-paused {
|
||||||
|
background: rgba(250, 173, 20, 0.15);
|
||||||
|
color: #faad14;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
464
src/pages/health/medicationRecord/index.vue
Normal file
464
src/pages/health/medicationRecord/index.vue
Normal file
@@ -0,0 +1,464 @@
|
|||||||
|
<template>
|
||||||
|
<view class="container">
|
||||||
|
<u-sticky offsetTop="0rpx" customNavHeight="0rpx">
|
||||||
|
<view class="search-view">
|
||||||
|
<u--input
|
||||||
|
v-model="queryParams.keys"
|
||||||
|
border="surround"
|
||||||
|
@click="searchBlur"
|
||||||
|
placeholder="搜索药品名称"
|
||||||
|
placeholderStyle="color: #909399"
|
||||||
|
color="#333333"
|
||||||
|
customStyle="background: rgba(102, 126, 234, 0.08); border: 2rpx solid rgba(102, 126, 234, 0.3); border-radius: 24rpx; height: 66rpx"
|
||||||
|
class="search-input"
|
||||||
|
suffixIcon="search"
|
||||||
|
suffixIconStyle="color: #667eea">
|
||||||
|
</u--input>
|
||||||
|
<view class="filter-btn" @click="filterPanel = !filterPanel">
|
||||||
|
<uni-icons type="list" size="18" color="#667eea"></uni-icons>
|
||||||
|
<text>筛选</text>
|
||||||
|
</view>
|
||||||
|
<u-transition :show="filterPanel" mode="fade">
|
||||||
|
<view class="filter-panel" :style="{ height: `${windowHeight - 42}px` }">
|
||||||
|
<view class="filter-panel-content">
|
||||||
|
<view class="filter-title">人员</view>
|
||||||
|
<view class="state-list">
|
||||||
|
<view v-for="item in personList" :key="item.id" class="state-item"
|
||||||
|
:class="queryParams.personId === item.id ? 'active' : ''" @click="selectPerson(item)">{{ item.name }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="filter-title">状态</view>
|
||||||
|
<view class="state-list">
|
||||||
|
<view v-for="item in statusList" :key="item.value" class="state-item"
|
||||||
|
:class="queryParams.status === item.value ? 'active' : ''" @click="selectStatus(item)">{{ item.label }}</view>
|
||||||
|
</view>
|
||||||
|
<view class="filter-title">日期范围</view>
|
||||||
|
<view class="date-range">
|
||||||
|
<u-input v-model="startDateText" placeholder="开始日期" @click="showStartDate = true" readonly />
|
||||||
|
<text>至</text>
|
||||||
|
<u-input v-model="endDateText" placeholder="结束日期" @click="showEndDate = true" readonly />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="btn-box">
|
||||||
|
<view class="btn-reset" @click="resetQuery()">
|
||||||
|
<uni-icons type="reload" size="16" color="#909399"></uni-icons>
|
||||||
|
<text>重置</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-confirm" @click="searchSubmit()">
|
||||||
|
<uni-icons type="checkmarkempty" size="16" color="#ffffff"></uni-icons>
|
||||||
|
<text>确定</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-transition>
|
||||||
|
</view>
|
||||||
|
</u-sticky>
|
||||||
|
|
||||||
|
<!-- 今日待服药快捷卡片 -->
|
||||||
|
<view class="today-card" v-if="todayRecords.length > 0">
|
||||||
|
<view class="today-header">
|
||||||
|
<text class="today-title">今日待服药</text>
|
||||||
|
<text class="today-count">{{ todayRecords.filter(r => r.status === '1').length }}项</text>
|
||||||
|
</view>
|
||||||
|
<scroll-view scroll-x class="today-scroll">
|
||||||
|
<view v-for="(item, idx) in todayRecords.filter(r => r.status === '1')" :key="idx" class="today-item" @click="handleTake(item)">
|
||||||
|
<view class="medicine-info">
|
||||||
|
<text class="medicine-name">{{ item.shortName }}</text>
|
||||||
|
<text class="dosage">{{ item.dosage }}{{ item.dosageUnit }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="time-info">
|
||||||
|
<text class="time">{{ formatTime(item.scheduledTime) }}</text>
|
||||||
|
<view class="take-btn">点击服药</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<u-list @scrolltolower="loadmore" :spaceHeight="todayRecords.length > 0 ? 280 : 116" lowerThreshold="100">
|
||||||
|
<u-list-item v-for="(item, index) in listData" :key="index">
|
||||||
|
<view class="list-item">
|
||||||
|
<view class="item-header">
|
||||||
|
<view class="card-name-section">
|
||||||
|
<view class="card-icon" :class="getStatusClass(item.status)">
|
||||||
|
<uni-icons :type="getStatusIcon(item.status)" size="20" color="#ffffff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<view class="card-info">
|
||||||
|
<text class="card-name">{{ item.shortName }}-{{ item.brand }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="status-tag" :class="getStatusClass(item.status)">
|
||||||
|
{{ getStatusText(item.status) }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="card-body">
|
||||||
|
<view class="info-row">
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">计划时间</text>
|
||||||
|
<text class="info-value">{{ formatDateTime(item.scheduledTime) }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">实际时间</text>
|
||||||
|
<text class="info-value">{{ item.actualTime ? formatDateTime(item.actualTime) : '--' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">剂量</text>
|
||||||
|
<text class="info-value">{{ item.dosage }}{{ item.dosageUnit }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="info-label">人员</text>
|
||||||
|
<text class="info-value">{{ item.personName }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="operate" v-if="item.status === '1'" @click.stop>
|
||||||
|
<view class="btn-take" @click="handleTake(item)">
|
||||||
|
<uni-icons type="checkmarkempty" size="16" color="#52c41a"></uni-icons>
|
||||||
|
<text>服药</text>
|
||||||
|
</view>
|
||||||
|
<view class="btn-skip" @click="handleSkip(item)">
|
||||||
|
<uni-icons type="closeempty" size="16" color="#faad14"></uni-icons>
|
||||||
|
<text>跳过</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-list-item>
|
||||||
|
<u-loadmore :status="status" loadingIcon="semicircle" height="88" fontSize="32rpx" @loadmore="loadmore" />
|
||||||
|
</u-list>
|
||||||
|
|
||||||
|
<!-- 日期选择器 -->
|
||||||
|
<u-datetime-picker :show="showStartDate" mode="date" @cancel="showStartDate = false"
|
||||||
|
@confirm="onStartDateConfirm"></u-datetime-picker>
|
||||||
|
<u-datetime-picker :show="showEndDate" mode="date" @cancel="showEndDate = false"
|
||||||
|
@confirm="onEndDateConfirm"></u-datetime-picker>
|
||||||
|
|
||||||
|
<suspend></suspend>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { listMedicationRecord, getTodayRecords, takeMedication, skipMedication } from '@/api/health/medicationRecord'
|
||||||
|
import { listPerson } from '@/api/health/person'
|
||||||
|
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||||
|
import auth from "@/plugins/auth"
|
||||||
|
import { reactive, toRefs, ref, computed } from "vue"
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
|
const pageNum = ref(1)
|
||||||
|
const listData = ref([])
|
||||||
|
const todayRecords = ref([])
|
||||||
|
const isShow = ref(false)
|
||||||
|
const status = ref('loadmore')
|
||||||
|
const filterPanel = ref(false)
|
||||||
|
const personList = ref([])
|
||||||
|
const showStartDate = ref(false)
|
||||||
|
const showEndDate = ref(false)
|
||||||
|
|
||||||
|
const statusList = ref([
|
||||||
|
{ value: '', label: '全部' },
|
||||||
|
{ value: '1', label: '待服用' },
|
||||||
|
{ value: '2', label: '已服用' },
|
||||||
|
{ value: '3', label: '已跳过' },
|
||||||
|
{ value: '4', label: '已过期' }
|
||||||
|
])
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
queryParams: {
|
||||||
|
keys: null,
|
||||||
|
personId: null,
|
||||||
|
status: null,
|
||||||
|
scheduledTimeBegin: null,
|
||||||
|
scheduledTimeEnd: null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const { queryParams } = toRefs(data)
|
||||||
|
const windowHeight = computed(() => uni.getSystemInfoSync().windowHeight - 50)
|
||||||
|
|
||||||
|
const startDateText = computed(() => queryParams.value.scheduledTimeBegin ? queryParams.value.scheduledTimeBegin.substring(0, 10) : '')
|
||||||
|
const endDateText = computed(() => queryParams.value.scheduledTimeEnd ? queryParams.value.scheduledTimeEnd.substring(0, 10) : '')
|
||||||
|
|
||||||
|
onLoad(() => {
|
||||||
|
getPersonList()
|
||||||
|
getList()
|
||||||
|
getToday()
|
||||||
|
})
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
if (isShow.value) {
|
||||||
|
listData.value = []
|
||||||
|
pageNum.value = 1
|
||||||
|
getList()
|
||||||
|
getToday()
|
||||||
|
isShow.value = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function getPersonList() {
|
||||||
|
listPerson({ pageNum: 1, pageSize: 100 }).then(res => {
|
||||||
|
personList.value = res.rows || []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getToday() {
|
||||||
|
getTodayRecords().then(res => {
|
||||||
|
todayRecords.value = res.data || []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadmore() {
|
||||||
|
pageNum.value += 1
|
||||||
|
if (status.value == 'loadmore') {
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getList() {
|
||||||
|
status.value = 'loading'
|
||||||
|
listMedicationRecord({ pageSize: 10, pageNum: pageNum.value, ...queryParams.value }).then(res => {
|
||||||
|
listData.value = listData.value.concat(res.rows)
|
||||||
|
if (listData.value.length < res.total) {
|
||||||
|
status.value = 'loadmore'
|
||||||
|
} else {
|
||||||
|
status.value = 'nomore'
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
status.value = 'nomore'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectPerson(item) {
|
||||||
|
queryParams.value.personId = item.id
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectStatus(item) {
|
||||||
|
queryParams.value.status = item.value
|
||||||
|
}
|
||||||
|
|
||||||
|
function onStartDateConfirm(e) {
|
||||||
|
queryParams.value.scheduledTimeBegin = dayjs(e.value).format('YYYY-MM-DD') + ' 00:00:00'
|
||||||
|
showStartDate.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEndDateConfirm(e) {
|
||||||
|
queryParams.value.scheduledTimeEnd = dayjs(e.value).format('YYYY-MM-DD') + ' 23:59:59'
|
||||||
|
showEndDate.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchSubmit() {
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
filterPanel.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchBlur() {
|
||||||
|
pageNum.value = 1
|
||||||
|
listData.value = []
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetQuery() {
|
||||||
|
queryParams.value.keys = ''
|
||||||
|
queryParams.value.personId = null
|
||||||
|
queryParams.value.status = null
|
||||||
|
queryParams.value.scheduledTimeBegin = null
|
||||||
|
queryParams.value.scheduledTimeEnd = null
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateTime(datetime) {
|
||||||
|
if (!datetime) return '--'
|
||||||
|
return datetime.substring(0, 16)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTime(datetime) {
|
||||||
|
if (!datetime) return '--'
|
||||||
|
return datetime.substring(11, 16)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusClass(status) {
|
||||||
|
const map = { '1': 'status-pending', '2': 'status-taken', '3': 'status-skipped', '4': 'status-expired' }
|
||||||
|
return map[status] || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusText(status) {
|
||||||
|
const map = { '1': '待服用', '2': '已服用', '3': '已跳过', '4': '已过期' }
|
||||||
|
return map[status] || '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStatusIcon(status) {
|
||||||
|
const map = { '1': 'clock', '2': 'checkmarkempty', '3': 'closeempty', '4': 'info' }
|
||||||
|
return map[status] || 'clock'
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTake(item) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '确认服药',
|
||||||
|
content: `确认已服用 ${item.shortName} ${item.dosage}${item.dosageUnit}?`,
|
||||||
|
confirmText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
takeMedication(item.id, item.dosage, null).then(() => {
|
||||||
|
uni.showToast({ title: '已记录', icon: 'success' })
|
||||||
|
listData.value = []
|
||||||
|
pageNum.value = 1
|
||||||
|
getList()
|
||||||
|
getToday()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSkip(item) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '跳过服药',
|
||||||
|
content: '确定跳过本次服药?',
|
||||||
|
confirmText: '跳过',
|
||||||
|
confirmColor: '#faad14',
|
||||||
|
cancelText: '取消',
|
||||||
|
success: function (res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
skipMedication(item.id, '用户主动跳过').then(() => {
|
||||||
|
uni.showToast({ title: '已跳过', icon: 'none' })
|
||||||
|
listData.value = []
|
||||||
|
pageNum.value = 1
|
||||||
|
getList()
|
||||||
|
getToday()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import '@/styles/health-common.scss';
|
||||||
|
|
||||||
|
.today-card {
|
||||||
|
margin: 24rpx;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 16rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.today-header {
|
||||||
|
padding: 24rpx;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.today-title {
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.today-count {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.today-scroll {
|
||||||
|
white-space: nowrap;
|
||||||
|
padding: 0 24rpx 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.today-item {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 200rpx;
|
||||||
|
padding: 20rpx;
|
||||||
|
margin-right: 16rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
border-radius: 12rpx;
|
||||||
|
|
||||||
|
.medicine-info {
|
||||||
|
.medicine-name {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #fff;
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dosage {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
margin-top: 4rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-info {
|
||||||
|
margin-top: 12rpx;
|
||||||
|
|
||||||
|
.time {
|
||||||
|
font-size: 32rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.take-btn {
|
||||||
|
margin-top: 8rpx;
|
||||||
|
padding: 8rpx 16rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.25);
|
||||||
|
border-radius: 20rpx;
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #fff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-tag {
|
||||||
|
padding: 6rpx 16rpx;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
|
||||||
|
&.status-pending {
|
||||||
|
background: rgba(250, 173, 20, 0.15);
|
||||||
|
color: #faad14;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-taken {
|
||||||
|
background: rgba(82, 196, 26, 0.15);
|
||||||
|
color: #52c41a;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-skipped {
|
||||||
|
background: rgba(140, 140, 140, 0.15);
|
||||||
|
color: #8c8c8c;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.status-expired {
|
||||||
|
background: rgba(245, 34, 45, 0.15);
|
||||||
|
color: #f5222d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-icon {
|
||||||
|
&.status-pending { background: #faad14; }
|
||||||
|
&.status-taken { background: #52c41a; }
|
||||||
|
&.status-skipped { background: #8c8c8c; }
|
||||||
|
&.status-expired { background: #f5222d; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
|
||||||
|
:deep(.u-input) {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
text {
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user