修改商品逻辑处理

v1.0.0
于肖磊 2024-10-14 11:47:50 +08:00
parent 13e17bdc46
commit 0668d9e222
6 changed files with 119 additions and 46 deletions

View File

@ -1,5 +1,5 @@
<template>
<i class="iconfont" :class="className" :style="'font-size:' + size + 'px;' + (props.color.indexOf('#') != -1 || props.color.indexOf('rgba') != -1 ? 'color:' + props.color + ';' : '') + styles" @click="onClick">
<i class="iconfont" :class="className" :style="'font-size:' + size + 'px;' + (props.color && (props.color.indexOf('#') != -1 || props.color.indexOf('rgba') != -1) ? 'color:' + props.color + ';' : '') + styles" @click="onClick">
<slot></slot>
</i>
</template>

View File

@ -51,7 +51,6 @@ const text_title = computed(() => {
});
const text_style = computed(() => {
console.log(form.text_size * props.scale);
let style = `font-size: ${ form.text_size * props.scale }px;line-height: ${ form.text_size * props.scale}px;color: ${ form.text_color }; text-align: ${ form.text_location }; transform: rotate(${form.text_rotate}deg);text-decoration: ${ form.text_option };${ padding_computer(form.text_padding, props.scale) };`;
if (form.text_weight == 'italic') {
style += `font-style: italic`;

View File

@ -179,7 +179,7 @@ watch(
() => data_list_computer.value,
(new_value, old_value) => {
// 使JSON.stringify()
if (JSON.stringify(new_value) !== JSON.stringify(old_value)) {
if ((JSON.stringify(new_value) !== JSON.stringify(old_value)) || props.isCommonStyle) {
if (new_value.data_type == '1') {
get_auto_data_list();
} else {

View File

@ -248,4 +248,32 @@
.clear-selection {
cursor: pointer;
color: $cr-main;
}
.drawer-container {
position: relative;
height: 100%;
overflow: hidden;
.drawer-custom-drag-bg {
background: #f2f8ff;
}
.drawer-drag-area {
height: 100%;
overflow-y: auto;
}
.drawer-drag {
cursor: move;
}
.drawer-drag:hover {
background: #f2f8ff;
.iconfont.icon-close-b {
display: block !important;
}
}
.iconfont.icon-close-b {
right: 1rem;
top: 1.4rem;
color: #8a8a8a;
cursor: pointer;
}
}

View File

@ -20,13 +20,23 @@
<slider v-model="center_height" :max="1000"></slider>
</card-container>
<card-container class="h selected">
<div class="mb-12 flex-row align-c jc-sb">已选组件<span class="clear-selection" @click="cancel"></span></div>
<div class="assembly">
<div v-if="!isEmpty(diy_data)" class="flex-row flex-wrap gap-10">
<div v-for="(item, index) in diy_data" :key="index" class="item flex jc-sb align-c size-14 cr-3" :class="{ 'item-active': item.show_tabs == '1' }" @click="on_choose(index, item.show_tabs)">{{ item.name }}<icon name="close" color="3" size="10" class="c-pointer" @click="del(index)"></icon></div>
</div>
<div v-else class="w h flex jc-c align-c">
<no-data></no-data>
<div class="flex-col gap-10 drawer-container">
<div class="flex-row align-c jc-sb">已选组件<span class="clear-selection" @click="cancel"></span></div>
<div ref="left_scrollTop" class="drawer-drag-area">
<VueDraggable v-model="diy_data" :animation="500" target=".sort-target" :scroll="true" @sort="on_sort">
<TransitionGroup type="transition" tag="ul" name="fade" class="sort-target flex-col">
<template v-if="!isEmpty(diy_data)">
<li v-for="(item, index) in diy_data" :key="index" :class="['flex-row ptb-12 plr-10 gap-y-8 re align-c drawer-drag', { 'drawer-custom-drag-bg': item.show_tabs == '1' }]" @click="on_choose(index, item.show_tabs)">
<el-icon class="iconfont icon-drag size-16 cr-d" />
<span class="size-12 cr-6">{{ item.name }}</span>
<el-icon class="iconfont icon-close-b size-16 abs" :style="[item.show_tabs == '1' ? '' : 'display:none']" @click.stop="del(index)" />
</li>
</template>
<div v-else class="w h flex jc-c align-c">
<no-data></no-data>
</div>
</TransitionGroup>
</VueDraggable>
</div>
</div>
</card-container>
@ -34,6 +44,10 @@
<!-- 视图渲染 -->
<div class="main">
<div class="model-content">
<div class="plug-in-right" chosenClass="close">
<el-icon class="iconfont icon-del" @click.stop="del(select_index)" />
<el-icon class="iconfont icon-copy" @click.stop="copy(select_index)" />
</div>
<!-- 拖拽区 -->
<div class="model-drag">
<div class="model-wall">
@ -41,12 +55,8 @@
<div class="w h" @mousedown.prevent="start_drag" @mousemove.prevent="move_drag" @mouseup.prevent="end_drag">
<DraggableContainer v-if="draggable_container" :reference-line-visible="true" :disabled="false" reference-line-color="#ddd" @selectstart.prevent @contextmenu.prevent @dragstart.prevent>
<!-- @mouseover="on_choose(index)" -->
<Vue3DraggableResizable v-for="(item, index) in diy_data" :key="item.id" v-model:w="item.com_data.com_width" v-model:h="item.com_data.com_height" :min-w="0" :min-h="0" :class="{ 'plug-in-show-tabs': item.show_tabs == '1', 'vdr-handle-z-index': item.com_data.bottom_up == '1'}" :init-w="item.com_data.com_width" :init-h="item.com_data.com_height" :x="item.location.x" :y="item.location.y" :parent="true" :draggable="is_draggable" @mousedown.stop="on_choose(index, item.show_tabs)" @click.stop="on_choose(index, item.show_tabs)" @drag-end="dragEndHandle($event, index)" @resizing="resizingHandle($event, item.key, index)" @resize-end="resizingHandle($event, item.key, index)">
<div v-if="item.show_tabs == '1'" class="plug-in-right" chosenClass="close">
<el-icon class="iconfont icon-del" @click.stop="del(index)" />
<el-icon class="iconfont icon-copy" @click.stop="copy(index)" />
</div>
<div :class="['main-content', { 'plug-in-border': item.show_tabs == '1' }]" :style="{ 'z-index': item.com_data.bottom_up == '1' ? 0 : 1 }">
<Vue3DraggableResizable v-for="(item, index) in diy_data" :key="item.id" v-model:w="item.com_data.com_width" v-model:h="item.com_data.com_height" :min-w="0" :min-h="0" :class="{ 'plug-in-show-tabs': item.show_tabs == '1', 'vdr-handle-z-index': item.com_data.bottom_up == '1', 'z-index': item.com_data.bottom_up == '1' ? 0 : 1}" :init-w="item.com_data.com_width" :init-h="item.com_data.com_height" :x="item.location.x" :y="item.location.y" :parent="true" :draggable="is_draggable" @mousedown.stop="on_choose(index, item.show_tabs)" @click.stop="on_choose(index, item.show_tabs)" @drag-end="dragEndHandle($event, index)" @resizing="resizingHandle($event, item.key, index)" @resize-end="resizingHandle($event, item.key, index)">
<div :class="['main-content', { 'plug-in-border': item.show_tabs == '1' }]">
<template v-if="item.key == 'text'">
<model-text :key="item.id" :value="item.com_data" :source-list="props.sourceList"></model-text>
</template>
@ -89,6 +99,7 @@
import { cloneDeep, isEmpty } from 'lodash';
import { get_math } from '@/utils';
import { text_com_data, img_com_data, line_com_data, icon_com_data, panel_com_data, isRectangleIntersecting } from "./index-default";
import { SortableEvent, VueDraggable } from 'vue-draggable-plus';
//
const app = getCurrentInstance();
//#region
@ -139,6 +150,15 @@ const url_computer = (name: string) => {
return new_url;
};
//#endregion
//#region
const select_index = ref<null | number>(null);
//
const on_sort = (item: SortableEvent) => {
let index = item?.newIndex || 0;
//
set_show_tabs(index);
};
//#endregion
//#region
const diy_data = toRef(props.list);
@ -151,37 +171,41 @@ const diy_data = toRef(props.list);
// });
//
const copy = (index: number) => {
// , id
const new_data = {
...cloneDeep(get_diy_index_data(index)),
id: get_math(),
};
//
diy_data.value.splice(index, 0, new_data);
set_show_tabs(index + 1);
const copy = (index: null | number) => {
if (index) {
// , id
const new_data = {
...cloneDeep(get_diy_index_data(index)),
id: get_math(),
};
//
diy_data.value.splice(index, 0, new_data);
set_show_tabs(index + 1);
}
};
//
const del = (index: number) => {
app?.appContext.config.globalProperties.$common.message_box('删除后不可恢复,确定继续吗?', 'warning').then(() => {
ElMessage({
type: 'success',
message: '删除成功!',
});
//
diy_data.value.splice(index, 1);
if (diy_data.value.length > 0) {
let new_index: number = index;
// 0
if (index > 0) {
new_index = new_index - 1;
const del = (index: null | number) => {
if (index) {
app?.appContext.config.globalProperties.$common.message_box('删除后不可恢复,确定继续吗?', 'warning').then(() => {
ElMessage({
type: 'success',
message: '删除成功!',
});
//
diy_data.value.splice(index, 1);
if (diy_data.value.length > 0) {
let new_index: number = index;
// 0
if (index > 0) {
new_index = new_index - 1;
}
set_show_tabs(new_index);
} else {
emits('rightUpdate', {});
}
set_show_tabs(new_index);
} else {
emits('rightUpdate', {});
}
});
});
}
};
// indexdiy_data
const get_diy_index_data = (index: number) => {
@ -193,11 +217,31 @@ const set_show_tabs = (index: number) => {
// false,true
item.show_tabs = '0';
if (for_index == index) {
select_index.value = for_index;
item.show_tabs = '1';
scroll();
emits('rightUpdate', item);
}
});
};
//
const left_scrollTop = ref<HTMLElement | null>(null);
const left_activeCard = ref<HTMLElement | null>(null);
//
const scroll = () => {
nextTick(() => {
//
left_activeCard.value = document.querySelector('.drawer-custom-drag-bg');
if (left_activeCard.value) {
//
const left_scrollY = left_activeCard.value.offsetTop;
if (left_scrollTop.value) {
//
left_scrollTop.value.scrollTo({ top: left_scrollY - 200, behavior: 'smooth' });
}
}
});
};
//
const on_choose = (index: number, show_tabs: string) => {
// ,
@ -211,6 +255,7 @@ const cancel = () => {
diy_data.value.forEach((item) => {
item.show_tabs = '0';
});
select_index.value = null;
emits('rightUpdate', {});
};
//#endregion
@ -387,6 +432,7 @@ const end_drag = (event: MouseEvent) => {
diy_data.value.forEach((item: any) => {
item.show_tabs = '0';
});
select_index.value = null;
emits('rightUpdate', {});
}
rect_start.value = { x: 0, y: 0, width: 0, height: 0 };

View File

@ -265,13 +265,13 @@ const get_products = () => {
};
//
const watch_data = computed(() => {
const { category_ids, brand, number, order_by_type, order_by_rule, data_type, data_list } = form.value;
return { category_ids: category_ids, brand: brand, number: number, order_by_type: order_by_type, order_by_rule: order_by_rule, data_type: data_type, data_list: data_list };
const { category_ids, brand_ids, number, order_by_type, order_by_rule, data_type, data_list } = form.value;
return { category_ids: category_ids, brand_ids: brand_ids, number: number, order_by_type: order_by_type, order_by_rule: order_by_rule, data_type: data_type, data_list: data_list };
})
// ,
watch(() => watch_data.value, (val, oldVal) => {
// 使JSON.stringify()
if (JSON.stringify(val) !== JSON.stringify(oldVal)) {
if ((JSON.stringify(val) !== JSON.stringify(oldVal)) || props.isCommonStyle) {
if (val.data_type == '0') {
if (!isEmpty(val.data_list)) {
list.value = cloneDeep(val.data_list).map((item: any) => ({