Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bf40cbbb
authored
Jan 21, 2026
by
Lin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 实时校验考勤天数输入
1 parent
c274bd01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
5 deletions
packageEquity/pages/salaryAppeal/components/appealSelector/appealSelector.js
packageEquity/pages/salaryAppeal/salaryAppeal.js
packageEquity/pages/salaryAppeal/components/appealSelector/appealSelector.js
View file @
bf40cbb
...
@@ -49,7 +49,7 @@ Component({
...
@@ -49,7 +49,7 @@ Component({
},
},
onAppealNumInput
(
e
)
{
onAppealNumInput
(
e
)
{
const
{
appealType
}
=
this
.
properties
const
{
appealType
,
maxValue
,
unit
}
=
this
.
properties
let
value
=
e
.
detail
.
value
let
value
=
e
.
detail
.
value
if
(
appealType
===
'recording'
)
{
if
(
appealType
===
'recording'
)
{
...
@@ -63,6 +63,19 @@ Component({
...
@@ -63,6 +63,19 @@ Component({
value
=
match
?
match
[
0
]
:
''
value
=
match
?
match
[
0
]
:
''
}
}
// 实时校验:如果输入值大于maxValue,显示toast提示
if
(
value
&&
value
.
trim
()
!==
''
)
{
const
numValue
=
appealType
===
'recording'
?
parseInt
(
value
,
10
)
:
parseFloat
(
value
)
if
(
!
isNaN
(
numValue
)
&&
numValue
>
maxValue
)
{
// 显示toast提示
wx
.
showToast
({
title
:
`
${
unit
}
数需在
${
maxValue
}${
unit
}
以内`
,
icon
:
'none'
,
duration
:
2000
})
}
}
this
.
setData
({
appealNum
:
value
})
this
.
setData
({
appealNum
:
value
})
},
},
...
...
packageEquity/pages/salaryAppeal/salaryAppeal.js
View file @
bf40cbb
...
@@ -15,6 +15,8 @@ Page({
...
@@ -15,6 +15,8 @@ Page({
// 当前选中的员工姓名
// 当前选中的员工姓名
currentStaffName
:
''
,
currentStaffName
:
''
,
currentStaffId
:
''
,
// 默认选中第一个员工
currentStaffId
:
''
,
// 默认选中第一个员工
// 当前选中的月份
currentMonth
:
''
,
// 员工选择弹出层相关
// 员工选择弹出层相关
showStaffPopup
:
false
,
showStaffPopup
:
false
,
staffOptions
:
[],
staffOptions
:
[],
...
@@ -238,6 +240,35 @@ Page({
...
@@ -238,6 +240,35 @@ Page({
},
},
/**
/**
* 根据年月字符串获取该月的天数
* @param {String} yearMonth 年月字符串,格式如 "2024-01" 或 "2024年01月"
* @returns {Number} 该月的天数
*/
getDaysInMonth
:
function
(
yearMonth
)
{
if
(
!
yearMonth
)
{
// 如果没有传入月份,返回当前月的天数
const
now
=
new
Date
()
return
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
()
+
1
,
0
).
getDate
()
}
// 处理格式 "2024-01" 或 "2024年01月"
let
year
,
month
if
(
yearMonth
.
includes
(
'-'
))
{
// 格式 "2024-01"
const
parts
=
yearMonth
.
split
(
'-'
)
year
=
parseInt
(
parts
[
0
])
month
=
parseInt
(
parts
[
1
])
}
else
{
// 默认返回当前月的天数
const
now
=
new
Date
()
return
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
()
+
1
,
0
).
getDate
()
}
// 使用 Date 对象计算该月的天数(月份从0开始,所以 month 就是下个月的第0天,即当前月的最后一天)
return
new
Date
(
year
,
month
,
0
).
getDate
()
},
/**
* 月份切换事件处理
* 月份切换事件处理
* 当组件内部月份发生变化时,会触发此事件
* 当组件内部月份发生变化时,会触发此事件
*/
*/
...
@@ -247,9 +278,9 @@ Page({
...
@@ -247,9 +278,9 @@ Page({
// 例如:根据新的月份加载对应的数据
// 例如:根据新的月份加载对应的数据
console
.
log
(
'月份已切换:'
,
timeBean
,
selectMonth
)
console
.
log
(
'月份已切换:'
,
timeBean
,
selectMonth
)
// 如果需要保存当前月份信息,可以在这里保存
// 如果需要保存当前月份信息,可以在这里保存
//
this.setData({
this
.
setData
({
//
currentMonth: timeBean.formatYearMonth
currentMonth
:
timeBean
.
formatYearMonth
//
})
})
},
},
/**
/**
...
@@ -269,6 +300,8 @@ Page({
...
@@ -269,6 +300,8 @@ Page({
// 从工资项中提取实际出勤天数(例如从 "26天" 中提取 26)
// 从工资项中提取实际出勤天数(例如从 "26天" 中提取 26)
const
daysMatch
=
item
.
value
.
match
(
/
(\d
+
)
/
)
const
daysMatch
=
item
.
value
.
match
(
/
(\d
+
)
/
)
const
actualDays
=
daysMatch
?
parseInt
(
daysMatch
[
1
])
:
26
const
actualDays
=
daysMatch
?
parseInt
(
daysMatch
[
1
])
:
26
// 根据当前月份计算该月的天数
const
maxDays
=
this
.
getDaysInMonth
(
this
.
data
.
currentMonth
)
this
.
setData
({
this
.
setData
({
showAppealPopup
:
true
,
showAppealPopup
:
true
,
actualDays
:
actualDays
,
actualDays
:
actualDays
,
...
@@ -277,7 +310,7 @@ Page({
...
@@ -277,7 +310,7 @@ Page({
appealCurrentLabel
:
'本月实际出勤天数'
,
appealCurrentLabel
:
'本月实际出勤天数'
,
appealLabel
:
'申诉修改实际出勤天数'
,
appealLabel
:
'申诉修改实际出勤天数'
,
appealUnit
:
'天'
,
appealUnit
:
'天'
,
appealMaxValue
:
31
appealMaxValue
:
maxDays
})
})
break
break
case
'daily'
:
case
'daily'
:
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment