{"remainingRequest":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\thread-loader\\dist\\cjs.js!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js!D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\eslint-loader\\index.js??ref--13-0!D:\\jenkins\\workspace\\xq-web-fvue\\src\\math.js","dependencies":[{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\src\\math.js","mtime":1667327529778},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\babel.config.js","mtime":1667327525434},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\thread-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xq-web-fvue\\node_modules\\eslint-loader\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["import \"core-js/modules/es6.regexp.split\";\nimport \"core-js/modules/es6.number.constructor\";\nimport \"core-js/modules/es6.regexp.to-string\";\nimport \"core-js/modules/es6.regexp.match\";\nimport \"core-js/modules/es6.regexp.replace\";\nimport utils from \"@/utils.js\";\nvar FormMath = {};\n\nFormMath.toNumber = function (x) {\n  if (x === null || x === undefined || x === '') return '';\n\n  if (typeof x == \"string\") {\n    x = x.replace(/,/g, \"\");\n  }\n\n  var match = x.toString().match(/([$|￥])\\d+\\.?\\d*/);\n\n  if (match) {\n    x = x.replace(match[1], '');\n  }\n\n  return Number(x);\n};\n/**\r\n * 返回x的绝对值\r\n * @param  {[type]} x [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.abs = function (x) {\n  return Math.abs(x);\n};\n/**\r\n * 把x四舍五入为最接近的整数\r\n * @param  {[type]} x [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.round = function (x) {\n  return Math.round(x);\n};\n/**\r\n * 对x进行上舍入，返回等于或者大于x,并且与x最接近的整数\r\n * @param  {[type]} x [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.ceil = function (x) {\n  return Math.ceil(x);\n};\n/**\r\n * 对x进行下舍入，返回小于或者等于x，并且与x最接近的整数\r\n * @param  {[type]} x [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.floor = function (x) {\n  return Math.floor(x);\n};\n/**\r\n * 返回集合ary中最大的数\r\n * @param  {[type]} ary [description]\r\n * @return {[type]}     [description]\r\n */\n\n\nFormMath.max = function (ary) {\n  var tmp,\n      x = 0,\n      size = ary.length;\n\n  for (var i = 0; i < size; i++) {\n    x = FormMath.toNumber(ary[i]);\n    if (isNaN(x)) continue;\n\n    if (tmp === undefined) {\n      tmp = x;\n    } else {\n      if (x > tmp) tmp = x;\n    }\n  }\n\n  tmp = FormMath.toNumber(tmp);\n  return tmp;\n};\n/**\r\n * 返回集合ary中最小的数\r\n * @param  {[type]} ary [description]\r\n * @return {[type]}     [description]\r\n */\n\n\nFormMath.min = function (ary) {\n  var tmp,\n      x = 0,\n      size = ary.length;\n\n  for (var i = 0; i < size; i++) {\n    x = FormMath.toNumber(ary[i]);\n    if (isNaN(x)) continue;\n\n    if (tmp === undefined) {\n      tmp = x;\n    } else {\n      if (x < tmp) tmp = x;\n    }\n  }\n\n  tmp = FormMath.toNumber(tmp);\n  return tmp;\n};\n/**\r\n * 返回x的平方根\r\n * @param  {[type]} x [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.sqrt = function (x) {\n  return Math.sqrt(x);\n};\n/**\r\n * 获取ary的平均值\r\n * @param  {[type]} ary [description]\r\n * @return {[type]}     [description]\r\n */\n\n\nFormMath.average = function (ary) {\n  var tmp,\n      x = 0,\n      size = ary.length;\n\n  for (var i = 0; i < size; i++) {\n    x = FormMath.toNumber(ary[i]);\n    if (isNaN(x)) continue;\n\n    if (tmp === undefined) {\n      tmp = x;\n    } else {\n      tmp += x;\n    }\n  }\n\n  tmp = FormMath.toNumber(tmp / size);\n  return tmp;\n};\n/**\r\n * 求ary的和\r\n * @param  {[type]} ary [description]\r\n * @return {[type]}     [description]\r\n */\n\n\nFormMath.sum = function (ary) {\n  var tmp,\n      x = 0,\n      size = ary.length;\n\n  for (var i = 0; i < size; i++) {\n    x = FormMath.toNumber(ary[i]);\n    if (isNaN(x)) continue;\n\n    if (tmp === undefined) {\n      tmp = x;\n    } else {\n      tmp += x;\n    }\n  }\n\n  tmp = FormMath.toNumber(tmp);\n  return tmp;\n};\n/**\r\n * 返回保留小数点后b位的x的四舍五入值\r\n * @param  {[type]} x [description]\r\n * @param  {[type]} b [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.tofixed = function (x, b) {\n  var tmp = FormMath.toNumber(x);\n  b = FormMath.toNumber(b);\n  if (isNaN(tmp) || isNaN(b)) return x;\n  return tmp.toFixed(b);\n};\n/**\r\n * 将数字转换为人民币大写\r\n * @param  {[type]} x [description]\r\n * @return {[type]}   [description]\r\n */\n\n\nFormMath.convertCurrency = function (x) {\n  var tmp = FormMath.toNumber(x);\n  if (isNaN(tmp)) return x; //TODO 转换为人民币大写\n\n  return utils.convertCurrency(tmp);\n}; // 解析表达式中的字段\n\n\nFormMath.parseFuncexpField = function (statFun) {\n  var myregexp = /\\(([data.main|data.sub|item].*?)\\)/g;\n  var match = myregexp.exec(statFun);\n  var arrs = [];\n\n  while (match != null) {\n    var str = match[1];\n    var has = false;\n\n    for (var i = 0, v; v = arrs[i++];) {\n      if (v == str) has = true;\n    }\n\n    if (!has) arrs.push(str);\n    match = myregexp.exec(statFun);\n  }\n\n  return arrs;\n}; // 计算子表中的行运算\n\n\nFormMath.calcSubExpValue = function (exp, scope, prefix, index) {\n  if (!exp || !scope || !prefix) return 0;\n  var reg = /\\{.*?\\(([data.main|data.sub|item].*?)\\)\\}/g;\n  exp = exp.replace(reg, function () {\n    var name = arguments[1],\n        value = 0;\n\n    if (name.split(\".\").length != 2) {\n      throw \"\\u5B50\\u8868\\u8FD0\\u7B97\\u4E2D\".concat(name, \"\\u5FC5\\u987B\\u4E3Aitem.xxx\\u683C\\u5F0F\\u7684\\u8868\\u8FBE\\u5F0F\");\n    }\n\n    var val = utils.getValueByPath(scope, \"\".concat(prefix, \"[\").concat(index, \"].\").concat(name.split(\".\")[1]));\n    val = FormMath.toNumber(val);\n    if (!isNaN(val) && \"\" != val) value = val;\n    return value;\n  });\n\n  if (exp.substring(0, 16) != \"FormMath.tofixed\") {\n    return FormMath.isValue(FormMath.tofixed(eval(\"(\".concat(exp, \")\")), 0));\n  }\n\n  return FormMath.isValue(eval(\"(\".concat(exp, \")\")));\n}; // 计算表达式中的值\n\n\nFormMath.calcExpValue = function (exp, scope) {\n  if (!exp) return 0;\n  var reg = /\\{.*?\\(([data.main|data.sub|item].*?)\\)\\}/g;\n  exp = exp.replace(reg, function () {\n    var name = arguments[1],\n        value = 0;\n\n    if (scope) {\n      //子表统计计算情况，多行数据\n      if (name.split(\".\").length > 3) {\n        var valArray = [];\n        var subMsg = name.split(\".\");\n        var fieldName = subMsg[3];\n        subMsg.splice(subMsg.length - 1, 1);\n        var subTableSrc = subMsg.join(\".\");\n        var rows = utils.getValueByPath(scope, subTableSrc);\n\n        for (var i = 0, row; row = rows[i++];) {\n          if (row[fieldName]) {\n            valArray.push(row[fieldName]);\n          }\n        }\n\n        value = valArray.join(\",\");\n      } else {\n        var val = utils.getValueByPath(scope, name);\n        val = FormMath.toNumber(val);\n        if (!isNaN(val) && \"\" != val) value = val;\n      }\n    }\n\n    if (!value) {\n      value = 0;\n    }\n\n    return value;\n  });\n\n  if (exp.substring(0, 16) != \"FormMath.tofixed\") {\n    return FormMath.isValue(FormMath.tofixed(eval(\"(\".concat(exp, \")\")), 0));\n  }\n\n  return FormMath.isValue(eval(\"(\".concat(exp, \")\")));\n};\n\nFormMath.isValue = function (value) {\n  if (!value) {\n    return \"\";\n  } else if (value == \"Infinity\") {\n    return \"\";\n  } else {\n    return value;\n  }\n};\n\nwindow.FormMath = FormMath;\nexport default FormMath;",null]}