Merge branch 'dev-3.4-report' of git.mesalab.cn:nezha/nezha-fronted into dev-3.4-crosshair

This commit is contained in:
zyh
2022-06-16 13:56:47 +08:00
2 changed files with 62 additions and 15 deletions

View File

@@ -52,7 +52,7 @@
<el-form-item <el-form-item
:label="$t('backup.start')" :label="$t('backup.start')"
class="form-item--half-width" class="form-item--half-width"
prop="stime" prop="param.report.schedule.stime"
> >
<my-date-picker align="right" class=" " <my-date-picker align="right" class=" "
v-model="editPanel.param.report.schedule.stime" v-model="editPanel.param.report.schedule.stime"
@@ -66,7 +66,7 @@
<el-form-item <el-form-item
:label="$t('dashboard.panel.endAt')" :label="$t('dashboard.panel.endAt')"
class="form-item--half-width" class="form-item--half-width"
prop="etime" prop="param.report.schedule.etime"
> >
<my-date-picker align="right" class=" " <my-date-picker align="right" class=" "
v-model="editPanel.param.report.schedule.etime" v-model="editPanel.param.report.schedule.etime"
@@ -77,7 +77,7 @@
type="datetime"> type="datetime">
</my-date-picker> </my-date-picker>
</el-form-item> </el-form-item>
<el-form-item :label='$t("dashboard.panel.period")' class="range-time" prop="unit"> <el-form-item :label='$t("dashboard.panel.period")' class="range-time" prop="param.report.range.unit">
<el-radio-group v-model="editPanel.param.report.range.unit" size="small"> <el-radio-group v-model="editPanel.param.report.range.unit" size="small">
<el-radio-button label="day">{{ $t("dashboard.panel.prevDay") }}</el-radio-button> <el-radio-button label="day">{{ $t("dashboard.panel.prevDay") }}</el-radio-button>
<el-radio-button label="week">{{ $t("dashboard.panel.prevWeek") }}</el-radio-button> <el-radio-button label="week">{{ $t("dashboard.panel.prevWeek") }}</el-radio-button>
@@ -86,7 +86,7 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
:label="$t('backup.schedule')" :label="$t('backup.schedule')"
prop="schType" prop="param.report.schedule.type"
class="form-tabs"> class="form-tabs">
<el-tabs <el-tabs
v-model="editPanel.param.report.schedule.type" v-model="editPanel.param.report.schedule.type"
@@ -102,7 +102,7 @@
<el-form-item <el-form-item
v-if="isShow === 2 || isShow === 3 ? true :false" v-if="isShow === 2 || isShow === 3 ? true :false"
:label="$t('backup.RepeatEvery')" :label="$t('backup.RepeatEvery')"
prop="repeat" prop="param.report.schedule.repeat"
class="form-day-week"> class="form-day-week">
<el-input <el-input
size="small" size="small"
@@ -144,7 +144,7 @@
>{{ item }}</el-checkbox-button> >{{ item }}</el-checkbox-button>
</el-checkbox-group> </el-checkbox-group>
</el-form-item> </el-form-item>
<el-form-item v-if="isShow !== 0 ? true : false" :label="$t('dashboard.panel.receivers')" class="item-receivers" prop="receivers"> <el-form-item :label="$t('dashboard.panel.receivers')" class="item-receivers" prop="param.report.receivers">
<el-select v-model="editPanel.param.report.receivers" clearable multiple placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="chartType"> <el-select v-model="editPanel.param.report.receivers" clearable multiple placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="chartType">
<el-option v-for="item in userData" :key="item.id" :label="item.name" :value="item.id"> <el-option v-for="item in userData" :key="item.id" :label="item.name" :value="item.id">
<span class="panel-dropdown-label-txt" >{{item.name}}</span> <span class="panel-dropdown-label-txt" >{{item.name}}</span>
@@ -175,6 +175,7 @@
<script> <script>
import editRigthBox from '../mixin/editRigthBox' import editRigthBox from '../mixin/editRigthBox'
import bus from '@/libs/bus' import bus from '@/libs/bus'
import { arrLength, datePicker } from '@/components/common/js/validate'
export default { export default {
name: 'panelBox', name: 'panelBox',
props: { props: {
@@ -192,6 +193,23 @@ export default {
rules: { rules: {
name: [ name: [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' } { required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
'param.report.range.unit': [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
'param.report.schedule.type': [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
],
'param.report.schedule.repeat': [
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
],
'param.report.schedule.stime': [{
required: true,
message: this.$t('validate.required')
}, { validator: datePicker, trigger: 'blur' }],
'param.report.receivers': [
{ required: true, message: this.$t('validate.required'), trigger: 'change' },
{ validator: arrLength }
] ]
}, },
week: [ week: [
@@ -247,8 +265,16 @@ export default {
if (this.editPanel.id) { if (this.editPanel.id) {
this.isShow = Number(this.editPanel.param.report.schedule.type) this.isShow = Number(this.editPanel.param.report.schedule.type)
this.editPanel.param.report.schedule.type = this.editPanel.param.report.schedule.type + '' this.editPanel.param.report.schedule.type = this.editPanel.param.report.schedule.type + ''
this.editPanel.param.report.schedule.stime = this.utcTimeToTimezoneStr(this.editPanel.param.report.schedule.stime) if (this.editPanel.param.report.schedule.stime !== '') {
this.editPanel.param.report.schedule.etime = this.utcTimeToTimezoneStr(this.editPanel.param.report.schedule.etime) this.editPanel.param.report.schedule.stime = this.utcTimeToTimezoneStr(this.editPanel.param.report.schedule.stime)
} else {
this.editPanel.param.report.schedule.stime = ''
}
if (this.editPanel.param.report.schedule.etime !== '') {
this.editPanel.param.report.schedule.etime = this.utcTimeToTimezoneStr(this.editPanel.param.report.schedule.etime)
} else {
this.editPanel.param.report.schedule.etime = ''
}
} }
}, },
mounted () { mounted () {
@@ -269,7 +295,7 @@ export default {
this.isShow = Number(tab.name) this.isShow = Number(tab.name)
if (this.editPanel.param.report.schedule.nums) { if (this.editPanel.param.report.schedule.nums) {
this.editPanel.param.report.schedule.nums = [] this.editPanel.param.report.schedule.nums = []
this.editPanel.param.report.schedule.repeat = 0 this.editPanel.param.report.schedule.repeat = 1
} }
}, },
/* 关闭弹框 */ /* 关闭弹框 */
@@ -300,9 +326,9 @@ export default {
schedule: { schedule: {
type: Number(this.editPanel.param.report.schedule.type), type: Number(this.editPanel.param.report.schedule.type),
repeat: this.editPanel.param.report.schedule.repeat ? this.editPanel.param.report.schedule.repeat : 1, repeat: this.editPanel.param.report.schedule.repeat ? this.editPanel.param.report.schedule.repeat : 1,
stime: this.timezoneToUtcTimeStr(this.editPanel.param.report.schedule.stime), nums: this.editPanel.param.report.schedule.nums,
etime: this.timezoneToUtcTimeStr(this.editPanel.param.report.schedule.etime), stime: this.editPanel.param.report.schedule.stime !== '' ? this.timezoneToUtcTimeStr(this.editPanel.param.report.schedule.stime) : this.editPanel.param.report.schedule.stime,
nums: this.editPanel.param.report.schedule.nums etime: this.editPanel.param.report.schedule.etime !== '' ? this.timezoneToUtcTimeStr(this.editPanel.param.report.schedule.etime) : this.editPanel.param.report.schedule.etime
}, },
receivers: this.editPanel.param.report.receivers receivers: this.editPanel.param.report.receivers
}, },

View File

@@ -200,8 +200,6 @@ export default {
unit: '' unit: ''
}, },
schedule: { schedule: {
stime: '',
etime: '',
repeat: 0, repeat: 0,
nums: [], nums: [],
type: 0 type: 0
@@ -394,6 +392,28 @@ export default {
}, },
edit (u) { edit (u) {
this.panel = Object.assign({}, u) this.panel = Object.assign({}, u)
if (!this.panel.param.report) {
this.panel = {
...u,
param: {
report: {
enable: false,
range: {
unit: ''
},
schedule: {
type: '0',
repeat: 1,
nums: [],
stime: '',
etime: ''
},
receivers: []
},
chartShare: 'none'
}
}
}
this.rightBox.panel.show = true this.rightBox.panel.show = true
}, },
toAdd () { toAdd () {
@@ -416,7 +436,8 @@ export default {
stime: '', stime: '',
etime: '', etime: '',
nums: [], nums: [],
type: 0 + '' type: 0 + '',
repeat: 1
} }
}, },
chartShare: 'none' chartShare: 'none'