Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-12-06 11:00:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a04fb135784d778b5d49a1e106ee727f240b2625
a04fb135
1 parent
3a65740b
新增展示组件-按钮控件
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
10 deletions
src/components/ButtonField/index.vue
src/hooks/useComponentType.js
src/views/index.vue
src/components/ButtonField/index.vue
0 → 100644
View file @
a04fb13
<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-11-22 14:23:49
* @FilePath: /data-table/src/components/DividerField/index.vue
* @Description: 按钮组件
-->
<template>
<div class="button-field-page">
<van-row justify="center" gutter="20">
<van-col v-for="item in props.item.component_props.config" key="index">
<van-button
@click="handleButton(item)"
:icon="iconType(item)"
:color="item.background ? item.background : backgroundColor"
>{{ item.text }}
</van-button>
</van-col>
</van-row>
</div>
<van-overlay :show="show" @click="onClose">
<div class="wrapper">
<div class="block">
<van-image width="100%" fit="cover" :src="qr_url" />
</div>
</div>
</van-overlay>
</template>
<script setup>
import { styleColor } from "@/constant.js";
const props = defineProps({
item: Object,
});
const show = ref(false);
const backgroundColor = styleColor.baseColor;
const iconType = (item) => {
if (item.type === "tel") return "phone-o";
if (item.type === "link") return "link-o";
if (item.type === "qr") return "qr";
};
const qr_url = ref("");
const handleButton = ({ type, content }) => {
if (type === "tel") {
location.href = "tel://" + content;
}
if (type === "link") {
location.href = content;
}
if (type === "qr") {
show.value = true;
qr_url.value = content;
}
};
const onClose = () => {
show.value = false;
};
onMounted(() => {
console.warn(props.item.component_props.config);
});
</script>
<style lang="less" scoped>
.button-field-page {
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.block {
width: 10rem;
height: 10rem;
background-color: #fff;
}
</style>
src/hooks/useComponentType.js
View file @
a04fb13
...
...
@@ -25,6 +25,7 @@ import MarqueeField from '@/components/MarqueeField/index.vue'
import
ContactField
from
'@/components/ContactField/index.vue'
import
RuleField
from
'@/components/RuleField/index.vue'
import
MultiRuleField
from
'@/components/MultiRuleField/index.vue'
import
ButtonField
from
'@/components/ButtonField/index.vue'
/**
* 生成自定义组件类型
...
...
@@ -150,6 +151,10 @@ export function createComponentType(data) {
item
.
name
=
item
.
key
;
item
.
component
=
RuleField
;
}
if
(
item
.
component_props
.
name
===
'button'
)
{
item
.
name
=
item
.
key
;
item
.
component
=
ButtonField
;
}
if
(
item
.
component_props
.
name
===
'multi_rule'
)
{
item
.
name
=
item
.
key
;
item
.
value
=
[];
...
...
src/views/index.vue
View file @
a04fb13
...
...
@@ -108,16 +108,28 @@ const formatData = (data) => {
const component_props = {
name: field.component_code,
};
field.property_list.forEach((prop) => {
const key = prop["property_code"];
const obj = {
[key]:
prop["setting_value"].length > 1
? prop["setting_value"]
: prop["setting_value"][0],
};
Object.assign(component_props, obj);
});
if (field.component_type === "h5edit") {
// 编辑组件
field.property_list.forEach((prop) => {
const key = prop["property_code"];
const obj = {
[key]:
prop["setting_value"].length > 1
? prop["setting_value"]
: prop["setting_value"][0],
};
Object.assign(component_props, obj);
});
} else {
// 展示组件
field.property_list.forEach((prop) => {
const key = prop["property_code"];
const obj = {
[key]: prop["setting_value"],
};
Object.assign(component_props, obj);
});
}
// 绑定组件名称标识
const temp = {
key: field.field_name,
...
...
Please
register
or
login
to post a comment