ccj před 11 měsíci
rodič
revize
7f5de54863

+ 5 - 0
package-lock.json

@@ -7438,6 +7438,11 @@
       "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
       "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA=="
     },
+    "decimal.js": {
+      "version": "10.4.3",
+      "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
+      "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
+    },
     "decode-uri-component": {
       "version": "0.2.2",
       "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz",

+ 1 - 0
package.json

@@ -52,6 +52,7 @@
     "base-core-lib": "^1.3.16",
     "base-template-lib": "^1.0.7-beta",
     "countup": "^1.8.2",
+    "decimal.js": "^10.4.3",
     "default-passive-events": "^2.0.0",
     "echarts": "^4.2.1",
     "element-china-area-data": "^5.0.2",

+ 4 - 2
src/main.js

@@ -21,8 +21,8 @@ window.$crudCommon = crudCommon;
 import vendors from '@/vendors'
 const { router, store } = vendors
 Vue.config.productionTip = false
-    // import AMap from 'vue-amap';
-    // Vue.use(AMap);
+// import AMap from 'vue-amap';
+// Vue.use(AMap);
 import imgPreview from '@/components/imgPreview'
 Vue.use(imgPreview)
 import echarts from 'echarts';
@@ -43,6 +43,8 @@ Vue.component('ItemWrap', ItemWrap)
 import Echart from './components/echart/index.vue'
 Vue.component('Echart', Echart)
 import '@/utils/jsmpeg.min'
+import { rewriteToFixed } from './utils/index'
+Number.prototype.rewriteToFixed = rewriteToFixed;
 // 初始化vue-amap
 // AMap.initAMapApiLoader({
 //   // 高德key

+ 143 - 110
src/utils/index.js

@@ -2,139 +2,172 @@
  * 获取路径参数
  * @param {*} url
  */
-export function getQueryObject (url) {
-  url = url == null ? window.location.href : url
-  const search = url.substring(url.lastIndexOf('?') + 1)
-  const obj = {}
-  const reg = /([^?&=]+)=([^?&=]*)/g
-  search.replace(reg, (rs, $1, $2) => {
-    const name = decodeURIComponent($1)
-    let val = decodeURIComponent($2)
-    val = String(val)
-    obj[name] = val
-    return rs
-  })
-  return obj
+export function getQueryObject(url) {
+    url = url == null ? window.location.href : url
+    const search = url.substring(url.lastIndexOf('?') + 1)
+    const obj = {}
+    const reg = /([^?&=]+)=([^?&=]*)/g
+    search.replace(reg, (rs, $1, $2) => {
+        const name = decodeURIComponent($1)
+        let val = decodeURIComponent($2)
+        val = String(val)
+        obj[name] = val
+        return rs
+    })
+    return obj
 }
 // 获取全局唯一id
 export function getUuid() {
-  const s = [];
-  const hexDigits = '0123456789abcdef';
-  for (let i = 0; i < 36; i++) {
-    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
-  }
-  s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
-  s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
-  s[8] = '-';
-  s[13] = '-';
-  s[18] = '-';
-  s[23] = '-';
+    const s = [];
+    const hexDigits = '0123456789abcdef';
+    for (let i = 0; i < 36; i++) {
+        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
+    }
+    s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
+    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
+    s[8] = '-';
+    s[13] = '-';
+    s[18] = '-';
+    s[23] = '-';
 
-  const uid = s.join('');
-  return uid;
+    const uid = s.join('');
+    return uid;
 }
 /**
  * @param {Sting} input value
  * @returns {number} output value
  */
-export function byteLength (str) {
-  // returns the byte length of an utf8 string
-  let s = str.length
-  for (var i = str.length - 1; i >= 0; i--) {
-    const code = str.charCodeAt(i)
-    if (code > 0x7f && code <= 0x7ff) s++
-    else if (code > 0x7ff && code <= 0xffff) s += 2
-    if (code >= 0xDC00 && code <= 0xDFFF) i--
-  }
-  return s
+export function byteLength(str) {
+    // returns the byte length of an utf8 string
+    let s = str.length
+    for (var i = str.length - 1; i >= 0; i--) {
+        const code = str.charCodeAt(i)
+        if (code > 0x7f && code <= 0x7ff) s++
+        else if (code > 0x7ff && code <= 0xffff) s += 2
+        if (code >= 0xDC00 && code <= 0xDFFF) i--
+    }
+    return s
 }
 
-export function html2Text (val) {
-  const div = document.createElement('div')
-  div.innerHTML = val
-  return div.textContent || div.innerText
+export function html2Text(val) {
+    const div = document.createElement('div')
+    div.innerHTML = val
+    return div.textContent || div.innerText
 }
 
 
-export function toggleClass (element, className) {
-  if (!element || !className) {
-    return
-  }
-  let classString = element.className
-  const nameIndex = classString.indexOf(className)
-  if (nameIndex === -1) {
-    classString += ' ' + className
-  } else {
-    classString =
-      classString.substr(0, nameIndex) +
-      classString.substr(nameIndex + className.length)
-  }
-  element.className = classString
+export function toggleClass(element, className) {
+    if (!element || !className) {
+        return
+    }
+    let classString = element.className
+    const nameIndex = classString.indexOf(className)
+    if (nameIndex === -1) {
+        classString += ' ' + className
+    } else {
+        classString =
+            classString.substr(0, nameIndex) +
+            classString.substr(nameIndex + className.length)
+    }
+    element.className = classString
 }
 
-export function debounce (func, wait, immediate) {
-  let timeout, args, context, timestamp, result
+export function debounce(func, wait, immediate) {
+    let timeout, args, context, timestamp, result
 
-  const later = function () {
-    // 据上一次触发时间间隔
-    const last = +new Date() - timestamp
+    const later = function () {
+        // 据上一次触发时间间隔
+        const last = +new Date() - timestamp
 
-    // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
-    if (last < wait && last > 0) {
-      timeout = setTimeout(later, wait - last)
-    } else {
-      timeout = null
-      // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
-      if (!immediate) {
-        result = func.apply(context, args)
-        if (!timeout) context = args = null
-      }
+        // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
+        if (last < wait && last > 0) {
+            timeout = setTimeout(later, wait - last)
+        } else {
+            timeout = null
+            // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
+            if (!immediate) {
+                result = func.apply(context, args)
+                if (!timeout) context = args = null
+            }
+        }
     }
-  }
 
-  return function (...args) {
-    context = this
-    timestamp = +new Date()
-    const callNow = immediate && !timeout
-    // 如果延时不存在,重新设定延时
-    if (!timeout) timeout = setTimeout(later, wait)
-    if (callNow) {
-      result = func.apply(context, args)
-      context = args = null
-    }
+    return function (...args) {
+        context = this
+        timestamp = +new Date()
+        const callNow = immediate && !timeout
+        // 如果延时不存在,重新设定延时
+        if (!timeout) timeout = setTimeout(later, wait)
+        if (callNow) {
+            result = func.apply(context, args)
+            context = args = null
+        }
 
-    return result
-  }
+        return result
+    }
 }
 
 export function formatTime(time, fmt) {
-  if (!time) return '';
-  else {
-    const date = new Date(time);
-    const o = {
-      'M+': date.getMonth() + 1,
-      'd+': date.getDate(),
-      'H+': date.getHours(),
-      'm+': date.getMinutes(),
-      's+': date.getSeconds(),
-      'q+': Math.floor((date.getMonth() + 3) / 3),
-      S: date.getMilliseconds(),
-    };
-    if (/(y+)/.test(fmt))
-      fmt = fmt.replace(
-        RegExp.$1,
-        (date.getFullYear() + '').substr(4 - RegExp.$1.length)
-      );
-    for (const k in o) {
-      if (new RegExp('(' + k + ')').test(fmt)) {
-        fmt = fmt.replace(
-          RegExp.$1,
-          RegExp.$1.length === 1
-            ? o[k]
-            : ('00' + o[k]).substr(('' + o[k]).length)
-        );
-      }
+    if (!time) return '';
+    else {
+        const date = new Date(time);
+        const o = {
+            'M+': date.getMonth() + 1,
+            'd+': date.getDate(),
+            'H+': date.getHours(),
+            'm+': date.getMinutes(),
+            's+': date.getSeconds(),
+            'q+': Math.floor((date.getMonth() + 3) / 3),
+            S: date.getMilliseconds(),
+        };
+        if (/(y+)/.test(fmt))
+            fmt = fmt.replace(
+                RegExp.$1,
+                (date.getFullYear() + '').substr(4 - RegExp.$1.length)
+            );
+        for (const k in o) {
+            if (new RegExp('(' + k + ')').test(fmt)) {
+                fmt = fmt.replace(
+                    RegExp.$1,
+                    RegExp.$1.length === 1
+                        ? o[k]
+                        : ('00' + o[k]).substr(('' + o[k]).length)
+                );
+            }
+        }
+        return fmt;
     }
-    return fmt;
-  }
 }
+// 重写toFixed,为了不替代原生属性toFixed,重新命名rewriteToFixed
+// 参数d表示要保留多少位小数
+export function rewriteToFixed(d) {
+    var s = this + "";
+    if (!d) d = 0;
+    if (s.indexOf(".") == -1) s += ".";
+    s += new Array(d + 1).join("0");
+    let test = new RegExp(
+        "^(-|\\+)?(\\d+(\\.\\d{0," + (d + 1) + "})?)\\d*$"
+    ).exec(s);
+    if (test) {
+        var s = "0" + test[2],
+            pm = test[1] ? test[1] : "",
+            a = test[3].length,
+            b = true;
+        if (a == d + 2) {
+            a = s.match(/\d/g);
+            if (parseInt(a[a.length - 1]) > 4) {
+                for (var i = a.length - 2; i >= 0; i--) {
+                    a[i] = parseInt(a[i]) + 1;
+                    if (a[i] == 10) {
+                        a[i] = 0;
+                        b = i != 1;
+                    } else break;
+                }
+            }
+            s = a.join("").replace(new RegExp("(\\d+)(\\d{" + d + "})\\d$"), "$1.$2");
+        }
+        if (b) s = s.substring(1);
+        return (pm + s).replace(/\.$/, "");
+    }
+    return this + "";
+}

+ 289 - 289
src/utils/util.js

@@ -1,5 +1,5 @@
 import {
-  validatenull
+    validatenull
 } from './validate'
 /**
  * 动态插入css
@@ -7,50 +7,50 @@ import {
 
 
 export const loadStyle = (url, callback) => {
-  if (!isInclude(url)) {
-    const link = document.createElement('link');
-    link.type = 'text/css';
-    link.rel = 'stylesheet';
-    link.href = url;
-    const head = document.getElementsByTagName('head')[0];
-    addCallback(link, callback)
-    head.appendChild(link);
-  } else {
-    callback && callback()
-  }
+    if (!isInclude(url)) {
+        const link = document.createElement('link');
+        link.type = 'text/css';
+        link.rel = 'stylesheet';
+        link.href = url;
+        const head = document.getElementsByTagName('head')[0];
+        addCallback(link, callback)
+        head.appendChild(link);
+    } else {
+        callback && callback()
+    }
 };
 
-export const allRoles=()=>{
-  var currectRole={
-    roleName:'',
-    roles:[]
-  }
-  var roles=JSON.parse(localStorage.getItem('winseaview-userInfo')).content.roles
-  currectRole.roles=roles
-  for (let i = 0; i < roles.length; i++) {
-    if(currectRole.roleName==''){
-      currectRole.roleName=roles[i].roleName
-    }else{
-      currectRole.roleName=currectRole.roleName+','+roles[i].roleName
+export const allRoles = () => {
+    var currectRole = {
+        roleName: '',
+        roles: []
     }
-  }
-  return currectRole
-  console.log(roles)
+    var roles = JSON.parse(localStorage.getItem('winseaview-userInfo')).content.roles
+    currectRole.roles = roles
+    for (let i = 0; i < roles.length; i++) {
+        if (currectRole.roleName == '') {
+            currectRole.roleName = roles[i].roleName
+        } else {
+            currectRole.roleName = currectRole.roleName + ',' + roles[i].roleName
+        }
+    }
+    return currectRole
+    console.log(roles)
 };
 /**
  * 动态插入js
  */
 export const loadScript = (url, callback) => {
-  if (!isInclude(url)) {
-    const link = document.createElement('script');
-    link.src = url;
-    link.type = 'text/javascript'
-    const head = document.getElementsByTagName('head')[0];
-    addCallback(link, callback)
-    head.appendChild(link);
-  } else {
-    callback && callback()
-  }
+    if (!isInclude(url)) {
+        const link = document.createElement('script');
+        link.src = url;
+        link.type = 'text/javascript'
+        const head = document.getElementsByTagName('head')[0];
+        addCallback(link, callback)
+        head.appendChild(link);
+    } else {
+        callback && callback()
+    }
 };
 
 /**
@@ -58,120 +58,120 @@ export const loadScript = (url, callback) => {
  * @param {*} name
  */
 const isInclude = (name) => {
-  var js = /js$/i.test(name);
-  var es = document.getElementsByTagName(js ? 'script' : 'link');
-  for (var i = 0; i < es.length; i++)
-    if (es[i][js ? 'src' : 'href'].indexOf(name) != -1) return true;
-  return false;
+    var js = /js$/i.test(name);
+    var es = document.getElementsByTagName(js ? 'script' : 'link');
+    for (var i = 0; i < es.length; i++)
+        if (es[i][js ? 'src' : 'href'].indexOf(name) != -1) return true;
+    return false;
 }
 const addCallback = (obj, callback) => {
-  if (obj.addEventListener) {
-    obj.addEventListener('load', function() {
-      callback && callback();
-    }, false);
-  } else if (obj.attachEvent) {
-    obj.attachEvent('onreadystatechange', function() {
-      var target = window.event.srcElement;
-      if (target.readyState == 'loaded') {
-        callback && callback();
-      }
-    });
-  }
+    if (obj.addEventListener) {
+        obj.addEventListener('load', function () {
+            callback && callback();
+        }, false);
+    } else if (obj.attachEvent) {
+        obj.attachEvent('onreadystatechange', function () {
+            var target = window.event.srcElement;
+            if (target.readyState == 'loaded') {
+                callback && callback();
+            }
+        });
+    }
 }
 
 
 
 //表单序列化
 export const serialize = data => {
-  let list = [];
-  Object.keys(data).forEach(ele => {
-    list.push(`${ele}=${data[ele]}`)
-  })
-  return list.join('&');
+    let list = [];
+    Object.keys(data).forEach(ele => {
+        list.push(`${ele}=${data[ele]}`)
+    })
+    return list.join('&');
 };
 export const getObjType = obj => {
-  var toString = Object.prototype.toString;
-  var map = {
-    '[object Boolean]': 'boolean',
-    '[object Number]': 'number',
-    '[object String]': 'string',
-    '[object Function]': 'function',
-    '[object Array]': 'array',
-    '[object Date]': 'date',
-    '[object RegExp]': 'regExp',
-    '[object Undefined]': 'undefined',
-    '[object Null]': 'null',
-    '[object Object]': 'object'
-  };
-  if (obj instanceof Element) {
-    return 'element';
-  }
-  return map[toString.call(obj)];
+    var toString = Object.prototype.toString;
+    var map = {
+        '[object Boolean]': 'boolean',
+        '[object Number]': 'number',
+        '[object String]': 'string',
+        '[object Function]': 'function',
+        '[object Array]': 'array',
+        '[object Date]': 'date',
+        '[object RegExp]': 'regExp',
+        '[object Undefined]': 'undefined',
+        '[object Null]': 'null',
+        '[object Object]': 'object'
+    };
+    if (obj instanceof Element) {
+        return 'element';
+    }
+    return map[toString.call(obj)];
 };
 /**
  * 对象深拷贝
  */
 export const deepClone = data => {
-  var type = getObjType(data);
-  var obj;
-  if (type === 'array') {
-    obj = [];
-  } else if (type === 'object') {
-    obj = {};
-  } else {
-    //不再具有下一层次
-    return data;
-  }
-  if (type === 'array') {
-    for (var i = 0, len = data.length; i < len; i++) {
-      obj.push(deepClone(data[i]));
+    var type = getObjType(data);
+    var obj;
+    if (type === 'array') {
+        obj = [];
+    } else if (type === 'object') {
+        obj = {};
+    } else {
+        //不再具有下一层次
+        return data;
     }
-  } else if (type === 'object') {
-    for (var key in data) {
-      obj[key] = deepClone(data[key]);
+    if (type === 'array') {
+        for (var i = 0, len = data.length; i < len; i++) {
+            obj.push(deepClone(data[i]));
+        }
+    } else if (type === 'object') {
+        for (var key in data) {
+            obj[key] = deepClone(data[key]);
+        }
     }
-  }
-  return obj;
+    return obj;
 };
 /**
  * 设置灰度模式
  */
 export const toggleGrayMode = (status) => {
-  if (status) {
-    document.body.className = document.body.className + ' grayMode';
-  } else {
-    document.body.className = document.body.className.replace(' grayMode', '');
-  }
+    if (status) {
+        document.body.className = document.body.className + ' grayMode';
+    } else {
+        document.body.className = document.body.className.replace(' grayMode', '');
+    }
 };
 /**
  * 设置主题
  */
 export const setTheme = (name) => {
-  document.body.className = name;
+    document.body.className = name;
 }
 
 /**
  * 加密处理
  */
 export const encryption = (params) => {
-  let {
-    data,
-    type,
-    param,
-    key
-  } = params;
-  let result = JSON.parse(JSON.stringify(data));
-  if (type == 'Base64') {
-    param.forEach(ele => {
-      result[ele] = btoa(result[ele]);
-    })
-  } else if (type == 'Aes') {
-    param.forEach(ele => {
-      result[ele] = window.CryptoJS.AES.encrypt(result[ele], key).toString();
-    })
+    let {
+        data,
+        type,
+        param,
+        key
+    } = params;
+    let result = JSON.parse(JSON.stringify(data));
+    if (type == 'Base64') {
+        param.forEach(ele => {
+            result[ele] = btoa(result[ele]);
+        })
+    } else if (type == 'Aes') {
+        param.forEach(ele => {
+            result[ele] = window.CryptoJS.AES.encrypt(result[ele], key).toString();
+        })
 
-  }
-  return result;
+    }
+    return result;
 };
 
 
@@ -179,267 +179,267 @@ export const encryption = (params) => {
  * 浏览器判断是否全屏
  */
 export const fullscreenToggel = () => {
-  if (fullscreenEnable()) {
-    exitFullScreen();
-  } else {
-    reqFullScreen();
-  }
+    if (fullscreenEnable()) {
+        exitFullScreen();
+    } else {
+        reqFullScreen();
+    }
 };
 /**
  * esc监听全屏
  */
 export const listenfullscreen = (callback) => {
-  function listen() {
-    callback()
-  }
-  document.addEventListener('fullscreenchange', function() {
-    listen();
-  });
-  document.addEventListener('mozfullscreenchange', function() {
-    listen();
-  });
-  document.addEventListener('webkitfullscreenchange', function() {
-    listen();
-  });
-  document.addEventListener('msfullscreenchange', function() {
-    listen();
-  });
+    function listen() {
+        callback()
+    }
+    document.addEventListener('fullscreenchange', function () {
+        listen();
+    });
+    document.addEventListener('mozfullscreenchange', function () {
+        listen();
+    });
+    document.addEventListener('webkitfullscreenchange', function () {
+        listen();
+    });
+    document.addEventListener('msfullscreenchange', function () {
+        listen();
+    });
 };
 /**
  * 浏览器判断是否全屏
  */
 export const fullscreenEnable = () => {
-  var isFullscreen = document.isFullScreen || document.mozIsFullScreen || document.webkitIsFullScreen
-  return isFullscreen;
+    var isFullscreen = document.isFullScreen || document.mozIsFullScreen || document.webkitIsFullScreen
+    return isFullscreen;
 }
 
 /**
  * 浏览器全屏
  */
 export const reqFullScreen = () => {
-  let _documentDom = document.getElementById('index')
-  if (_documentDom.requestFullScreen) {
-    _documentDom.requestFullScreen();
-  } else if (_documentDom.webkitRequestFullScreen) {
-    _documentDom.webkitRequestFullScreen();
-  } else if (_documentDom.mozRequestFullScreen) {
-    _documentDom.mozRequestFullScreen();
-  }
-  // if (document.documentElement.requestFullScreen) {
-  //   document.documentElement.requestFullScreen();
-  // } else if (document.documentElement.webkitRequestFullScreen) {
-  //   document.documentElement.webkitRequestFullScreen();
-  // } else if (document.documentElement.mozRequestFullScreen) {
-  //   document.documentElement.mozRequestFullScreen();
-  // }
+    let _documentDom = document.getElementById('index')
+    if (_documentDom.requestFullScreen) {
+        _documentDom.requestFullScreen();
+    } else if (_documentDom.webkitRequestFullScreen) {
+        _documentDom.webkitRequestFullScreen();
+    } else if (_documentDom.mozRequestFullScreen) {
+        _documentDom.mozRequestFullScreen();
+    }
+    // if (document.documentElement.requestFullScreen) {
+    //   document.documentElement.requestFullScreen();
+    // } else if (document.documentElement.webkitRequestFullScreen) {
+    //   document.documentElement.webkitRequestFullScreen();
+    // } else if (document.documentElement.mozRequestFullScreen) {
+    //   document.documentElement.mozRequestFullScreen();
+    // }
 };
 /**
  * 浏览器退出全屏
  */
 export const exitFullScreen = () => {
-  let _documentDom = document.getElementById('contentView')
+    let _documentDom = document.getElementById('contentView')
     if (_documentDom.requestFullScreen) {
-    document.exitFullScreen();
-  } else if (_documentDom.webkitRequestFullScreen) {
-    document.webkitCancelFullScreen();
-  } else if (_documentDom.mozRequestFullScreen) {
-    document.mozCancelFullScreen();
-  }
-  // if (document.documentElement.requestFullScreen) {
-  //   document.exitFullScreen();
-  // } else if (document.documentElement.webkitRequestFullScreen) {
-  //   document.webkitCancelFullScreen();
-  // } else if (document.documentElement.mozRequestFullScreen) {
-  //   document.mozCancelFullScreen();
-  // }
+        document.exitFullScreen();
+    } else if (_documentDom.webkitRequestFullScreen) {
+        document.webkitCancelFullScreen();
+    } else if (_documentDom.mozRequestFullScreen) {
+        document.mozCancelFullScreen();
+    }
+    // if (document.documentElement.requestFullScreen) {
+    //   document.exitFullScreen();
+    // } else if (document.documentElement.webkitRequestFullScreen) {
+    //   document.webkitCancelFullScreen();
+    // } else if (document.documentElement.mozRequestFullScreen) {
+    //   document.mozCancelFullScreen();
+    // }
 };
 /**
  * 递归寻找子类的父类
  */
 
 export const findParent = (menu, id) => {
-  for (let i = 0; i < menu.length; i++) {
-    if (menu[i].children.length != 0) {
-      for (let j = 0; j < menu[i].children.length; j++) {
-        if (menu[i].children[j].id == id) {
-          return menu[i];
-        } else {
-          if (menu[i].children[j].children.length != 0) {
-            return findParent(menu[i].children[j].children, id);
-          }
+    for (let i = 0; i < menu.length; i++) {
+        if (menu[i].children.length != 0) {
+            for (let j = 0; j < menu[i].children.length; j++) {
+                if (menu[i].children[j].id == id) {
+                    return menu[i];
+                } else {
+                    if (menu[i].children[j].children.length != 0) {
+                        return findParent(menu[i].children[j].children, id);
+                    }
+                }
+            }
         }
-      }
     }
-  }
 };
 
 /**
  * 判断路由是否相等
  */
 export const diff = (obj1, obj2) => {
-  delete obj1.close;
-  var o1 = obj1 instanceof Object;
-  var o2 = obj2 instanceof Object;
-  if (!o1 || !o2) {
-    /*  判断不是对象  */
-    return obj1 === obj2;
-  }
+    delete obj1.close;
+    var o1 = obj1 instanceof Object;
+    var o2 = obj2 instanceof Object;
+    if (!o1 || !o2) {
+        /*  判断不是对象  */
+        return obj1 === obj2;
+    }
 
-  if (Object.keys(obj1).length !== Object.keys(obj2).length) {
-    return false;
-    //Object.keys() 返回一个由对象的自身可枚举属性(key值)组成的数组,例如:数组返回下表:let arr = ["a", "b", "c"];console.log(Object.keys(arr))->0,1,2;
-  }
+    if (Object.keys(obj1).length !== Object.keys(obj2).length) {
+        return false;
+        //Object.keys() 返回一个由对象的自身可枚举属性(key值)组成的数组,例如:数组返回下表:let arr = ["a", "b", "c"];console.log(Object.keys(arr))->0,1,2;
+    }
 
-  for (var attr in obj1) {
-    var t1 = obj1[attr] instanceof Object;
-    var t2 = obj2[attr] instanceof Object;
-    if (t1 && t2) {
-      return diff(obj1[attr], obj2[attr]);
-    } else if (obj1[attr] !== obj2[attr]) {
-      return false;
+    for (var attr in obj1) {
+        var t1 = obj1[attr] instanceof Object;
+        var t2 = obj2[attr] instanceof Object;
+        if (t1 && t2) {
+            return diff(obj1[attr], obj2[attr]);
+        } else if (obj1[attr] !== obj2[attr]) {
+            return false;
+        }
     }
-  }
-  return true;
+    return true;
 }
 /**
  * 根据字典的value显示label
  */
 export const findByvalue = (dic, value) => {
-  let result = '';
-  if (validatenull(dic)) return value;
-  if (typeof(value) == 'string' || typeof(value) == 'number' || typeof(value) == 'boolean') {
-    let index = 0;
-    index = findArray(dic, value);
-    if (index != -1) {
-      result = dic[index].label;
-    } else {
-      result = value;
+    let result = '';
+    if (validatenull(dic)) return value;
+    if (typeof (value) == 'string' || typeof (value) == 'number' || typeof (value) == 'boolean') {
+        let index = 0;
+        index = findArray(dic, value);
+        if (index != -1) {
+            result = dic[index].label;
+        } else {
+            result = value;
+        }
+    } else if (value instanceof Array) {
+        result = [];
+        let index = 0;
+        value.forEach(ele => {
+            index = findArray(dic, ele);
+            if (index != -1) {
+                result.push(dic[index].label);
+            } else {
+                result.push(value);
+            }
+        });
+        result = result.toString();
     }
-  } else if (value instanceof Array) {
-    result = [];
-    let index = 0;
-    value.forEach(ele => {
-      index = findArray(dic, ele);
-      if (index != -1) {
-        result.push(dic[index].label);
-      } else {
-        result.push(value);
-      }
-    });
-    result = result.toString();
-  }
-  return result;
+    return result;
 };
 /**
  * 根据字典的value查找对应的index
  */
 export const findArray = (dic, value) => {
-  for (let i = 0; i < dic.length; i++) {
-    if (dic[i].value == value) {
-      return i;
+    for (let i = 0; i < dic.length; i++) {
+        if (dic[i].value == value) {
+            return i;
+        }
     }
-  }
-  return -1;
+    return -1;
 };
 /**
  * 生成随机len位数字
  */
 export const randomLenNum = (len, date) => {
-  let random = '';
-  random = Math.ceil(Math.random() * 100000000000000).toString().substr(0, len ? len : 4);
-  if (date) random = random + Date.now();
-  return random;
+    let random = '';
+    random = Math.ceil(Math.random() * 100000000000000).toString().substr(0, len ? len : 4);
+    if (date) random = random + Date.now();
+    return random;
 };
 /**
  * 打开小窗口
  */
 export const openWindow = (url, title, w, h) => {
-  // Fixes dual-screen position                            Most browsers       Firefox
-  const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left
-  const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top
+    // Fixes dual-screen position                            Most browsers       Firefox
+    const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left
+    const dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top
 
-  const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document
-    .documentElement.clientWidth : screen.width
-  const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document
-    .documentElement.clientHeight : screen.height
+    const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document
+        .documentElement.clientWidth : screen.width
+    const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document
+        .documentElement.clientHeight : screen.height
 
-  const left = ((width / 2) - (w / 2)) + dualScreenLeft
-  const top = ((height / 2) - (h / 2)) + dualScreenTop
-  const newWindow = window.open(url, title,
-    'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' +
-    w + ', height=' + h + ', top=' + top + ', left=' + left)
+    const left = ((width / 2) - (w / 2)) + dualScreenLeft
+    const top = ((height / 2) - (h / 2)) + dualScreenTop
+    const newWindow = window.open(url, title,
+        'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' +
+        w + ', height=' + h + ', top=' + top + ', left=' + left)
 
-  // Puts focus on the newWindow
-  if (window.focus) {
-    newWindow.focus()
-  }
+    // Puts focus on the newWindow
+    if (window.focus) {
+        newWindow.focus()
+    }
 }
 
 
 // 路由处理 开始
 export const isURL = (s) => {
-  return /^http[s]?:\/\/.*/.test(s);
+    return /^http[s]?:\/\/.*/.test(s);
 }
 export const objToform = (obj) => {
-  let result = [];
-  Object.keys(obj).forEach(ele => {
-    result.push(`${ele}=${obj[ele]}`);
-  });
-  return result.join('&');
+    let result = [];
+    Object.keys(obj).forEach(ele => {
+        result.push(`${ele}=${obj[ele]}`);
+    });
+    return result.join('&');
 }
 // 设置标题
 export const setTitle = title => {
-  const defaultTitle = this.$t('title');
-  title = title ? `${title}-${defaultTitle}` : defaultTitle;
-  document.title = title;
+    const defaultTitle = this.$t('title');
+    title = title ? `${title}-${defaultTitle}` : defaultTitle;
+    document.title = title;
 }
 export const closeTag = value => {
-  let tag = value || this.$store.getters.tag;
-  if (typeof value === 'string') {
-    tag = this.$store.getters.tagList.filter(ele => ele.value === value)[0];
-  }
-  this.$store.commit('DEL_TAG', tag);
+    let tag = value || this.$store.getters.tag;
+    if (typeof value === 'string') {
+        tag = this.$store.getters.tagList.filter(ele => ele.value === value)[0];
+    }
+    this.$store.commit('DEL_TAG', tag);
 }
 export const generateTitle = (title, key, _this) => {
-  const hasKey = _this.$te('route.' + (key || title));
-  if (hasKey) {
-    const translatedTitle = _this.$t('route.' + (key || title))
-    return translatedTitle;
+    const hasKey = _this.$te('route.' + (key || title));
+    if (hasKey) {
+        const translatedTitle = _this.$t('route.' + (key || title))
+        return translatedTitle;
 
-  }
-  console.log(title)
-  return title;
+    }
+    console.log(title)
+    return title;
 }
 //处理路由
 export const getPath = (params) => {
-  let {
-    src
-  } = params;
-  let result = src || '/';
-  if (src.includes('http') || src.includes('https')) {
-    result = `/myiframe/urlPath?${objToform(params)}`;
-  }
-  return result;
+    let {
+        src
+    } = params;
+    let result = src || '/';
+    if (src.includes('http') || src.includes('https')) {
+        result = `/myiframe/urlPath?${objToform(params)}`;
+    }
+    return result;
 }
 
 //设置路由值
 export const getValue = (route) => {
-  let value = '';
-  if (route.query.src) {
-    value = route.query.src;
-  } else {
-    value = route.path;
-  }
-  return value;
+    let value = '';
+    if (route.query.src) {
+        value = route.query.src;
+    } else {
+        value = route.path;
+    }
+    return value;
 }
 // 路由处理 结束
 
 // null赋值空字符串
 export const nullToString = (obj) => {
-  Object.keys(obj).forEach(function(key) {
-    console.log(key, obj[key])
-    if (obj[key] === null) {
-      obj[key] = ''
-    }
-  })
+    Object.keys(obj).forEach(function (key) {
+        console.log(key, obj[key])
+        if (obj[key] === null) {
+            obj[key] = ''
+        }
+    })
 }

+ 77 - 39
src/views/houseSelfCollect/settlement.vue

@@ -416,10 +416,7 @@
               <ws-input
                 type="number"
                 @mousewheel.native.prevent
-                :v-model="
-                  paymentList.qualityInspectionManagement.waterContent -
-                    ganwater
-                "
+                v-model="paymentList.diaoWater"
                 placeholder="请输入掉水"
                 maxlength="100"
                 size="small"
@@ -987,6 +984,7 @@
   </div>
 </template>
 <script>
+import Decimal from 'decimal.js'
 import {
   getpaymentexamine,
   postpaymentedit,
@@ -1004,12 +1002,13 @@ export default {
     return {
       paymentList: {
         qualityInspectionManagement: {
-          waterContent: '',
+          waterContent: 0,
           buckleWeightRatio: 0,
           grainMoney: 0,
           waterMin: 0
         },
-        unitDeduction: 0
+        unitDeduction: 0,
+        diaoWater: 0
       },
       ganwater: 15,
       disabled: false,
@@ -1219,7 +1218,7 @@ export default {
             this.paymentList.unloadDeduction = (
               (Number(this.paymentList.netWeight) / 1000) *
               5
-            ).toFixed(0)
+            ).rewriteToFixed(0)
           }
           let compIdTmp = localStorage.getItem('ws-pf_compId')
           if (this.paymentList.warehouseName == '先锋新屯分库') {
@@ -1236,34 +1235,61 @@ export default {
               this.paymentList.buckleWeightRatio = 1.2
             }
             this.ganwater = 14.5
-            this.paymentList.tidalGrainPrice = this.paymentList.tidalGrainPrice.toFixed(
+            this.paymentList.tidalGrainPrice = this.paymentList.tidalGrainPrice.rewriteToFixed(
               4
             )
             if (this.paymentList.qualityInspectionManagement.paramType == '2') {
-              this.paymentList.qualityInspectionManagement.weightDeduction =
-                (this.paymentList.qualityInspectionManagement.waterContent -
-                  this.ganwater) *
-                this.paymentList.buckleWeightRatio
-              this.paymentList.qualityInspectionManagement.weightDeduction = this.paymentList.qualityInspectionManagement.weightDeduction.toFixed(
-                5
+              this.paymentList.qualityInspectionManagement.weightDeduction = new Decimal(
+                this.paymentList.qualityInspectionManagement.waterContent
               )
-              this.paymentList.base =
-                (100 -
-                  this.paymentList.qualityInspectionManagement
-                    .weightDeduction) /
-                100
-              this.paymentList.base = this.paymentList.base.toFixed(5)
+                .sub(new Decimal(this.ganwater))
+                .mul(new Decimal(this.paymentList.buckleWeightRatio))
+                .toNumber()
+                .rewriteToFixed(2)
+              this.paymentList.base = new Decimal(100)
+                .sub(
+                  new Decimal(
+                    this.paymentList.qualityInspectionManagement.weightDeduction
+                  )
+                )
+                .div(new Decimal(100))
+                .toNumber()
+                .rewriteToFixed(3)
               if (this.paymentList.type == '潮粮') {
                 if (this.paymentList.base > 1) {
                   this.paymentList.base = 1
                 }
-                this.paymentList.pureWeight =
-                  this.paymentList.base *
-                  this.paymentList.weighingManagement.netWeight
-                this.paymentList.pureWeight = Math.round(
-                  this.paymentList.pureWeight
-                )
+                this.paymentList.pureWeight = new Decimal(this.paymentList.base)
+                  .mul(
+                    new Decimal(this.paymentList.weighingManagement.netWeight)
+                  )
+                  .toNumber()
+                  .rewriteToFixed(0)
               }
+              //   this.paymentList.qualityInspectionManagement.weightDeduction =
+              //     (this.paymentList.qualityInspectionManagement.waterContent -
+              //       this.ganwater) *
+              //     this.paymentList.buckleWeightRatio
+              //   this.paymentList.qualityInspectionManagement.weightDeduction = this.paymentList.qualityInspectionManagement.weightDeduction.rewriteToFixed(
+              //     5
+              //   )
+              //   this.paymentList.base =
+              //     (100 -
+              //       this.paymentList.qualityInspectionManagement
+              //         .weightDeduction) /
+              //     100
+              //   this.paymentList.base = this.paymentList.base.rewriteToFixed(5)
+              //   if (this.paymentList.type == '潮粮') {
+              //     if (this.paymentList.base > 1) {
+              //       this.paymentList.base = 1
+              //     }
+              //     this.paymentList.pureWeight =
+              //       this.paymentList.base *
+              //       this.paymentList.weighingManagement.netWeight
+              //     this.paymentList.pureWeight = Math.round(
+              //       this.paymentList.pureWeight
+              //     )
+              //   }
             } else {
               if (this.paymentList.type == '潮粮') {
                 let paramtmp = (100 - this.paymentList.param) / 100
@@ -1299,7 +1325,7 @@ export default {
                   this.paymentList.qualityInspectionManagement.waterContent) *
                   0.01
             }
-            this.paymentList.tidalGrainPrice = this.paymentList.tidalGrainPrice.toFixed(
+            this.paymentList.tidalGrainPrice = this.paymentList.tidalGrainPrice.rewriteToFixed(
               4
             )
             if (this.paymentList.qualityInspectionManagement.paramType == '2') {
@@ -1307,7 +1333,7 @@ export default {
                 (this.paymentList.qualityInspectionManagement.waterContent -
                   15) *
                 this.paymentList.buckleWeightRatio
-              this.paymentList.qualityInspectionManagement.weightDeduction = this.paymentList.qualityInspectionManagement.weightDeduction.toFixed(
+              this.paymentList.qualityInspectionManagement.weightDeduction = this.paymentList.qualityInspectionManagement.weightDeduction.rewriteToFixed(
                 2
               )
               this.paymentList.base =
@@ -1315,7 +1341,7 @@ export default {
                   this.paymentList.qualityInspectionManagement
                     .weightDeduction) /
                 100
-              this.paymentList.base = this.paymentList.base.toFixed(3)
+              this.paymentList.base = this.paymentList.base.rewriteToFixed(3)
               if (this.paymentList.type == '潮粮') {
                 if (this.paymentList.base > 1) {
                   this.paymentList.base = 1
@@ -1346,6 +1372,14 @@ export default {
                 this.paymentList.base
             }
           }
+          //   this.diaoWater =
+          //     this.paymentList.qualityInspectionManagement.waterContent -
+          //     this.ganwater
+          this.paymentList.diaoWater = new Decimal(
+            this.paymentList.qualityInspectionManagement.waterContent
+          )
+            .sub(new Decimal(this.ganwater))
+            .toNumber()
           this.grainMoney()
         })
     },
@@ -1374,7 +1408,7 @@ export default {
         this.paymentList.solidGrainPrice = (
           Number(this.paymentList.grainMoney) /
           Number(this.paymentList.pureWeight)
-        ).toFixed(4)
+        ).rewriteToFixed(4)
         this.paymentList.calculationPayable =
           Number(this.paymentList.grainMoney) +
           Number(this.paymentList.weighingSubsidy) +
@@ -1386,7 +1420,7 @@ export default {
           Number(this.paymentList.unloadDeduction) -
           Number(this.paymentList.otherDeduction) -
           Number(this.paymentList.qualityDeduction)
-        this.paymentList.calculationPayable = this.paymentList.calculationPayable.toFixed(
+        this.paymentList.calculationPayable = this.paymentList.calculationPayable.rewriteToFixed(
           2
         )
         this.paymentList.actualPayment = this.paymentList.calculationPayable
@@ -1399,7 +1433,7 @@ export default {
         this.paymentList.solidGrainPrice = (
           Number(this.paymentList.grainMoney) /
           Number(this.paymentList.pureWeight)
-        ).toFixed(4)
+        ).rewriteToFixed(4)
         this.paymentList.calculationPayable =
           Number(this.paymentList.grainMoney) +
           Number(this.paymentList.weighingSubsidy) +
@@ -1411,7 +1445,7 @@ export default {
           Number(this.paymentList.unloadDeduction) -
           Number(this.paymentList.otherDeduction) -
           Number(this.paymentList.qualityDeduction)
-        this.paymentList.calculationPayable = this.paymentList.calculationPayable.toFixed(
+        this.paymentList.calculationPayable = this.paymentList.calculationPayable.rewriteToFixed(
           2
         )
 
@@ -1433,13 +1467,15 @@ export default {
           Number(this.paymentList.unloadDeduction) -
           Number(this.paymentList.otherDeduction) -
           Number(this.paymentList.qualityDeduction)
-        this.paymentList.calculationPayable = this.paymentList.calculationPayable.toFixed(
+        this.paymentList.calculationPayable = this.paymentList.calculationPayable.rewriteToFixed(
           2
         )
         this.paymentList.actualPayment = this.paymentList.calculationPayable
         this.actualPayment(this.paymentList.actualPayment)
       }
-      this.paymentList.grainMoney = this.paymentList.grainMoney.toFixed(2)
+      this.paymentList.grainMoney = this.paymentList.grainMoney.rewriteToFixed(
+        2
+      )
     },
     /**
      * 将金额数字转为汉字大写
@@ -1722,13 +1758,13 @@ export default {
         this.paymentList.qualityInspectionManagement.weightDeduction =
           (this.paymentList.qualityInspectionManagement.waterContent - 15) *
           this.paymentList.buckleWeightRatio
-        this.paymentList.qualityInspectionManagement.weightDeduction = this.paymentList.qualityInspectionManagement.weightDeduction.toFixed(
+        this.paymentList.qualityInspectionManagement.weightDeduction = this.paymentList.qualityInspectionManagement.weightDeduction.rewriteToFixed(
           2
         )
         this.paymentList.base =
           (100 - this.paymentList.qualityInspectionManagement.weightDeduction) /
           100
-        this.paymentList.base = this.paymentList.base.toFixed(3)
+        this.paymentList.base = this.paymentList.base.rewriteToFixed(3)
         if (this.paymentList.base > 1) {
           this.paymentList.base = 1
         }
@@ -1737,8 +1773,10 @@ export default {
         this.paymentList.solidGrainPrice = (
           Number(this.paymentList.grainMoney) /
           Number(this.paymentList.pureWeight)
-        ).toFixed(4)
-        this.paymentList.pureWeight = this.paymentList.pureWeight.toFixed(2)
+        ).rewriteToFixed(4)
+        this.paymentList.pureWeight = this.paymentList.pureWeight.rewriteToFixed(
+          2
+        )
       } else {
         this.$message({
           message: '扣重比输入错误',

+ 6 - 5
src/views/warehousenew/warehouseManagementList.vue

@@ -833,14 +833,15 @@ export default {
         this.headerText = '导出记录'
       } else if (index == 2) {
         this.headerText = '打印记录'
-        let date = new Date()
-        var year = date.getFullYear()
-        var month = date.getMonth() + 1
-        var strDate = date.getDate() + 1
+        let now = new Date()
+        let tomorrow = new Date(now.getTime() + 24 * 60 * 60 * 1000)
+        var year = tomorrow.getFullYear()
+        var month = tomorrow.getMonth() + 1
+        var strDate = tomorrow.getDate()
         if (strDate < 10) {
           strDate = '0' + strDate
         }
-        var pastdate = new Date(date.getTime())
+        var pastdate = new Date()
         this.StartDate =
           pastdate.getFullYear() +
           '-' +