//先加载时间过滤器 Vue.filter('dateTimeFormat', function(value, key) { if (String(value).length !== 13) { value *= 1000; } let date = new Date(value); let Y = date.getFullYear(); let m = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1); let d = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()); let H = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()); let i = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()); let s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()); if (!value) return '--' switch (key) { case 'Y-m-d H:i:s': return `${Y}-${m}-${d} ${H}:${i}:${s}`; case 'Y-m-d H:i': return `${Y}-${m}-${d} ${H}:${i}`; case 'Y-m-d': return `${Y}-${m}-${d}`; case 'Y-m': return `${Y}-${m}`; case 'm-d': return `${m}-${d}`; case 'Y': return `${Y}`; case 'm': return `${m}`; case 'd': return `${d}`; case 'H:i:s': return `${H}:${i}:${s}`; case 'H:i': return `${H}:${i}`; case 'i:s': return `${i}:${s}`; case 'H': return `${H}`; case 'i': return `${i}`; case 's': return `${s}`; default: return "格式错误"; } }); Vue.filter('emptyFilled', function(value, defalt='--', is_contain_string_data_type=false) { if (isEmpty(value)) return defalt; if(is_contain_string_data_type){ if(inArray(value,['null','false','undefined'])){ return defalt; } } return value; }); Vue.filter('hiddenMobile', function(value, defalt='--', character='*') { value = String(value) if (isEmpty(value)) return defalt; return value.substr(0,3)+character.repeat(4)+value.substr(7); }); Vue.filter('parseAmount', function (val) { if (!val) val = 0 return parseFloat(val / 100).toFixed(2) })