Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
梁建民
/
wmsApp
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8cba824c
authored
Jul 28, 2025
by
liangjianmin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat(tallyReceive): 增加日期转DC格式处理逻辑
在理货接收操作页面中,新增日期转DC格式的处理方法,支持用户输入6位数字日期并进行合法性校验,计算周数并更新表单参数。
parent
cad5d188
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
1 deletions
pages/tallyReceive/operate.vue
pages/tallyReceive/operate.vue
View file @
8cba824c
...
...
@@ -469,6 +469,12 @@
}
else
{
this
.
formParams
.
image_ids
=
''
;
}
},
// 监听日期转DC输入
date_code_format
:
{
handler
:
function
(
val
)
{
this
.
handleDateCodeFormat
(
val
);
}
}
},
methods
:
{
...
...
@@ -996,7 +1002,71 @@
setTimeout
(()
=>
{
this
.
is_focus
=
true
;
},
200
);
}
},
/**
* 处理日期转DC格式
* @param {String} val - 输入的6位数字日期
*/
handleDateCodeFormat
:
debounce
(
function
(
val
)
{
if
(
val
&&
val
.
length
===
6
)
{
// 获取年份后两位
var
year
=
val
.
substring
(
0
,
2
);
// 获取月日部分
var
monthDay
=
val
.
substring
(
2
);
// 检查月份和日期是否合法
var
month
=
Number
(
monthDay
.
substring
(
0
,
2
));
var
day
=
Number
(
monthDay
.
substring
(
2
));
if
(
month
<
1
||
month
>
12
||
day
<
1
||
day
>
31
)
{
uni
.
showToast
({
title
:
'日期格式不合法'
,
icon
:
'none'
});
return
;
}
try
{
// 计算周数
var
date
=
new
Date
(
Number
(
'20'
+
year
),
month
-
1
,
day
);
// 检查日期是否有效
if
(
isNaN
(
date
.
getTime
()))
{
uni
.
showToast
({
title
:
'日期格式不合法'
,
icon
:
'none'
});
return
;
}
var
firstDayOfYear
=
new
Date
(
date
.
getFullYear
(),
0
,
1
);
// 计算当前日期是一年中的第几天
var
dayOfYear
=
Math
.
floor
((
date
-
firstDayOfYear
)
/
(
24
*
60
*
60
*
1000
))
+
1
;
// 计算当前日期是一年中的第几周
var
weekNumber
=
Math
.
ceil
(
dayOfYear
/
7
);
// 格式化周数为两位数
var
weekStr
=
weekNumber
<
10
?
'0'
+
weekNumber
:
String
(
weekNumber
);
// 组合成DC格式:年份后两位 + 周数
this
.
formParams
.
date_code
=
year
+
weekStr
;
}
catch
(
error
)
{
uni
.
showToast
({
title
:
'日期转换失败'
,
icon
:
'none'
});
}
}
else
if
(
val
&&
val
.
length
>
0
&&
val
.
length
<
6
)
{
// 输入不足6位时不处理,等待用户继续输入
}
else
if
(
val
&&
val
.
length
>
6
)
{
uni
.
showToast
({
title
:
'请输入6位数字日期'
,
icon
:
'none'
});
}
},
500
)
}
};
</
script
>
...
...
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