|
|
|
|
const pad2 = str => ('0' + str).substr(-2)
|
|
|
|
|
|
|
|
|
|
function fMoney (s, n) {
|
|
|
|
|
n = n > 0 && n <= 20 ? n : 2
|
|
|
|
|
s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + ''
|
|
|
|
|
let l = s.split('.')[0].split('').reverse()
|
|
|
|
|
let r = s.split('.')[1]
|
|
|
|
|
let t = ''
|
|
|
|
|
for(let i = 0; i < l.length; i ++ ) {
|
|
|
|
|
t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? ',' : '')
|
|
|
|
|
}
|
|
|
|
|
return t.split('').reverse().join('') + '.' + r
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toDateTime (date, time) {
|
|
|
|
|
if (!date) return ''
|
|
|
|
|
date = date.toString()
|
|
|
|
|
time = time ? time.toString() : ''
|
|
|
|
|
let str = `${date.substr(0, 4)}-${date.substr(4, 2)}-${date.substr(6, 2)}`
|
|
|
|
|
if (date.length == 14) {
|
|
|
|
|
str += ` ${date.substr(8, 2)}:${date.substr(10, 2)}:${date.substr(12, 2)}`
|
|
|
|
|
} else if (date.length == 6) {
|
|
|
|
|
str = `${date.substr(0, 2)}:${date.substr(2, 2)}:${date.substr(4, 2)}`
|
|
|
|
|
} else if (time) {
|
|
|
|
|
str += ` ${time.substr(0, 2)}:${time.substr(2, 2)}:${time.substr(4, 2)}`
|
|
|
|
|
}
|
|
|
|
|
return str
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fMoney2 (m) {
|
|
|
|
|
return parseFloat(m).toFixed(2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function orderreleaseType (sts) {
|
|
|
|
|
const status = {
|
|
|
|
|
'0': '手动发布',
|
|
|
|
|
'1': '定时发布',
|
|
|
|
|
}
|
|
|
|
|
return status[sts] || '未知状态'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function orderflag (sts) {
|
|
|
|
|
const status = {
|
|
|
|
|
'0': true,
|
|
|
|
|
'1': false,
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return status[sts] || '未知状态'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function orderassesmentState (sts) {
|
|
|
|
|
const status = {
|
|
|
|
|
'0': '待开始',
|
|
|
|
|
'1': '进行中',
|
|
|
|
|
'2': '已结束',
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return status[sts] || '未知状态'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function orderfounder (sts) {
|
|
|
|
|
const status = {
|
|
|
|
|
'0': '系统',
|
|
|
|
|
'1': '老师'
|
|
|
|
|
}
|
|
|
|
|
return status[sts] || '未知状态'
|
|
|
|
|
}
|
|
|
|
|
function projectPermissions (sts) {
|
|
|
|
|
const status = {
|
|
|
|
|
'1': '考核',
|
|
|
|
|
'2': '竞赛',
|
|
|
|
|
'0': '练习'
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return status[sts] || '未知状态'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function roleType (type) {
|
|
|
|
|
const types = {
|
|
|
|
|
'2': '管理员',
|
|
|
|
|
'3': '老师',
|
|
|
|
|
'4': '学生'
|
|
|
|
|
}
|
|
|
|
|
return types[type] || '未知类型'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function educationDegreeList (id) {
|
|
|
|
|
const list = [
|
|
|
|
|
{
|
|
|
|
|
name: '专科',
|
|
|
|
|
value: 1
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '本科',
|
|
|
|
|
value: 2
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '硕士',
|
|
|
|
|
value: 3
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '博士',
|
|
|
|
|
value: 4
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '其他',
|
|
|
|
|
value: 5
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
let educationdegree = list.find((n,k) => {
|
|
|
|
|
return n.value == id
|
|
|
|
|
}).name
|
|
|
|
|
return educationdegree
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//返回格式化时间,传参例如:"yyyy-MM-dd hh:mm:ss"
|
|
|
|
|
function formatDate(fmt,date) {
|
|
|
|
|
var date = date ? date : new Date()
|
|
|
|
|
var 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(var 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeByValue(arr, val) {
|
|
|
|
|
for(var i=0; i<arr.length; i++) {
|
|
|
|
|
if(arr[i] == val) {
|
|
|
|
|
arr.splice(i, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formateTime(num) {
|
|
|
|
|
return num < 10 ? `0${num}` : num
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getCaption(obj){
|
|
|
|
|
var index=obj.lastIndexOf("\h");
|
|
|
|
|
obj=obj.substring(index+1,obj.length);
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// new Date('2020-11-12 00:00:00') 在IE下失效,因此把-替换成/
|
|
|
|
|
function dateCompatible(date) {
|
|
|
|
|
return date.replace(/\-/g, '/')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 是否IE
|
|
|
|
|
function isIE() {
|
|
|
|
|
if (!!window.ActiveXObject || "ActiveXObject" in window) return true
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 是否edge
|
|
|
|
|
function isEdge() {
|
|
|
|
|
let userAgent = navigator.userAgent
|
|
|
|
|
if (userAgent.includes("Edge")) return true
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 是否火狐
|
|
|
|
|
function isFirefox() {
|
|
|
|
|
let userAgent = navigator.userAgent
|
|
|
|
|
if (userAgent.indexOf("Firefox") > -1) return true
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default{
|
|
|
|
|
orderfounder,
|
|
|
|
|
projectPermissions,
|
|
|
|
|
orderassesmentState,
|
|
|
|
|
fMoney,
|
|
|
|
|
fMoney2,
|
|
|
|
|
toDateTime,
|
|
|
|
|
orderreleaseType,
|
|
|
|
|
orderflag,
|
|
|
|
|
roleType,
|
|
|
|
|
educationDegreeList,
|
|
|
|
|
removeByValue,
|
|
|
|
|
formateTime,
|
|
|
|
|
getCaption,
|
|
|
|
|
formatDate,
|
|
|
|
|
isIE,
|
|
|
|
|
isFirefox,
|
|
|
|
|
isEdge,
|
|
|
|
|
dateCompatible
|
|
|
|
|
}
|