diff --git a/ebts-ui/src/api/system/dict/type.js b/ebts-ui/src/api/system/dict/type.js index bc77692..35028a3 100644 --- a/ebts-ui/src/api/system/dict/type.js +++ b/ebts-ui/src/api/system/dict/type.js @@ -61,9 +61,9 @@ export function exportType(query) { } // 获取字典选择框列表 -export function optionselect() { +export function optionSelect() { return request({ url: '/system/dict/type/optionselect', method: 'get' }) -} \ No newline at end of file +} diff --git a/ebts-ui/src/api/system/user.js b/ebts-ui/src/api/system/user.js index b806cce..23394e3 100644 --- a/ebts-ui/src/api/system/user.js +++ b/ebts-ui/src/api/system/user.js @@ -1,5 +1,5 @@ import request from '@/utils/request' -import { praseStrEmpty } from "@/utils/hcy"; +import { praseStrEmpty } from "@/utils/ebts"; // 查询用户列表 export function listUser(query) { diff --git a/ebts-ui/src/main.js b/ebts-ui/src/main.js index b2774cd..6fb9bec 100644 --- a/ebts-ui/src/main.js +++ b/ebts-ui/src/main.js @@ -18,7 +18,17 @@ import './assets/icons' // icon import './permission' // permission control import { getDicts } from "@/api/system/dict/data"; import { getConfigKey } from "@/api/system/config"; -import { parseTime, resetForm, addDateRange, addCreateDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/hcy"; +import { + parseTime, + resetForm, + addDateRange, + addCreateDateRange, + selectDictLabel, + selectDictLabels, + download, + handleTree, + parseDateOrTime, checkDateType +} from "@/utils/ebts"; import Pagination from "@/components/Pagination"; //自定义表格工具扩展 import RightToolbar from "@/components/RightToolbar" @@ -32,6 +42,8 @@ Vue.prototype.addDateRange = addDateRange Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.addCreateDateRange = addCreateDateRange Vue.prototype.selectDictLabels = selectDictLabels +Vue.prototype.parseDateOrTime = parseDateOrTime +Vue.prototype.checkDateType = checkDateType Vue.prototype.download = download Vue.prototype.handleTree = handleTree diff --git a/ebts-ui/src/utils/hcy.js b/ebts-ui/src/utils/ebts.js similarity index 85% rename from ebts-ui/src/utils/hcy.js rename to ebts-ui/src/utils/ebts.js index dada41d..f120ea1 100644 --- a/ebts-ui/src/utils/hcy.js +++ b/ebts-ui/src/utils/ebts.js @@ -5,6 +5,20 @@ const baseURL = process.env.VUE_APP_BASE_API + +export function parseDateOrTime(time){ + if (time){ + return parseTime(new Date(time),'{y}-{m}-{d} {h}:{m}:{s}') + } +} +/** + * 检查是否为时间类型 + * @param prop + */ +export function checkDateType(prop){ + prop = prop.toLowerCase().replace('update','') + return !(-1 === prop.indexOf('date') && -1 === prop.indexOf('time')) +} // 日期格式化 export function parseTime(time, pattern) { if (arguments.length === 0 || !time) { @@ -55,7 +69,7 @@ export function resetForm(refName) { // 添加日期范围 export function addDateRange(params, dateRange) { - var search = params; + let search = params; search.beginTime = ""; search.endTime = ""; if (null != dateRange && '' != dateRange) { @@ -66,7 +80,7 @@ export function addDateRange(params, dateRange) { } // 添加搜索创建时间日期范围 export function addCreateDateRange(params, dateRange) { - var search = params; + let search = params; let data = { beginCreateTime : "", endCreateTime : "", @@ -81,9 +95,9 @@ export function addCreateDateRange(params, dateRange) { // 回显数据字典 export function selectDictLabel(datas, value) { - var actions = []; + let actions = []; Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + value)) { + if (datas[key].dictValue === ('' + value)) { actions.push(datas[key].dictLabel); return true; } @@ -93,12 +107,12 @@ export function selectDictLabel(datas, value) { // 回显数据字典(字符串数组) export function selectDictLabels(datas, value, separator) { - var actions = []; - var currentSeparator = undefined === separator ? "," : separator; - var temp = value.split(currentSeparator); + let actions = []; + let currentSeparator = undefined === separator ? "," : separator; + let temp = value.split(currentSeparator); Object.keys(value.split(currentSeparator)).some((val) => { Object.keys(datas).some((key) => { - if (datas[key].dictValue == ('' + temp[val])) { + if (datas[key].dictValue === ('' + temp[val])) { actions.push(datas[key].dictLabel + currentSeparator); } }) @@ -113,9 +127,9 @@ export function download(fileName) { // 字符串格式化(%s ) export function sprintf(str) { - var args = arguments, flag = true, i = 1; + let args = arguments, flag = true, i = 1; str = str.replace(/%s/g, function () { - var arg = args[i++]; + let arg = args[i++]; if (typeof arg === 'undefined') { flag = false; return ''; diff --git a/ebts-ui/src/utils/index.js b/ebts-ui/src/utils/index.js index 91be37f..8bea0bc 100644 --- a/ebts-ui/src/utils/index.js +++ b/ebts-ui/src/utils/index.js @@ -1,17 +1,17 @@ -import { parseTime } from './hcy' +import { parseTime } from './ebts' /** * 表格时间格式化 */ export function formatDate(cellValue) { 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 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() + let date = new Date(cellValue) + let year = date.getFullYear() + let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1 + let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() + let hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() + let minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() + let seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds } @@ -84,7 +84,7 @@ export function getQueryObject(url) { export function byteLength(str) { // returns the byte length of an utf8 string let s = str.length - for (var i = str.length - 1; i >= 0; i--) { + for (let i = str.length - 1; i >= 0; i--) { const code = str.charCodeAt(i) if (code > 0x7f && code <= 0x7ff) s++ else if (code > 0x7ff && code <= 0xffff) s += 2 diff --git a/ebts-ui/src/views/system/query/queryDate.vue b/ebts-ui/src/views/system/query/queryDate.vue index 01738a0..c063fbe 100644 --- a/ebts-ui/src/views/system/query/queryDate.vue +++ b/ebts-ui/src/views/system/query/queryDate.vue @@ -60,12 +60,23 @@ - + + + + + + import {realInfo, realData, exportReal} from "@/api/system/data" +import {parseTime} from "@/utils/ebts"; function listInit(list) { for (let i = 0; i < list.length; i++) { diff --git a/ebts-ui/src/views/tool/gen/editTable.vue b/ebts-ui/src/views/tool/gen/editTable.vue index c25d54e..4d6b1e9 100644 --- a/ebts-ui/src/views/tool/gen/editTable.vue +++ b/ebts-ui/src/views/tool/gen/editTable.vue @@ -117,7 +117,7 @@ :value="dict.dictType"> {{ dict.dictName }} {{ dict.dictType }} - + @@ -137,7 +137,7 @@ -