Commit b53e3235 by xinla

--no commit message

1 parent ebcdff1c
...@@ -64,6 +64,9 @@ Vue.prototype.msgInfo = function(msg) { ...@@ -64,6 +64,9 @@ Vue.prototype.msgInfo = function(msg) {
this.$message.info(msg) this.$message.info(msg)
} }
import { pickerOptions } from '@/utils/index'
Vue.prototype.pickerOptions = pickerOptions
// 全局组件挂载 // 全局组件挂载
Vue.component('Pagination', Pagination) Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar) Vue.component('RightToolbar', RightToolbar)
......
...@@ -4,15 +4,20 @@ import { parseTime } from './common' ...@@ -4,15 +4,20 @@ import { parseTime } from './common'
* 表格时间格式化 * 表格时间格式化
*/ */
export function formatDate(cellValue) { export function formatDate(cellValue) {
if (cellValue == null || cellValue == "") return ""; if (cellValue == null || cellValue == '') return ''
var date = new Date(cellValue) var date = new Date(cellValue)
var year = date.getFullYear() var year = date.getFullYear()
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 var month =
date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() var minutes =
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds var seconds =
date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return (
year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
)
} }
/** /**
...@@ -88,7 +93,7 @@ export function byteLength(str) { ...@@ -88,7 +93,7 @@ export function byteLength(str) {
const code = str.charCodeAt(i) const code = str.charCodeAt(i)
if (code > 0x7f && code <= 0x7ff) s++ if (code > 0x7f && code <= 0x7ff) s++
else if (code > 0x7ff && code <= 0xffff) s += 2 else if (code > 0x7ff && code <= 0xffff) s += 2
if (code >= 0xDC00 && code <= 0xDFFF) i-- if (code >= 0xdc00 && code <= 0xdfff) i--
} }
return s return s
} }
...@@ -114,7 +119,7 @@ export function cleanArray(actual) { ...@@ -114,7 +119,7 @@ export function cleanArray(actual) {
export function param(json) { export function param(json) {
if (!json) return '' if (!json) return ''
return cleanArray( return cleanArray(
Object.keys(json).map(key => { Object.keys(json).map((key) => {
if (json[key] === undefined) return '' if (json[key] === undefined) return ''
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]) return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
}) })
...@@ -132,7 +137,7 @@ export function param2Obj(url) { ...@@ -132,7 +137,7 @@ export function param2Obj(url) {
} }
const obj = {} const obj = {}
const searchArr = search.split('&') const searchArr = search.split('&')
searchArr.forEach(v => { searchArr.forEach((v) => {
const index = v.indexOf('=') const index = v.indexOf('=')
if (index !== -1) { if (index !== -1) {
const name = v.substring(0, index) const name = v.substring(0, index)
...@@ -166,7 +171,7 @@ export function objectMerge(target, source) { ...@@ -166,7 +171,7 @@ export function objectMerge(target, source) {
if (Array.isArray(source)) { if (Array.isArray(source)) {
return source.slice() return source.slice()
} }
Object.keys(source).forEach(property => { Object.keys(source).forEach((property) => {
const sourceProperty = source[property] const sourceProperty = source[property]
if (typeof sourceProperty === 'object') { if (typeof sourceProperty === 'object') {
target[property] = objectMerge(target[property], sourceProperty) target[property] = objectMerge(target[property], sourceProperty)
...@@ -218,7 +223,7 @@ export function getTime(type) { ...@@ -218,7 +223,7 @@ export function getTime(type) {
export function debounce(func, wait, immediate) { export function debounce(func, wait, immediate) {
let timeout, args, context, timestamp, result let timeout, args, context, timestamp, result
const later = function () { const later = function() {
// 据上一次触发时间间隔 // 据上一次触发时间间隔
const last = +new Date() - timestamp const last = +new Date() - timestamp
...@@ -235,7 +240,7 @@ export function debounce(func, wait, immediate) { ...@@ -235,7 +240,7 @@ export function debounce(func, wait, immediate) {
} }
} }
return function (...args) { return function(...args) {
context = this context = this
timestamp = +new Date() timestamp = +new Date()
const callNow = immediate && !timeout const callNow = immediate && !timeout
...@@ -262,7 +267,7 @@ export function deepClone(source) { ...@@ -262,7 +267,7 @@ export function deepClone(source) {
throw new Error('error arguments', 'deepClone') throw new Error('error arguments', 'deepClone')
} }
const targetObj = source.constructor === Array ? [] : {} const targetObj = source.constructor === Array ? [] : {}
Object.keys(source).forEach(keys => { Object.keys(source).forEach((keys) => {
if (source[keys] && typeof source[keys] === 'object') { if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = deepClone(source[keys]) targetObj[keys] = deepClone(source[keys])
} else { } else {
...@@ -326,9 +331,7 @@ export function makeMap(str, expectsLowerCase) { ...@@ -326,9 +331,7 @@ export function makeMap(str, expectsLowerCase) {
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
map[list[i]] = true map[list[i]] = true
} }
return expectsLowerCase return expectsLowerCase ? (val) => map[val.toLowerCase()] : (val) => map[val]
? val => map[val.toLowerCase()]
: val => map[val]
} }
export const exportDefault = 'export default ' export const exportDefault = 'export default '
...@@ -351,7 +354,7 @@ export const beautifierConf = { ...@@ -351,7 +354,7 @@ export const beautifierConf = {
indent_inner_html: true, indent_inner_html: true,
comma_first: false, comma_first: false,
e4x: true, e4x: true,
indent_empty_lines: true indent_empty_lines: true,
}, },
js: { js: {
indent_size: '2', indent_size: '2',
...@@ -370,21 +373,56 @@ export const beautifierConf = { ...@@ -370,21 +373,56 @@ export const beautifierConf = {
indent_inner_html: true, indent_inner_html: true,
comma_first: false, comma_first: false,
e4x: true, e4x: true,
indent_empty_lines: true indent_empty_lines: true,
} },
} }
// 首字母大小 // 首字母大小
export function titleCase(str) { export function titleCase(str) {
return str.replace(/( |^)[a-z]/g, L => L.toUpperCase()) return str.replace(/( |^)[a-z]/g, (L) => L.toUpperCase())
} }
// 下划转驼峰 // 下划转驼峰
export function camelCase(str) { export function camelCase(str) {
return str.replace(/-[a-z]/g, str1 => str1.substr(-1).toUpperCase()) return str.replace(/-[a-z]/g, (str1) => str1.substr(-1).toUpperCase())
} }
export function isNumberStr(str) { export function isNumberStr(str) {
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
} }
// 日期快捷选项
export const pickerOptions = {
disabledDate(time) {
return time.getTime() > Date.now()
},
shortcuts: [
{
text: '最近一周',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
picker.$emit('pick', [start, end])
},
},
{
text: '最近一个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
},
},
{
text: '最近三个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
picker.$emit('pick', [start, end])
},
},
],
}
...@@ -10,6 +10,7 @@ export default { ...@@ -10,6 +10,7 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
activityScene: '', activityScene: '',
createBy: '',
beginTime: '', // "开始时间", beginTime: '', // "开始时间",
endTime: '', // "结束时间" endTime: '', // "结束时间"
}, },
...@@ -48,8 +49,7 @@ export default { ...@@ -48,8 +49,7 @@ export default {
} }
page && (this.query.pageNum = page) page && (this.query.pageNum = page)
this.loading = true this.loading = true
api getList(this.query)
.getList(this.query)
.then(({ rows, total }) => { .then(({ rows, total }) => {
this.list = rows this.list = rows
this.total = +total this.total = +total
...@@ -147,9 +147,9 @@ export default { ...@@ -147,9 +147,9 @@ export default {
<el-input v-model="query.name" placeholder="请输入"></el-input> <el-input v-model="query.name" placeholder="请输入"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="创建人"> <el-form-item label="创建人">
<div class="tag-input" @click="dialogVisibleSelectUser = true"> <el-input v-model="query.createBy" placeholder="请输入"></el-input>
<el-input v-model="query.name" placeholder="请输入"></el-input> <!-- <div class="tag-input" @click="dialogVisibleSelectUser = true">
<!-- <span class="tag-place" v-if="!queryUser.length">请选择</span> <span class="tag-place" v-if="!queryUser.length">请选择</span>
<template v-else> <template v-else>
<el-tag <el-tag
type="info" type="info"
...@@ -157,8 +157,8 @@ export default { ...@@ -157,8 +157,8 @@ export default {
:key="unique" :key="unique"
>{{ unit.name }}</el-tag >{{ unit.name }}</el-tag
> >
</template> --> </template>
</div> </div> -->
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="创建时间">
<el-date-picker <el-date-picker
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!