Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
S
shop-new
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
王天霸
shop-new
Commits
298de8a7
提交
298de8a7
authored
9月 02, 2022
作者:
王天霸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
精度丢失
上级
0e7fcd05
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
131 行增加
和
11 行删除
+131
-11
main.js
src/main.js
+3
-0
calculation.js
src/utils/calculation.js
+115
-0
index.js
src/utils/index.js
+1
-0
index.vue
src/views/system/goods/add/index.vue
+12
-11
没有找到文件。
src/main.js
浏览文件 @
298de8a7
...
@@ -51,6 +51,9 @@ Vue.prototype.msgError = function (msg) {
...
@@ -51,6 +51,9 @@ Vue.prototype.msgError = function (msg) {
Vue
.
prototype
.
msgInfo
=
function
(
msg
)
{
Vue
.
prototype
.
msgInfo
=
function
(
msg
)
{
this
.
$message
.
info
(
msg
);
this
.
$message
.
info
(
msg
);
}
}
//乘法精度丢失
import
cal
from
'@/utils/calculation'
;
Vue
.
prototype
.
cal
=
cal
// 动态修改meta
// 动态修改meta
import
MetaInfo
from
'vue-meta-info'
import
MetaInfo
from
'vue-meta-info'
...
...
src/utils/calculation.js
0 → 100644
浏览文件 @
298de8a7
var
countDecimals
=
function
(
num
)
{
var
len
=
0
;
try
{
num
=
Number
(
num
);
var
str
=
num
.
toString
().
toUpperCase
();
if
(
str
.
split
(
'E'
).
length
===
2
)
{
var
isDecimal
=
false
;
if
(
str
.
split
(
'.'
).
length
===
2
)
{
str
=
str
.
split
(
'.'
)[
1
];
if
(
parseInt
(
str
.
split
(
'E'
)[
0
])
!==
0
)
{
isDecimal
=
true
;
}
}
let
x
=
str
.
split
(
'E'
);
if
(
isDecimal
)
{
len
=
x
[
0
].
length
;
}
len
-=
parseInt
(
x
[
1
]);
}
else
if
(
str
.
split
(
'.'
).
length
===
2
)
{
if
(
parseInt
(
str
.
split
(
'.'
)[
1
])
!==
0
)
{
len
=
str
.
split
(
'.'
)[
1
].
length
;
}
}
}
catch
(
e
)
{
throw
e
;
}
finally
{
if
(
isNaN
(
len
)
||
len
<
0
)
{
len
=
0
;
}
return
len
;
}
};
var
convertToInt
=
function
(
num
)
{
num
=
Number
(
num
);
var
newNum
=
num
;
var
times
=
countDecimals
(
num
);
var
temp_num
=
num
.
toString
().
toUpperCase
();
if
(
temp_num
.
split
(
'E'
).
length
===
2
)
{
newNum
=
Math
.
round
(
num
*
Math
.
pow
(
10
,
times
));
}
else
{
newNum
=
Number
(
temp_num
.
replace
(
"."
,
""
));
}
return
newNum
;
};
var
getCorrectResult
=
function
(
type
,
num1
,
num2
,
result
)
{
var
temp_result
=
0
;
switch
(
type
)
{
case
"add"
:
temp_result
=
num1
+
num2
;
break
;
case
"sub"
:
temp_result
=
num1
-
num2
;
break
;
case
"div"
:
temp_result
=
num1
/
num2
;
break
;
case
"mul"
:
temp_result
=
num1
*
num2
;
break
;
}
if
(
Math
.
abs
(
result
-
temp_result
)
>
1
)
{
return
temp_result
;
}
return
result
;
};
export
default
{
//加法
accAdd
(
num1
,
num2
)
{
num1
=
Number
(
num1
);
num2
=
Number
(
num2
);
var
dec1
,
dec2
,
times
;
try
{
dec1
=
countDecimals
(
num1
)
+
1
;
}
catch
(
e
)
{
dec1
=
0
;
}
try
{
dec2
=
countDecimals
(
num2
)
+
1
;
}
catch
(
e
)
{
dec2
=
0
;
}
times
=
Math
.
pow
(
10
,
Math
.
max
(
dec1
,
dec2
));
var
result
=
(
this
.
accMul
(
num1
,
times
)
+
this
.
accMul
(
num2
,
times
))
/
times
;
return
getCorrectResult
(
"add"
,
num1
,
num2
,
result
);
},
//减法
accSub
(
num1
,
num2
)
{
num1
=
Number
(
num1
);
num2
=
Number
(
num2
);
var
dec1
,
dec2
,
times
;
try
{
dec1
=
countDecimals
(
num1
)
+
1
;
}
catch
(
e
)
{
dec1
=
0
;
}
try
{
dec2
=
countDecimals
(
num2
)
+
1
;
}
catch
(
e
)
{
dec2
=
0
;
}
times
=
Math
.
pow
(
10
,
Math
.
max
(
dec1
,
dec2
));
var
result
=
Number
((
this
.
accMul
(
num1
,
times
)
-
this
.
accMul
(
num2
,
times
))
/
times
);
return
getCorrectResult
(
"sub"
,
num1
,
num2
,
result
);
},
//除法
accDiv
(
num1
,
num2
)
{
num1
=
Number
(
num1
);
num2
=
Number
(
num2
);
var
t1
=
0
,
t2
=
0
,
dec1
,
dec2
;
try
{
t1
=
countDecimals
(
num1
);
}
catch
(
e
)
{}
try
{
t2
=
countDecimals
(
num2
);
}
catch
(
e
)
{}
dec1
=
convertToInt
(
num1
);
dec2
=
convertToInt
(
num2
);
var
result
=
this
.
accMul
((
dec1
/
dec2
),
Math
.
pow
(
10
,
t2
-
t1
));
return
getCorrectResult
(
"div"
,
num1
,
num2
,
result
);
},
//乘法
accMul
(
num1
,
num2
)
{
num1
=
Number
(
num1
);
num2
=
Number
(
num2
);
var
times
=
0
,
s1
=
num1
.
toString
(),
s2
=
num2
.
toString
();
try
{
times
+=
countDecimals
(
s1
);
}
catch
(
e
)
{}
try
{
times
+=
countDecimals
(
s2
);
}
catch
(
e
)
{}
var
result
=
convertToInt
(
s1
)
*
convertToInt
(
s2
)
/
Math
.
pow
(
10
,
times
);
return
getCorrectResult
(
"mul"
,
num1
,
num2
,
result
);
}
}
\ No newline at end of file
src/utils/index.js
浏览文件 @
298de8a7
...
@@ -422,3 +422,4 @@ export function camelCase(str) {
...
@@ -422,3 +422,4 @@ export function camelCase(str) {
export
function
isNumberStr
(
str
)
{
export
function
isNumberStr
(
str
)
{
return
/^
[
+-
]?(
0|
([
1-9
]\d
*
))(\.\d
+
)?
$/g
.
test
(
str
)
return
/^
[
+-
]?(
0|
([
1-9
]\d
*
))(\.\d
+
)?
$/g
.
test
(
str
)
}
}
src/views/system/goods/add/index.vue
浏览文件 @
298de8a7
...
@@ -121,7 +121,6 @@
...
@@ -121,7 +121,6 @@
import
GoodsParameter
from
'./components/goodsparameter'
;
import
GoodsParameter
from
'./components/goodsparameter'
;
import
Goodsimg
from
'./components/goodsimg2'
;
import
Goodsimg
from
'./components/goodsimg2'
;
import
Goodsaftersale
from
'./components/goodsaftersale'
;
import
Goodsaftersale
from
'./components/goodsaftersale'
;
export
default
{
export
default
{
name
:
'Index'
,
name
:
'Index'
,
components
:
{
components
:
{
...
@@ -702,7 +701,7 @@
...
@@ -702,7 +701,7 @@
this
.
goodsAllData
.
ladder
=
ladder
this
.
goodsAllData
.
ladder
=
ladder
// 进一步处理金额数据
// 进一步处理金额数据
this
.
goodsAllData
.
ladder
.
map
((
item
)
=>
{
this
.
goodsAllData
.
ladder
.
map
((
item
)
=>
{
item
.
money
=
item
.
money
*
10000
/
100
item
.
money
=
formatNumber
(
item
.
money
*
100
)
return
item
return
item
});
});
}
}
...
@@ -743,7 +742,7 @@
...
@@ -743,7 +742,7 @@
// 所有数据合并
// 所有数据合并
Object
.
assign
(
this
.
goodsAllData
,
spxxData
,
spsjData
,
ssffData
);
Object
.
assign
(
this
.
goodsAllData
,
spxxData
,
spsjData
,
ssffData
);
debugger
this
.
goodsAllData
.
description
=
spxqData
this
.
goodsAllData
.
description
=
spxqData
// 经营类目,服务标签,需要单独处理数据格式
// 经营类目,服务标签,需要单独处理数据格式
...
@@ -756,10 +755,11 @@
...
@@ -756,10 +755,11 @@
// 价格数字需要 乘以100
// 价格数字需要 乘以100
if
(
this
.
goodsAllData
.
specs_group
&&
this
.
goodsAllData
.
specs_group
.
length
>
0
)
{
if
(
this
.
goodsAllData
.
specs_group
&&
this
.
goodsAllData
.
specs_group
.
length
>
0
)
{
this
.
goodsAllData
.
specs_group
.
forEach
((
item
)
=>
{
this
.
goodsAllData
.
specs_group
.
forEach
((
item
)
=>
{
item
.
sc_price
=
(
Number
(
item
.
sc_price
)
*
1000
)
/
10
;
item
.
sc_price
=
Number
(
this
.
cal
.
accMul
(
item
.
sc_price
,
100
));
item
.
price
=
(
Number
(
item
.
price
)
*
1000
)
/
10
;
item
.
price
=
Number
(
this
.
cal
.
accMul
(
item
.
price
,
100
))
;
item
.
js_price
=
(
Number
(
item
.
js_price
)
*
1000
)
/
10
;
item
.
js_price
=
Number
(
this
.
cal
.
accMul
(
item
.
js_price
,
100
));
item
.
prime_cost
=
(
Number
(
item
.
prime_cost
)
*
1000
)
/
10
;
debugger
item
.
prime_cost
=
Number
(
this
.
cal
.
accMul
(
item
.
prime_cost
,
100
));
item
.
stock
=
Number
(
item
.
stock
);
item
.
stock
=
Number
(
item
.
stock
);
item
.
stock_warning
=
Number
(
item
.
stock_warning
);
item
.
stock_warning
=
Number
(
item
.
stock_warning
);
item
.
bar_code
=
Number
(
item
.
bar_code
);
item
.
bar_code
=
Number
(
item
.
bar_code
);
...
@@ -771,10 +771,11 @@
...
@@ -771,10 +771,11 @@
delete
this
.
goodsAllData
.
stock
;
delete
this
.
goodsAllData
.
stock
;
delete
this
.
goodsAllData
.
weight
;
delete
this
.
goodsAllData
.
weight
;
}
else
{
}
else
{
this
.
goodsAllData
.
sc_price
=
(
Number
(
this
.
goodsAllData
.
sc_price
)
*
1000
)
/
10
this
.
goodsAllData
.
sc_price
=
Number
(
this
.
cal
.
accMul
(
this
.
goodsAllData
.
sc_price
,
100
))
this
.
goodsAllData
.
price
=
(
Number
(
this
.
goodsAllData
.
price
)
*
1000
)
/
10
this
.
goodsAllData
.
price
=
Number
(
this
.
cal
.
accMul
(
this
.
goodsAllData
.
price
,
100
))
this
.
goodsAllData
.
js_price
=
(
Number
(
this
.
goodsAllData
.
js_price
)
*
1000
)
/
10
this
.
goodsAllData
.
js_price
=
Number
(
this
.
cal
.
accMul
(
this
.
goodsAllData
.
js_price
,
100
))
this
.
goodsAllData
.
prime_cost
=
(
Number
(
this
.
goodsAllData
.
prime_cost
)
*
1000
)
/
10
debugger
this
.
goodsAllData
.
prime_cost
=
Number
(
this
.
cal
.
accMul
(
this
.
goodsAllData
.
prime_cost
,
100
))
this
.
goodsAllData
.
stock
=
Number
(
this
.
goodsAllData
.
stock
);
this
.
goodsAllData
.
stock
=
Number
(
this
.
goodsAllData
.
stock
);
this
.
goodsAllData
.
stock_warning
=
Number
(
this
.
goodsAllData
.
stock_warning
);
this
.
goodsAllData
.
stock_warning
=
Number
(
this
.
goodsAllData
.
stock_warning
);
this
.
goodsAllData
.
bar_code
=
Number
(
this
.
goodsAllData
.
bar_code
);
this
.
goodsAllData
.
bar_code
=
Number
(
this
.
goodsAllData
.
bar_code
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论