hookehuyr

新增富文本显示控件

1 +<!--
2 + * @Date: 2022-08-29 14:31:20
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-01-05 10:07:18
5 + * @FilePath: /data-table/src/components/NoteField/index.vue
6 + * @Description: 富文本组件
7 +-->
8 +<template>
9 + <div class="note-field-page">
10 + <div class="label">{{ item.component_props.label }}<span v-if="item.component_props.required">&nbsp;*</span></div>
11 + <div class="html" style="padding: 0.5rem 1rem 0 1rem;" v-html="item.component_props.note"></div>
12 + </div>
13 +</template>
14 +
15 +<script setup>
16 +const props = defineProps({
17 + item: Object,
18 +});
19 +</script>
20 +
21 +<style lang="less">
22 +.note-field-page {
23 + .label {
24 + padding: 1rem 1rem 0 1rem;
25 + font-size: 0.9rem;
26 + font-weight: bold;
27 +
28 + span {
29 + color: red;
30 + }
31 + }
32 + .html {
33 + img {
34 + width: 100%;
35 + }
36 + }
37 +}
38 +</style>
...@@ -26,6 +26,7 @@ import ContactField from '@/components/ContactField/index.vue' ...@@ -26,6 +26,7 @@ import ContactField from '@/components/ContactField/index.vue'
26 import RuleField from '@/components/RuleField/index.vue' 26 import RuleField from '@/components/RuleField/index.vue'
27 import MultiRuleField from '@/components/MultiRuleField/index.vue' 27 import MultiRuleField from '@/components/MultiRuleField/index.vue'
28 import ButtonField from '@/components/ButtonField/index.vue' 28 import ButtonField from '@/components/ButtonField/index.vue'
29 +import NoteField from '@/components/NoteField/index.vue';
29 30
30 /** 31 /**
31 * 生成自定义组件类型 32 * 生成自定义组件类型
...@@ -52,6 +53,7 @@ import ButtonField from '@/components/ButtonField/index.vue' ...@@ -52,6 +53,7 @@ import ButtonField from '@/components/ButtonField/index.vue'
52 * @type marquee 跑马灯控件 MarqueeField 53 * @type marquee 跑马灯控件 MarqueeField
53 * @type rule 活动规则控件 RuleField 54 * @type rule 活动规则控件 RuleField
54 * @type multi_rule 活动规则控件 MultiRuleField 55 * @type multi_rule 活动规则控件 MultiRuleField
56 + * @type note 富文本控件 NoteField
55 */ 57 */
56 export function createComponentType(data) { 58 export function createComponentType(data) {
57 // 判断类型和使用组件 59 // 判断类型和使用组件
...@@ -160,5 +162,9 @@ export function createComponentType(data) { ...@@ -160,5 +162,9 @@ export function createComponentType(data) {
160 item.value = []; 162 item.value = [];
161 item.component = MultiRuleField; 163 item.component = MultiRuleField;
162 } 164 }
165 + if (item.component_props.tag === 'note') {
166 + item.name = item.key;
167 + item.component = NoteField;
168 + }
163 }) 169 })
164 } 170 }
......