vr-uniapp/src/components/model-custom/model-custom-content.vue

135 lines
4.0 KiB
Vue
Raw Normal View History

<template>
<div class="auxiliary-line">
<el-form :model="form" label-width="60">
<card-container class="common-content-height">
<div class="mb-20">数据源</div>
<el-form-item label="动态数据">
<el-select v-model="form.data_source" value-key="id" placeholder="Select" size="default">
<el-option v-for="item in options" :key="item.id" :label="item.label" :value="item" />
</el-select>
</el-form-item>
<div class="mb-20">内容设置</div>
<el-button class="w" size="large" @click="custom_edit"><icon name="edit" size="12"></icon>自定义编辑</el-button>
</card-container>
</el-form>
<Dialog ref="dialog" @accomplish="accomplish">
<div class="flex-row h w">
2024-08-12 08:10:56 +00:00
<DragIndex ref="draglist" :key="dragkey" v-model:height="center_height" :list="custom_list" @right-update="right_update"></DragIndex>
<div class="settings">
<template v-if="diy_data.key === 'img'">
<model-image-style :key="key" v-model:height="center_height" :value="diy_data"></model-image-style>
</template>
<template v-else-if="diy_data.key == 'text'">
<model-text-style :key="key" v-model:height="center_height" :value="diy_data"></model-text-style>
</template>
<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>
</div>
</div>
</Dialog>
</div>
</template>
<script setup lang="ts">
import Dialog from './components/dialog.vue';
import DragIndex from './components/index.vue';
import { cloneDeep } from 'lodash';
const props = defineProps({
value: {
type: Object,
default: () => {},
},
});
const dialog = ref<expose | null>(null);
2024-08-12 08:10:56 +00:00
const draglist = ref<diy_data | null>(null);
const form = reactive(props.value);
// 弹出框里的内容
let custom_list = reactive([]);
const center_height = ref(0);
const options = [
{ id: 1, label: 'Option A', desc: 'Option A - 230506' },
{ id: 2, label: 'Option B', desc: 'Option B - 230506' },
{ id: 3, label: 'Option C', desc: 'Option C - 230506' },
{ id: 4, label: 'Option A', desc: 'Option A - 230507' },
];
const diy_data = ref<diy>({
key: '',
location: {
x: 0,
y: 0,
staging_y: 0,
},
com_data: {},
});
const key = ref('');
const dragkey = ref('');
const right_update = (item: any) => {
diy_data.value = item;
// 生成随机id
key.value = Math.random().toString(36).substring(2);
};
const custom_edit = () => {
if (!dialog.value) return;
dialog.value.dialogVisible = true;
dragkey.value = Math.random().toString(36).substring(2);
custom_list = cloneDeep(form.custom_list);
center_height.value = cloneDeep(form.height);
};
const accomplish = () => {
2024-08-12 08:10:56 +00:00
if (!draglist.value) {
return;
} else {
form.custom_list = draglist.value.diy_data;
}
form.height = center_height.value;
};
</script>
<style lang="scss" scoped>
.card.mb-8 {
.el-form-item:last-child {
margin-bottom: 0;
}
}
.settings {
width: 46rem;
overflow: auto;
display: flex;
flex-direction: column;
}
@media screen and (max-width: 1540px) {
.settings {
width: 40rem;
}
}
:deep(.el-dialog) {
margin-top: 0;
padding: 0;
overflow: hidden;
.el-dialog__header {
padding: 3rem;
.el-dialog__title {
font-size: 16px;
}
.el-dialog__headerbtn {
font-size: 2.4rem;
padding: 3rem;
height: auto;
width: auto;
}
}
.el-dialog__body {
background: #f5f5f5;
height: calc(100% - 16.4rem);
}
.el-dialog__footer {
padding: 2.4rem 3rem;
}
}
</style>