From 401524fb5661d57ffb2229d683fe4de85b65fd1c Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期四, 31 八月 2023 17:54:24 +0800
Subject: [PATCH] 生产管理看板+删不需要的文件

---
 src/scripts/util.js |  111 +++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 91 insertions(+), 20 deletions(-)

diff --git a/src/scripts/util.js b/src/scripts/util.js
index 19cd19d..b5e737e 100644
--- a/src/scripts/util.js
+++ b/src/scripts/util.js
@@ -3,10 +3,23 @@
   return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
 }
 const guid = () => {
-  return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
+  return (
+    S4() +
+    S4() +
+    '-' +
+    S4() +
+    '-' +
+    S4() +
+    '-' +
+    S4() +
+    '-' +
+    S4() +
+    S4() +
+    S4()
+  )
 }
 /* http 浼犲弬鏂规硶json2url, json2path, json2formData, */
-const json2url = (json) => {
+const json2url = json => {
   if (!json) {
     return false
   }
@@ -17,7 +30,7 @@
   var str = arr.join('&')
   return str
 }
-const json2path = (json) => {
+const json2path = json => {
   if (!json) {
     return false
   }
@@ -28,7 +41,8 @@
   var str = arr.join('/')
   return str
 }
-const json2formData = (json) => { // Content-Type: multipart/form-data;boundary=${bound}  //浠h〃鍒嗗壊绗﹀彿
+const json2formData = json => {
+  // Content-Type: multipart/form-data;boundary=${bound}  //浠h〃鍒嗗壊绗﹀彿
   if (!json) {
     return false
   }
@@ -50,12 +64,14 @@
   return false
 }
 /* 鑾峰彇褰撳墠璺敱淇℃伅 */
-const thisRouterObjFn = (routesArr) => {
+const thisRouterObjFn = routesArr => {
   if (!routesArr && !Array.isArray(routesArr)) {
     return false
   }
   let pathArr = []
-  let MenuInfo = sessionStorage.getItem('fSDoorwayManagementMenuInfo') && JSON.parse(sessionStorage.getItem('fSDoorwayManagementMenuInfo'))
+  let MenuInfo =
+    sessionStorage.getItem('fSDoorwayManagementMenuInfo') &&
+    JSON.parse(sessionStorage.getItem('fSDoorwayManagementMenuInfo'))
   if (MenuInfo) {
     for (let i = 0; i < routesArr.length; i++) {
       const element = routesArr[i]
@@ -73,7 +89,7 @@
 }
 
 // 鍒ゆ柇鍥剧墖鏄惁瀛樺湪
-const isHasImg = (pathImg) => {
+const isHasImg = pathImg => {
   var ImgObj = new Image()
   ImgObj.src = pathImg
   if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
@@ -89,7 +105,7 @@
  ***/
 
 const findButtonAuthoritys = (arr, fn) => {
-  fn = fn || function () {}
+  fn = fn || function() {}
   if (Array.isArray(arr)) {
     for (let iteam of arr) {
       if (iteam.type === 2 && iteam.permission !== '') {
@@ -136,7 +152,7 @@
   return arr
 }
 // json 鏄惁涓虹┖
-const isJsonNull = (jsonStr) => {
+const isJsonNull = jsonStr => {
   if (typeof jsonStr === 'object' && jsonStr != null) {
     for (let key in jsonStr) {
       if (jsonStr[key]) {
@@ -146,10 +162,10 @@
   }
   return false
 }
-const cloneDeep = (node) => {
+const cloneDeep = node => {
   if (!node) return node
   var newNode = {}
-  Object.keys(node).forEach(function (key) {
+  Object.keys(node).forEach(function(key) {
     if (key[0] === '_') return
     var val = node[key]
 
@@ -165,7 +181,7 @@
   })
   return newNode
 }
-var Week = (function () {
+var Week = (function() {
   var ONE_DAY = 24 * 3600 * 1000
   var ONE_WEEK = 7 * ONE_DAY
 
@@ -183,7 +199,19 @@
     var nextWeekday = formatNumber(nextWeek.getDate() - 1)
     /* 鍙埅鍙栧綋鍓嶅勾浠芥椂闂� */
     if (year === nextWeekYear) {
-      return year + '-' + month + '-' + day + '~' + nextWeekYear + '-' + nextWeekMonth + '-' + nextWeekday
+      return (
+        year +
+        '-' +
+        month +
+        '-' +
+        day +
+        '~' +
+        nextWeekYear +
+        '-' +
+        nextWeekMonth +
+        '-' +
+        nextWeekday
+      )
     } else {
       return year + '-' + month + '-' + day + '~' + year + '-' + month + '-31'
     }
@@ -199,18 +227,18 @@
     this.days = 0
     this.weeks = 0
   }
-  Week.prototype.getDays = function () {
+  Week.prototype.getDays = function() {
     this.days = Math.ceil((this.nextYear - this.year) / ONE_DAY)
     return Math.ceil((this.nextYear - this.year) / ONE_DAY)
   }
-  Week.prototype.getWeeks = function () {
+  Week.prototype.getWeeks = function() {
     this.weeks = Math.ceil(this.days || this.getDays() / 7)
     return Math.ceil(this.days || this.getDays() / 7)
   }
-  Week.prototype.getSomeWeek = function (num) {
+  Week.prototype.getSomeWeek = function(num) {
     return formatDate(new Date(+this.year + ONE_WEEK * num), num)
   }
-  Week.prototype.showWeek = function (num) {
+  Week.prototype.showWeek = function(num) {
     num = parseInt(num - 1) || 0
     if (!this.weeks) {
       this.getWeeks()
@@ -222,8 +250,7 @@
       return this.getSomeWeek(num)
     } else {
       var arr = []
-      while (num <
-        this.weeks) {
+      while (num < this.weeks) {
         arr.push(this.getSomeWeek(num))
         num++
       }
@@ -249,6 +276,48 @@
   }
 }
 
+//鎷嗗垎浜岀淮鏁扮粍
+const chunkArr = (arr, size = 1) => {
+  if (arr.length == 0) return
+  const tempContainer = []
+  let innerArr = []
+  arr.forEach(item => {
+    if (innerArr.length == 0) {
+      tempContainer.push(innerArr)
+    }
+    innerArr.push(item)
+    if (innerArr.length == size) {
+      innerArr = []
+    }
+  })
+  return tempContainer
+}
+const numberFormat = (nums, retain) => {
+  var num
+  var result = ''
+  var dot = ''
+  var minus = ''
+  if (nums || Number(nums) === 0) {
+    num = (nums * 1).toFixed(retain).toString()
+    if (num.indexOf('-') > -1) {
+      minus = '-'
+      num = num.split('-')[1]
+    }
+    if (num.indexOf('.') > -1) {
+      var newnum = num.split('.')
+      num = newnum[0]
+      dot = newnum[1]
+    }
+    while (num.length > 3) {
+      result = ',' + num.slice(-3) + result
+      num = num.slice(0, num.length - 3)
+    }
+    if (num) {
+      result = retain ? minus + num + result + '.' + dot : minus + num + result
+    }
+  }
+  return result
+}
 export {
   thisRouterObjFn,
   json2url,
@@ -264,5 +333,7 @@
   guid,
   cloneDeep,
   getYearWeek,
-  getContainerRect
+  getContainerRect,
+  chunkArr,
+  numberFormat
 }

--
Gitblit v1.8.0