明树Git Lab

Commit 6e2f55bc authored by chenron's avatar chenron

修改

parent f989b20b
Pipeline #104180 passed with stage
in 12 seconds
...@@ -30,19 +30,15 @@ ...@@ -30,19 +30,15 @@
<p class="comparison">累计同期环比</p> <p class="comparison">累计同期环比</p>
<p <p
class="comparison-value" class="comparison-value"
:class="{ 'down-trend': item.title === '运营成本' }" :class="{ 'down-trend': isDownTrend(item.compareValue) }"
> >
{{ item.compareValue }} {{ item.compareValue }}
<el-icon <el-icon
class="trend-icon" class="trend-icon"
:class="{ 'down-trend': item.title === '运营成本' }" :class="{ 'down-trend': isDownTrend(item.compareValue) }"
> >
<span v-if="item.compareValue !== '*'"> <span v-if="item.compareValue !== '*'">
<Bottom <Bottom v-if="isDownTrend(item.compareValue)" />
v-if="
item.title === '运营成本' || item.title === '利润总额'
"
/>
<Top v-else /> <Top v-else />
</span> </span>
</el-icon> </el-icon>
...@@ -57,12 +53,42 @@ ...@@ -57,12 +53,42 @@
<script setup> <script setup>
import { onMounted, reactive, watch, ref } from "vue"; import { onMounted, reactive, watch, ref } from "vue";
import { Top, Bottom } from "@element-plus/icons-vue"; import { Top, Bottom } from "@element-plus/icons-vue";
const props = defineProps({ const props = defineProps({
numberList: { numberList: {
type: Array, type: Array,
default: () => [], 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> </script>
<style scoped lang="less"> <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