Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
longhui_web
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
杨硕
longhui_web
Commits
d41451df
Commit
d41451df
authored
Jun 29, 2023
by
高宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
f09179cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
1 deletion
+58
-1
main.js
src/main.js
+3
-0
thousand.js
src/utils/thousand.js
+54
-0
activityadd.vue
src/views/activity/activityadd.vue
+1
-1
No files found.
src/main.js
View file @
d41451df
...
...
@@ -12,6 +12,8 @@ import App from './App'
import
store
from
'./store'
import
router
from
'./router'
import
permission
from
'./directive/permission'
// 千分位转换
import
thousand
from
'@/utils/thousand'
// import drective from '@/utils/directive.js'
import
'@/icons'
// icon
import
'@/assets/icons'
// icon
...
...
@@ -54,6 +56,7 @@ Viewer.setDefaults({
})
// 全局方法挂载
Vue
.
prototype
.
thousand
=
thousand
Vue
.
prototype
.
getDicts
=
getDicts
Vue
.
prototype
.
getConfigKey
=
getConfigKey
Vue
.
prototype
.
parseTime
=
parseTime
...
...
src/utils/thousand.js
0 → 100644
View file @
d41451df
const
thousand
=
{
// 千分位格式化:10000转为10,000 n=0,不允许有小数
fmoney
(
s
,
n
)
{
if
(
s
==
''
||
s
==
null
||
(
s
==
undefined
)
|
isNaN
(
Number
(
s
)))
{
return
s
}
s
=
Number
(
s
)
?
Number
(
s
)
:
s
// n = (n || n == 0) && n > -1 && n <= 20 ? n : 2;
n
=
0
s
=
parseFloat
((
s
+
''
).
replace
(
/
[^\d\.
-
]
/g
,
''
)).
toFixed
(
n
)
+
''
var
l
=
s
.
split
(
'.'
)[
0
].
split
(
''
).
reverse
()
var
r
=
s
.
split
(
'.'
)[
1
]
var
t
=
''
for
(
var
i
=
0
;
i
<
l
.
length
;
i
++
)
{
t
+=
l
[
i
]
+
((
i
+
1
)
%
3
==
0
&&
i
+
1
!=
l
.
length
?
','
:
''
)
}
if
(
n
>
0
)
{
r
=
'.'
+
r
}
else
if
(
n
==
0
)
{
r
=
''
}
let
returnT
=
t
.
split
(
''
).
reverse
().
join
(
''
)
+
r
// 负数处理
if
(
returnT
[
0
]
==
'-'
&&
returnT
[
1
]
==
','
)
{
returnT
=
'-'
+
returnT
.
substring
(
2
)
}
return
returnT
},
// 千分位反格式化:10,000.00转为10000
rmoney
(
s
)
{
let
str
=
''
if
(
s
)
{
str
=
String
(
s
).
replace
(
/,/g
,
''
)
}
if
(
s
&&
(
s
+
''
).
indexOf
(
'.'
)
>
-
1
&&
Number
(
str
))
{
return
String
(
s
).
replace
(
/
[^\d\.
-
]
/g
,
''
)
}
else
if
(
s
&&
Number
(
str
))
{
return
str
}
else
{
return
s
}
},
//用于会显示,带有小数点的数字转化为千分位
decimalFmoney
(
num
)
{
const
res
=
num
.
toString
().
replace
(
/
\d
+/
,
function
(
n
){
// 先提取小数点前后的整数部分
//(\d)(?=(\d{3})正则的意思是匹配连续三个数结尾的数字,例如1234,1后面有234连续三个数的数字,就可以匹配上,匹配的是1这个数字。如果是123,因为1后面是两位数,所以就匹配不上了
return
n
.
replace
(
/
(\d)(?=(\d{3})
+$
)
/g
,
function
(
$1
){
return
$1
+
","
;
});
})
return
res
;
}
}
export
default
thousand
src/views/activity/activityadd.vue
View file @
d41451df
...
...
@@ -10,7 +10,7 @@
<el-input
v-model
.
trim=
"form.name"
:disabled=
"formdisable"
:maxlength=
"30"
placeholder=
"请输入活动名称"
/>
</el-form-item>
<el-form-item
label=
"活动价格"
prop=
"price"
style=
"flex: 1"
>
<el-input
v-model
.
trim=
"form.price"
:disabled=
"formdisable"
:maxlength=
"30"
placeholder=
"请输入活动价格"
/>
<el-input
v-model
.
trim=
"form.price"
:disabled=
"formdisable"
:maxlength=
"30"
placeholder=
"请输入活动价格"
/>
</el-form-item>
</div>
<div
style=
"display: flex;justify-content: space-between"
>
...
...
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