|
|
@@ -2,7 +2,7 @@ import { queryPermancePlanTmp } from "../../../../services/api/orders/index"
|
|
|
import { accountid, clientType, getErrorMsg, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../../services/utils"
|
|
|
import { hideLoading, showLoading, showModel, showToast } from "../../../../utils/message/index"
|
|
|
import services from "../../../../services/index"
|
|
|
-import { formatDate } from "../../../../utils/util"
|
|
|
+import { formatDate, getDecimalNum } from "../../../../utils/util"
|
|
|
import { FunCode } from "../../../../constants/enum/funcode"
|
|
|
import { sendMsgToMQ } from "../../../../services/api/common/index"
|
|
|
import { encryptBody } from "../../../../utils/websocket/crypto"
|
|
|
@@ -217,27 +217,8 @@ Page({
|
|
|
|
|
|
// input输入中
|
|
|
getInputNum (e: any) {
|
|
|
- let amount = e.detail
|
|
|
- let num = null
|
|
|
- // 小数点后最多只能输入两位
|
|
|
- num = amount.replace(new RegExp('^(\\d+\\.\\d{2}).+'), '$1')
|
|
|
-
|
|
|
- // 小数点开头得话,让前面加个0 eg: 0.xx
|
|
|
- const startPoint = /^\./g
|
|
|
- if (startPoint.test(num)) { num = amount.replace(startPoint, '0.') }
|
|
|
-
|
|
|
- // 若没有小数点,前面输入多个0,去掉0取整
|
|
|
- // if(num有值 && 没有小数点 && 不等于'0')
|
|
|
- if (num && !num.includes('.') && num !== '0') { num = +num }
|
|
|
- // 若出现多个小数点,则替换为1个
|
|
|
- const morePoint = /\.+(\d*|\.+)\./g
|
|
|
- if (morePoint.test(num)) {
|
|
|
- num = amount
|
|
|
- .replace(/\.{2,}/g, ".")
|
|
|
- .replace(".", "$#$")
|
|
|
- .replace(/\./g, "")
|
|
|
- .replace("$#$", ".")
|
|
|
- }
|
|
|
+ /// 截取两位小数位
|
|
|
+ let num = getDecimalNum(e.detail)
|
|
|
switch (e.target.id) {
|
|
|
case 'maxbuyqty': /// 最大采购单位
|
|
|
this.setData({ maxbuyqty: num})
|
|
|
@@ -363,7 +344,7 @@ Page({
|
|
|
/**
|
|
|
* 新增价格
|
|
|
*/
|
|
|
- addPrice(e: any) {
|
|
|
+ addPrice() {
|
|
|
this.setData({
|
|
|
datas: this.data.datas.concat([{price: 0.0, qty: 0.0, step: this.data.datas.length+1}])
|
|
|
})
|
|
|
@@ -393,29 +374,8 @@ Page({
|
|
|
const row = <number><unknown>ids[0]
|
|
|
const id = ids[1]
|
|
|
var obj = this.data.datas[row-1]
|
|
|
-
|
|
|
- let amount = e.detail
|
|
|
- let num = null
|
|
|
- // 小数点后最多只能输入两位
|
|
|
- num = amount.replace(new RegExp('^(\\d+\\.\\d{2}).+'), '$1')
|
|
|
-
|
|
|
- // 小数点开头得话,让前面加个0 eg: 0.xx
|
|
|
- const startPoint = /^\./g
|
|
|
- if (startPoint.test(num)) { num = amount.replace(startPoint, '0.') }
|
|
|
-
|
|
|
- // 若没有小数点,前面输入多个0,去掉0取整
|
|
|
- // if(num有值 && 没有小数点 && 不等于'0')
|
|
|
- if (num && !num.includes('.') && num !== '0') { num = +num }
|
|
|
- // 若出现多个小数点,则替换为1个
|
|
|
- const morePoint = /\.+(\d*|\.+)\./g
|
|
|
-
|
|
|
- if (morePoint.test(num)) {
|
|
|
- num = amount
|
|
|
- .replace(/\.{2,}/g, ".")
|
|
|
- .replace(".", "$#$")
|
|
|
- .replace(/\./g, "")
|
|
|
- .replace("$#$", ".")
|
|
|
- }
|
|
|
+ /// 截取两位小数
|
|
|
+ let num = getDecimalNum(e.detail)
|
|
|
/// 数据赋值
|
|
|
if (id === "qty") { obj.qty = num } else { obj.price = num }
|
|
|
/// 删除数据
|