refactor(frontend): 视图 指标下拉菜单扩展

This commit is contained in:
junjie 2021-03-16 13:32:35 +08:00
parent 221227e710
commit cdf50243c9
4 changed files with 91 additions and 13 deletions

View File

@ -600,7 +600,9 @@ export default {
max: '最大值', max: '最大值',
min: '最小值', min: '最小值',
std: '标准差', std: '标准差',
var_samp: '方差' var_samp: '方差',
quick_calc: '快速计算',
show_name_set: '显示名设置'
}, },
dataset: { dataset: {
datalist: '数据集', datalist: '数据集',

View File

@ -1,6 +1,6 @@
<template> <template>
<span> <span>
<el-dropdown trigger="click" size="small"> <el-dropdown trigger="click" size="small" @command="clickItem">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
<el-tag size="small" class="item-axis"> <el-tag size="small" class="item-axis">
{{ item.name }}<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span><i class="el-icon-arrow-down el-icon--right" /> {{ item.name }}<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span><i class="el-icon-arrow-down el-icon--right" />
@ -21,12 +21,34 @@
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item icon="el-icon-delete"> <el-dropdown-item icon="el-icon-s-grid">
item4 <el-dropdown placement="right-start" size="small" @command="quickCalc">
<span class="el-dropdown-link">
{{ $t('chart.quick_calc') }}<span class="summary-span">(test)</span><i class="el-icon-arrow-right el-icon--right" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeQuickCalc('none')">test</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown-item>
<el-dropdown-item icon="el-icon-edit-outline" divided :command="beforeClickItem('rename')">
<span>{{ $t('chart.show_name_set') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</span> </span>
</el-dropdown> </el-dropdown>
<el-dialog :title="$t('chart.show_name_set')" :visible="renameItem" :show-close="false" width="30%">
<el-form ref="itemForm" :model="itemForm" :rules="itemFormRules">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="itemForm.name" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button size="mini" @click="closeRename()">{{ $t('chart.cancel') }}</el-button>
<el-button type="primary" size="mini" @click="saveRename(itemForm)">{{ $t('chart.confirm') }}</el-button>
</div>
</el-dialog>
</span> </span>
</template> </template>
@ -40,7 +62,17 @@ export default {
} }
}, },
data() { data() {
return {} return {
renameItem: false,
itemForm: {
name: ''
},
itemFormRules: {
name: [
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' }
]
}
}
}, },
mounted() { mounted() {
@ -49,12 +81,55 @@ export default {
summary(param) { summary(param) {
// console.log(param) // console.log(param)
this.item.summary = param.type this.item.summary = param.type
this.$emit('onQuotaSummaryChange', this.item) this.$emit('onQuotaItemChange', this.item)
}, },
beforeSummary(type) { beforeSummary(type) {
return { return {
type: type type: type
} }
},
quickCalc(param) {
},
beforeQuickCalc(type) {
return {
type: type
}
},
clickItem(param) {
if (!param) {
return
}
switch (param.type) {
case 'rename':
this.showRename()
break
default:
break
}
},
beforeClickItem(type) {
return {
type: type
}
},
showRename() {
this.itemForm.name = this.item.name
this.renameItem = true
},
closeRename() {
this.renameItem = false
this.resetRename()
},
saveRename(param) {
this.item.name = param.name
this.$emit('onQuotaItemChange', this.item)
this.closeRename()
},
resetRename() {
this.itemForm = {
name: ''
}
} }
} }
} }

View File

@ -487,6 +487,7 @@ export default {
sceneClick(data, node) { sceneClick(data, node) {
this.$store.dispatch('chart/setViewId', null) this.$store.dispatch('chart/setViewId', null)
this.$store.dispatch('chart/setViewId', data.id) this.$store.dispatch('chart/setViewId', data.id)
this.$store.dispatch('chart/setTableId', null)
this.$store.dispatch('chart/setTableId', data.tableId) this.$store.dispatch('chart/setTableId', data.tableId)
// this.$router.push('/chart/chart-edit') // this.$router.push('/chart/chart-edit')
this.$emit('switchComponent', { name: 'ChartEdit' }) this.$emit('switchComponent', { name: 'ChartEdit' })

View File

@ -125,7 +125,7 @@
@end="end2" @end="end2"
> >
<transition-group class="draggable-group"> <transition-group class="draggable-group">
<quota-item v-for="(item) in view.yaxis" :key="item.id" :item="item" @onQuotaSummaryChange="quotaSummaryChange" /> <quota-item v-for="(item) in view.yaxis" :key="item.id" :item="item" @onQuotaItemChange="quotaItemChange" />
</transition-group> </transition-group>
</draggable> </draggable>
</el-row> </el-row>
@ -357,13 +357,13 @@ export default {
return true return true
}, },
quotaSummaryChange(item) { quotaItemChange(item) {
// item // item
this.view.yaxis.forEach(function(ele) { // this.view.yaxis.forEach(function(ele) {
if (ele.id === item.id) { // if (ele.id === item.id) {
ele.summary = item.summary // ele.summary = item.summary
} // }
}) // })
this.save() this.save()
} }
} }