2021-03-11 14:33:24 +08:00
|
|
|
<template>
|
|
|
|
<span>
|
2021-03-16 14:48:06 +08:00
|
|
|
<el-dropdown trigger="click" size="mini" @command="clickItem">
|
2021-03-11 14:33:24 +08:00
|
|
|
<span class="el-dropdown-link">
|
2021-03-11 15:57:54 +08:00
|
|
|
<el-tag size="small" class="item-axis">
|
2021-03-15 12:25:11 +08:00
|
|
|
{{ item.name }}<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span><i class="el-icon-arrow-down el-icon--right" />
|
2021-03-11 15:57:54 +08:00
|
|
|
</el-tag>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item icon="el-icon-notebook-2">
|
2021-03-16 14:48:06 +08:00
|
|
|
<el-dropdown placement="right-start" size="mini" @command="summary">
|
2021-03-11 15:57:54 +08:00
|
|
|
<span class="el-dropdown-link">
|
|
|
|
{{ $t('chart.summary') }}<span class="summary-span">({{ $t('chart.'+item.summary) }})</span><i class="el-icon-arrow-right el-icon--right" />
|
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
<el-dropdown-item :command="beforeSummary('sum')">{{ $t('chart.sum') }}</el-dropdown-item>
|
2021-03-23 15:31:57 +08:00
|
|
|
<el-dropdown-item :command="beforeSummary('count')">{{ $t('chart.count') }}</el-dropdown-item>
|
2021-03-11 15:57:54 +08:00
|
|
|
<el-dropdown-item :command="beforeSummary('avg')">{{ $t('chart.avg') }}</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeSummary('max')">{{ $t('chart.max') }}</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeSummary('min')">{{ $t('chart.min') }}</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeSummary('std')">{{ $t('chart.std') }}</el-dropdown-item>
|
|
|
|
<el-dropdown-item :command="beforeSummary('var_samp')">{{ $t('chart.var_samp') }}</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</el-dropdown>
|
|
|
|
</el-dropdown-item>
|
2021-03-16 13:32:35 +08:00
|
|
|
<el-dropdown-item icon="el-icon-s-grid">
|
2021-03-16 14:48:06 +08:00
|
|
|
<el-dropdown placement="right-start" size="mini" @command="quickCalc">
|
2021-03-16 13:32:35 +08:00
|
|
|
<span class="el-dropdown-link">
|
2021-03-18 17:20:59 +08:00
|
|
|
{{ $t('chart.quick_calc') }}<span class="summary-span">(无)</span><i class="el-icon-arrow-right el-icon--right" />
|
2021-03-16 13:32:35 +08:00
|
|
|
</span>
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
2021-03-18 17:20:59 +08:00
|
|
|
<el-dropdown-item :command="beforeQuickCalc('none')">无</el-dropdown-item>
|
2021-03-16 13:32:35 +08:00
|
|
|
</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>
|
2021-03-11 15:57:54 +08:00
|
|
|
</el-dropdown-item>
|
2021-03-23 15:31:57 +08:00
|
|
|
<el-dropdown-item icon="el-icon-delete" divided :command="beforeClickItem('remove')">
|
|
|
|
<span>{{ $t('chart.delete') }}</span>
|
|
|
|
</el-dropdown-item>
|
2021-03-11 15:57:54 +08:00
|
|
|
</el-dropdown-menu>
|
2021-03-11 14:33:24 +08:00
|
|
|
</span>
|
2021-03-11 16:02:28 +08:00
|
|
|
</el-dropdown>
|
2021-03-16 13:32:35 +08:00
|
|
|
|
|
|
|
<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">
|
2021-03-16 14:48:06 +08:00
|
|
|
<el-input v-model="itemForm.name" size="mini"/>
|
2021-03-16 13:32:35 +08:00
|
|
|
</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>
|
2021-03-11 14:33:24 +08:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'QuotaItem',
|
|
|
|
props: {
|
|
|
|
item: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
2021-03-23 15:31:57 +08:00
|
|
|
},
|
|
|
|
index: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2021-03-11 14:33:24 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
2021-03-16 13:32:35 +08:00
|
|
|
return {
|
|
|
|
renameItem: false,
|
|
|
|
itemForm: {
|
|
|
|
name: ''
|
|
|
|
},
|
|
|
|
itemFormRules: {
|
|
|
|
name: [
|
|
|
|
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 14:33:24 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
summary(param) {
|
2021-03-11 15:06:13 +08:00
|
|
|
// console.log(param)
|
2021-03-11 14:33:24 +08:00
|
|
|
this.item.summary = param.type
|
2021-03-16 13:32:35 +08:00
|
|
|
this.$emit('onQuotaItemChange', this.item)
|
2021-03-11 14:33:24 +08:00
|
|
|
},
|
|
|
|
beforeSummary(type) {
|
|
|
|
return {
|
|
|
|
type: type
|
|
|
|
}
|
2021-03-16 13:32:35 +08:00
|
|
|
},
|
|
|
|
quickCalc(param) {
|
|
|
|
|
|
|
|
},
|
|
|
|
beforeQuickCalc(type) {
|
|
|
|
return {
|
|
|
|
type: type
|
|
|
|
}
|
|
|
|
},
|
|
|
|
clickItem(param) {
|
|
|
|
if (!param) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
switch (param.type) {
|
|
|
|
case 'rename':
|
|
|
|
this.showRename()
|
|
|
|
break
|
2021-03-23 15:31:57 +08:00
|
|
|
case 'remove':
|
|
|
|
this.removeItem()
|
|
|
|
break
|
2021-03-16 13:32:35 +08:00
|
|
|
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: ''
|
|
|
|
}
|
2021-03-23 15:31:57 +08:00
|
|
|
},
|
|
|
|
removeItem() {
|
|
|
|
this.item.index = this.index
|
|
|
|
this.$emit('onQuotaItemRemove', this.item)
|
2021-03-11 14:33:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.item-axis {
|
|
|
|
padding: 1px 6px;
|
|
|
|
margin: 0 3px 2px 3px;
|
|
|
|
text-align: left;
|
|
|
|
height: 24px;
|
|
|
|
line-height: 22px;
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 4px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item-axis:hover {
|
|
|
|
background-color: #fdfdfd;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
span {
|
|
|
|
font-size: 12px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.summary-span{
|
|
|
|
margin-left: 4px;
|
|
|
|
color: #878d9f;;
|
|
|
|
}
|
|
|
|
</style>
|