济菏高速业务端
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.

150 lines
3.2 KiB

<template>
1 year ago
<div class="Descriptions keep-ratio" origin="left" :style="getStyle()">
<div class="item" v-for="(item, index) in getResolveList" :key="`${item.key || item.label}${index}`"
:style="[gridStyle(item, index), transformStyle(itemStyle)]">
1 year ago
<div class="text title" :style="{...transformStyle(titleStyle), width: labelWidth }">
1 year ago
<p>
<slot :name="`title-${item.key || item.label}`" :data="item">
1 year ago
{{ item.label || "-" }}
1 year ago
</slot>
1 year ago
</p>
:
</div>
<ContentText :style="transformStyle(titleStyle)" class="content text" :data="data" :_config="item">
1 year ago
<template #default="{ value }">
<slot :name="`content-${item.key || item.label}`" :value="value" :data="item">
1 year ago
{{ value }}
</slot>
</template>
</ContentText>
</div>
</div>
</template>
<script>
1 year ago
import { getContent } from "@screen/components/FormConfig/utils/index.js";
import ContentText from "@screen/components/FormConfig/components/Text.vue";
export default {
1 year ago
name: "Descriptions",
1 year ago
components: {
1 year ago
ContentText,
1 year ago
},
props: {
data: {
type: Object,
1 year ago
default: () => ({}),
},
/**
* {
* key: string;
* label: string;
* gridRow: number;
* gridColumn: number;
* }[]
*/
list: {
type: Array,
1 year ago
default: () => [],
},
column: {
type: String,
1 year ago
default: "2",
},
1 year ago
labelWidth: String,
titleStyle: {
type: [String, Object],
1 year ago
default: null,
},
contentStyle: {
type: [String, Object],
1 year ago
default: null,
},
itemStyle: {
type: [String, Object],
1 year ago
default: null,
},
},
computed: {
gridStyle() {
return (item, index) => ({
gridRow: `span ${item.gridRow || 1}`,
gridColumn: `span ${item.gridColumn || 1}`,
1 year ago
});
1 year ago
},
getText() {
1 year ago
return (item) => getContent(this.data, item);
1 year ago
},
getResolveList() {
return this.list.reduce((prev, data) => {
1 year ago
if (typeof data.visible === "function") {
1 year ago
if (!data.visible(data)) return prev;
}
1 year ago
1 year ago
prev.push(data);
1 year ago
return prev;
}, []);
},
},
methods: {
getStyle() {
return {
gridTemplateColumns: `repeat(${this.column}, 1fr)`,
1 year ago
};
},
getComponent(type) {
1 year ago
return `Form${type.replace(/^[a-z]/, (word) => word.toUpperCase())}`;
},
transformStyle(style) {
1 year ago
if (typeof style != "string") return style;
1 year ago
return style.split(";").reduce((prev, cur) => {
const [key, value] = cur.split(":");
prev[key] = value;
return prev;
}, {});
1 year ago
},
},
};
</script>
1 year ago
<style lang="scss" scoped>
.Descriptions {
display: grid;
gap: 9px;
.text {
font-size: 15px;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
1 year ago
color: #fff;
line-height: 18px;
gap: 3px;
1 year ago
display: flex;
}
.item {
display: flex;
1 year ago
align-items: center;
gap: 6px;
.title {
1 year ago
color: #3de8ff;
1 year ago
p {
width: 100%;
text-align: justify;
text-align-last: justify;
}
}
.content {
flex: 1;
gap: 6px;
}
}
}
</style>