新增自定义接口显示
parent
b8bd964a2b
commit
3de196663c
|
|
@ -8,7 +8,7 @@
|
|||
<upload v-model="form.img_src" :limit="1" size="50"></upload>
|
||||
<div class="flex-row align-c gap-10 mt-12">
|
||||
<el-select v-model="form.data_source_id" value-key="id" placeholder="请选择图片数据字段" size="default" class="flex-1">
|
||||
<el-option v-for="item in options" :key="item.id" :label="item.label" :value="item" />
|
||||
<el-option v-for="item in options.filter(item => item.type == 'images')" :key="item.field" :label="item.name" :value="item.field" />
|
||||
</el-select>
|
||||
<el-popover placement="top-start" :width="200" trigger="hover" content="this is content, this is content, this is content">
|
||||
<template #reference>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<el-input v-model="form.text_title" placeholder="请输入链接" type="textarea" :rows="3"></el-input>
|
||||
<div class="flex-row align-c gap-10 mt-12">
|
||||
<el-select v-model="form.data_source_id" value-key="id" placeholder="请选择图片数据字段" size="default" class="flex-1">
|
||||
<el-option v-for="item in options" :key="item.id" :label="item.label" :value="item" />
|
||||
<el-option v-for="item in options.filter(item => item.type == 'text')" :key="item.field" :label="item.name" :value="item.field" />
|
||||
</el-select>
|
||||
<el-popover placement="top-start" :width="200" trigger="hover" content="this is content, this is content, this is content">
|
||||
<template #reference>
|
||||
|
|
@ -21,9 +21,6 @@
|
|||
<el-form-item label="链接">
|
||||
<url-value v-model="form.text_link"></url-value>
|
||||
</el-form-item>
|
||||
<el-form-item label="富文本">
|
||||
<el-switch v-model="form.is_rich_text" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文字颜色">
|
||||
<color-picker v-model="form.text_color" default-color="#FF3F3F"></color-picker>
|
||||
</el-form-item>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
<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 v-model="form.data_source" value-key="id" placeholder="请选择数据源" @change="changeDataSource">
|
||||
<el-option v-for="item in options" :key="item.type" :label="item.name" :value="item.type" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="mb-20">内容设置</div>
|
||||
|
|
@ -17,10 +17,10 @@
|
|||
<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>
|
||||
<model-image-style :key="key" v-model:height="center_height" :options="model_data_source" :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>
|
||||
<model-text-style :key="key" v-model:height="center_height" :options="model_data_source" :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>
|
||||
|
|
@ -39,6 +39,7 @@
|
|||
import Dialog from './components/dialog.vue';
|
||||
import DragIndex from './components/index.vue';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import CustomAPI from '@/api/custom';
|
||||
import { DataSourceStore } from '@/store';
|
||||
const data_source = DataSourceStore();
|
||||
|
||||
|
|
@ -56,12 +57,33 @@ 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 options = ref<source_list[]>([]);
|
||||
interface data_list {
|
||||
name: string;
|
||||
field: string;
|
||||
type: string;
|
||||
};
|
||||
interface source_list {
|
||||
name: string;
|
||||
data: data_list[];
|
||||
type: string;
|
||||
};
|
||||
const init = () => {
|
||||
CustomAPI.getCustominit().then((res) => {
|
||||
const { data_source } = res.data;
|
||||
options.value = data_source;
|
||||
data_source.set_data_source(data_source);
|
||||
});
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
if (!data_source.is_data_source_api) {
|
||||
data_source.set_is_data_source_api(true);
|
||||
init();
|
||||
} else {
|
||||
options.value = data_source.data_source_list;
|
||||
}
|
||||
});
|
||||
|
||||
const diy_data = ref<diy>({
|
||||
key: '',
|
||||
|
|
@ -99,6 +121,15 @@ const accomplish = () => {
|
|||
}
|
||||
form.height = center_height.value;
|
||||
};
|
||||
const model_data_source = ref<data_list[]>([])
|
||||
const changeDataSource = (key: any) => {
|
||||
const list = options.value.filter(item => item.type == key);
|
||||
if (list.length > 0) {
|
||||
model_data_source.value = list[0].data;
|
||||
} else {
|
||||
model_data_source.value = [];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.card.mb-8 {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="显示数量">
|
||||
<el-input-number v-model="form.number" :min="1" :max="100" type="number" placeholder="请输入显示数量" value-on-clear="min" class="w" controls-position="right"></el-input-number>
|
||||
<el-input-number v-model="form.number" :min="1" :max="100" type="number" placeholder="请输入显示数量" value-on-clear="min" class="w number-show" controls-position="right"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序类型">
|
||||
<el-radio-group v-model="form.sort">
|
||||
|
|
@ -128,7 +128,7 @@ const init = () => {
|
|||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
onBeforeMount(() => {
|
||||
if (!shop_store.is_shop_api) {
|
||||
shop_store.set_is_shop_api(true);
|
||||
init();
|
||||
|
|
@ -179,4 +179,9 @@ const change_style = (val: any):void => {
|
|||
width: 4rem;
|
||||
height: 4rem;
|
||||
}
|
||||
.number-show {
|
||||
:deep(.el-input__wrapper .el-input__inner) {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -2,21 +2,27 @@ import { ref } from 'vue';
|
|||
import { defineStore } from 'pinia';
|
||||
|
||||
export const DataSourceStore = defineStore('dataSource', () => {
|
||||
interface product_list {
|
||||
id: number;
|
||||
interface data_list {
|
||||
name: string;
|
||||
field: string;
|
||||
type: string;
|
||||
};
|
||||
interface source_list {
|
||||
name: string;
|
||||
data: data_list[];
|
||||
type: string;
|
||||
};
|
||||
// 上传是否需要调接口判断
|
||||
const is_data_source_api = ref(false);
|
||||
// 数据源
|
||||
const data_source_list = ref<product_list[]>([]);
|
||||
const data_source_list = ref<source_list[]>([]);
|
||||
// 存储上传分类列表
|
||||
const set_data_source = (category: product_list[], brand: product_list[]) => {
|
||||
data_source_list.value = category;
|
||||
const set_data_source = (source_list: source_list[]) => {
|
||||
data_source_list.value = source_list;
|
||||
is_data_source_api.value = true;
|
||||
};
|
||||
// 如果为false 则转为true
|
||||
const set_is_shop_api = (bool: boolean) => {
|
||||
const set_is_data_source_api = (bool: boolean) => {
|
||||
is_data_source_api.value = bool;
|
||||
};
|
||||
|
||||
|
|
@ -24,6 +30,6 @@ export const DataSourceStore = defineStore('dataSource', () => {
|
|||
data_source_list,
|
||||
is_data_source_api,
|
||||
set_data_source,
|
||||
set_is_shop_api,
|
||||
set_is_data_source_api,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue