明树Git Lab

Commit 6e2f55bc authored by chenron's avatar chenron

修改

parent f989b20b
Pipeline #104180 passed with stage
in 12 seconds
......@@ -30,19 +30,15 @@
<p class="comparison">累计同期环比</p>
<p
class="comparison-value"
:class="{ 'down-trend': item.title === '运营成本' }"
:class="{ 'down-trend': isDownTrend(item.compareValue) }"
>
{{ item.compareValue }}
<el-icon
class="trend-icon"
:class="{ 'down-trend': item.title === '运营成本' }"
:class="{ 'down-trend': isDownTrend(item.compareValue) }"
>
<span v-if="item.compareValue !== '*'">
<Bottom
v-if="
item.title === '运营成本' || item.title === '利润总额'
"
/>
<Bottom v-if="isDownTrend(item.compareValue)" />
<Top v-else />
</span>
</el-icon>
......@@ -57,12 +53,42 @@
<script setup>
import { onMounted, reactive, watch, ref } from "vue";
import { Top, Bottom } from "@element-plus/icons-vue";
const props = defineProps({
numberList: {
type: Array,
default: () => [],
},
});
// 判断是否为下降趋势
const isDownTrend = (compareValue) => {
if (!compareValue || compareValue === '*') return false;
// 处理百分比值
const value = compareValue.toString();
// 如果包含负号,表示下降
if (value.includes('-')) {
return true;
}
// 如果包含百分号,提取数值判断
if (value.includes('%')) {
const numValue = parseFloat(value.replace('%', ''));
return numValue < 0;
}
// 如果是纯数字
const numValue = parseFloat(value);
if (!isNaN(numValue)) {
return numValue < 0;
}
// 默认情况下,根据业务逻辑判断(运营成本下降是好的,显示绿色)
// 这里简化处理,如果负数则下降,正数则上升
return false;
};
</script>
<style scoped lang="less">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment