|
@@ -159,13 +159,73 @@ function formatYMD2(str) {
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
function handleRichTextImgAuto(content) {
|
|
|
- return content.replace(/\<img/gi, '<img style="max-width:100%;height:auto')
|
|
|
+ return content.replace(/\<img/gi, '<img style="max-width:100%;height:auto').replace(/ /g,'  ')
|
|
|
}
|
|
|
|
|
|
function getNowDate() {
|
|
|
return dayjs().format("YYYYMMDD")
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+/**
|
|
|
+ * 计算小数
|
|
|
+ * @param f
|
|
|
+ * @param digit
|
|
|
+ * @returns {number}
|
|
|
+ */
|
|
|
+function formatNum(f, digit = 5) {
|
|
|
+ var m = Math.pow(10, digit);
|
|
|
+ return parseInt(f * m, 10) / m;
|
|
|
+}
|
|
|
+
|
|
|
+function formatSize(fileSize) {
|
|
|
+ let newSize = fileSize + "b";
|
|
|
+ if (fileSize > 1024) {
|
|
|
+ newSize = (fileSize / 1024).toFixed(1);
|
|
|
+ fileSize = newSize + "kb"
|
|
|
+ }
|
|
|
+ if (newSize > 1024) {
|
|
|
+ newSize = (newSize / 1024).toFixed(1);
|
|
|
+ fileSize = newSize + "mb"
|
|
|
+ }
|
|
|
+ if (newSize > 1024) {
|
|
|
+ newSize = (newSize / 1024).toFixed(1);
|
|
|
+ fileSize = "大于1gb"
|
|
|
+ }
|
|
|
+ return fileSize
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否邮箱
|
|
|
+ * @param email
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+function isEmail(email) {
|
|
|
+ if (!email.trim()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
|
|
|
+ if (!reg.test(email)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 扩展获取字典项方法,使用storage 缓存失效来实现在一定时间内不重复加载字典
|
|
|
+ */
|
|
|
+async function getDict(dictType){
|
|
|
+ // let data = storage.getItem(dictType);
|
|
|
+ // if (data){
|
|
|
+ // return data;
|
|
|
+ // }else{
|
|
|
+ // const dictData = await Api.getDict(dictType);
|
|
|
+ // storage.setItem(dictType,dictData.data,DICT_CACHE_TIME)
|
|
|
+ // return dictData.data;
|
|
|
+ // }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
export {
|
|
|
throttle,
|
|
|
getDataSet,
|