Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jz_Travel
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengke
jz_Travel
Commits
30a86de8
Commit
30a86de8
authored
Jul 23, 2025
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
fd5aa2e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
38 deletions
+35
-38
productInfor1.vue
pages/teamLeader/components/report/productInfor1.vue
+3
-1
utils.js
plugin/utils.js
+32
-37
No files found.
pages/teamLeader/components/report/productInfor1.vue
View file @
30a86de8
...
...
@@ -283,8 +283,10 @@
}
else
{
validValue
=
this
.
$utils
.
checkPrice
(
value
,
true
);
}
// 更新数据
item
[
field
]
=
validValue
;
console
.
log
(
"handleInput"
,
item
[
field
]);
// 触发其他逻辑(如计算)
this
.
getTotal
();
},
...
...
@@ -297,7 +299,7 @@
}
// 更新数据
item
[
field
]
=
formattedValue
;
this
.
$set
(
item
,
field
,
formattedValue
);
console
.
log
(
"handleBlur"
,
item
[
field
]
);
// 触发其他逻辑
this
.
getTotal
();
},
...
...
plugin/utils.js
View file @
30a86de8
...
...
@@ -237,43 +237,38 @@ function goZanYangUrl() {
});
}
//验证只能输入2位小数【负数:isMinus传true】
function
checkPrice
(
value
,
isMinus
)
{
var
newValue
=
''
;
if
(
value
)
{
newValue
=
value
+
''
;
}
var
t
=
newValue
.
length
>
0
?
newValue
[
0
]
:
''
;
newValue
=
newValue
.
replace
(
/
[^\d
.
]
/g
,
''
);
//清除“数字”和“.”以外的字符
newValue
=
newValue
.
replace
(
/
\.{2,}
/g
,
'.'
);
//只保留第一个. 清除多余的
newValue
=
newValue
.
replace
(
'.'
,
"$#$"
)
.
replace
(
/
\.
/g
,
''
)
.
replace
(
'$#$'
,
'.'
);
newValue
=
newValue
.
replace
(
/^
(\-)
*
(\d
+
)\.(\d\d)
.*$/
,
'$1$2.$3'
);
//只能输入两个小数
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉
//是否允许负数
if
(
isMinus
&&
t
==
'-'
)
{
newValue
=
'-'
+
newValue
;
}
return
newValue
;
}
//验证只能输入整数【负数:isMinus传true】
function
checkInteger
(
value
,
isMinus
)
{
var
newValue
=
''
;
if
(
value
)
{
newValue
=
value
+
''
;
}
var
t
=
newValue
.
length
>
0
?
newValue
[
0
]
:
''
;
newValue
=
newValue
.
replace
(
/
[^\d]
/g
,
''
);
//是否允许负数
if
(
isMinus
&&
t
==
'-'
)
{
newValue
=
'-'
+
newValue
;
}
return
newValue
;
}
// utils.js
function
checkPrice
(
value
,
isMinus
)
{
// 确保 value 总是字符串
let
newValue
=
value
===
null
||
value
===
undefined
?
''
:
String
(
value
);
const
t
=
newValue
[
0
]
||
''
;
newValue
=
newValue
.
replace
(
/
[^\d
.
]
/g
,
''
);
// 清除非法字符
newValue
=
newValue
.
replace
(
/
\.{2,}
/g
,
'.'
);
// 保留第一个小数点
newValue
=
newValue
.
replace
(
'.'
,
"$#$"
)
.
replace
(
/
\.
/g
,
''
)
.
replace
(
'$#$'
,
'.'
);
newValue
=
newValue
.
replace
(
/^
(\-)
*
(\d
+
)\.(\d\d)
.*$/
,
'$1$2.$3'
);
// 限制两位小数
if
(
isMinus
&&
t
===
'-'
)
{
newValue
=
'-'
+
newValue
;
}
return
newValue
;
}
function
checkInteger
(
value
,
isMinus
)
{
// 确保 value 总是字符串
let
newValue
=
value
===
null
||
value
===
undefined
?
''
:
String
(
value
);
const
t
=
newValue
[
0
]
||
''
;
newValue
=
newValue
.
replace
(
/
[^\d]
/g
,
''
);
if
(
isMinus
&&
t
===
'-'
)
{
newValue
=
'-'
+
newValue
;
}
return
newValue
;
}
//判断是否为整数,小数,支持负数
function
checkIsNum
(
str
)
{
var
flag
=
false
;
...
...
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