diff --git a/.env.dev b/.env.dev index 8b5bbe52..1da25e71 100644 --- a/.env.dev +++ b/.env.dev @@ -13,8 +13,8 @@ VUE_APP_TITLE = MES系统 # 芋道管理系统/开发环境 # VUE_APP_BASE_API = 'http://100.64.0.26:48082' -# VUE_APP_BASE_API = 'http://192.168.0.33:48082' -VUE_APP_BASE_API = 'http://192.168.4.173:48080' +VUE_APP_BASE_API = 'http://192.168.0.33:48082' +# VUE_APP_BASE_API = 'http://192.168.4.173:48080' # VUE_APP_BASE_API = 'http://192.168.2.173:48080' # VUE_APP_BASE_API = 'http://192.168.1.49:48082' # VUE_APP_BASE_API = 'http://192.168.1.8:48082' diff --git a/src/utils/ruoyi.js b/src/utils/ruoyi.js index 3b4e5256..5d875af0 100644 --- a/src/utils/ruoyi.js +++ b/src/utils/ruoyi.js @@ -5,7 +5,7 @@ const baseURL = process.env.VUE_APP_BASE_API -// 日期格式化 +// 日期格式化(通用) export function parseTime(time, pattern) { if (arguments.length === 0 || !time) { return null @@ -48,6 +48,51 @@ export function parseTime(time, pattern) { return time_str } +// 日期格式化(仅适用表格) +export function parseTimeTable(pattern) { + return function(time){ + if (arguments.length === 0 || !time) { + return null + } + const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}' + let date + if (typeof time === 'object') { + date = time + } else { + if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { + time = parseInt(time) + } else if (typeof time === 'string') { + time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.\d{3}/gm),''); + } + if ((typeof time === 'number') && (time.toString().length === 10)) { + time = time * 1000 + } + date = new Date(time) + } + const formatObj = { + y: date.getFullYear(), + m: date.getMonth() + 1, + d: date.getDate(), + h: date.getHours(), + i: date.getMinutes(), + s: date.getSeconds(), + a: date.getDay() + } + const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => { + let value = formatObj[key] + // Note: getDay() returns 0 on Sunday + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value] + } + if (result.length > 0 && value < 10) { + value = '0' + value + } + return value || 0 + }) + return time_str + } +} + // 表单重置 export function resetForm(refName) { if (this.$refs[refName]) { diff --git a/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue b/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue index 8d40d3d8..1dda33d5 100644 --- a/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue +++ b/src/views/energy/base/energyQuantityManual/components/energyQuantityManualAdd.vue @@ -45,7 +45,8 @@ @@ -89,20 +90,17 @@ export default { }, methods: { init(params) { - console.log(params) - this.form.recordTime = moment().format('YYYY-MM-DD') - console.log(this.form.recordTime) + this.form.recordTime = moment().valueOf() if (params.type === 'add') { this.isEdit = false } else if (params.type === 'meterReading') { this.isEdit = false - this.form.energyTypeId = params.energyType + this.form.energyTypeId = params.energyTypeId this.form.tableName = params.tableName + '' }else { this.isEdit = true this.form.id = params.id energyQuantityManualGet({id: this.form.id}).then(res => { - console.log(res) if (res.code === 0) { this.form.energyTypeId = res.data.energyTypeId this.form.tableName = res.data.tableName ? res.data.tableName+'' : '' @@ -118,6 +116,7 @@ export default { if (valid) { if (!this.form.unit) { this.$modal.msgError("抄表数单位不能为空"); + return false } if (this.isEdit) { // 编辑 diff --git a/src/views/energy/base/energyQuantityManual/index.vue b/src/views/energy/base/energyQuantityManual/index.vue index 33a5edf2..e94da7bc 100644 --- a/src/views/energy/base/energyQuantityManual/index.vue +++ b/src/views/energy/base/energyQuantityManual/index.vue @@ -48,26 +48,29 @@ import { energyQuantityManualPage, energyQuantityManualDelete, energyQuantityManualExport } from "@/api/base/energyQuantityManual" import { getEnergyTypeListAll } from "@/api/base/energyType" import { publicFormatter } from '@/utils/dict' -import { parseTime } from '@/utils/ruoyi' +import { parseTime, parseTimeTable } from '@/utils/ruoyi' // import FileSaver from "file-saver" // import * as XLSX from 'xlsx/xlsx.mjs' -import EnergyQuantityManualAdd from './components/energyQuantityManualAdd.vue' +import EnergyQuantityManualAdd from './components/energyQuantityManualAdd' import moment from 'moment' const tableProps = [ { prop: 'energyType', - label: '能源类型' + label: '能源类型', + minWidth: 110, + showOverflowtooltip: true }, { prop: 'tableName', label: '水/气表名', - filter: publicFormatter('table_name') + filter: publicFormatter('table_name'), + minWidth: 110 }, { prop: 'recordTime', label: '抄表日期', - filter: parseTime, - minWidth: 160 + filter: parseTimeTable('{y}-{m}-{d}'), + minWidth: 110 }, { prop: 'readingQuantity', @@ -76,12 +79,13 @@ const tableProps = [ { prop: 'recordTimeLast', label: '上期抄表日期', - filter: parseTime, - minWidth: 160 + filter: parseTimeTable('{y}-{m}-{d}'), + minWidth: 110 }, { prop: 'readingQuantityLast', - label: '上期抄表值' + label: '上期抄表值', + minWidth: 110 }, { prop: 'diff', @@ -191,42 +195,15 @@ export default { window.addEventListener('resize', () => { this.tableH = this.tableHeight(260) }) - if (location.href.indexOf('?') > 0) { - let arr = location.href.split('?')[1].split('&') - this.formConfig[1].defaultSelect = [arr[0].split('=')[1], arr[1].split('=')[1]] - this.queryParams.recordTime[0] = arr[0].split('=')[1] - this.queryParams.recordTime[1] = arr[1].split('=')[1] - } else { - let end = moment(moment().format('YYYY-MM-DD 23:59:59')).valueOf() - let start = moment(moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')).valueOf() - this.formConfig[1].defaultSelect = [start, end] - this.queryParams.recordTime[0] = start - this.queryParams.recordTime[1] = end - } + let end = moment(moment().format('YYYY-MM-DD 23:59:59')).valueOf() + let start = moment(moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')).valueOf() + this.formConfig[1].defaultSelect = [start, end] + this.queryParams.recordTime[0] = start + this.queryParams.recordTime[1] = end this.getList(); this.getTypeList() }, - watch: { - $route: 'initData' - }, methods: { - initData(to) { - if (to.name === 'EnergyQuantityManual') { - if (location.href.indexOf('?') > 0) { - let arr = location.href.split('?')[1].split('&') - this.formConfig[1].defaultSelect = [arr[0].split('=')[1], arr[1].split('=')[1]] - this.queryParams.recordTime[0] = arr[0].split('=')[1] - this.queryParams.recordTime[1] = arr[1].split('=')[1] - } else { - let end = moment(moment().format('YYYY-MM-DD 23:59:59')).valueOf() - let start = moment(moment().subtract(7, 'days').format('YYYY-MM-DD 00:00:00')).valueOf() - this.formConfig[1].defaultSelect = [start, end] - this.queryParams.recordTime[0] = start - this.queryParams.recordTime[1] = end - } - this.getList() - } - }, buttonClick(val) { this.queryParams.pageNo = 1; this.queryParams.energyTypeId = val.energyTypeId @@ -293,7 +270,7 @@ export default { this.centervisible = true let paramB = {} paramB.type = 'meterReading' - paramB.energyType = val.data.energyType + paramB.energyTypeId = val.data.energyTypeId paramB.tableName = val.data.tableName this.$nextTick(() => { this.$refs.energyQuantityManualAdd.init(paramB) diff --git a/src/views/energy/base/energyType/components/InnerTable.vue b/src/views/energy/base/energyType/components/InnerTable.vue index c7bfcfa7..5eab7af9 100644 --- a/src/views/energy/base/energyType/components/InnerTable.vue +++ b/src/views/energy/base/energyType/components/InnerTable.vue @@ -80,7 +80,6 @@ export default { let id = data.id getEnergyType(id).then((res) => { if (res.code === 0) { - console.log(res) if (res.data.pricingMethod === 0) { this.tableProps = this.temp1 this.singlePrice = '' diff --git a/src/views/energy/base/energyType/components/InputArea.vue b/src/views/energy/base/energyType/components/InputArea.vue index 94088653..3da297e7 100644 --- a/src/views/energy/base/energyType/components/InputArea.vue +++ b/src/views/energy/base/energyType/components/InputArea.vue @@ -22,7 +22,6 @@ export default { }, methods: { changeInput() { - console.log(this.list) this.$emit('emitData', this.list) } } diff --git a/src/views/energy/base/energyType/components/TimePickerArea.vue b/src/views/energy/base/energyType/components/TimePickerArea.vue index d3b6810b..04730552 100644 --- a/src/views/energy/base/energyType/components/TimePickerArea.vue +++ b/src/views/energy/base/energyType/components/TimePickerArea.vue @@ -28,7 +28,6 @@ export default { }, methods: { changeInput() { - console.log(this.list) this.$emit('emitData', this.list) } } diff --git a/src/views/energy/base/energyType/components/energyTypeAdd.vue b/src/views/energy/base/energyType/components/energyTypeAdd.vue index 73c8cd2a..0e9a9342 100644 --- a/src/views/energy/base/energyType/components/energyTypeAdd.vue +++ b/src/views/energy/base/energyType/components/energyTypeAdd.vue @@ -221,10 +221,10 @@ export default { // 增加 emitButtonClick1() { let n = this.tableData1.length - if (n >=3) { - this.$modal.msgWarning('最多可添加3档计价') - return false - } + // if (n >=3) { + // this.$modal.msgWarning('最多可添加3档计价') + // return false + // } let obj = {} obj.startTime = n === 0 ? '' : this.tableData1[n-1].endTime obj.endTime = '' diff --git a/src/views/energy/monitoring/energyOverlimitLog/index.vue b/src/views/energy/monitoring/energyOverlimitLog/index.vue index c9284dea..1cffef1e 100644 --- a/src/views/energy/monitoring/energyOverlimitLog/index.vue +++ b/src/views/energy/monitoring/energyOverlimitLog/index.vue @@ -43,6 +43,7 @@ import { getEnergyOverlimitLogPage } from "@/api/monitoring/energyOverlimitLog"; import { getEnergyTypeListAll } from "@/api/base/energyType"; import { publicFormatter } from '@/utils/dict' +import { parseTime } from '@/utils/ruoyi' const tableProps = [ { prop: 'objName', diff --git a/src/views/group/base/groupTeamScheduling/index.vue b/src/views/group/base/groupTeamScheduling/index.vue index 2682c964..54800965 100644 --- a/src/views/group/base/groupTeamScheduling/index.vue +++ b/src/views/group/base/groupTeamScheduling/index.vue @@ -290,8 +290,7 @@ export default { break; case '2': // 能源 this.$router.push({ - // path: '/energy/base/energy-quantity-realtime?startTime='+this.chooseObj.startTime+'&endTime='+this.chooseObj.endTime - path: '/energy/base/energy-quantity-manual?startTime='+this.chooseObj.startTime+'&endTime='+this.chooseObj.endTime + path: '/energy/base/energy-quantity-realtime?startTime='+this.chooseObj.startTime+'&endTime='+this.chooseObj.endTime }) break; default: diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 3397a935..9561f92e 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -28,6 +28,7 @@ +