feat: 指标卡>指标值>后缀增加显示设置

This commit is contained in:
ulleo 2024-01-22 17:11:15 +08:00
parent e105f811b6
commit 230384e2b1
5 changed files with 153 additions and 129 deletions

View File

@ -194,6 +194,8 @@ const indicatorSuffixClass = ref<CSSProperties>({
'font-synthesis': 'weight style' 'font-synthesis': 'weight style'
}) })
const showSuffix = ref<boolean>(DEFAULT_INDICATOR_STYLE.suffixEnable)
const suffixContent = ref('') const suffixContent = ref('')
const indicatorNameShow = ref(false) const indicatorNameShow = ref(false)
@ -293,6 +295,7 @@ const renderChart = async view => {
'font-synthesis': 'weight style' 'font-synthesis': 'weight style'
} }
showSuffix.value = customAttr.indicator.suffixEnable
suffixContent.value = defaultTo(customAttr.indicator.suffix, '') suffixContent.value = defaultTo(customAttr.indicator.suffix, '')
} }
if (customAttr.indicatorName && customAttr.indicatorName.show) { if (customAttr.indicatorName && customAttr.indicatorName.show) {
@ -359,7 +362,7 @@ defineExpose({
<div :style="contentStyle"> <div :style="contentStyle">
<div> <div>
<span :style="indicatorClass">{{ formattedResult }}</span> <span :style="indicatorClass">{{ formattedResult }}</span>
<span :style="indicatorSuffixClass">{{ suffixContent }}</span> <span :style="indicatorSuffixClass" v-if="showSuffix">{{ suffixContent }}</span>
</div> </div>
<div v-if="indicatorNameShow"> <div v-if="indicatorNameShow">
<span :style="indicatorNameClass">{{ resultName }}</span> <span :style="indicatorNameClass">{{ resultName }}</span>

View File

@ -44,6 +44,7 @@ declare interface ChartIndicatorStyle {
letterSpace: string letterSpace: string
fontShadow: boolean fontShadow: boolean
suffixEnable: boolean
suffix: string suffix: string
suffixFontSize: string suffixFontSize: string
suffixColor: string suffixColor: string

View File

@ -149,6 +149,7 @@ watch(
<el-form-item class="form-item" :class="'form-item-' + themes" style="padding-left: 4px"> <el-form-item class="form-item" :class="'form-item-' + themes" style="padding-left: 4px">
<el-select <el-select
size="small"
:effect="themes" :effect="themes"
v-model="state.indicatorNameForm.letterSpace" v-model="state.indicatorNameForm.letterSpace"
:placeholder="t('chart.quota_letter_space')" :placeholder="t('chart.quota_letter_space')"

View File

@ -360,12 +360,21 @@ watch(
<el-divider class="m-divider" :class="{ 'divider-dark': themes === 'dark' }" /> <el-divider class="m-divider" :class="{ 'divider-dark': themes === 'dark' }" />
<el-form-item <el-form-item class="form-item" :class="'form-item-' + themes">
class="form-item" <el-checkbox
:class="'form-item-' + themes" size="small"
:label="t('chart.indicator_suffix')" :effect="themes"
v-model="state.indicatorValueForm.suffixEnable"
@change="changeTitleStyle('suffixEnable')"
> >
{{ t('chart.indicator_suffix') }}
</el-checkbox>
</el-form-item>
<div style="padding-left: 22px">
<el-form-item class="form-item" :class="'form-item-' + themes">
<el-input <el-input
:disabled="!state.indicatorValueForm.suffixEnable"
v-model="state.indicatorValueForm.suffix" v-model="state.indicatorValueForm.suffix"
:placeholder="t('chart.indicator_suffix_placeholder')" :placeholder="t('chart.indicator_suffix_placeholder')"
maxlength="10" maxlength="10"
@ -375,6 +384,7 @@ watch(
<el-form-item class="form-item" :class="'form-item-' + themes" :effect="themes"> <el-form-item class="form-item" :class="'form-item-' + themes" :effect="themes">
<el-select <el-select
:disabled="!state.indicatorValueForm.suffixEnable"
:effect="themes" :effect="themes"
v-model="state.indicatorValueForm.suffixFontFamily" v-model="state.indicatorValueForm.suffixFontFamily"
:placeholder="t('chart.font_family')" :placeholder="t('chart.font_family')"
@ -392,6 +402,7 @@ watch(
<div style="display: flex"> <div style="display: flex">
<el-form-item class="form-item" :class="'form-item-' + themes" style="padding-right: 4px"> <el-form-item class="form-item" :class="'form-item-' + themes" style="padding-right: 4px">
<el-color-picker <el-color-picker
:disabled="!state.indicatorValueForm.suffixEnable"
:effect="themes" :effect="themes"
v-model="state.indicatorValueForm.suffixColor" v-model="state.indicatorValueForm.suffixColor"
class="color-picker-style" class="color-picker-style"
@ -403,6 +414,7 @@ watch(
<el-form-item class="form-item" :class="'form-item-' + themes" style="padding: 0 4px"> <el-form-item class="form-item" :class="'form-item-' + themes" style="padding: 0 4px">
<el-tooltip content="字号" :effect="toolTip" placement="top"> <el-tooltip content="字号" :effect="toolTip" placement="top">
<el-select <el-select
:disabled="!state.indicatorValueForm.suffixEnable"
style="width: 56px" style="width: 56px"
:effect="themes" :effect="themes"
v-model="state.indicatorValueForm.suffixFontSize" v-model="state.indicatorValueForm.suffixFontSize"
@ -422,6 +434,8 @@ watch(
<el-form-item class="form-item" :class="'form-item-' + themes" style="padding-left: 4px"> <el-form-item class="form-item" :class="'form-item-' + themes" style="padding-left: 4px">
<el-select <el-select
size="small"
:disabled="!state.indicatorValueForm.suffixEnable"
:effect="themes" :effect="themes"
v-model="state.indicatorValueForm.suffixLetterSpace" v-model="state.indicatorValueForm.suffixLetterSpace"
:placeholder="t('chart.quota_letter_space')" :placeholder="t('chart.quota_letter_space')"
@ -445,6 +459,7 @@ watch(
<el-space> <el-space>
<el-form-item class="form-item" :class="'form-item-' + themes"> <el-form-item class="form-item" :class="'form-item-' + themes">
<el-checkbox <el-checkbox
:disabled="!state.indicatorValueForm.suffixEnable"
:effect="themes" :effect="themes"
class="icon-checkbox" class="icon-checkbox"
v-model="state.indicatorValueForm.suffixIsBolder" v-model="state.indicatorValueForm.suffixIsBolder"
@ -471,6 +486,7 @@ watch(
<el-form-item class="form-item" :class="'form-item-' + themes"> <el-form-item class="form-item" :class="'form-item-' + themes">
<el-checkbox <el-checkbox
:disabled="!state.indicatorValueForm.suffixEnable"
:effect="themes" :effect="themes"
class="icon-checkbox" class="icon-checkbox"
v-model="state.indicatorValueForm.suffixIsItalic" v-model="state.indicatorValueForm.suffixIsItalic"
@ -498,6 +514,7 @@ watch(
<el-form-item class="form-item" :class="'form-item-' + themes"> <el-form-item class="form-item" :class="'form-item-' + themes">
<el-checkbox <el-checkbox
:disabled="!state.indicatorValueForm.suffixEnable"
size="small" size="small"
:effect="themes" :effect="themes"
v-model="state.indicatorValueForm.suffixFontShadow" v-model="state.indicatorValueForm.suffixFontShadow"
@ -506,6 +523,7 @@ watch(
{{ t('chart.font_shadow') }} {{ t('chart.font_shadow') }}
</el-checkbox> </el-checkbox>
</el-form-item> </el-form-item>
</div>
</el-form> </el-form>
</div> </div>
</template> </template>

View File

@ -359,6 +359,7 @@ export const DEFAULT_INDICATOR_STYLE: ChartIndicatorStyle = {
letterSpace: '0', letterSpace: '0',
fontShadow: false, fontShadow: false,
suffixEnable: true,
suffix: '', suffix: '',
suffixFontSize: '14', suffixFontSize: '14',
suffixColor: '#5470C6', suffixColor: '#5470C6',