Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
be8c4f4b
Commit
be8c4f4b
authored
Jul 28, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feedingIndex
parent
b30f907d
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
830 additions
and
526 deletions
+830
-526
feedingAnalysis.vue
pages/feedingAnalysis/feedingAnalysis.vue
+42
-17
feedingIndex.vue
pages/feedingIndex/feedingIndex.vue
+725
-504
feedingRecord.vue
pages/feedingRecord/feedingRecord.vue
+63
-5
demo7.png
static/feedingIndex/v1/demo7.png
+0
-0
icon_fushi_add.png
static/feedingIndex/v1/icon_fushi_add.png
+0
-0
icon_fushi_btn_add.png
static/feedingIndex/v1/icon_fushi_btn_add.png
+0
-0
icon_fushi_btn_cancel.png
static/feedingIndex/v1/icon_fushi_btn_cancel.png
+0
-0
icon_fushi_drop.png
static/feedingIndex/v1/icon_fushi_drop.png
+0
-0
icon_fushi_up.png
static/feedingIndex/v1/icon_fushi_up.png
+0
-0
icon_shanchu.png
static/feedingIndex/v1/icon_shanchu.png
+0
-0
icon_shanchu_x.png
static/feedingIndex/v1/icon_shanchu_x.png
+0
-0
No files found.
pages/feedingAnalysis/feedingAnalysis.vue
View file @
be8c4f4b
...
@@ -96,6 +96,13 @@
...
@@ -96,6 +96,13 @@
<text
class=
"edit-btn"
@
click=
"editRecord(index)"
>
修改
</text>
<text
class=
"edit-btn"
@
click=
"editRecord(index)"
>
修改
</text>
</view>
</view>
<view
class=
"record-details"
>
<view
class=
"record-details"
>
<!-- 优先显示 foodDetails,如果存在则显示,否则显示原有字段 -->
<view
v-if=
"record.foodDetails"
class=
"content-info"
>
<view
class=
"content-text"
>
{{
record
.
foodDetails
}}
</view>
</view>
<!-- 如果没有 foodDetails,则显示原有字段 -->
<view
v-else
>
<!-- 母乳亲喂:显示左右时间,时间加粗 -->
<!-- 母乳亲喂:显示左右时间,时间加粗 -->
<view
v-if=
"record.type === '母乳亲喂' && (record.leftDuration || record.rightDuration)"
<view
v-if=
"record.type === '母乳亲喂' && (record.leftDuration || record.rightDuration)"
class=
"duration-info"
>
class=
"duration-info"
>
...
@@ -128,6 +135,7 @@
...
@@ -128,6 +135,7 @@
<!-- 辅食:显示内容,超出显示... -->
<!-- 辅食:显示内容,超出显示... -->
<view
v-if=
"record.type === '辅食' && record.content"
class=
"content-info"
>
<view
v-if=
"record.type === '辅食' && record.content"
class=
"content-info"
>
<view
class=
"content-text"
>
{{
record
.
content
}}
</view>
<view
class=
"content-text"
>
{{
record
.
content
}}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -520,12 +528,14 @@ async function loadRecordsByDate(date) {
...
@@ -520,12 +528,14 @@ async function loadRecordsByDate(date) {
return
{
return
{
id
:
record
.
id
,
// 保留原始记录ID,用于修改时传递
id
:
record
.
id
,
// 保留原始记录ID,用于修改时传递
recordId
:
record
.
recordId
,
// 添加recordId字段用于编辑
time
:
formatTimeFromTimestamp
(
record
.
recordTime
),
time
:
formatTimeFromTimestamp
(
record
.
recordTime
),
type
:
getFeedingTypeLabel
(
record
.
feedingType
),
type
:
getFeedingTypeLabel
(
record
.
feedingType
),
leftDuration
:
record
.
durationLeftSeconds
?
formatDuration
(
record
.
durationLeftSeconds
)
:
''
,
leftDuration
:
record
.
durationLeftSeconds
?
formatDuration
(
record
.
durationLeftSeconds
)
:
''
,
rightDuration
:
record
.
durationRightSeconds
?
formatDuration
(
record
.
durationRightSeconds
)
:
''
,
rightDuration
:
record
.
durationRightSeconds
?
formatDuration
(
record
.
durationRightSeconds
)
:
''
,
amount
:
record
.
volume
?
`
${
record
.
volume
}
ml`
:
''
,
amount
:
record
.
volume
?
`
${
record
.
volume
}
ml`
:
''
,
content
:
record
.
foodDetails
||
''
content
:
record
.
foodDetails
||
''
,
foodDetails
:
record
.
foodDetails
||
''
// 添加foodDetails字段
}
}
}).
filter
(
record
=>
record
!==
null
)
// 过滤掉无效记录
}).
filter
(
record
=>
record
!==
null
)
// 过滤掉无效记录
...
@@ -712,7 +722,7 @@ function editRecord(index) {
...
@@ -712,7 +722,7 @@ function editRecord(index) {
editForm
.
value
=
{
editForm
.
value
=
{
time
:
record
.
time
||
''
,
time
:
record
.
time
||
''
,
type
:
record
.
type
||
''
,
type
:
record
.
type
||
''
,
content
:
record
.
content
||
''
,
content
:
record
.
foodDetails
||
record
.
content
||
''
,
// 优先使用foodDetails
leftDuration
:
record
.
leftDuration
||
''
,
leftDuration
:
record
.
leftDuration
||
''
,
rightDuration
:
record
.
rightDuration
||
''
,
rightDuration
:
record
.
rightDuration
||
''
,
amount
:
record
.
amount
||
''
amount
:
record
.
amount
||
''
...
@@ -873,7 +883,10 @@ function saveEditRecord() {
...
@@ -873,7 +883,10 @@ function saveEditRecord() {
apiData
.
durationRightSeconds
=
parseDurationToSeconds
(
editForm
.
value
.
rightDuration
)
apiData
.
durationRightSeconds
=
parseDurationToSeconds
(
editForm
.
value
.
rightDuration
)
}
else
if
(
editForm
.
value
.
type
===
'母乳瓶喂'
||
editForm
.
value
.
type
===
'奶粉喂养'
)
{
}
else
if
(
editForm
.
value
.
type
===
'母乳瓶喂'
||
editForm
.
value
.
type
===
'奶粉喂养'
)
{
apiData
.
volume
=
parseVolumeToNumber
(
editForm
.
value
.
amount
)
apiData
.
volume
=
parseVolumeToNumber
(
editForm
.
value
.
amount
)
}
else
if
(
editForm
.
value
.
type
===
'辅食'
)
{
}
// 统一添加 foodDetails 字段
if
(
editForm
.
value
.
content
)
{
apiData
.
foodDetails
=
editForm
.
value
.
content
apiData
.
foodDetails
=
editForm
.
value
.
content
}
}
...
@@ -894,18 +907,9 @@ async function saveRecordToAPI(apiData, index) {
...
@@ -894,18 +907,9 @@ async function saveRecordToAPI(apiData, index) {
title
:
'保存中...'
title
:
'保存中...'
})
})
// Mock 数据模拟
const
mockResponse
=
{
code
:
'000000'
,
message
:
'保存成功'
}
const
response
=
await
feedingRecordsAPI
(
apiData
)
const
response
=
await
feedingRecordsAPI
(
apiData
)
if
(
response
&&
response
.
code
===
'000000'
)
{
if
(
response
&&
response
.
code
===
'000000'
)
{
// 更新本地数据
updateLocalRecord
(
index
,
editForm
.
value
)
uni
.
showToast
({
uni
.
showToast
({
title
:
'保存成功'
,
title
:
'保存成功'
,
icon
:
'success'
icon
:
'success'
...
@@ -913,10 +917,16 @@ async function saveRecordToAPI(apiData, index) {
...
@@ -913,10 +917,16 @@ async function saveRecordToAPI(apiData, index) {
closeEditPopup
()
closeEditPopup
()
// 刷新当前日期的记录
// 清空缓存,确保获取最新数据
clearCache
()
// 重新加载当前日期的记录
if
(
selectedDate
.
value
)
{
if
(
selectedDate
.
value
)
{
loadRecordsByDate
(
selectedDate
.
value
)
await
loadRecordsByDate
(
selectedDate
.
value
)
}
}
// 更新图表数据
updateChartData
()
}
else
{
}
else
{
throw
new
Error
(
response
?.
message
||
'保存失败'
)
throw
new
Error
(
response
?.
message
||
'保存失败'
)
}
}
...
@@ -1026,13 +1036,28 @@ watch(selectedDate, () => {
...
@@ -1026,13 +1036,28 @@ watch(selectedDate, () => {
updateChartData
()
updateChartData
()
})
})
// 页面卸载时清理资源
// 格式化月份字符串
onUnmounted
(()
=>
{
function
formatMonthString
(
date
)
{
// 清理缓存
const
year
=
date
.
getFullYear
()
const
month
=
String
(
date
.
getMonth
()
+
1
).
padStart
(
2
,
'0'
)
return
`
${
year
}
-
${
month
}
`
}
// 清空缓存函数
function
clearCache
()
{
console
.
log
(
'清空缓存...'
)
statisticsCache
.
value
.
clear
()
statisticsCache
.
value
.
clear
()
recordsCache
.
value
.
clear
()
recordsCache
.
value
.
clear
()
loadingStatistics
.
value
.
clear
()
loadingStatistics
.
value
.
clear
()
loadingRecords
.
value
.
clear
()
loadingRecords
.
value
.
clear
()
apiStatistics
.
value
=
{}
apiRecords
.
value
=
{}
}
// 页面卸载时清理资源
onUnmounted
(()
=>
{
// 清理缓存
clearCache
()
})
})
// 测试函数(开发时使用)
// 测试函数(开发时使用)
...
...
pages/feedingIndex/feedingIndex.vue
View file @
be8c4f4b
This diff is collapsed.
Click to expand it.
pages/feedingRecord/feedingRecord.vue
View file @
be8c4f4b
...
@@ -89,6 +89,13 @@
...
@@ -89,6 +89,13 @@
<text
class=
"edit-btn"
@
click=
"editRecord(index)"
>
修改
</text>
<text
class=
"edit-btn"
@
click=
"editRecord(index)"
>
修改
</text>
</view>
</view>
<view
class=
"record-details"
>
<view
class=
"record-details"
>
<!-- 优先显示 foodDetails,如果存在则显示,否则显示原有字段 -->
<view
v-if=
"record.foodDetails"
class=
"content-info"
>
<view
class=
"content-text"
>
{{
record
.
foodDetails
}}
</view>
</view>
<!-- 如果没有 foodDetails,则显示原有字段 -->
<view
v-else
>
<!-- 母乳亲喂:显示左右时间,时间加粗 -->
<!-- 母乳亲喂:显示左右时间,时间加粗 -->
<view
v-if=
"record.type === '母乳亲喂' && (record.leftDuration || record.rightDuration)"
<view
v-if=
"record.type === '母乳亲喂' && (record.leftDuration || record.rightDuration)"
class=
"duration-info"
>
class=
"duration-info"
>
...
@@ -121,6 +128,7 @@
...
@@ -121,6 +128,7 @@
<!-- 辅食:显示内容,超出显示... -->
<!-- 辅食:显示内容,超出显示... -->
<view
v-if=
"record.type === '辅食' && record.content"
class=
"content-info"
>
<view
v-if=
"record.type === '辅食' && record.content"
class=
"content-info"
>
<view
class=
"content-text"
>
{{
record
.
content
}}
</view>
<view
class=
"content-text"
>
{{
record
.
content
}}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
...
@@ -269,6 +277,17 @@ const newRecord = ref({
...
@@ -269,6 +277,17 @@ const newRecord = ref({
content
:
''
content
:
''
})
})
// 编辑表单
const
editForm
=
ref
({
time
:
''
,
type
:
''
,
content
:
''
})
// 编辑状态
const
showEditPopup
=
ref
(
false
)
const
editingRecord
=
ref
(
null
)
// 喂养类型选项
// 喂养类型选项
const
feedingTypes
=
[
'母乳亲喂'
,
'母乳瓶喂'
,
'奶粉喂养'
,
'辅食'
]
const
feedingTypes
=
[
'母乳亲喂'
,
'母乳瓶喂'
,
'奶粉喂养'
,
'辅食'
]
...
@@ -597,7 +616,7 @@ function editRecord(index) {
...
@@ -597,7 +616,7 @@ function editRecord(index) {
editForm
.
value
=
{
editForm
.
value
=
{
time
:
record
.
time
||
''
,
time
:
record
.
time
||
''
,
type
:
record
.
type
||
''
,
type
:
record
.
type
||
''
,
content
:
record
.
content
||
''
content
:
record
.
foodDetails
||
record
.
content
||
''
// 优先使用foodDetails
}
}
editingRecord
.
value
=
{
index
,
record
}
editingRecord
.
value
=
{
index
,
record
}
showEditPopup
.
value
=
true
showEditPopup
.
value
=
true
...
@@ -630,17 +649,54 @@ async function saveEditRecord() {
...
@@ -630,17 +649,54 @@ async function saveEditRecord() {
uni
.
showToast
({
title
:
'编辑记录不存在'
,
icon
:
'none'
})
uni
.
showToast
({
title
:
'编辑记录不存在'
,
icon
:
'none'
})
return
return
}
}
try
{
uni
.
showLoading
({
title
:
'保存中...'
})
const
{
index
,
record
}
=
editingRecord
.
value
const
{
index
,
record
}
=
editingRecord
.
value
const
apiData
=
{
const
apiData
=
{
recordId
:
record
.
recordId
,
recordId
:
record
.
recordId
,
babyId
:
feedStore
.
getCurrentBabyId
(),
babyId
:
feedStore
.
getCurrentBabyId
(),
recordTime
:
formatDateTimeString
(
currentSelectedDate
.
value
,
editForm
.
value
.
time
),
recordTime
:
formatDateTimeString
(
currentSelectedDate
.
value
,
editForm
.
value
.
time
),
feedingType
:
getFeedingTypeId
(
editForm
.
value
.
type
),
feedingType
:
getFeedingTypeId
(
editForm
.
value
.
type
),
foodDetails
:
editForm
.
value
.
content
foodDetails
:
editForm
.
value
.
content
// 统一使用foodDetails字段
}
}
await
feedingRecordsAPI
(
apiData
)
const
response
=
await
feedingRecordsAPI
(
apiData
)
if
(
response
&&
response
.
code
===
'000000'
)
{
uni
.
showToast
({
title
:
'保存成功'
,
icon
:
'success'
})
closeEditPopup
()
closeEditPopup
()
if
(
currentSelectedDate
.
value
)
loadRecordsByDate
(
currentSelectedDate
.
value
)
// 清空缓存,确保获取最新数据
clearCache
()
// 重新加载当前日期的记录
if
(
currentSelectedDate
.
value
)
{
await
loadRecordsByDate
(
currentSelectedDate
.
value
)
}
// 重新加载当前月份的日历状态
const
currentMonth
=
formatMonthString
(
currentDate
.
value
)
await
loadCalendarStatus
(
currentMonth
)
}
else
{
throw
new
Error
(
response
?.
message
||
'保存失败'
)
}
}
catch
(
error
)
{
console
.
error
(
'保存记录失败:'
,
error
)
uni
.
showToast
({
title
:
error
.
message
||
'保存失败'
,
icon
:
'none'
})
}
finally
{
uni
.
hideLoading
()
}
}
}
function
goToFeedingAnalysis
()
{
function
goToFeedingAnalysis
()
{
...
@@ -759,12 +815,14 @@ async function loadRecordsByDate(date) {
...
@@ -759,12 +815,14 @@ async function loadRecordsByDate(date) {
return
{
return
{
id
:
record
.
id
,
// 保留原始记录ID,用于修改时传递
id
:
record
.
id
,
// 保留原始记录ID,用于修改时传递
recordId
:
record
.
recordId
,
// 添加recordId字段用于编辑
time
:
formatTimeFromTimestamp
(
record
.
recordTime
),
time
:
formatTimeFromTimestamp
(
record
.
recordTime
),
type
:
getFeedingTypeLabel
(
record
.
feedingType
),
type
:
getFeedingTypeLabel
(
record
.
feedingType
),
leftDuration
:
record
.
durationLeftSeconds
?
formatDuration
(
record
.
durationLeftSeconds
)
:
''
,
leftDuration
:
record
.
durationLeftSeconds
?
formatDuration
(
record
.
durationLeftSeconds
)
:
''
,
rightDuration
:
record
.
durationRightSeconds
?
formatDuration
(
record
.
durationRightSeconds
)
:
''
,
rightDuration
:
record
.
durationRightSeconds
?
formatDuration
(
record
.
durationRightSeconds
)
:
''
,
amount
:
record
.
volume
?
`
${
record
.
volume
}
ml`
:
''
,
amount
:
record
.
volume
?
`
${
record
.
volume
}
ml`
:
''
,
content
:
record
.
foodDetails
||
''
content
:
record
.
foodDetails
||
''
,
foodDetails
:
record
.
foodDetails
||
''
// 添加foodDetails字段
}
}
}).
filter
(
record
=>
record
!==
null
)
// 过滤掉无效记录
}).
filter
(
record
=>
record
!==
null
)
// 过滤掉无效记录
...
...
static/feedingIndex/v1/demo7.png
0 → 100644
View file @
be8c4f4b
26.6 KB
static/feedingIndex/v1/icon_fushi_add.png
0 → 100644
View file @
be8c4f4b
1.23 KB
static/feedingIndex/v1/icon_fushi_btn_add.png
0 → 100644
View file @
be8c4f4b
3.14 KB
static/feedingIndex/v1/icon_fushi_btn_cancel.png
0 → 100644
View file @
be8c4f4b
3.17 KB
static/feedingIndex/v1/icon_fushi_drop.png
0 → 100644
View file @
be8c4f4b
428 Bytes
static/feedingIndex/v1/icon_fushi_up.png
0 → 100644
View file @
be8c4f4b
420 Bytes
static/feedingIndex/v1/icon_shanchu.png
0 → 100644
View file @
be8c4f4b
585 Bytes
static/feedingIndex/v1/icon_shanchu_x.png
0 → 100644
View file @
be8c4f4b
874 Bytes
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment