From 606ed22977e7586736ee24cc85c8ca4872ad93cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Mon, 14 Oct 2024 14:56:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=92=8C=E5=95=86=E5=93=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model-custom/components/index.scss | 93 +++++++++++++--- .../model-custom/components/index.ts | 1 + .../model-custom/components/index.vue | 102 ++++++++++++++---- .../model-custom/model-custom-content.vue | 2 +- src/config/const/goods-list.ts | 2 +- src/config/const/goods-tabs.ts | 2 +- 6 files changed, 167 insertions(+), 35 deletions(-) diff --git a/src/components/model-custom/components/index.scss b/src/components/model-custom/components/index.scss index 98646f3c..963ad115 100644 --- a/src/components/model-custom/components/index.scss +++ b/src/components/model-custom/components/index.scss @@ -53,8 +53,54 @@ .vdr-handle.vdr-handle-bl, .vdr-handle.vdr-handle-bm, .vdr-handle.vdr-handle-br { + width: 5px; + height: 5px; display: none !important; } + .vdr-handle-tl { + top: -3px; + left: -3px; + cursor: nw-resize; + } + .vdr-handle-tm { + top: -3px; + left: 50%; + margin-left: -3px; + cursor: n-resize; + } + .vdr-handle-tr { + top: -3px; + right: -3px; + cursor: ne-resize; + } + .vdr-handle-ml { + top: 50%; + margin-top: -3px; + left: -3px; + cursor: w-resize; + } + .vdr-handle-mr { + top: 50%; + margin-top: -3px; + right: -3px; + cursor: e-resize; + } + .vdr-handle-bl { + bottom: -3px; + left: -3px; + cursor: sw-resize; + } + .vdr-handle-bm { + bottom: -3px; + left: 50%; + margin-left: -3px; + cursor: s-resize; + } + .vdr-handle-br { + bottom: -3px; + right: -3px; + cursor: se-resize; + } } :deep(.plug-in-show-tabs.vdr-container) { .vdr-handle.vdr-handle-tl, @@ -85,14 +131,14 @@ .plug-in-border { cursor: pointer; position: relative; - box-shadow: 0px 0 0px 0.2rem $cr-main; + box-shadow: 0rem 0 0rem 0.1rem $cr-main; border: 0; } .plug-in-right { cursor: default; background: $cr-main; - position: absolute; - right: -5rem; + // position: absolute; + // right: -5rem; display: flex; flex-direction: column; gap: 2rem; @@ -147,10 +193,10 @@ } .drag-btn { position: absolute; - width: 7px; - height: 7px; + width: 0.7rem; + height: 0.7rem; background: #f0f0f0; - border: 1px solid #333; + border: 0.1rem solid #333; z-index: 1; } .drag-tl { @@ -237,10 +283,10 @@ position: absolute; background: rgba(41, 128, 185, 0.3); border: 1px dashed #34495e; - width: 0px; - height: 0px; - left: 0px; - top: 0px; + width: 0rem; + height: 0rem; + left: 0rem; + top: 0rem; z-index: 6; display: none; } @@ -249,6 +295,17 @@ cursor: pointer; color: $cr-main; } +.acticons { + position: absolute; + left: 50%; + margin-left: 23rem; + top: 50%; + display: flex; + flex-direction: column; + gap: 2rem; + z-index: 1; + transform: translate(-50%, -50%); +} .drawer-container { position: relative; @@ -262,18 +319,26 @@ overflow-y: auto; } .drawer-drag { + height: 4rem; cursor: move; } .drawer-drag:hover { background: #f2f8ff; - .iconfont.icon-close-b { - display: block !important; + .draggable-icon { + opacity: 1 !important; } } - .iconfont.icon-close-b { + .draggable-icon { + display: flex; + align-items: center; + gap: 1rem; right: 1rem; - top: 1.4rem; color: #8a8a8a; cursor: pointer; } +} + +.break{ + word-wrap: break-word; + word-break:break-all; } \ No newline at end of file diff --git a/src/components/model-custom/components/index.ts b/src/components/model-custom/components/index.ts index 4aa09660..b85b707b 100644 --- a/src/components/model-custom/components/index.ts +++ b/src/components/model-custom/components/index.ts @@ -14,6 +14,7 @@ interface diy_content extends diy{ com_width: number, com_height: number, name: string, + new_name: string, show_tabs: string, is_enable: string, src: string, diff --git a/src/components/model-custom/components/index.vue b/src/components/model-custom/components/index.vue index bd3a2bd5..34e6d865 100644 --- a/src/components/model-custom/components/index.vue +++ b/src/components/model-custom/components/index.vue @@ -24,12 +24,22 @@
已选组件清除选中
- +
@@ -44,9 +54,11 @@
-
- - +
+
+ + +
@@ -120,26 +132,31 @@ const components = reactive([ { key: 'text', name: '文本', + new_name: '', com_data: text_com_data }, { key: 'img', name: '图片', + new_name: '', com_data: img_com_data, }, { key: 'auxiliary-line', name: '线条', + new_name: '', com_data: line_com_data, }, { key: 'icon', name: '图标', + new_name: '', com_data: icon_com_data, }, { key: 'panel', name: '面板', + new_name: '', com_data: panel_com_data, }, ], @@ -169,10 +186,53 @@ const diy_data = toRef(props.list); // on_choose(0, false); // } // }); +onMounted(() => { + // 监听点击事件 + document.addEventListener('click', outerClick); +}); +onUnmounted(() => { + // 移除监听事件 + document.removeEventListener('click', outerClick); +}); +const edit_index = ref(-1); +const on_edit = (index: number) => { + if (edit_index.value === index) { + edit_close_processing(index); + edit_index.value = -1; + } else { + edit_index.value = index; + edit_processing(index); + } +}; +// 判断点击的是否是可以点击的区域,其他区域隐藏掉编辑属性 +const outerClick = (e: any) => { + if (!e.target.className.includes('do-not-trigger') && !e.target.parentNode.className.includes('do-not-trigger')) { + edit_close_processing(edit_index.value); + edit_index.value = -1; + } +}; +const double_click = (index: number) => { + edit_index.value = index; + edit_processing(index); +}; +// 编辑时的数据处理 +const edit_processing = (index: number) => { + const list = diy_data.value[index]; + if (!isEmpty(list) && isEmpty(list.new_name)) { + list.new_name = list.name; + } +}; +//编辑关闭前的处理 +const edit_close_processing = (index: number) => { + const list = diy_data.value[index]; + if (!isEmpty(list) && !isEmpty(list.new_name) && list.new_name === list.name) { + list.new_name = ''; + } +}; // 复制 const copy = (index: null | number) => { - if (index) { + if (typeof index === 'number' && !isNaN(index)) { // 获取当前数据, 复制的时候id更换一下 const new_data = { ...cloneDeep(get_diy_index_data(index)), @@ -186,23 +246,29 @@ const copy = (index: null | number) => { // 删除 const del = (index: null | number) => { - if (index) { + if (typeof index === 'number' && !isNaN(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; + const show_tabs_index = diy_data.value.findIndex((item: any) => item.show_tabs == '1'); + // 删除的是当前的这个数据 + if (show_tabs_index == index) { + // 调用删除接口,然后,更新数据 + 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', {}); + diy_data.value.splice(index, 1); } }); } diff --git a/src/components/model-custom/model-custom-content.vue b/src/components/model-custom/model-custom-content.vue index ccbb2b26..425ca0ed 100644 --- a/src/components/model-custom/model-custom-content.vue +++ b/src/components/model-custom/model-custom-content.vue @@ -105,7 +105,7 @@ onBeforeMount(() => { }); // 处理显示的图片和传递到下去的数据结构 const model_data_source = ref([]); -const is_show_more = ref(true); +const is_show_more = ref(false); const processing_data = (key: string) => { const list = options.value.filter((item) => item.type == key); if (list.length > 0) { diff --git a/src/config/const/goods-list.ts b/src/config/const/goods-list.ts index dad9054e..956b29c7 100644 --- a/src/config/const/goods-list.ts +++ b/src/config/const/goods-list.ts @@ -76,7 +76,7 @@ const defaultProductList: DefaultProductList = { is_shop_show: '1', shop_type: 'text', shop_button_text: '购买', - shop_button_icon_class: '', + shop_button_icon_class: 'cart', shop_button_effect: '0', shop_button_size: '1', }, diff --git a/src/config/const/goods-tabs.ts b/src/config/const/goods-tabs.ts index 41d188e6..ed07d676 100644 --- a/src/config/const/goods-tabs.ts +++ b/src/config/const/goods-tabs.ts @@ -93,7 +93,7 @@ const defaultProductList: DefaultProductList = { is_price_solo: '1', shop_type: 'text', shop_button_text: '购买', - shop_button_icon_class: '', + shop_button_icon_class: 'cart', shop_button_effect: '0', shop_button_size: '1', },