Commit b53e3235 by xinla

--no commit message

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