济菏高速业务端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

169 lines
3.9 KiB

<template>
<div class="Descriptions " :style="getStyle()">
<div class="item" v-for="(item, index) in getResolveList" :key="`${item.key || item.label}${index}`"
:style="[gridStyle(item, index), transformStyle(itemStyle)]" v-if="item.visible != false">
<div v-if="!item.labelHidden" class="text title" :style="{ ...transformStyle(titleStyle), width: labelWidth }">
<p>
<slot :name="`title-${item.key || item.label}`" :data="item">
{{ item.label || "-" }}
</slot>
</p>
:
</div>
<ContentText :style="transformStyle(titleStyle)" class="content text" :data="data" :_config="item">
<template #default="{ value }">
<slot :name="`content-${item.key || item.label}`" :value="value" :data="item">
{{ value }}
</slot>
</template>
</ContentText>
</div>
</div>
</template>
<script>
import { getContent } from "@screen/components/FormConfig/utils/index.js";
import ContentText from "@screen/components/FormConfig/components/Text.vue";
export default {
name: "Descriptions",
components: {
ContentText,
},
props: {
data: {
type: Object,
default: () => ({}),
},
/**
* {
* key: string;
* label: string;
* gridRow: number;
* gridColumn: number;
* }[]
*/
list: {
type: Array,
default: () => [],
},
column: {
type: String,
default: "2",
},
labelWidth: String,
titleStyle: {
type: [String, Object],
default: null,
},
contentStyle: {
type: [String, Object],
default: null,
},
itemStyle: {
type: [String, Object],
default: null,
},
},
computed: {
gridStyle() {
return (item, index) => ({
gridRow: `span ${item.gridRow || 1}`,
gridColumn: `span ${item.gridColumn || 1}`,
});
},
getText() {
return (item) => getContent(this.data, item);
},
getResolveList() {
// 要过滤掉的 property 类型列表
const disallowedProperties = ['cellVoltage', 'chargeCurrent','solarVoltage','time','averageData'];
return this.list.reduce((prev, data) => {
if (disallowedProperties.includes(data.key)) {
return prev; // 如果在列表中,则跳过该数据项
}
// 原有的 visible 函数或属性判断
if (typeof data.visible === "function") {
if (!data.visible(data)) return prev;
} else if (data.visible === false) {
return prev;
}
prev.push(data);
return prev;
}, []);
}
/* getResolveList() {
return this.list.reduce((prev, data) => {
if (typeof data.visible === "function") {
if (!data.visible(data)) return prev;
}
prev.push(data);
return prev;
}, []);
},*/
},
methods: {
getStyle() {
return {
gridTemplateColumns: `repeat(${this.column}, 1fr)`,
};
},
getComponent(type) {
return `Form${type.replace(/^[a-z]/, (word) => word.toUpperCase())}`;
},
transformStyle(style) {
if (typeof style != "string") return style;
return style.split(";").reduce((prev, cur) => {
const [key, value] = cur.split(":");
prev[key] = value;
return prev;
}, {});
},
},
};
</script>
<style lang="scss" scoped>
.Descriptions {
display: grid;
gap: 9px;
.text {
font-size: 13px;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #fff;
line-height: 14px;
gap: 3px;
display: flex;
}
.item {
display: flex;
align-items: center;
gap: 6px;
.title {
color: #3de8ff;
p {
width: 100%;
text-align: justify;
text-align-last: justify;
}
}
.content {
flex: 1;
gap: 6px;
}
}
}
</style>