NEZ-1787 fix : 时间选择器组件 优化 国际化以及不同页面的样式修改

This commit is contained in:
zhangxiaolong
2022-04-13 19:06:47 +08:00
parent e0aed5d4f8
commit 9258a0d7fd
3 changed files with 23 additions and 37 deletions

View File

@@ -151,10 +151,17 @@
background: $--background-color-empty; background: $--background-color-empty;
} }
} }
&.el-button--mini{ .date-range-panel{
color: $--color-text-label; .el-button--primary{
background-color: $--color-primary; color: $--color-text-label;
border-color: $--color-primary; background-color: $--color-primary;
border-color: $--color-primary;
}
.el-button--primary:hover{
color: $--color-text-label;
background-color: $--color-primary;
border-color: $--color-primary;
}
} }
.nz-dashboard-dropdown { .nz-dashboard-dropdown {

View File

@@ -108,7 +108,7 @@
visibility: hidden !important; visibility: hidden !important;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: -20px;
} }
.date-range-text { .date-range-text {
@@ -183,7 +183,9 @@
} }
.content-input { .content-input {
width: 230px;
.el-input{ .el-input{
width: auto;
.el-input__inner{ .el-input__inner{
border: 1px solid #E7EAED; border: 1px solid #E7EAED;
border-radius: 2px; border-radius: 2px;
@@ -198,10 +200,6 @@
} }
} }
.content-input:focus {
border: 1px solid #169AFF;
}
.date-range-history { .date-range-history {
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;

View File

@@ -34,7 +34,7 @@
class="date-range-panel-content date-range-panel-content-left" class="date-range-panel-content date-range-panel-content-left"
> >
<div class="date-range-title" style="padding-left: 0"> <div class="date-range-title" style="padding-left: 0">
Absolute time range {{$t('timepicker.timerange')}}
</div> </div>
<my-date-picker <my-date-picker
prefix-icon=" " prefix-icon=" "
@@ -50,13 +50,13 @@
> >
</my-date-picker> </my-date-picker>
<div class="content-title">From</div> <div class="content-title">{{$t('dashboard.panel.chartForm.valMapping.from')}}</div>
<div @click="myDatePickerShow('start')" tabindex="1" class="content-input"> <div @click="myDatePickerShow('start')" tabindex="1" class="content-input">
<el-input v-model="searchTime[0]" @change="dateChange('start',searchTime[0])"> </el-input> <el-input v-model="searchTime[0]" @change="dateChange('start',searchTime[0])"> </el-input>
</div> </div>
<div class="content-title">To</div> <div class="content-title">{{$t('dashboard.panel.chartForm.valMapping.to')}}</div>
<div @click="myDatePickerShow('end')" tabindex="2" class="content-input"> <div @click="myDatePickerShow('end')" tabindex="2" class="content-input">
<el-input v-model="searchTime[1]" @change="dateChange('end',searchTime[1])"> </el-input> <el-input v-model="searchTime[1]" @change="dateChange('end',searchTime[1])"> </el-input>
</div> </div>
<div> <div>
@@ -65,11 +65,11 @@
type="primary" type="primary"
size="mini" size="mini"
class="time-range-button el-button--primary" class="time-range-button el-button--primary"
>Apply time range</el-button >{{$t('timepicker.applytimerange')}}</el-button
> >
</div> </div>
<div class="date-range-title" style="padding-left: 0"> <div class="date-range-title" style="padding-left: 0">
Recently used absolute ranges {{$t('timepicker.recentlyUsed')}}
</div> </div>
<div class="date-range-history"> <div class="date-range-history">
<div <div
@@ -79,7 +79,7 @@
@click="historyChange(item)" @click="historyChange(item)"
> >
{{ timeFormate(item.start) }} {{ timeFormate(item.start) }}
{{ $t("dashboard.panel.to") }}
{{ timeFormate(item.end) }} {{ timeFormate(item.end) }}
</div> </div>
</div> </div>
@@ -89,7 +89,7 @@
class="date-range-panel-content date-range-panel-content-right" class="date-range-panel-content date-range-panel-content-right"
style="border-left: 1px solid rgba(0, 0, 0, 0.09)" style="border-left: 1px solid rgba(0, 0, 0, 0.09)"
> >
<div class="date-range-title">Relatime time ranges</div> <div class="date-range-title">{{$t('timepicker.relatime')}}</div>
<ul class="date-range-item"> <ul class="date-range-item">
<li <li
v-for="(item, key) in timeData" v-for="(item, key) in timeData"
@@ -247,7 +247,6 @@ export default {
this.getItem() this.getItem()
this.getUtcStr() this.getUtcStr()
this.getRangeHistoryArr() this.getRangeHistoryArr()
console.log(this.sign)
}, },
methods: { methods: {
changeDropdownFlag(){ changeDropdownFlag(){
@@ -300,10 +299,8 @@ export default {
this.$set(this.searchTime, 2, '') this.$set(this.searchTime, 2, '')
this.showDropdown() this.showDropdown()
this.getRangeHistoryArr() this.getRangeHistoryArr()
console.log('timerange里searchTime', this.searchTime)
this.setSearchTime('', '', this.searchTime) this.setSearchTime('', '', this.searchTime)
this.$emit('change', this.searchTime) this.$emit('change', this.searchTime)
console.log(this.searchTime)
}, },
showDropdown () { showDropdown () {
this.dropdownFlag = !this.dropdownFlag this.dropdownFlag = !this.dropdownFlag
@@ -314,9 +311,7 @@ export default {
const startTime = bus.timeFormate(this.searchTimeValue).trim().split(' ')[0] + ' ' const startTime = bus.timeFormate(this.searchTimeValue).trim().split(' ')[0] + ' '
this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 0, startTime)
} else { } else {
console.log(v)
const str = v.trim().split(' ')[1] const str = v.trim().split(' ')[1]
console.log(str)
const reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/ const reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
if (reg.test(str)) { if (reg.test(str)) {
const startTime = bus.timeFormate(v) const startTime = bus.timeFormate(v)
@@ -331,7 +326,6 @@ export default {
this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 1, endTime)
} else { } else {
const str = v.trim().split(' ')[1] const str = v.trim().split(' ')[1]
console.log(str)
const reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/ const reg = /^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/
if (reg.test(str)) { if (reg.test(str)) {
const endTime = bus.timeFormate(v) const endTime = bus.timeFormate(v)
@@ -342,7 +336,6 @@ export default {
} }
} }
this.searchTime[2] = '' this.searchTime[2] = ''
console.log('searchTime', this.searchTime)
this.$set(this.showTime, 'id', 0) this.$set(this.showTime, 'id', 0)
this.$set( this.$set(
this.showTime, this.showTime,
@@ -353,15 +346,12 @@ export default {
' ' + ' ' +
this.searchTime[1] this.searchTime[1]
) )
console.log('showTime', this.showTime)
}, },
setCustomTime (timeGroup, timeRange) { setCustomTime (timeGroup, timeRange) {
if (timeGroup) { if (timeGroup) {
console.log('timeGroup', timeGroup)
this.showTime = this.nowTimeType = this.timeData.find( this.showTime = this.nowTimeType = this.timeData.find(
(item) => item.id == timeGroup.id (item) => item.id == timeGroup.id
) )
console.log(this.showTime)
if (this.showTime) { if (this.showTime) {
this.showTime = Object.assign({}, this.showTime) this.showTime = Object.assign({}, this.showTime)
this.$set(this.searchTime, 0, timeGroup.start_time) this.$set(this.searchTime, 0, timeGroup.start_time)
@@ -371,7 +361,6 @@ export default {
this.showTime = this.nowTimeType = { this.showTime = this.nowTimeType = {
text: time[0] + ' ' + this.$t('dashboard.panel.to') + ' ' + time[1] text: time[0] + ' ' + this.$t('dashboard.panel.to') + ' ' + time[1]
} }
console.log(this.showTime)
this.$set(this.searchTime, 0, bus.timeFormate(time[0])) this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
this.$set(this.searchTime, 1, bus.timeFormate(time[1])) this.$set(this.searchTime, 1, bus.timeFormate(time[1]))
// this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time)); // this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time));
@@ -397,7 +386,6 @@ export default {
// this.$set(this.searchTime, 0, bus.timeFormate(time[0])); // this.$set(this.searchTime, 0, bus.timeFormate(time[0]));
} }
} else { } else {
console.log('no timegroup')
this.showTime = this.nowTimeType = { this.showTime = this.nowTimeType = {
id: 4, id: 4,
text: this.$t('dashboard.panel.lastOneHour'), text: this.$t('dashboard.panel.lastOneHour'),
@@ -410,7 +398,6 @@ export default {
} }
}, },
timeChange (val, from) { timeChange (val, from) {
console.log(val, from)
this.nowTimeType = val this.nowTimeType = val
this.$set(this.showTime, 'id', val.id) this.$set(this.showTime, 'id', val.id)
this.$set(this.showTime, 'text', val.text) this.$set(this.showTime, 'text', val.text)
@@ -450,7 +437,6 @@ export default {
} }
} }
} else { } else {
console.log('else', this.searchTime)
// this.isCustom = false; // this.isCustom = false;
this.showDropdown() this.showDropdown()
if (this.showEmpty && id === 12) { if (this.showEmpty && id === 12) {
@@ -534,11 +520,6 @@ export default {
} }
}, },
watch: { watch: {
searchTime: {
handler (n, o) {
console.log(n)
}
},
defaultPick: { defaultPick: {
immediate: true, immediate: true,
handler (n, o) { handler (n, o) {