修改自定义数据显示
parent
b903cb4cbb
commit
efe8ac7255
|
|
@ -1,18 +1,12 @@
|
|||
<template>
|
||||
<div class="img-outer re oh" :style="com_style">
|
||||
<div :style="text_style" class="break">
|
||||
<template v-if="form.is_rich_text == '1'">
|
||||
<div class="rich-text-content" :innerHTML="text_title"></div>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ text_title }}
|
||||
</template>
|
||||
<div :style="icon_style" class="flex-row">
|
||||
<icon :name="form.icon_class" :color="form.icon_color" :size="form.icon_size"></icon>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { radius_computer, padding_computer } from '@/utils';
|
||||
import { isEmpty } from 'lodash';
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: Object,
|
||||
|
|
@ -34,36 +28,23 @@ const props = defineProps({
|
|||
});
|
||||
// 用于页面判断显示
|
||||
const form = reactive(props.value);
|
||||
const text_title = computed(() => {
|
||||
let text = '';
|
||||
if (!isEmpty(form.text_title)) {
|
||||
text = form.text_title;
|
||||
} else if(!isEmpty(props.sourceList[form.data_source_id])) {
|
||||
text = props.sourceList[form.data_source_id];
|
||||
} else if(!props.isPercentage){
|
||||
text = '请在此输入文字';
|
||||
}
|
||||
return text;
|
||||
});
|
||||
|
||||
const text_style = computed(() => {
|
||||
let style = `font-size: ${ form.text_size }px;color: ${ form.text_color }; text-align: ${ form.text_location }; transform: rotate(${form.text_rotate}deg);text-decoration: ${ form.text_option };${ padding_computer(form.text_padding) };`;
|
||||
if (form.text_weight == 'italic') {
|
||||
style += `font-style: italic`;
|
||||
} else if (form.text_weight == '500') {
|
||||
style += `font-weight: 500`;
|
||||
}
|
||||
return style;
|
||||
});
|
||||
|
||||
const com_style = computed(() => {
|
||||
let style = `${ set_count() } background-color: ${ form.com_bg }; ${ radius_computer(form.bg_radius) }`;
|
||||
if (form.border_show == '1') {
|
||||
style += `border: ${form.border_size}px ${form.border_style} ${form.border_color};`;
|
||||
}
|
||||
// 是富文本并且开启了上下滚动的开关
|
||||
if (form.is_rich_text == '1' && form.is_up_down == '1') {
|
||||
style += `overflow-y: auto;`
|
||||
return style;
|
||||
});
|
||||
|
||||
const icon_style = computed(() => {
|
||||
let style = `transform: rotate(${form.icon_rotate}deg);${ padding_computer(form.icon_padding) };`;
|
||||
if (form.icon_location == 'center') {
|
||||
style += `justify-content: center;`;
|
||||
} else if (form.icon_location == 'left') {
|
||||
style += `justify-content: flex-start;`;
|
||||
} else if (form.icon_location == 'right') {
|
||||
style += `justify-content: flex-end;`;
|
||||
}
|
||||
return style;
|
||||
});
|
||||
|
|
@ -76,15 +57,4 @@ const set_count = () => {
|
|||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.break{
|
||||
word-wrap: break-word;
|
||||
word-break:break-all;
|
||||
}
|
||||
.rich-text-content {
|
||||
white-space: normal;
|
||||
word-break:break-all;
|
||||
* {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -3,39 +3,25 @@
|
|||
<el-form :model="form" label-width="70">
|
||||
<card-container>
|
||||
<div class="mb-12">文本设置</div>
|
||||
<el-form-item label="文本内容">
|
||||
<el-input v-model="form.text_title" placeholder="请输入文本内容" type="textarea" clearable :rows="3" @input="text_change('1')"></el-input>
|
||||
<el-form-item label="选择图标">
|
||||
<upload v-model:icon-value="form.icon_class" :limit="1" size="50" is-icon type="icon" @update:model-value="icon_change('1')"></upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据字段">
|
||||
<el-select v-model="form.data_source_id" value-key="id" clearable filterable placeholder="请选择图片数据字段" size="default" class="flex-1" @change="text_change('2')">
|
||||
<el-select v-model="form.data_source_id" value-key="id" clearable filterable placeholder="请选择数据字段" size="default" class="flex-1" @change="icon_change('2')">
|
||||
<el-option v-for="item in options.filter((item) => item.type == 'icon')" :key="item.field" :label="item.name" :value="item.field" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="链接">
|
||||
<url-value v-model="form.text_link"></url-value>
|
||||
<url-value v-model="form.icon_link"></url-value>
|
||||
</el-form-item>
|
||||
<el-form-item label="文字颜色">
|
||||
<color-picker v-model="form.text_color" default-color="#FF3F3F"></color-picker>
|
||||
<el-form-item label="图标颜色">
|
||||
<color-picker v-model="form.icon_color" default-color="#FF3F3F"></color-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="文字大小">
|
||||
<el-radio-group v-model="form.text_weight">
|
||||
<el-radio value="500">加粗</el-radio>
|
||||
<el-radio value="normal">正常</el-radio>
|
||||
<el-radio value="italic">倾斜</el-radio>
|
||||
</el-radio-group>
|
||||
<el-form-item label="字号" label-width="40" class="mb-0 w">
|
||||
<slider v-model="form.text_size" :max="100"></slider>
|
||||
</el-form-item>
|
||||
<el-form-item label="图标大小">
|
||||
<slider v-model="form.icon_size" :max="100"></slider>
|
||||
</el-form-item>
|
||||
<el-form-item label="字符选项">
|
||||
<el-radio-group v-model="form.text_option">
|
||||
<el-radio value="none"><span style="text-decoration: none">Aa</span></el-radio>
|
||||
<el-radio value="underline"><span style="text-decoration: underline">Aa</span></el-radio>
|
||||
<el-radio value="line-through"><span style="text-decoration: line-through">Aa</span></el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="文字位置">
|
||||
<el-radio-group v-model="form.text_location" is-button>
|
||||
<el-form-item label="图标位置">
|
||||
<el-radio-group v-model="form.icon_location" is-button>
|
||||
<el-tooltip content="左对齐" placement="top" effect="light">
|
||||
<el-radio-button value="left"><icon name="iconfont icon-left"></icon></el-radio-button>
|
||||
</el-tooltip>
|
||||
|
|
@ -48,10 +34,10 @@
|
|||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="内边距">
|
||||
<padding :value="form.text_padding" @update:value="padding_change"></padding>
|
||||
<padding :value="form.icon_padding" @update:value="padding_change"></padding>
|
||||
</el-form-item>
|
||||
<el-form-item label="旋转角度">
|
||||
<slider v-model="form.text_rotate" :max="1000"></slider>
|
||||
<slider v-model="form.icon_rotate" :max="1000"></slider>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否置底">
|
||||
<el-switch v-model="form.bottom_up" active-value="1" inactive-value="0" />
|
||||
|
|
@ -67,7 +53,7 @@
|
|||
<slider v-model="form.com_height" :max="1000"></slider>
|
||||
</el-form-item>
|
||||
<el-form-item label="背景颜色">
|
||||
<color-picker v-model="form.com_bg" default-color="#FF3F3F"></color-picker>
|
||||
<color-picker v-model="form.com_bg"></color-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="圆角">
|
||||
<radius :value="form.bg_radius" @update:value="bg_radius_change"></radius>
|
||||
|
|
@ -121,15 +107,15 @@ const form = ref(diy_data.value.com_data);
|
|||
const center_height = defineModel('height', { type: Number, default: 0 });
|
||||
|
||||
const padding_change = (padding: any) => {
|
||||
form.value.text_padding = Object.assign(form.value.text_padding, pick(padding, ['padding', 'padding_top', 'padding_bottom', 'padding_left', 'padding_right']));
|
||||
form.value.icon_padding = Object.assign(form.value.icon_padding, pick(padding, ['padding', 'padding_top', 'padding_bottom', 'padding_left', 'padding_right']));
|
||||
};
|
||||
const bg_radius_change = (radius: any) => {
|
||||
form.value.bg_radius = Object.assign(form.value.bg_radius, pick(radius, ['radius', 'radius_top_left', 'radius_top_right', 'radius_bottom_left', 'radius_bottom_right']));
|
||||
};
|
||||
|
||||
const text_change = (key: string) => {
|
||||
const icon_change = (key: string) => {
|
||||
if (key == '2') {
|
||||
form.value.text_title = '';
|
||||
form.value.icon_title = '';
|
||||
} else {
|
||||
form.value.data_source_id = '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<slider v-model="form.line_size" :min="1" :max="100"></slider>
|
||||
</el-form-item>
|
||||
<el-form-item label="线条颜色">
|
||||
<color-picker v-model="form.line_color" default-color="#FF3F3F"></color-picker>
|
||||
<color-picker v-model="form.line_color"></color-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否置底">
|
||||
<el-switch v-model="form.bottom_up" active-value="1" inactive-value="0" />
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
<slider v-model="form.com_height" :max="1000"></slider>
|
||||
</el-form-item>
|
||||
<el-form-item label="背景颜色">
|
||||
<color-picker v-model="form.com_bg" default-color="#FF3F3F"></color-picker>
|
||||
<color-picker v-model="form.com_bg"></color-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="圆角">
|
||||
<radius :value="form.bg_radius" @update:value="bg_radius_change"></radius>
|
||||
|
|
|
|||
|
|
@ -309,5 +309,7 @@ const slideChange = (swiper: { realIndex: number }) => {
|
|||
}
|
||||
.video-class {
|
||||
max-width: 100%;
|
||||
margin-right: 10px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -82,6 +82,44 @@ export const line_com_data = {
|
|||
bottom_up: '1',
|
||||
}
|
||||
|
||||
// icon的默认值
|
||||
export const icon_com_data = {
|
||||
com_width: 36,
|
||||
com_height: 36,
|
||||
staging_height: 36,
|
||||
icon_class: '',
|
||||
data_source_id: '',
|
||||
data_source_list: {},
|
||||
icon_link: {},
|
||||
is_rich_icon: '0',
|
||||
is_up_down: '1',
|
||||
icon_color: '#000',
|
||||
icon_weight: 'normal',
|
||||
icon_size: 12,
|
||||
icon_option: 'none',
|
||||
icon_location: 'left',
|
||||
icon_padding: {
|
||||
padding: 0,
|
||||
padding_top: 0,
|
||||
padding_bottom: 0,
|
||||
padding_left: 0,
|
||||
padding_right: 0,
|
||||
},
|
||||
icon_rotate: 0,
|
||||
border_show: '0',
|
||||
border_color: '#FF5D5D',
|
||||
border_style: 'solid',
|
||||
bg_radius: {
|
||||
radius: 0,
|
||||
radius_top_left: 0,
|
||||
radius_top_right: 0,
|
||||
radius_bottom_left: 0,
|
||||
radius_bottom_right: 0,
|
||||
},
|
||||
border_size: 1,
|
||||
com_bg: '',
|
||||
bottom_up: '1',
|
||||
}
|
||||
// 判断两个矩形是否有交集或者被包裹
|
||||
export const isRectangleIntersecting = (rect1: react1, rect2: react1) => {
|
||||
// 矩形的格式为 { x, y, width, height }
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@
|
|||
<template v-else-if="item.key == 'auxiliary-line'">
|
||||
<model-lines :key="item.id" :value="item.com_data" :source-list="props.sourceList"></model-lines>
|
||||
</template>
|
||||
<template v-else-if="item.key == 'icon'">
|
||||
<model-icon :key="item.id" :value="item.com_data" :source-list="props.sourceList"></model-icon>
|
||||
</template>
|
||||
</div>
|
||||
</Vue3DraggableResizable>
|
||||
</DraggableContainer>
|
||||
|
|
@ -82,7 +85,7 @@
|
|||
<script setup lang="ts">
|
||||
import { cloneDeep, isEmpty } from 'lodash';
|
||||
import { get_math } from '@/utils';
|
||||
import { text_com_data, img_com_data, line_com_data, isRectangleIntersecting } from "./index-default";
|
||||
import { text_com_data, img_com_data, line_com_data, icon_com_data, isRectangleIntersecting } from "./index-default";
|
||||
// 删除
|
||||
const app = getCurrentInstance();
|
||||
//#region 传递参数和传出数据的处理
|
||||
|
|
@ -115,6 +118,11 @@ const components = reactive([
|
|||
name: '线条',
|
||||
com_data: line_com_data,
|
||||
},
|
||||
{
|
||||
key: 'icon',
|
||||
name: '图标',
|
||||
com_data: icon_com_data,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
<template v-else-if="item.key == 'auxiliary-line'">
|
||||
<model-lines :key="item.com_data" :value="item.com_data" :source-list="form.data_source_content" :is-percentage="true"></model-lines>
|
||||
</template>
|
||||
<template v-else-if="item.key == 'icon'">
|
||||
<model-icon :key="item.com_data" :value="item.com_data" :source-list="form.data_source_content" :is-percentage="true"></model-icon>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
<template v-else-if="diy_data.key == 'auxiliary-line'">
|
||||
<model-lines-style :key="key" v-model:height="center_height" :value="diy_data"></model-lines-style>
|
||||
</template>
|
||||
<template v-else-if="diy_data.key == 'icon'">
|
||||
<model-icon-style :key="key" v-model:height="center_height" :value="diy_data"></model-icon-style>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="w h flex align-c bg-f">
|
||||
<no-data></no-data>
|
||||
|
|
|
|||
Loading…
Reference in New Issue