diff --git a/nezha-fronted/src/components/chart/chartHeader.vue b/nezha-fronted/src/components/chart/chartHeader.vue index 51ff3adb4..5b5ca6319 100644 --- a/nezha-fronted/src/components/chart/chartHeader.vue +++ b/nezha-fronted/src/components/chart/chartHeader.vue @@ -46,7 +46,7 @@ - + diff --git a/nezha-fronted/src/components/common/rightBox/asset/assetBox.vue b/nezha-fronted/src/components/common/rightBox/asset/assetBox.vue index 5c1376850..a3f696302 100644 --- a/nezha-fronted/src/components/common/rightBox/asset/assetBox.vue +++ b/nezha-fronted/src/components/common/rightBox/asset/assetBox.vue @@ -74,7 +74,6 @@ popper-class="right-box-select-top" style="width: 100%" type="date" - :value-format="timeFormatStrToDatePickFormat(timeFormatMain, 1)" :format="timeFormatStrToDatePickFormat(timeFormatMain, 1)"> @@ -139,13 +138,12 @@ @@ -158,8 +156,7 @@ popper-class="right-box-select-top" size="small" style="width: 100%" - :value-format="timeFormatStrToDatePickFormat(timeFormatMain)" - :format="timeFormatStrToDatePickFormat(timeFormatMain)"> + :format="timeFormatStrToDatePickFormat(timeFormatMain, JSON.parse(label.param).subType === assetConstants.labelSubTypeData.date)"> @@ -306,6 +303,7 @@ import { asset as assetConstants } from '@/components/common/js/constants' import selectAssetType from '@/components/common/popBox/selectAssetType' import locationCascader from '@/components/common/rightBox/locationCascader' import editRigthBox from '../../mixin/editRigthBox' +import bus from '@/libs/bus' export default { name: 'assetBox', @@ -667,6 +665,23 @@ export default { this.$refs.form.validate((valid) => { if (valid) { const params = JSON.parse(JSON.stringify(this.editAsset)) + console.log(params) + params.fields.forEach(field => { + if (field.type === 'DATETIME') { + const param = JSON.parse(field.param) + if (param.subType === 'date') { + field.value = field.value.map(time => bus.timeFormate(new Date(time), 'YYYY-MM-DD')) + } else if (param.subType === 'datetime') { + field.value = field.value.map(time => bus.timeFormate(new Date(time), 'YYYY-MM-DD HH:mm:ss')) + } + } + }) + console.log(params) + if (params.purchaseDate) { + console.log(params.purchaseDate) + params.purchaseDate = bus.timeFormate(new Date(params.purchaseDate), 'YYYY-MM-DD') + console.log(params.purchaseDate) + } if (params.type.vm !== 1) { params.parent = {} params.pid = '-1' diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue index 4dc689a4d..ba27c598d 100644 --- a/nezha-fronted/src/components/page/asset/asset.vue +++ b/nezha-fronted/src/components/page/asset/asset.vue @@ -758,6 +758,19 @@ export default { this.titleSearchList[key].show = true this.detailSearchList[key].show = true }) + }, + edit (u) { + this.$get(`${this.url}/${u.id}`).then(response => { + if (response.code === 200) { + if (response.data.purchaseDate) { + response.data.purchaseDate += ' 00:00:00' + response.data.purchaseDate = new Date(response.data.purchaseDate) + console.log(response.data.purchaseDate) + } + this.object = response.data + this.rightBox.show = true + } + }) } }, created () { diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/main.js index 27e0e6f8a..bd451fd50 100644 --- a/nezha-fronted/src/main.js +++ b/nezha-fronted/src/main.js @@ -161,8 +161,8 @@ Vue.mixin({ translation (key) { return i18n.t(key) }, - timeFormatStrToDatePickFormat (str, index) { - if (index === 1) { + timeFormatStrToDatePickFormat (str, flag) { + if (flag) { const reg = /Y/g str = str.replace(reg, 'y') const reg1 = /D/g