|
@ -25,68 +25,67 @@ const baseURL = process.env.VUE_APP_BASE_API |
|
|
* @return {{beginTime: string, endTime: string}} |
|
|
* @return {{beginTime: string, endTime: string}} |
|
|
*/ |
|
|
*/ |
|
|
export function calcRange(array) { |
|
|
export function calcRange(array) { |
|
|
let range = {}; |
|
|
let range = {} |
|
|
if (array && array.length > 0) { |
|
|
if (array && array.length > 0) { |
|
|
range.beginTime = parseTime(array[0]); |
|
|
range.beginTime = parseTime(array[0]) |
|
|
range.endTime = parseTime(array[1]); |
|
|
range.endTime = parseTime(array[1]) |
|
|
// 替换 endTime 为 23:59:59
|
|
|
// 替换 endTime 为 23:59:59
|
|
|
range.endTime = range.endTime.replace(/(\d{2}:\d{2}:\d{2})/, '23:59:59'); |
|
|
range.endTime = range.endTime.replace(/(\d{2}:\d{2}:\d{2})/, '23:59:59') |
|
|
} else { |
|
|
} else { |
|
|
throw new Error('Date range is empty!'); |
|
|
throw new Error('Date range is empty!') |
|
|
} |
|
|
} |
|
|
return range; |
|
|
return range |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 时区北京
|
|
|
// 时区北京
|
|
|
export function BeiJingDate() { |
|
|
export function BeiJingDate() { |
|
|
return new Date(new Date().getTime()+(parseInt(new Date().getTimezoneOffset()/60) + 8)*3600*1000); |
|
|
return new Date(new Date().getTime() + (parseInt(new Date().getTimezoneOffset() / 60) + 8) * 3600 * 1000) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 通用下载方法
|
|
|
// 通用下载方法
|
|
|
export function download(fileName) { |
|
|
export function download(fileName) { |
|
|
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true; |
|
|
window.location.href = baseURL + '/common/download?fileName=' + encodeURI(fileName) + '&delete=' + true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//获取当前年月日
|
|
|
//获取当前年月日
|
|
|
export function today() { |
|
|
export function today() { |
|
|
let nowDate = new Date(); |
|
|
let nowDate = new Date() |
|
|
let date = { |
|
|
let date = { |
|
|
year: nowDate.getFullYear(), |
|
|
year: nowDate.getFullYear(), |
|
|
month: nowDate.getMonth() + 1, |
|
|
month: nowDate.getMonth() + 1, |
|
|
date: nowDate.getDate(), |
|
|
date: nowDate.getDate() |
|
|
} |
|
|
} |
|
|
if (date.date <= 9) { |
|
|
if (date.date <= 9) { |
|
|
return date.year + '-' + 0 + date.month + '-' + 0 + date.date; |
|
|
return date.year + '-' + 0 + date.month + '-' + 0 + date.date |
|
|
} else { |
|
|
} else { |
|
|
return date.year + '-' + 0 + date.month + '-' + date.date; |
|
|
return date.year + '-' + 0 + date.month + '-' + date.date |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加日期范围
|
|
|
// 添加日期范围
|
|
|
export function addSESDateRange(params, dateRange, propName) { |
|
|
export function addSESDateRange(params, dateRange, propName) { |
|
|
var search = params; |
|
|
var search = params |
|
|
search.beginTime = null |
|
|
search.beginTime = null |
|
|
search.endTime = null; |
|
|
search.endTime = null |
|
|
search.updateBeginTime = null |
|
|
search.updateBeginTime = null |
|
|
search.updateEndTime = null; |
|
|
search.updateEndTime = null |
|
|
if (propName) { |
|
|
if (propName) { |
|
|
if (dateRange[0]) { |
|
|
if (dateRange[0]) { |
|
|
if (dateRange[0][0] && dateRange[0][1]) { |
|
|
if (dateRange[0][0] && dateRange[0][1]) { |
|
|
search.beginTime = dateRange[0][0]; |
|
|
search.beginTime = dateRange[0][0] |
|
|
search.endTime = dateRange[0][1]; |
|
|
search.endTime = dateRange[0][1] |
|
|
} else if (!dateRange[0][0]) { |
|
|
} else if (!dateRange[0][0]) { |
|
|
search.beginTime = undefined; |
|
|
search.beginTime = undefined |
|
|
search.endTime = undefined; |
|
|
search.endTime = undefined |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (dateRange[1]) { |
|
|
if (dateRange[1]) { |
|
|
if (dateRange[1][0] && dateRange[1][1]) { |
|
|
if (dateRange[1][0] && dateRange[1][1]) { |
|
|
search.updateBeginTime = dateRange[1][0]; |
|
|
search.updateBeginTime = dateRange[1][0] |
|
|
search.updateEndTime = dateRange[1][1]; |
|
|
search.updateEndTime = dateRange[1][1] |
|
|
} else if (!dateRange[1][0]) { |
|
|
} else if (!dateRange[1][0]) { |
|
|
search.updateBeginTime = undefined; |
|
|
search.updateBeginTime = undefined |
|
|
search.updateEndTime = undefined; |
|
|
search.updateEndTime = undefined |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -95,16 +94,16 @@ export function addSESDateRange(params, dateRange, propName) { |
|
|
// search.beginTime = dateRange[0];
|
|
|
// search.beginTime = dateRange[0];
|
|
|
// search.endTime = dateRange[1];
|
|
|
// search.endTime = dateRange[1];
|
|
|
if (dateRange[0] && dateRange[1]) { |
|
|
if (dateRange[0] && dateRange[1]) { |
|
|
search.beginTime = dateRange[0]; |
|
|
search.beginTime = dateRange[0] |
|
|
search.endTime = dateRange[1]; |
|
|
search.endTime = dateRange[1] |
|
|
} else if (!dateRange[0]) { |
|
|
} else if (!dateRange[0]) { |
|
|
search.beginTime = undefined; |
|
|
search.beginTime = undefined |
|
|
search.endTime = undefined; |
|
|
search.endTime = undefined |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return search; |
|
|
return search |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 日期格式化
|
|
|
// 日期格式化
|
|
@ -120,7 +119,7 @@ export function parseTime(time, pattern) { |
|
|
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { |
|
|
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { |
|
|
time = parseInt(time) |
|
|
time = parseInt(time) |
|
|
} else if (typeof time === 'string') { |
|
|
} else if (typeof time === 'string') { |
|
|
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), ''); |
|
|
time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), '') |
|
|
} |
|
|
} |
|
|
if ((typeof time === 'number') && (time.toString().length === 10)) { |
|
|
if ((typeof time === 'number') && (time.toString().length === 10)) { |
|
|
time = time * 1000 |
|
|
time = time * 1000 |
|
@ -153,91 +152,91 @@ export function parseTime(time, pattern) { |
|
|
// 表单重置
|
|
|
// 表单重置
|
|
|
export function resetForm(refName) { |
|
|
export function resetForm(refName) { |
|
|
if (this.$refs[refName]) { |
|
|
if (this.$refs[refName]) { |
|
|
this.$refs[refName].resetFields(); |
|
|
this.$refs[refName].resetFields() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 添加日期范围
|
|
|
// 添加日期范围
|
|
|
export function addDateRange(params, dateRange, propName) { |
|
|
export function addDateRange(params, dateRange, propName) { |
|
|
let search = params; |
|
|
let search = params |
|
|
search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {}; |
|
|
search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {} |
|
|
dateRange = Array.isArray(dateRange) ? dateRange : []; |
|
|
dateRange = Array.isArray(dateRange) ? dateRange : [] |
|
|
if (typeof (propName) === 'undefined') { |
|
|
if (typeof (propName) === 'undefined') { |
|
|
search.params['beginTime'] = dateRange[0]; |
|
|
search.params['beginTime'] = dateRange[0] |
|
|
search.params['endTime'] = dateRange[1]; |
|
|
search.params['endTime'] = dateRange[1] |
|
|
} else { |
|
|
} else { |
|
|
search.params['begin' + propName] = dateRange[0]; |
|
|
search.params['begin' + propName] = dateRange[0] |
|
|
search.params['end' + propName] = dateRange[1]; |
|
|
search.params['end' + propName] = dateRange[1] |
|
|
} |
|
|
} |
|
|
return search; |
|
|
return search |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 回显数据字典
|
|
|
// 回显数据字典
|
|
|
export function selectDictLabel(datas, value) { |
|
|
export function selectDictLabel(datas, value) { |
|
|
if (value === undefined) { |
|
|
if (value === undefined) { |
|
|
return ""; |
|
|
return '' |
|
|
} |
|
|
} |
|
|
var actions = []; |
|
|
var actions = [] |
|
|
Object.keys(datas).some((key) => { |
|
|
Object.keys(datas).some((key) => { |
|
|
if (datas[key].value == ('' + value)) { |
|
|
if (datas[key].value == ('' + value)) { |
|
|
actions.push(datas[key].label); |
|
|
actions.push(datas[key].label) |
|
|
return true; |
|
|
return true |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
if (actions.length === 0) { |
|
|
if (actions.length === 0) { |
|
|
actions.push(value); |
|
|
actions.push(value) |
|
|
} |
|
|
} |
|
|
return actions.join(''); |
|
|
return actions.join('') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 回显数据字典(字符串、数组)
|
|
|
// 回显数据字典(字符串、数组)
|
|
|
export function selectDictLabels(datas, value, separator) { |
|
|
export function selectDictLabels(datas, value, separator) { |
|
|
if (value === undefined || value.length === 0) { |
|
|
if (value === undefined || value.length === 0) { |
|
|
return ""; |
|
|
return '' |
|
|
} |
|
|
} |
|
|
if (Array.isArray(value)) { |
|
|
if (Array.isArray(value)) { |
|
|
value = value.join(","); |
|
|
value = value.join(',') |
|
|
} |
|
|
} |
|
|
var actions = []; |
|
|
var actions = [] |
|
|
var currentSeparator = undefined === separator ? "," : separator; |
|
|
var currentSeparator = undefined === separator ? ',' : separator |
|
|
var temp = value.split(currentSeparator); |
|
|
var temp = value.split(currentSeparator) |
|
|
Object.keys(value.split(currentSeparator)).some((val) => { |
|
|
Object.keys(value.split(currentSeparator)).some((val) => { |
|
|
var match = false; |
|
|
var match = false |
|
|
Object.keys(datas).some((key) => { |
|
|
Object.keys(datas).some((key) => { |
|
|
if (datas[key].value == ('' + temp[val])) { |
|
|
if (datas[key].value == ('' + temp[val])) { |
|
|
actions.push(datas[key].label + currentSeparator); |
|
|
actions.push(datas[key].label + currentSeparator) |
|
|
match = true; |
|
|
match = true |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
if (!match) { |
|
|
if (!match) { |
|
|
actions.push(temp[val] + currentSeparator); |
|
|
actions.push(temp[val] + currentSeparator) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
return actions.join('').substring(0, actions.join('').length - 1); |
|
|
return actions.join('').substring(0, actions.join('').length - 1) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 字符串格式化(%s )
|
|
|
// 字符串格式化(%s )
|
|
|
export function sprintf(str) { |
|
|
export function sprintf(str) { |
|
|
var args = arguments, |
|
|
var args = arguments, |
|
|
flag = true, |
|
|
flag = true, |
|
|
i = 1; |
|
|
i = 1 |
|
|
str = str.replace(/%s/g, function () { |
|
|
str = str.replace(/%s/g, function() { |
|
|
var arg = args[i++]; |
|
|
var arg = args[i++] |
|
|
if (typeof arg === 'undefined') { |
|
|
if (typeof arg === 'undefined') { |
|
|
flag = false; |
|
|
flag = false |
|
|
return ''; |
|
|
return '' |
|
|
} |
|
|
} |
|
|
return arg; |
|
|
return arg |
|
|
}); |
|
|
}) |
|
|
return flag ? str : ''; |
|
|
return flag ? str : '' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 转换字符串,undefined,null等转化为""
|
|
|
// 转换字符串,undefined,null等转化为""
|
|
|
export function parseStrEmpty(str) { |
|
|
export function parseStrEmpty(str) { |
|
|
if (!str || str == "undefined" || str == "null") { |
|
|
if (!str || str == 'undefined' || str == 'null') { |
|
|
return ""; |
|
|
return '' |
|
|
} |
|
|
} |
|
|
return str; |
|
|
return str |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 数据合并
|
|
|
// 数据合并
|
|
@ -245,16 +244,16 @@ export function mergeRecursive(source, target) { |
|
|
for (var p in target) { |
|
|
for (var p in target) { |
|
|
try { |
|
|
try { |
|
|
if (target[p].constructor == Object) { |
|
|
if (target[p].constructor == Object) { |
|
|
source[p] = mergeRecursive(source[p], target[p]); |
|
|
source[p] = mergeRecursive(source[p], target[p]) |
|
|
} else { |
|
|
} else { |
|
|
source[p] = target[p]; |
|
|
source[p] = target[p] |
|
|
} |
|
|
} |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|
source[p] = target[p]; |
|
|
source[p] = target[p] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return source; |
|
|
return source |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 构造树型结构数据 |
|
|
* 构造树型结构数据 |
|
@ -268,43 +267,44 @@ export function handleTree(data, id, parentId, children) { |
|
|
id: id || 'id', |
|
|
id: id || 'id', |
|
|
parentId: parentId || 'parentId', |
|
|
parentId: parentId || 'parentId', |
|
|
childrenList: children || 'children' |
|
|
childrenList: children || 'children' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
var childrenListMap = {}; |
|
|
var childrenListMap = {} |
|
|
var nodeIds = {}; |
|
|
var nodeIds = {} |
|
|
var tree = []; |
|
|
var tree = [] |
|
|
|
|
|
|
|
|
for (let d of data) { |
|
|
for (let d of data) { |
|
|
let parentId = d[config.parentId]; |
|
|
let parentId = d[config.parentId] |
|
|
if (childrenListMap[parentId] == null) { |
|
|
if (childrenListMap[parentId] == null) { |
|
|
childrenListMap[parentId] = []; |
|
|
childrenListMap[parentId] = [] |
|
|
} |
|
|
} |
|
|
nodeIds[d[config.id]] = d; |
|
|
nodeIds[d[config.id]] = d |
|
|
childrenListMap[parentId].push(d); |
|
|
childrenListMap[parentId].push(d) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (let d of data) { |
|
|
for (let d of data) { |
|
|
let parentId = d[config.parentId]; |
|
|
let parentId = d[config.parentId] |
|
|
if (nodeIds[parentId] == null) { |
|
|
if (nodeIds[parentId] == null) { |
|
|
tree.push(d); |
|
|
tree.push(d) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (let t of tree) { |
|
|
for (let t of tree) { |
|
|
adaptToChildrenList(t); |
|
|
adaptToChildrenList(t) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function adaptToChildrenList(o) { |
|
|
function adaptToChildrenList(o) { |
|
|
if (childrenListMap[o[config.id]] !== null) { |
|
|
if (childrenListMap[o[config.id]] !== null) { |
|
|
o[config.childrenList] = childrenListMap[o[config.id]]; |
|
|
o[config.childrenList] = childrenListMap[o[config.id]] |
|
|
} |
|
|
} |
|
|
if (o[config.childrenList]) { |
|
|
if (o[config.childrenList]) { |
|
|
for (let c of o[config.childrenList]) { |
|
|
for (let c of o[config.childrenList]) { |
|
|
adaptToChildrenList(c); |
|
|
adaptToChildrenList(c) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return tree; |
|
|
|
|
|
|
|
|
return tree |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -314,19 +314,19 @@ export function handleTree(data, id, parentId, children) { |
|
|
export function tansParams(params) { |
|
|
export function tansParams(params) { |
|
|
let result = '' |
|
|
let result = '' |
|
|
for (const propName of Object.keys(params)) { |
|
|
for (const propName of Object.keys(params)) { |
|
|
const value = params[propName]; |
|
|
const value = params[propName] |
|
|
var part = encodeURIComponent(propName) + "="; |
|
|
var part = encodeURIComponent(propName) + '=' |
|
|
if (value !== null && value !== "" && typeof (value) !== "undefined") { |
|
|
if (value !== null && value !== '' && typeof (value) !== 'undefined') { |
|
|
if (typeof value === 'object') { |
|
|
if (typeof value === 'object') { |
|
|
for (const key of Object.keys(value)) { |
|
|
for (const key of Object.keys(value)) { |
|
|
if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { |
|
|
if (value[key] !== null && value[key] !== '' && typeof (value[key]) !== 'undefined') { |
|
|
let params = propName + '[' + key + ']'; |
|
|
let params = propName + '[' + key + ']' |
|
|
var subPart = encodeURIComponent(params) + "="; |
|
|
var subPart = encodeURIComponent(params) + '=' |
|
|
result += subPart + encodeURIComponent(value[key]) + "&"; |
|
|
result += subPart + encodeURIComponent(value[key]) + '&' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
result += part + encodeURIComponent(value) + "&"; |
|
|
result += part + encodeURIComponent(value) + '&' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -336,11 +336,11 @@ export function tansParams(params) { |
|
|
// 验证是否为blob格式
|
|
|
// 验证是否为blob格式
|
|
|
export async function blobValidate(data) { |
|
|
export async function blobValidate(data) { |
|
|
try { |
|
|
try { |
|
|
const text = await data.text(); |
|
|
const text = await data.text() |
|
|
JSON.parse(text); |
|
|
JSON.parse(text) |
|
|
return false; |
|
|
return false |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
return true; |
|
|
return true |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -348,8 +348,8 @@ export async function blobValidate(data) { |
|
|
* toFixed 但是不四舍五入 |
|
|
* toFixed 但是不四舍五入 |
|
|
*/ |
|
|
*/ |
|
|
export function toFixedWithOutRounded(num, s) { |
|
|
export function toFixedWithOutRounded(num, s) { |
|
|
const re = new RegExp('^-?\\d+(?:\.\\d{0,' + (s || -1) + '})?'); |
|
|
const re = new RegExp('^-?\\d+(?:\.\\d{0,' + (s || -1) + '})?') |
|
|
return num.toString().match(re)[0]; |
|
|
return num.toString().match(re)[0] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -374,29 +374,29 @@ export const amountFormat = (o) => { |
|
|
decimalLength = 2, |
|
|
decimalLength = 2, |
|
|
decimalSeparator = '.', |
|
|
decimalSeparator = '.', |
|
|
thousandSeparator = ',' |
|
|
thousandSeparator = ',' |
|
|
} = o; |
|
|
} = o |
|
|
|
|
|
|
|
|
// 将金额转换为数字类型
|
|
|
// 将金额转换为数字类型
|
|
|
const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount; |
|
|
const numAmount = typeof amount === 'string' ? parseFloat(amount) : amount |
|
|
if (isNaN(numAmount)) { |
|
|
if (isNaN(numAmount)) { |
|
|
return ''; |
|
|
return '' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 根据精度对金额进行四舍五入
|
|
|
// 根据精度对金额进行四舍五入
|
|
|
const roundedAmount = numAmount / precision; |
|
|
const roundedAmount = numAmount / precision |
|
|
|
|
|
|
|
|
// 格式化小数部分
|
|
|
// 格式化小数部分
|
|
|
let formattedAmount = decimal ? roundedAmount.toFixed(decimalLength) : Math.floor(roundedAmount).toString(); |
|
|
let formattedAmount = decimal ? roundedAmount.toFixed(decimalLength) : Math.floor(roundedAmount).toString() |
|
|
|
|
|
|
|
|
// 添加千分位分隔符
|
|
|
// 添加千分位分隔符
|
|
|
if (thousand) { |
|
|
if (thousand) { |
|
|
const parts = formattedAmount.split('.'); |
|
|
const parts = formattedAmount.split('.') |
|
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator); |
|
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator) |
|
|
formattedAmount = parts.join(decimalSeparator); |
|
|
formattedAmount = parts.join(decimalSeparator) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return formattedAmount; |
|
|
return formattedAmount |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 格式化金额, 自动进万, 百万 |
|
|
* 格式化金额, 自动进万, 百万 |
|
@ -404,65 +404,57 @@ export const amountFormat = (o) => { |
|
|
* @param unit |
|
|
* @param unit |
|
|
*/ |
|
|
*/ |
|
|
export function amountFriendlyFormat(amount, unit) { |
|
|
export function amountFriendlyFormat(amount, unit) { |
|
|
// 百万
|
|
|
const result = { |
|
|
if (amount >= 1000000 || unit === '百万') { |
|
|
unit: '', |
|
|
return { |
|
|
amount: Number(toFixedWithOutRounded(amount, 2)), |
|
|
unit: '百万', |
|
|
display: Number(toFixedWithOutRounded(amount, 2)) |
|
|
amount: amount / 1000000, |
|
|
|
|
|
display: `${amount / 1000000}百万` |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 千万
|
|
|
|
|
|
if (amount >= 10000000 || unit === '千万') { |
|
|
|
|
|
result.unit = '千万' |
|
|
|
|
|
result.amount = Number(toFixedWithOutRounded(amount / 10000000, 0)) |
|
|
|
|
|
result.display = `${result.amount} 千万` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 万
|
|
|
// 万
|
|
|
if (amount >= 10000 || unit === '万') { |
|
|
if (amount >= 10000 || unit === '万') { |
|
|
return { |
|
|
result.unit = '万' |
|
|
unit: '万', |
|
|
result.amount = Number(toFixedWithOutRounded(amount / 10000, 0)) |
|
|
amount: amount / 10000, |
|
|
result.display = `${result.amount} 万` |
|
|
display: `${amount / 10000}万` |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
return result |
|
|
// 百
|
|
|
|
|
|
// if (amount >= 100 || unit === '百') {
|
|
|
|
|
|
// return {
|
|
|
|
|
|
// unit: '百',
|
|
|
|
|
|
// amount: amount / 100,
|
|
|
|
|
|
// display: `${amount / 100}百`
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
return { |
|
|
|
|
|
unit: '', |
|
|
|
|
|
amount: amount, |
|
|
|
|
|
display: amount |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* sortBy |
|
|
* sortBy |
|
|
*/ |
|
|
*/ |
|
|
export function sortBy(arr, key) { |
|
|
export function sortBy(arr, key) { |
|
|
return arr.sort(function (a, b) { |
|
|
return arr.sort(function(a, b) { |
|
|
return a[key] - b[key]; |
|
|
return a[key] - b[key] |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取今天星期几 |
|
|
* 获取今天星期几 |
|
|
*/ |
|
|
*/ |
|
|
export function getWeek() { |
|
|
export function getWeek() { |
|
|
let week = new Date().getDay(); |
|
|
let week = new Date().getDay() |
|
|
switch (week) { |
|
|
switch (week) { |
|
|
case 0: |
|
|
case 0: |
|
|
return "星期日"; |
|
|
return '星期日' |
|
|
case 1: |
|
|
case 1: |
|
|
return "星期一"; |
|
|
return '星期一' |
|
|
case 2: |
|
|
case 2: |
|
|
return "星期二"; |
|
|
return '星期二' |
|
|
case 3: |
|
|
case 3: |
|
|
return "星期三"; |
|
|
return '星期三' |
|
|
case 4: |
|
|
case 4: |
|
|
return "星期四"; |
|
|
return '星期四' |
|
|
case 5: |
|
|
case 5: |
|
|
return "星期五"; |
|
|
return '星期五' |
|
|
case 6: |
|
|
case 6: |
|
|
return "星期六"; |
|
|
return '星期六' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|