Procházet zdrojové kódy

修改金额显示

chenrui před 2 roky
rodič
revize
01591fa741
2 změnil soubory, kde provedl 44 přidání a 57 odebrání
  1. 2 2
      hybrid/html/index.html
  2. 42 55
      hybrid/html/js/resize.js

+ 2 - 2
hybrid/html/index.html

@@ -209,8 +209,8 @@
 									<span>{{item.bizNo}}</span>
 								</div>
 								<div class="order-b  flex align_center flex-between">
-									<div>应付:¥{{item.bizAmount ||0}}</div>
-									<div>已付:¥{{item.settledAmount | 0}}</div>
+									<div>应付:¥{{toThousands(item.bizAmount,2)}}</div>
+									<div>已付:¥{{toThousands(item.settledAmount,2)}}</div>
 									<div>
 										欠款:<span>¥{{item.unsettleAmount ? toThousands(item.unsettleAmount,2): 0}}</span>
 									</div>

+ 42 - 55
hybrid/html/js/resize.js

@@ -1,64 +1,51 @@
 (function(doc, win) {
-   var docEl = doc.documentElement,
-    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
-    recalc = function() {
-     var clientWidth = docEl.clientWidth;
-     if(!clientWidth) return;
-     if(clientWidth >= 1080) {
-      docEl.style.fontSize = '100px';
-     } else {
-      docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
-     }
-    };
+	var docEl = doc.documentElement,
+		resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
+		recalc = function() {
+			var clientWidth = docEl.clientWidth;
+			if (!clientWidth) return;
+			if (clientWidth >= 1080) {
+				docEl.style.fontSize = '100px';
+			} else {
+				docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
+			}
+		};
 
-   if(!doc.addEventListener) return;
-   win.addEventListener(resizeEvt, recalc, false);
-   doc.addEventListener('DOMContentLoaded', recalc, false);
-   var docEl = document.documentElement;
-   var clientWidth = docEl.clientHeight;
-  })(document, window);
+	if (!doc.addEventListener) return;
+	win.addEventListener(resizeEvt, recalc, false);
+	doc.addEventListener('DOMContentLoaded', recalc, false);
+	var docEl = document.documentElement;
+	var clientWidth = docEl.clientHeight;
+})(document, window);
 
 
 // 导出
-function  downloadExcel(data, fileName) {
-  if (!data) { return }
-  const a = moment().format('YYYYMMDDHHmmss')
-  const fname = fileName + a
-  const blob = new Blob([data], { type: 'application/vnd.ms-excel' })
-  if (window.navigator && window.navigator.msSaveOrOpenBlob) {
-    navigator.msSaveBlob(blob, fname + '.xlsx')
-  } else {
-    const link = document.createElement('a')
-    link.style.display = 'none'
-    var href = URL.createObjectURL(blob)
-    link.href = href
-    link.setAttribute('download', fname + '.xlsx')
+function downloadExcel(data, fileName) {
+	if (!data) {
+		return
+	}
+	const a = moment().format('YYYYMMDDHHmmss')
+	const fname = fileName + a
+	const blob = new Blob([data], {
+		type: 'application/vnd.ms-excel'
+	})
+	if (window.navigator && window.navigator.msSaveOrOpenBlob) {
+		navigator.msSaveBlob(blob, fname + '.xlsx')
+	} else {
+		const link = document.createElement('a')
+		link.style.display = 'none'
+		var href = URL.createObjectURL(blob)
+		link.href = href
+		link.setAttribute('download', fname + '.xlsx')
 
-    document.body.appendChild(link)
-    link.click()
-    document.body.removeChild(link)
-    window.URL.revokeObjectURL(href) // 释放掉blob对象
-  }
+		document.body.appendChild(link)
+		link.click()
+		document.body.removeChild(link)
+		window.URL.revokeObjectURL(href) // 释放掉blob对象
+	}
 }
 
-function toThousands (num, decimal) {
-  if (decimal) {
-    num = formatDecimal(num, decimal)
-  }
-  return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
-    return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) {
-      return $1 + ','
-    })
-  })
-}
-
-function formatDecimal (num, decimal) {
-  num = num.toString()
-  const index = num.indexOf('.')
-  if (index !== -1) {
-    num = num.substring(0, decimal + index + 1)
-  } else {
-    num = num.substring(0)
-  }
-  return parseFloat(num).toFixed(decimal)
+function toThousands(num, decimal) {
+	let numInfo = num ? num : 0
+	return parseFloat(numInfo).toFixed(decimal)
 }