正在显示
13 个修改的文件
包含
51 行增加
和
39 行删除
| @@ -18,13 +18,13 @@ import './assets/icons' // icon | @@ -18,13 +18,13 @@ import './assets/icons' // icon | ||
| 18 | import './permission' // permission control | 18 | import './permission' // permission control |
| 19 | import { getDicts } from "@/api/system/dict/data"; | 19 | import { getDicts } from "@/api/system/dict/data"; |
| 20 | import { getConfigKey } from "@/api/system/config"; | 20 | import { getConfigKey } from "@/api/system/config"; |
| 21 | -import { dateFormat, resetForm, addDateRange, selectDictLabel } from "@/utils/ruoyi"; | 21 | +import { parseTime, resetForm, addDateRange, selectDictLabel } from "@/utils/ruoyi"; |
| 22 | import Pagination from "@/components/Pagination"; | 22 | import Pagination from "@/components/Pagination"; |
| 23 | 23 | ||
| 24 | // 全局方法挂载 | 24 | // 全局方法挂载 |
| 25 | Vue.prototype.getDicts = getDicts | 25 | Vue.prototype.getDicts = getDicts |
| 26 | Vue.prototype.getConfigKey = getConfigKey | 26 | Vue.prototype.getConfigKey = getConfigKey |
| 27 | -Vue.prototype.dateFormat = dateFormat | 27 | +Vue.prototype.parseTime = parseTime |
| 28 | Vue.prototype.resetForm = resetForm | 28 | Vue.prototype.resetForm = resetForm |
| 29 | Vue.prototype.addDateRange = addDateRange | 29 | Vue.prototype.addDateRange = addDateRange |
| 30 | Vue.prototype.selectDictLabel = selectDictLabel | 30 | Vue.prototype.selectDictLabel = selectDictLabel |
| @@ -4,12 +4,42 @@ | @@ -4,12 +4,42 @@ | ||
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | // 日期格式化 | 6 | // 日期格式化 |
| 7 | -export function dateFormat(date, pattern) { | ||
| 8 | - var d = new Date(date).Format("yyyy-MM-dd hh:mm:ss"); | ||
| 9 | - if (pattern) { | ||
| 10 | - d = new Date(date).Format(pattern); | ||
| 11 | - } | ||
| 12 | - return d.toLocaleString(); | 7 | +export function parseTime(time, pattern) { |
| 8 | + if (arguments.length === 0) { | ||
| 9 | + return null | ||
| 10 | + } | ||
| 11 | + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' | ||
| 12 | + let date | ||
| 13 | + if (typeof time === 'object') { | ||
| 14 | + date = time | ||
| 15 | + } else { | ||
| 16 | + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { | ||
| 17 | + time = parseInt(time) | ||
| 18 | + } | ||
| 19 | + if ((typeof time === 'number') && (time.toString().length === 10)) { | ||
| 20 | + time = time * 1000 | ||
| 21 | + } | ||
| 22 | + date = new Date(time) | ||
| 23 | + } | ||
| 24 | + const formatObj = { | ||
| 25 | + y: date.getFullYear(), | ||
| 26 | + m: date.getMonth() + 1, | ||
| 27 | + d: date.getDate(), | ||
| 28 | + h: date.getHours(), | ||
| 29 | + i: date.getMinutes(), | ||
| 30 | + s: date.getSeconds(), | ||
| 31 | + a: date.getDay() | ||
| 32 | + } | ||
| 33 | + const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => { | ||
| 34 | + let value = formatObj[key] | ||
| 35 | + // Note: getDay() returns 0 on Sunday | ||
| 36 | + if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] } | ||
| 37 | + if (result.length > 0 && value < 10) { | ||
| 38 | + value = '0' + value | ||
| 39 | + } | ||
| 40 | + return value || 0 | ||
| 41 | + }) | ||
| 42 | + return time_str | ||
| 13 | } | 43 | } |
| 14 | 44 | ||
| 15 | // 表单重置 | 45 | // 表单重置 |
| @@ -55,22 +85,4 @@ export function sprintf(str) { | @@ -55,22 +85,4 @@ export function sprintf(str) { | ||
| 55 | return arg; | 85 | return arg; |
| 56 | }); | 86 | }); |
| 57 | return flag ? str : ''; | 87 | return flag ? str : ''; |
| 58 | -} | ||
| 59 | - | ||
| 60 | -Date.prototype.Format = function (fmt) { | ||
| 61 | - var o = { | ||
| 62 | - "M+": this.getMonth() + 1, // 月份 | ||
| 63 | - "d+": this.getDate(), // 日 | ||
| 64 | - "h+": this.getHours(), // 小时 | ||
| 65 | - "m+": this.getMinutes(), // 分 | ||
| 66 | - "s+": this.getSeconds(), // 秒 | ||
| 67 | - "q+": Math.floor((this.getMonth() + 3) / 3), // 季度 | ||
| 68 | - "S": this.getMilliseconds() // 毫秒 | ||
| 69 | - }; | ||
| 70 | - if (/(y+)/.test(fmt)) | ||
| 71 | - fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); | ||
| 72 | - for (var k in o) | ||
| 73 | - if (new RegExp("(" + k + ")").test(fmt)) | ||
| 74 | - fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); | ||
| 75 | - return fmt; | ||
| 76 | -} | ||
| 88 | +} |
| @@ -65,7 +65,7 @@ | @@ -65,7 +65,7 @@ | ||
| 65 | <el-table-column label="操作信息" align="center" prop="msg" /> | 65 | <el-table-column label="操作信息" align="center" prop="msg" /> |
| 66 | <el-table-column label="登录日期" align="center" prop="loginTime" width="180"> | 66 | <el-table-column label="登录日期" align="center" prop="loginTime" width="180"> |
| 67 | <template slot-scope="scope"> | 67 | <template slot-scope="scope"> |
| 68 | - <span>{{ dateFormat(scope.row.loginTime) }}</span> | 68 | + <span>{{ parseTime(scope.row.loginTime) }}</span> |
| 69 | </template> | 69 | </template> |
| 70 | </el-table-column> | 70 | </el-table-column> |
| 71 | </el-table> | 71 | </el-table> |
| @@ -81,7 +81,7 @@ | @@ -81,7 +81,7 @@ | ||
| 81 | <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" /> | 81 | <el-table-column label="操作状态" align="center" prop="status" :formatter="statusFormat" /> |
| 82 | <el-table-column label="操作日期" align="center" prop="operTime" width="180"> | 82 | <el-table-column label="操作日期" align="center" prop="operTime" width="180"> |
| 83 | <template slot-scope="scope"> | 83 | <template slot-scope="scope"> |
| 84 | - <span>{{ dateFormat(scope.row.operTime) }}</span> | 84 | + <span>{{ parseTime(scope.row.operTime) }}</span> |
| 85 | </template> | 85 | </template> |
| 86 | </el-table-column> | 86 | </el-table-column> |
| 87 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 87 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -135,7 +135,7 @@ | @@ -135,7 +135,7 @@ | ||
| 135 | </el-form-item> | 135 | </el-form-item> |
| 136 | </el-col> | 136 | </el-col> |
| 137 | <el-col :span="12"> | 137 | <el-col :span="12"> |
| 138 | - <el-form-item label="操作时间:">{{ dateFormat(form.operTime) }}</el-form-item> | 138 | + <el-form-item label="操作时间:">{{ parseTime(form.operTime) }}</el-form-item> |
| 139 | </el-col> | 139 | </el-col> |
| 140 | <el-col :span="24"> | 140 | <el-col :span="24"> |
| 141 | <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item> | 141 | <el-form-item label="异常信息:" v-if="form.status === 1">{{ form.errorMsg }}</el-form-item> |
| @@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
| 58 | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | 58 | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| 59 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 59 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 60 | <template slot-scope="scope"> | 60 | <template slot-scope="scope"> |
| 61 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 61 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 62 | </template> | 62 | </template> |
| 63 | </el-table-column> | 63 | </el-table-column> |
| 64 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 64 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -51,7 +51,7 @@ | @@ -51,7 +51,7 @@ | ||
| 51 | <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column> | 51 | <el-table-column prop="status" label="状态" :formatter="statusFormat" width="100"></el-table-column> |
| 52 | <el-table-column label="创建时间" align="center" prop="createTime" width="200"> | 52 | <el-table-column label="创建时间" align="center" prop="createTime" width="200"> |
| 53 | <template slot-scope="scope"> | 53 | <template slot-scope="scope"> |
| 54 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 54 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 55 | </template> | 55 | </template> |
| 56 | </el-table-column> | 56 | </el-table-column> |
| 57 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 57 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
| 45 | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | 45 | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| 46 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 46 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 47 | <template slot-scope="scope"> | 47 | <template slot-scope="scope"> |
| 48 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 48 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 49 | </template> | 49 | </template> |
| 50 | </el-table-column> | 50 | </el-table-column> |
| 51 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 51 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -69,7 +69,7 @@ | @@ -69,7 +69,7 @@ | ||
| 69 | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> | 69 | <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
| 70 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 70 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 71 | <template slot-scope="scope"> | 71 | <template slot-scope="scope"> |
| 72 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 72 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 73 | </template> | 73 | </template> |
| 74 | </el-table-column> | 74 | </el-table-column> |
| 75 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 75 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
| 44 | <el-table-column prop="visible" label=" 可见" :formatter="visibleFormat" width="80px"></el-table-column> | 44 | <el-table-column prop="visible" label=" 可见" :formatter="visibleFormat" width="80px"></el-table-column> |
| 45 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 45 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 46 | <template slot-scope="scope"> | 46 | <template slot-scope="scope"> |
| 47 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 47 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 48 | </template> | 48 | </template> |
| 49 | </el-table-column> | 49 | </el-table-column> |
| 50 | <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width"> | 50 | <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width"> |
| @@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
| 60 | <el-table-column label="创建者" align="center" prop="createBy" width="100" /> | 60 | <el-table-column label="创建者" align="center" prop="createBy" width="100" /> |
| 61 | <el-table-column label="创建时间" align="center" prop="createTime" width="100"> | 61 | <el-table-column label="创建时间" align="center" prop="createTime" width="100"> |
| 62 | <template slot-scope="scope"> | 62 | <template slot-scope="scope"> |
| 63 | - <span>{{ dateFormat(scope.row.createTime, 'yyyy-MM-dd') }}</span> | 63 | + <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> |
| 64 | </template> | 64 | </template> |
| 65 | </el-table-column> | 65 | </el-table-column> |
| 66 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 66 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
| 43 | <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" /> | 43 | <el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" /> |
| 44 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 44 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 45 | <template slot-scope="scope"> | 45 | <template slot-scope="scope"> |
| 46 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 46 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 47 | </template> | 47 | </template> |
| 48 | </el-table-column> | 48 | </el-table-column> |
| 49 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 49 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -78,7 +78,7 @@ | @@ -78,7 +78,7 @@ | ||
| 78 | </el-table-column> | 78 | </el-table-column> |
| 79 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 79 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 80 | <template slot-scope="scope"> | 80 | <template slot-scope="scope"> |
| 81 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 81 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 82 | </template> | 82 | </template> |
| 83 | </el-table-column> | 83 | </el-table-column> |
| 84 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 84 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| @@ -100,7 +100,7 @@ | @@ -100,7 +100,7 @@ | ||
| 100 | </el-table-column> | 100 | </el-table-column> |
| 101 | <el-table-column label="创建时间" align="center" prop="createTime" width="160"> | 101 | <el-table-column label="创建时间" align="center" prop="createTime" width="160"> |
| 102 | <template slot-scope="scope"> | 102 | <template slot-scope="scope"> |
| 103 | - <span>{{ dateFormat(scope.row.createTime) }}</span> | 103 | + <span>{{ parseTime(scope.row.createTime) }}</span> |
| 104 | </template> | 104 | </template> |
| 105 | </el-table-column> | 105 | </el-table-column> |
| 106 | <el-table-column | 106 | <el-table-column |
-
请 注册 或 登录 后发表评论