You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
120 lines
3.6 KiB
120 lines
3.6 KiB
import store from '../store'
|
|
|
|
export default {
|
|
formatterCategory(row, column, cellValue) {
|
|
const categoryList = store.getters.allCategory
|
|
for (let i = 0; i < categoryList.length; i++) {
|
|
if (categoryList[i].code === cellValue) {
|
|
return categoryList[i].name
|
|
}
|
|
}
|
|
},
|
|
getChineseName(row, column, cellValue) {
|
|
// 所有用户信息
|
|
const allUsers = store.getters.allUser
|
|
// 认领人 ids
|
|
if (cellValue !== null && cellValue !== undefined) {
|
|
let ids
|
|
let cnName = ''
|
|
if (cellValue.toString().indexOf('[') > -1) {
|
|
ids = JSON.parse(cellValue)
|
|
} else {
|
|
ids = cellValue.toString().split(',')
|
|
}
|
|
if (allUsers.length > 0 && !!cellValue) {
|
|
ids.forEach(id => {
|
|
allUsers.every(user => {
|
|
if (user.id === parseInt(id)) {
|
|
cnName = cnName + user.nickname + ','
|
|
return false
|
|
} else {
|
|
return true
|
|
}
|
|
})
|
|
})
|
|
}
|
|
return cnName.substring(0, cnName.length - 1)
|
|
} else {
|
|
return null
|
|
}
|
|
},
|
|
getNowTime() {
|
|
let dateTime = ''
|
|
const yy = new Date().getFullYear()
|
|
const mm = new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1
|
|
const dd = new Date().getDate() < 10 ? '0' + new Date().getDate()
|
|
: new Date().getDate()
|
|
const hh = new Date().getHours()
|
|
const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes()
|
|
: new Date().getMinutes()
|
|
const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds()
|
|
: new Date().getSeconds()
|
|
dateTime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss
|
|
return dateTime
|
|
},
|
|
/**
|
|
* 格式化日期
|
|
* 对Date的扩展,将 Date 转化为指定格式的String
|
|
* 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
|
|
* 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
|
|
* 例子:
|
|
* dateFormat("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
|
|
* dateFormat("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
|
|
* @param fmt
|
|
* @param date
|
|
* @returns {*}
|
|
*/
|
|
dateFormat(fmt, date) {
|
|
if (!date) {
|
|
date = new Date()
|
|
}
|
|
const 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 (const 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
|
|
},
|
|
moneyFormat(row, column, cellValue) {
|
|
return cellValue + '元'
|
|
},
|
|
formatEquipment(row, column, cellValue) {
|
|
const jylb = row.jianyanleibie
|
|
// 格式化
|
|
let name = ''
|
|
switch (cellValue) {
|
|
case '3000':
|
|
name = '电梯'
|
|
break
|
|
case '4000':
|
|
case '5000':
|
|
name = '起重'
|
|
break
|
|
case '1000':
|
|
name = jylb === 'ZJ' ? '锅炉监检' : '锅炉定检'
|
|
break
|
|
case '2000':
|
|
name = jylb === 'ZJ' ? '容器监检' : '容器定检'
|
|
break
|
|
case '8000':
|
|
name = '压力管道'
|
|
break
|
|
case '7000':
|
|
name = '安全阀'
|
|
break
|
|
}
|
|
return name
|
|
}
|
|
}
|
|
|