Showing
2 changed files
with
101 additions
and
0 deletions
src/components/RuleField/index.vue
0 → 100644
| 1 | +<!-- | ||
| 2 | + * @Date: 2022-08-30 11:34:19 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-11-24 14:33:47 | ||
| 5 | + * @FilePath: /data-table/src/components/RuleField/index.vue | ||
| 6 | + * @Description: 规则确认控件 | ||
| 7 | +--> | ||
| 8 | +<template> | ||
| 9 | + <div class="rule-field-page"> | ||
| 10 | + <div class="label"> | ||
| 11 | + {{ item.component_props.label | ||
| 12 | + }}<span v-if="item.component_props.required"> *</span> | ||
| 13 | + </div> | ||
| 14 | + <van-field | ||
| 15 | + :name="item.key" | ||
| 16 | + :rules="item.rules" | ||
| 17 | + :border="false" | ||
| 18 | + style="padding-bottom: 0" | ||
| 19 | + > | ||
| 20 | + <template #input> | ||
| 21 | + <van-radio-group v-model="item.value"> | ||
| 22 | + <van-radio name="1">{{ item.component_props.rule_desc }}</van-radio> | ||
| 23 | + </van-radio-group> | ||
| 24 | + </template> | ||
| 25 | + </van-field> | ||
| 26 | + <div class="rule-box" @click="show = true"> | ||
| 27 | + {{ item.component_props.rule_link }} >> | ||
| 28 | + </div> | ||
| 29 | + </div> | ||
| 30 | + | ||
| 31 | + <van-overlay :show="show" @click="show = false"> | ||
| 32 | + <div class="rule-wrapper" @click.stop> | ||
| 33 | + <div class="rule-block"> | ||
| 34 | + <div | ||
| 35 | + style="height: 70vh; overflow: scroll" | ||
| 36 | + v-html="item.component_props.rule_content" | ||
| 37 | + ></div> | ||
| 38 | + <div class="close-btn"> | ||
| 39 | + <van-button type="primary" block @click="show = false" | ||
| 40 | + >关 闭</van-button | ||
| 41 | + > | ||
| 42 | + </div> | ||
| 43 | + <div></div> | ||
| 44 | + </div> | ||
| 45 | + </div> | ||
| 46 | + </van-overlay> | ||
| 47 | +</template> | ||
| 48 | + | ||
| 49 | +<script setup> | ||
| 50 | +const props = defineProps({ | ||
| 51 | + item: Object, | ||
| 52 | +}); | ||
| 53 | + | ||
| 54 | +const show = ref(false); | ||
| 55 | +</script> | ||
| 56 | + | ||
| 57 | +<style lang="less" scoped> | ||
| 58 | +.rule-field-page { | ||
| 59 | + .label { | ||
| 60 | + padding: 1rem 1rem 0 1rem; | ||
| 61 | + font-size: 0.9rem; | ||
| 62 | + font-weight: bold; | ||
| 63 | + span { | ||
| 64 | + color: red; | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + .rule-box { | ||
| 68 | + font-size: 0.85rem; | ||
| 69 | + margin-left: 2.7rem; | ||
| 70 | + padding-bottom: 1rem; | ||
| 71 | + color: #1989fa; | ||
| 72 | + } | ||
| 73 | +} | ||
| 74 | +.rule-wrapper { | ||
| 75 | + display: flex; | ||
| 76 | + align-items: center; | ||
| 77 | + justify-content: center; | ||
| 78 | + height: 100%; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +.rule-block { | ||
| 82 | + position: relative; | ||
| 83 | + width: 80vw; | ||
| 84 | + height: 80vh; | ||
| 85 | + background-color: #fff; | ||
| 86 | + overflow: scroll; | ||
| 87 | + padding: 1rem; | ||
| 88 | + .close-btn { | ||
| 89 | + position: absolute; | ||
| 90 | + bottom: 1rem; | ||
| 91 | + // transform: translateX(100%); | ||
| 92 | + width: calc(100% - 2rem); | ||
| 93 | + } | ||
| 94 | +} | ||
| 95 | +</style> |
| ... | @@ -22,6 +22,7 @@ import DividerField from '@/components/DividerField/index.vue' | ... | @@ -22,6 +22,7 @@ import DividerField from '@/components/DividerField/index.vue' |
| 22 | import VideoField from '@/components/VideoField/index.vue' | 22 | import VideoField from '@/components/VideoField/index.vue' |
| 23 | import MarqueeField from '@/components/MarqueeField/index.vue' | 23 | import MarqueeField from '@/components/MarqueeField/index.vue' |
| 24 | import ContactField from '@/components/ContactField/index.vue' | 24 | import ContactField from '@/components/ContactField/index.vue' |
| 25 | +import RuleField from '@/components/RuleField/index.vue' | ||
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| 27 | * 生成自定义组件类型 | 28 | * 生成自定义组件类型 |
| ... | @@ -46,6 +47,7 @@ import ContactField from '@/components/ContactField/index.vue' | ... | @@ -46,6 +47,7 @@ import ContactField from '@/components/ContactField/index.vue' |
| 46 | * @type divider 分割线 DividerField | 47 | * @type divider 分割线 DividerField |
| 47 | * @type video 视频控件 VideoField | 48 | * @type video 视频控件 VideoField |
| 48 | * @type marquee 跑马灯控件 MarqueeField | 49 | * @type marquee 跑马灯控件 MarqueeField |
| 50 | + * @type rule 活动规则控件 RuleField | ||
| 49 | */ | 51 | */ |
| 50 | export function createComponentType(data) { | 52 | export function createComponentType(data) { |
| 51 | // 判断类型和使用组件 | 53 | // 判断类型和使用组件 |
| ... | @@ -138,5 +140,9 @@ export function createComponentType(data) { | ... | @@ -138,5 +140,9 @@ export function createComponentType(data) { |
| 138 | item.name = item.key; | 140 | item.name = item.key; |
| 139 | item.component = ContactField; | 141 | item.component = ContactField; |
| 140 | } | 142 | } |
| 143 | + if (item.component_props.name === 'rule') { | ||
| 144 | + item.name = item.key; | ||
| 145 | + item.component = RuleField; | ||
| 146 | + } | ||
| 141 | }) | 147 | }) |
| 142 | } | 148 | } | ... | ... |
-
Please register or login to post a comment