提交 24905b74 编写于 作者: changdi.hao's avatar changdi.hao

修复浮点字符的问题

上级 3921bb7c
......@@ -808,3 +808,23 @@ export const setOptionLabel = (self,selfModel,selfEId,selfEName,list,listEId,lis
export function deepCopy(obj) {
return obj ? JSON.parse(JSON.stringify(obj)) : obj;
}
//按照有效数字位数进行四舍五入,默认6位有效数字
export function signFigures(num, rank = 6){
if(!num) return(0);
const sign = num / Math.abs(num);
const number = num * sign;
const temp = rank - 1 - Math.floor(Math.log10(number));
let ans;
if (temp > 0) {
ans = parseFloat(number.toFixed(temp));
}
else if (temp < 0) {
ans = Math.round(number / Math.pow(10, temp)) * temp;
}
else {
ans = Math.round(number);
}
return (ans * sign);
};
......@@ -867,7 +867,7 @@
<script>
import BreadCrumb from "@/components/breadcrumb.vue";
let vm = null;
import { openLoading, closeLoading } from "../../utils/utils";
import { openLoading, closeLoading, signFigures } from "../../utils/utils";
import { isEmptyUtils } from "@/utils/index";
import { doUpload, getFilePath, createFilePath } from "../../utils/qiniu-util";
import { updateGoods ,updateStock,dosageAll,getDeparts,getGoodsList, getGoodDetails, updateGoodsV2, getHospitalInfoByStoreId, getCheckPackageIdList, getTypeCodeList,getBusinessCategory } from '@/utils/goods';
......@@ -1535,10 +1535,11 @@
return;
}
}
if(!isTrue){
return false;
}else{
this.formData.costPrice = this.formData.optPrice*100
this.formData.costPrice = signFigures(this.formData.optPrice*100);
this.formData.hasChanged = true;
this.formData.inputType = this.inputType;
this.updateGoodsInfo();
......@@ -1560,7 +1561,7 @@
updateGoodsInfo(){
console.log('提交值',JSON.parse(JSON.stringify(this.formData)));
const submieFn = this.isCheckServe ? updateGoodsV2 : updateGoods;
let params = JSON.parse(JSON.stringify(this.formData))
let params = JSON.parse(JSON.stringify(this.formData));
params.scorePerformance = params.scorePerformance * 100;
submieFn(params).then((res)=>{
if (res.code !== '000000') {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册