fix: 智聪健康,吃奶记录、吃奶量统计功能新增。

This commit is contained in:
tianyongbao
2025-02-05 17:53:24 +08:00
parent 5845121c7e
commit d64a099506
7 changed files with 1293 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询吃奶记录列表
export function listMilkPowderRecord(query) {
return request({
url: '/health/milkPowderRecord/list',
method: 'get',
params: query
})
}
// 查询吃奶记录详细
export function getMilkPowderRecord(id) {
return request({
url: '/health/milkPowderRecord/' + id,
method: 'get'
})
}
// 新增吃奶记录
export function addMilkPowderRecord(data) {
return request({
url: '/health/milkPowderRecord',
method: 'post',
data
})
}
// 修改吃奶记录
export function updateMilkPowderRecord(data) {
return request({
url: '/health/milkPowderRecord',
method: 'put',
data
})
}
// 删除吃奶记录
export function delMilkPowderRecord(id) {
return request({
url: '/health/milkPowderRecord/' + id,
method: 'delete'
})
}

View File

@@ -41,3 +41,10 @@ export function getDoctorAnalysis(query) {
})
}
export function getMilkPowderAnalysis(query) {
return request({
url: '/health/analysis/milkPowderAnalysis',
method: 'get',
params: query
})
}

View File

@@ -177,11 +177,24 @@
}
,
{
"path": "pages/health/heightWeightRecord/addEdit",
"path": "pages/health/milkPowderRecord/addEdit",
"style": {
"navigationBarTitleText": "身高体重记录"
"navigationBarTitleText": "吃奶记录"
}
},
{
"path": "pages/health/milkPowderRecord/list",
"style": {
"navigationBarTitleText": "吃奶记录"
}
}
,
{
"path": "pages/health/heightWeightRecord/addEdit",
"style": {
"navigationBarTitleText": "身高体重记录"
}
},
{
"path": "pages/health/person/list",
"style": {
@@ -231,6 +244,12 @@
"style": {
"navigationBarTitleText": "体温统计"
}
} ,
{
"path": "pages/health/statistic/milkPowderStatistic/index",
"style": {
"navigationBarTitleText": "吃奶量统计"
}
}
],
"subPackages": [

View File

@@ -15,6 +15,19 @@
</uni-grid>
</view>
<!-- 宫格组件 -->
<uni-section title="婴幼儿管理" v-show="auth.hasPermi('health:milkPowderRecord:list')" type="line"></uni-section>
<view class="grid-body">
<uni-grid :column="4" :showBorder="false">
<uni-grid-item v-for="(item, index) in babycareGridList" :key="index" v-show="auth.hasPermi(item.permission)" @click="navigateTo(item.path)">
<view class="grid-item-box">
<uni-icons :type="item.icon" size="30"></uni-icons>
<text class="text">{{ item.text }}</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
@@ -39,6 +52,11 @@ import auth from "@/plugins/auth"; // 建议使用auth进行鉴权操作
{ path: '/pages/health/medicineStockIn/list', text: '药品入库清单', icon: 'arrow-down', permission: 'health:medicineStockIn:list' },
{ path: '/pages/health/medicineStock/list', text: '药品实时库存', icon: 'color', permission: 'health:medicineStockIn:list' }
])
const babycareGridList=ref([
{ path: '/pages/health/milkPowderRecord/list', text: '吃奶记录', icon: 'map-pin-ellipse', permission: 'health:milkPowderRecord:list' },
{ path: '/pages/health/statistic/milkPowderStatistic/index', text: '吃奶量统计', icon: 'spinner-cycle', permission: 'health:temperatureRecord:list' }
])
function navigateTo(path) {
uni.navigateTo({

View File

@@ -0,0 +1,208 @@
<template>
<view class="container" style="paddingBottom:1rpx;">
<u-navbar
leftIconSize="40rpx"
leftIconColor="#333333"
title="吃奶记录"
>
</u-navbar>
<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="auto"
:labelStyle="{ color: '#333333', fontSize: '30rpx' }">
<u-form-item label="人员姓名" prop="personName" required @click="handlePerson">
<u--input v-model="form.personName" disabled disabledColor="#ffffff" placeholder="请选择人员"
inputAlign="right" border="none"></u--input>
<u-icon slot="right" name="arrow-down"></u-icon>
</u-form-item>
<u-form-item label="吃奶时间" prop="sucklesTime" required @click="selectDate()">
<u--input v-model="form.sucklesTime" disabled disabledColor="#ffffff" placeholder="请选择吃奶时间" inputAlign="right" border="none"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
<u-form-item label="吃奶量" required prop="consumption" >
<u--input v-model="form.consumption" type="number" placeholder="请填写吃奶量"
inputAlign="right" border="none">
<template #suffix>
<up-text
text="毫升"
></up-text>
</template>
</u--input>
</u-form-item>
<u-form-item label="奶粉品牌" prop="milkPowderBrand" >
<u--input v-model="form.milkPowderBrand" placeholder="请填写奶粉品牌"
inputAlign="right" border="none"></u--input>
</u-form-item>
<u-form-item label="备注" prop="remark" labelPosition="top">
<u--textarea v-model="form.remark" placeholder="请填写备注" border="none" autoHeight inputAlign="right" count
maxlength="2000" style="padding:18rpx 0;"></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 itemHeight="88" :show="showPerson" :columns="personList" keyName="name" @cancel="handlePersonCancel"
@confirm="handlePersonConfirm"></u-picker>
<u-datetime-picker
:show="datePickShow"
mode="datetime"
ref="sucklesTimeRef"
@cancel="datePickShow=false"
@confirm="datePickConfirm"
itemHeight="88"
></u-datetime-picker>
</view>
</template>
<script setup>
import { listMilkPowderRecord, getMilkPowderRecord, delMilkPowderRecord, addMilkPowderRecord, updateMilkPowderRecord } from '@/api/health/milkPowderRecord'
import { listPerson, } from '@/api/health/person'
const { proxy } = getCurrentInstance()
import dayjs from 'dayjs'
import {onLoad,onReady} from "@dcloudio/uni-app";
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
import {reactive ,toRefs,ref,computed ,getCurrentInstance }from "vue";
const datePickShow = ref(false)
const showPerson = ref(false)
const title = ref("吃奶记录")
const personList = ref([])
const data = reactive({
form: {
id: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
delFlag: null,
remark: null,
sucklesTime: null,
consumption: null,
personId: null,
milkPowderBrand: null,
spoonful: null
},
queryPersonParams: {
pageNum: 1,
status: '1',
pageSize: 1000
},
rules: {
personName: [{ required: true, message: '人员不能为空', trigger: ['change', 'blur'] }],
sucklesTime: [{ required: true, message: '吃奶时间不能为空', trigger: ['change', 'blur'] }]
}
})
const { form, queryPersonParams, rules} = toRefs(data)
onLoad((option) => {
form.value.id = option.id
if(form.value.id!=null){
title.value="吃奶记录-修改"
}else{
title.value="吃奶记录-新增"
}
getData()
})
onReady(() => {
form.value.sucklesTime = dayjs(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
})
function getData() {
listPerson(queryPersonParams.value).then((response) => {
personList.value = [response.rows]
if(response.rows.length>0){
form.value.personName= response.rows[0].name
form.value.personId = response.rows[0].id
}
})
if(form.value.id!=null){
getMilkPowderRecord(form.value.id).then(res => {
form.value = res.data
})
}
}
function handlePerson() {
if (personList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '人员为空 ', type: 'warning'
})
} else {
showPerson.value = true
}
}
function handlePersonConfirm(e) {
form.value.personName = e.value[0].name
form.value.personId = e.value[0].id
form.value.healthRecordName = ''
form.value.healthRecordId = ''
queryHealthRecordParams.value.personId=e.value[0].id
listHealthRecord(queryHealthRecordParams.value).then((response) => {
healthRecordList.value = [response.rows]
showPerson.value = false
})
}
function handlePersonCancel() {
showPerson.value = false
}
function selectDate() {
datePickShow.value = true
proxy.$refs['sucklesTimeRef'].innerValue = new Date().getTime()
}
function datePickConfirm(e) {
form.value.sucklesTime = dayjs(e.value).format("YYYY-MM-DD HH:mm:ss")
datePickShow.value = false
}
function submit() {
proxy.$refs['uForm'].validate().then(() => {
if (form.value.id != null) {
updateMilkPowderRecord(form.value).then(res => {
proxy.$refs['uToast'].show({
message: '修改成功', complete() {
uni.navigateTo({ url: `/pages/health/milkPowderRecord/list` })
}
})
})
}else {
addMilkPowderRecord(form.value).then(res => {
proxy.$refs['uToast'].show({
message: '新增成功', complete() {
uni.navigateTo({ url: `/pages/health/milkPowderRecord/list` })
}
})
})
}
})
}
</script>
<style lang="scss" scoped>
.section {
margin: 24rpx;
padding: 16rpx 24rpx;
background-color: #fff;
border-radius: 8rpx;
.section-title {
width: 360rpx;
color: #333333;
line-height: 44rpx;
font-size: 30rpx;
border-left: 6rpx solid #2681FF;
padding-left: 26rpx;
}
.form-view {
padding: 20rpx 0rpx 0 10rpx;
.form-btn {
padding-top: 20rpx;
}
}
}
</style>

View File

@@ -0,0 +1,441 @@
<template>
<view class="container">
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
<view class="search-view">
<u-input v-model="queryParams.personName" border="false" type="select" @click="handlePerson" placeholder="请选择人员" suffixIcon="search"
suffixIconStyle="color: #909399" class="search-input">
</u-input>
<u-icon name="plus-circle-fill" color="#666666" size="28" style="margin-left:10px" label="新增"
labelPos="left" labelSize="32rpx" labelColor="#666666" @click="handleAdd()"></u-icon>
</view>
</u-sticky>
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
<view class="search-view">
<u-input v-model="queryParams.time" border="false" type="select" readonly placeholder="请选择吃奶日期" suffixIcon="calendar"
suffixIconStyle="color: #909399" class="search-input">
</u-input>
<u-icon :name="filterPanel ? 'arrow-up-fill' : 'arrow-down-fill'" color="#666666" size="28" label="筛选"
labelPos="left" labelSize="32rpx" labelColor="#666666" @click="filterPanel = !filterPanel"></u-icon>
<u-transition :show="filterPanel" mode="fade">
<view class="filter-panel" :style="{ height: `${windowHeight - 42}px` }">
<view class="filter-panel-content">
<view class="select-header">吃奶日期</view>
<view class="selcet-content" style="padding: 0 24rpx">
<u-input
:disabled="true"
:disabledColor="'#fff'"
class="dateInput"
border="surround"
v-model="queryParams.startTime"
placeholder="请选择开始时间"
>
<template v-slot:suffix>
<u-icon name="calendar" @click="openOrCloseDate(true)"></u-icon>
</template>
</u-input>
<u-input
:disabled="true"
:disabledColor="'#fff'"
class="dateInput"
border="surround"
v-model="queryParams.endTime"
placeholder="请选择结束时间"
>
<template v-slot:suffix>
<u-icon name="calendar" @click="openOrCloseDate(false)"></u-icon>
</template>
</u-input>
</view>
</view>
<view class="btn-box">
<u-button text="重置" style="margin-right:20rpx" @click="resetQuery()"></u-button>
<u-button type="primary" text="确定" @click="searchSubmit()"></u-button>
</view>
<u-datetime-picker
:closeOnClickOverlay="true"
:show="timeShow"
v-model="time"
mode="date"
@close="openOrCloseDate"
@cancel="openOrCloseDate"
@confirm="confirm"
></u-datetime-picker>
</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">
<view class="item-header">
<u--text lines="2" iconStyle="font-size: 18px; color: #333333; font-weight:bold"
:text="item.personName+' '+item.sucklesTime+',吃奶 '+item.consumption +'毫升'" size="30rpx" color="#333333" :bold="true"></u--text>
</view>
<!-- <view class="item-row">
<text class="row-label">吃奶时间</text>
<text class="row-value">{{ item.sucklesTime }}</text>
</view> -->
<view class="item-row">
<text class="row-label">奶粉品牌</text>
<text class="row-value">{{ item.milkPowderBrand }}</text>
</view>
<view class="item-row">
<text class="row-label">备注</text>
<text class="row-value">{{ item.remark }}</text>
</view>
<view class="operate" >
<view class="btn filling" @click="handleEdit(item)">修改</view>
<view class="btn filling" @click="handleDelete(item)">删除</view>
</view>
</view>
</u-list-item>
<view>
</view>
<u-loadmore :status="status" loadingIcon="semicircle" height="88" fontSize="32rpx" @loadmore="loadmore" />
</u-list>
<u-picker itemHeight="88" :show="settingPickShow" :columns="settingColumns" keyName="settingName"
@confirm="settingConfirm" @cancel="settingCancel"></u-picker>
<u-picker itemHeight="88" :show="showPerson" :columns="personList" keyName="name" @cancel="handlePersonCancel"
@confirm="handlePersonConfirm"></u-picker>
</view>
<!--返回首页按钮 -->
<suspend></suspend>
</template>
<script setup>
import { listMilkPowderRecord, getMilkPowderRecord, delMilkPowderRecord, addMilkPowderRecord, updateMilkPowderRecord } from '@/api/health/milkPowderRecord'
import { listPerson } from '@/api/health/person'
import { timeHandler } from '@/utils/common.ts'
import {onLoad,onShow} from "@dcloudio/uni-app";
import dayjs from 'dayjs'
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
import {reactive ,toRefs,ref,computed }from "vue";
const pageNum = ref(1)
const listData = ref([])
const isShow = ref(false)
const status = ref('loadmore')
const settingPickShow = ref(false)
const settingColumns = ref([])
const timeShow= ref(false)
const showPerson = ref(false)
const personList = ref([])
const flag= ref(true)
const time =ref( Number(new Date()))
const data = reactive({
filterPanel: false,
queryPersonParams: {
pageNum: 1,
pageSize: 100
},
queryParams: {
measureTime: null,
weight: null,
personId: null,
height: null
}
})
const { filterPanel, queryPersonParams, queryParams} = toRefs(data)
const windowHeight = computed(() => {
uni.getSystemInfoSync().windowHeight - 50
})
onLoad(() => {
getList()
});
onShow(() => {
if (isShow.value) {
listData.value=[]
getList()
isShow.value = false
}
});
function openOrCloseDate(data) {
timeShow.value = !timeShow.value
flag.value = data
}
function loadmore() {
pageNum.value += 1
if (status.value == 'loadmore') {
getList()
}
}
function getList() {
listPerson(queryPersonParams.value).then((response) => {
personList.value = [response.rows]
})
status.value = 'loading'
listMilkPowderRecord({ 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 confirm(e) {
const date = timeHandler(new Date(e.value), '-', ':')
let formatValue = 'YYYY-MM-DD'
dayjs(date).format(formatValue)
if (flag.value) {
queryParams.value.startTime = dayjs(date).format(formatValue)
} else {
queryParams.value.endTime = dayjs(date).format(formatValue)
}
timeShow.value = false
}
function settingConfirm(e) {
queryParams.value.settingId = e.value[0].settingId
queryParams.value.settingName = e.value[0].settingName
settingPickShow.value = false
}
function settingCancel() {
settingPickShow.value = false
}
function searchSubmit() {
if(queryParams.value.startTime!=''&&queryParams.value.startTime!=undefined&&queryParams.value.endTime!=''&&queryParams.value.endTime!=undefined){
queryParams.value.time = queryParams.value.startTime+'-'+queryParams.value.endTime
}
pageNum.value = 1
listData.value = []
getList()
filterPanel.value = false
}
function handlePerson() {
if (personList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '人员为空 ', type: 'warning'
})
} else {
showPerson.value = true
}
}
function handlePersonConfirm(e) {
queryParams.value.personName = e.value[0].name
queryParams.value.personId= e.value[0].id
showPerson.value = false
pageNum.value = 1
listData.value = []
getList()
}
function handlePersonCancel() {
queryParams.value.personName = ''
queryParams.value.personId = ''
showPerson.value = false
pageNum.value = 1
listData.value = []
getList()
}
function searchBlur() {
pageNum.value = 1
listData.value = []
getList()
}
function resetQuery() {
queryParams.value.personName = ''
queryParams.value.startTime = ''
queryParams.value.time = ''
queryParams.value.endTime = ''
queryParams.value.personId = ''
}
function handleEdit(item) {
uni.navigateTo({ url: `/pages/health/milkPowderRecord/addEdit?id=${item.id}` })
isShow.value = true
}
function handleAdd() {
uni.navigateTo({ url: `/pages/health/milkPowderRecord/addEdit` })
isShow.value = true
}
function handleDelete(item) {
uni.showModal({
title: '提示',
content: '你确定要删除吗',
success: function (res) {
if (res.confirm) {
delMilkPowderRecord(item.id)
uni.navigateTo({ url: `/pages/health/milkPowderRecord/list` })
} else if (res.cancel) {
console.log('取消');
}
}
});
}
</script>
<style lang="scss" scoped>
.btnAdd {
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 8rpx;
display:float;
text-align: center;
}
.search-view {
padding: 12rpx 32rpx;
background-color: #ffffff;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
.search-input {
background: #F5F5F5;
color: #333333;
margin-right: 36rpx;
}
.filter-panel {
width: 100%;
position: absolute;
left: 0;
top: 96rpx;
background-color: rgba(0, 0, 0, 0.5);
.filter-panel-content {
background-color: #ffff;
padding: 0 30rpx 30rpx;
.filter-title {
color: #000000;
font-size: 30rpx;
font-weight: 500;
padding: 30rpx 0;
}
.state-list {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.state-item {
width: 210rpx;
height: 72rpx;
border: 1rpx solid rgba(0, 0, 0, 0.25);
border-radius: 72rpx;
text-align: center;
line-height: 72rpx;
margin: 0 20rpx 20rpx 0;
font-size: 28rpx;
color: #000000;
}
.active {
background-color: rgba(222, 241, 255, 1);
border: 1rpx solid rgba(22, 119, 255, 1);
}
}
}
.btn-box {
display: flex;
padding: 24rpx 30rpx;
background-color: #fff;
box-shadow: 0rpx -10rpx 20rpx #EEEEEE;
}
}
}
.list-item {
margin: 0 24rpx 24rpx;
padding: 32rpx;
background-color: #fff;
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16rpx;
.status {
.status-item {
width: 120rpx;
height: 44rpx;
text-align: center;
line-height: 44rpx;
border-radius: 4rpx;
font-size: 24rpx;
}
.status1 {
background: #F0F0F0;
color: #8C8C8C;
}
.status2 {
background: rgba(38, 129, 255, 0.2);
color: #2681FF;
}
.status3 {
background: #F7F7F7;
color: #2681FF;
}
.status4 {
background: rgba(255, 85, 51, 0.2);
color: #FF5533;
}
.status5 {
background: #F7F7F7;
color: rgba(0, 0, 0, 0.85);
}
.status7 {
background: rgba(255, 129, 51, 0.2);
color: #FF8133;
}
.status8 {
background: rgba(65, 217, 165, 0.2);
color: #41D9A5;
}
}
}
.item-row {
padding: 16rpx 0;
.row-label {
color: rgba(0, 0, 0, 0.55);
}
.row-value {
color: rgba(0, 0, 0, 0.85)
}
}
.operate {
display: flex;
justify-content: flex-end;
.btn {
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 8rpx;
margin-left: 5rpx;
text-align: center;
}
.circulation {
background: rgba(0, 0, 0, 0.04);
margin-right: 24rpx;
color: rgba(0, 0, 0, 0.85);
}
.filling {
background: #2681FF;
border-radius: 8rpx;
color: #FFFFFF;
}
}
}
</style>

View File

@@ -0,0 +1,554 @@
<template>
<view class="container">
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
<view class="search-view">
<u-input v-model="queryParams.personName" border="false" type="select" @click="handlePerson" placeholder="请选择人员" suffixIcon="search"
suffixIconStyle="color: #909399" class="search-input">
</u-input>
</view>
</u-sticky>
<u-sticky offsetTop="8rpx" customNavHeight="8rpx">
<view class="search-view">
<u-input v-model="queryParams.time" placeholder="请选择吃奶日期" border="false" type="select" readonly suffixIcon="calendar"
suffixIconStyle="color: #909399" class="search-input">
</u-input>
<u-icon :name="filterPanel ? 'arrow-up-fill' : 'arrow-down-fill'" color="#666666" size="28" label="筛选"
labelPos="left" labelSize="32rpx" labelColor="#666666" @click="filterPanel = !filterPanel"></u-icon>
<u-transition :show="filterPanel" mode="fade">
<view class="filter-panel" :style="{ height: `${windowHeight - 42}px` }">
<view class="filter-panel-content">
<view class="select-header">吃奶日期</view>
<view class="selcet-content" style="padding: 0 24rpx">
<u-input
:disabled="true"
:disabledColor="'#fff'"
class="dateInput"
border="surround"
v-model="queryParams.startTime"
placeholder="请选择开始时间"
>
<template v-slot:suffix>
<u-icon name="calendar" @click="openOrCloseDate(true)"></u-icon>
</template>
</u-input>
<u-input
:disabled="true"
:disabledColor="'#fff'"
class="dateInput"
border="surround"
v-model="queryParams.endTime"
placeholder="请选择结束时间"
>
<template v-slot:suffix>
<u-icon name="calendar" @click="openOrCloseDate(false)"></u-icon>
</template>
</u-input>
</view>
</view>
<view class="btn-box">
<u-button text="重置" style="margin-right:20rpx" @click="resetQuery()"></u-button>
<u-button type="primary" text="确定" @click="searchSubmit()"></u-button>
</view>
<u-datetime-picker
:closeOnClickOverlay="true"
:show="timeShow"
v-model="time"
mode="date"
:minDate="-2209017600000"
@close="openOrCloseDate"
@cancel="openOrCloseDate"
@confirm="confirm"
></u-datetime-picker>
</view>
</u-transition>
</view>
</u-sticky>
<div class="app-container" style="overflow: auto">
<div class="header-con" ref="searchHeightRef">
<div class="item">
<img src="@/static/images/one.png" alt="" />
<div class="info-sum">
<div class="title">今日吃奶次数</div>
<div class="num">{{ milkPowder.todayCount }}<span></span></div>
</div>
</div>
<div class="item">
<img src="@/static/images/ticketSum.png" alt="" />
<div class="info-sum">
<div class="title">今日吃奶量</div>
<div class="num">{{ milkPowder.todayConsumption }}<span>毫升</span></div>
</div>
</div>
</div>
<div class="header-con" ref="searchHeightRef">
<div class="item">
<img src="@/static/images/one.png" alt="" />
<div class="info-sum">
<div class="title">今日单次平均吃奶量</div>
<div class="num">{{ milkPowder.todayPerConsumption }}<span>毫升</span></div>
</div>
</div>
<div class="item">
<img src="@/static/images/ticketSum.png" alt="" />
<div class="info-sum">
<div class="title">近7日吃奶量</div>
<div class="num">{{ milkPowder.sevenDayConsumption }}<span>毫升</span></div>
</div>
</div>
</div>
<div class="header-con" ref="searchHeightRef">
<div class="item">
<img src="@/static/images/one.png" alt="" />
<div class="info-sum">
<div class="title">近7日日平均吃奶量</div>
<div class="num">{{ milkPowder.sevenDayPerConsumption }}<span>毫升</span></div>
</div>
</div>
<div class="item">
<img src="@/static/images/ticketSum.png" alt="" />
<div class="info-sum">
<div class="title">近1月吃奶量</div>
<div class="num">{{ milkPowder.oneMonthConsumption }}<span>毫升</span></div>
</div>
</div>
</div>
<div class="header-con" ref="searchHeightRef">
<div class="item">
<img src="@/static/images/one.png" alt="" />
<div class="info-sum">
<div class="title">近3月吃奶量</div>
<div class="num">{{ milkPowder.threeMonthConsumption }}<span>毫升</span></div>
</div>
</div>
<div class="item">
<img src="@/static/images/ticketSum.png" alt="" />
<div class="info-sum">
<div class="title">近6月吃奶量</div>
<div class="num">{{ milkPowder.sixMonthConsumption }}<span>毫升</span></div>
</div>
</div>
</div>
<div class="header-con" ref="searchHeightRef">
<div class="item">
<img src="@/static/images/one.png" alt="" />
<div class="info-sum">
<div class="title">近1年吃奶量</div>
<div class="num">{{ milkPowder.oneYearConsumption }}<span>毫升</span></div>
</div>
</div>
<div class="item">
<img src="@/static/images/ticketSum.png" alt="" />
<div class="info-sum">
<div class="title">总吃奶量</div>
<div class="num">{{ milkPowder.totalConsumption }}<span>毫升</span></div>
</div>
</div>
</div>
<div></div>
</div>
<u-list :spaceHeight="116" lowerThreshold="100">
<u-list-item v-for="(item, index) in listData" :key="index">
<view class="list-item">
<view class="item-header">
<u--text lines="2"
:text="item.time+' 吃奶 '+item.value+' 毫升'" size="30rpx" color="#333333" ></u--text>
</view>
</view>
</u-list-item>
<view>
</view>
</u-list>
<u-picker itemHeight="88" :show="settingPickShow" :columns="settingColumns" keyName="settingName"
@confirm="settingConfirm" @cancel="settingCancel"></u-picker>
<u-picker itemHeight="88" :show="showPerson" :columns="personList" keyName="name" @cancel="handlePersonCancel"
@confirm="handlePersonConfirm"></u-picker>
</view>
<!-- 悬停按钮返回工作台-->
<suspend></suspend>
</template>
<script setup>
import { getMilkPowderAnalysis } from '@/api/health/statisticAnalysis'
import { listPerson } from '@/api/health/person'
import { getDicts } from '@/api/system/dict/data.js'
import dayjs from 'dayjs'
import { timeHandler } from '@/utils/common.ts'
import {onLoad,onShow} from "@dcloudio/uni-app";
// 计算属性与监听属性是在vue中而非uniap中 需要注意!!!
import {reactive ,toRefs,ref,computed }from "vue";
const pageNum = ref(1)
const listData = ref([])
const isShow = ref(false)
const personList = ref([])
const settingPickShow = ref(false)
const settingColumns = ref([])
const showPerson = ref(false)
const timeShow= ref(false)
const time =ref( Number(new Date()))
const flag= ref(true)
const milkPowder = ref({})
const data = reactive({
filterPanel: false,
queryPersonParams: {
pageNum: 1,
pageSize: 100
},
queryParams: {
type: 1,
time: null,
dataType: null,
recordId: null,
id: null
}
})
const { filterPanel, queryPersonParams, queryParams} = toRefs(data)
const windowHeight = computed(() => {
uni.getSystemInfoSync().windowHeight - 50
})
onLoad(() => {
getDict()
// getList()
});
onShow(() => {
if (isShow.value) {
listData.value=[]
getList()
isShow.value = false
}
});
function formatMultiLineData(data) {
if (data != null) {
return data.replace(/<br\/>/g, '\n')
}
}
function openOrCloseDate(data) {
timeShow.value = !timeShow.value
flag.value = data
}
function confirm(e) {
const date = timeHandler(new Date(e.value), '-', ':')
let formatValue = 'YYYY-MM-DD'
dayjs(date).format(formatValue)
if (flag.value) {
queryParams.value.startTime = dayjs(date).format(formatValue)
} else {
queryParams.value.endTime = dayjs(date).format(formatValue)
}
timeShow.value = false
}
function searchSubmit() {
if(queryParams.value.startTime!=''&&queryParams.value.startTime!=undefined&&queryParams.value.endTime!=''&&queryParams.value.endTime!=undefined){
queryParams.value.time = queryParams.value.startTime+'-'+queryParams.value.endTime
}
pageNum.value = 1
listData.value = []
getList()
filterPanel.value = false
}
function resetQuery() {
queryParams.value.type = '1'
let formatValue = 'YYYY-MM-DD'
const today = new Date()
const end = today.getFullYear() + '-' + ('0' + (today.getMonth() + 1)).slice(-2) + '-' + ('0' + today.getDate()).slice(-2)
const start = dayjs(end).add(-30, 'day')
queryParams.value.time = dayjs(start).format(formatValue)+'-'+dayjs(end).format(formatValue)
queryParams.value.startTime = dayjs(start).format(formatValue)
queryParams.value.endTime = dayjs(end).format(formatValue)
queryParams.value.time = ''
}
function getList() {
getMilkPowderAnalysis({...queryParams.value }).then(res => {
milkPowder.value = { ...res.data.milkPowderStatistic }
listData.value = listData.value.concat(res.data.milkPowderTableList)
}).catch(() => {
})
}
function getDict() {
let formatValue = 'YYYY-MM-DD'
const today = new Date()
const end = today.getFullYear() + '-' + ('0' + (today.getMonth() + 1)).slice(-2) + '-' + ('0' + today.getDate()).slice(-2)
const start = dayjs(end).add(-30, 'day')
queryParams.value.startTime = dayjs(start).format(formatValue)
queryParams.value.endTime = dayjs(end).format(formatValue)
queryParams.value.time = dayjs(start).format(formatValue)+'-'+dayjs(end).format(formatValue)
listPerson(queryPersonParams.value).then((response) => {
personList.value = [response.rows]
if(response.rows.length>0){
queryParams.value.personName= response.rows[0].name
queryParams.value.id = response.rows[0].id
getMilkPowderAnalysis({...queryParams.value }).then(res => {
milkPowder.value = { ...res.data.milkPowderStatistic }
listData.value = listData.value.concat(res.data.milkPowderTableList)
}).catch(() => {
})
}
})
}
function settingConfirm(e) {
queryParams.value.settingId = e.value[0].settingId
queryParams.value.settingName = e.value[0].settingName
settingPickShow.value = false
}
function settingCancel() {
settingPickShow.value = false
}
function handlePerson() {
if (personList.value[0].length === 0) {
proxy.$refs['uToast'].show({
message: '人员为空 ', type: 'warning'
})
} else {
showPerson.value = true
}
}
function handlePersonConfirm(e) {
queryParams.value.personName = e.value[0].name
queryParams.value.id= e.value[0].id
queryHealthRecordParams.value.personId=e.value[0].id
showPerson.value = false
pageNum.value = 1
listData.value = []
getList()
}
function handlePersonCancel() {
// queryParams.value.personName = ''
// queryParams.value.id=''
showPerson.value = false
listData.value = []
getList()
filterPanel.value = false
}
</script>
<style lang="scss" scoped>
.app-container {
.header-con {
width: 100%;
height: 100px;
background-color: #ffffff;
margin-bottom: 5px;
display: flex;
justify-content: space-between;
align-items: center;
.item {
width: 50%;
height: 100%;
display: flex;
position: relative;
align-items: center;
margin: 5px 10px 5px 10px;
.title {
margin-left: 5px;
color: rgb(133, 133, 148);
margin-bottom: 5px;
font-size: 14px;
}
.num {
margin-left: 5px;
font-weight: bold;
font-size: 14px;
}
}
img {
height: 30px;
width: 30px;
}
}
.header-title {
width: 100%;
height: 30px;
background-color: #ffffff;
margin-bottom: 3px;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 16px;
}
}
.btnAdd {
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 8rpx;
display:float;
text-align: center;
}
.search-view {
padding: 12rpx 32rpx;
background-color: #ffffff;
display: flex;
align-items: center;
position: relative;
.search-input {
background: #F5F5F5;
color: #333333;
margin-right: 36rpx;
}
.filter-panel {
width: 100%;
position: absolute;
left: 0;
top: 96rpx;
background-color: rgba(0, 0, 0, 0.5);
.filter-panel-content {
background-color: #ffff;
padding: 0 30rpx 30rpx;
.filter-title {
color: #000000;
font-size: 30rpx;
font-weight: 500;
padding: 30rpx 0;
}
.state-list {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.state-item {
width: 210rpx;
height: 72rpx;
border: 1rpx solid rgba(0, 0, 0, 0.25);
border-radius: 72rpx;
text-align: center;
line-height: 72rpx;
margin: 0 20rpx 20rpx 0;
font-size: 28rpx;
color: #000000;
}
.active {
background-color: rgba(222, 241, 255, 1);
border: 1rpx solid rgba(22, 119, 255, 1);
}
}
}
.btn-box {
display: flex;
padding: 24rpx 30rpx;
background-color: #fff;
box-shadow: 0rpx -10rpx 20rpx #EEEEEE;
}
}
}
.list-item {
margin: 0 24rpx 24rpx;
padding: 32rpx;
background-color: #fff;
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 16rpx;
.status {
.status-item {
width: 120rpx;
height: 44rpx;
text-align: center;
line-height: 44rpx;
border-radius: 4rpx;
font-size: 24rpx;
}
.status1 {
background: #F0F0F0;
color: #8C8C8C;
}
.status2 {
background: rgba(38, 129, 255, 0.2);
color: #2681FF;
}
.status3 {
background: #F7F7F7;
color: #2681FF;
}
.status4 {
background: rgba(255, 85, 51, 0.2);
color: #FF5533;
}
.status5 {
background: #F7F7F7;
color: rgba(0, 0, 0, 0.85);
}
.status7 {
background: rgba(255, 129, 51, 0.2);
color: #FF8133;
}
.status8 {
background: rgba(65, 217, 165, 0.2);
color: #41D9A5;
}
}
}
.item-row {
padding: 16rpx 0;
.row-label {
color: rgba(0, 0, 0, 0.55);
}
.row-value {
color: rgba(0, 0, 0, 0.85)
}
}
.operate {
display: flex;
justify-content: flex-end;
.btn {
width: 146rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 8rpx;
margin-left: 5rpx;
text-align: center;
}
.circulation {
background: rgba(0, 0, 0, 0.04);
margin-right: 24rpx;
color: rgba(0, 0, 0, 0.85);
}
.filling {
background: #2681FF;
border-radius: 8rpx;
color: #FFFFFF;
}
}
}
</style>