diff --git a/src/assets/icons/iconfont.css b/src/assets/icons/iconfont.css index 268f5315..49f8d140 100644 --- a/src/assets/icons/iconfont.css +++ b/src/assets/icons/iconfont.css @@ -1,9 +1,9 @@ @font-face { font-family: "iconfont"; /* Project id 4227145 */ - src: url('iconfont.woff2?t=1728611284151') format('woff2'), - url('iconfont.woff?t=1728611284151') format('woff'), - url('iconfont.ttf?t=1728611284151') format('truetype'), - url('iconfont.svg?t=1728611284151#iconfont') format('svg'); + src: url('iconfont.woff2?t=1728898698610') format('woff2'), + url('iconfont.woff?t=1728898698610') format('woff'), + url('iconfont.ttf?t=1728898698610') format('truetype'), + url('iconfont.svg?t=1728898698610#iconfont') format('svg'); } .iconfont { @@ -14,6 +14,14 @@ -moz-osx-font-smoothing: grayscale; } +.icon-top-up:before { + content: "\e7a1"; +} + +.icon-bottom-up:before { + content: "\e7a0"; +} + .icon-domain:before { content: "\e7cf"; } @@ -182,11 +190,11 @@ content: "\e738"; } -.icon-arrow-left1:before { +.icon-arrow-left:before { content: "\e73f"; } -.icon-arrow-right1:before { +.icon-arrow-right:before { content: "\e737"; } @@ -574,10 +582,6 @@ content: "\e6d4"; } -.icon-arrow-left:before { - content: "\e6d1"; -} - .icon-scan:before { content: "\e6cf"; } @@ -650,10 +654,6 @@ content: "\e6c1"; } -.icon-arrow-right:before { - content: "\e6c2"; -} - .icon-zhibo-shixiao:before { content: "\e6bb"; } @@ -670,7 +670,7 @@ content: "\e6b8"; } -.icon-categroy-more:before { +.icon-category-more:before { content: "\e6b7"; } diff --git a/src/assets/icons/iconfont.js b/src/assets/icons/iconfont.js index 06093d34..d76924b0 100644 --- a/src/assets/icons/iconfont.js +++ b/src/assets/icons/iconfont.js @@ -1 +1 @@ -window._iconfont_svg_string_4227145='',(h=>{var a=(l=(l=document.getElementsByTagName("script"))[l.length-1]).getAttribute("data-injectcss"),l=l.getAttribute("data-disable-injectsvg");if(!l){var c,o,i,m,v,t=function(a,l){l.parentNode.insertBefore(a,l)};if(a&&!h.__iconfont__svg__cssinject__){h.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}c=function(){var a,l=document.createElement("div");l.innerHTML=h._iconfont_svg_string_4227145,(l=l.getElementsByTagName("svg")[0])&&(l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.width=0,l.style.height=0,l.style.overflow="hidden",l=l,(a=document.body).firstChild?t(l,a.firstChild):a.appendChild(l))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(c,0):(o=function(){document.removeEventListener("DOMContentLoaded",o,!1),c()},document.addEventListener("DOMContentLoaded",o,!1)):document.attachEvent&&(i=c,m=h.document,v=!1,d(),m.onreadystatechange=function(){"complete"==m.readyState&&(m.onreadystatechange=null,z())})}function z(){v||(v=!0,i())}function d(){try{m.documentElement.doScroll("left")}catch(a){return void setTimeout(d,50)}z()}})(window); \ No newline at end of file +window._iconfont_svg_string_4227145='',(h=>{var a=(l=(l=document.getElementsByTagName("script"))[l.length-1]).getAttribute("data-injectcss"),l=l.getAttribute("data-disable-injectsvg");if(!l){var c,o,i,m,v,t=function(a,l){l.parentNode.insertBefore(a,l)};if(a&&!h.__iconfont__svg__cssinject__){h.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}c=function(){var a,l=document.createElement("div");l.innerHTML=h._iconfont_svg_string_4227145,(l=l.getElementsByTagName("svg")[0])&&(l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.width=0,l.style.height=0,l.style.overflow="hidden",l=l,(a=document.body).firstChild?t(l,a.firstChild):a.appendChild(l))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(c,0):(o=function(){document.removeEventListener("DOMContentLoaded",o,!1),c()},document.addEventListener("DOMContentLoaded",o,!1)):document.attachEvent&&(i=c,m=h.document,v=!1,d(),m.onreadystatechange=function(){"complete"==m.readyState&&(m.onreadystatechange=null,z())})}function z(){v||(v=!0,i())}function d(){try{m.documentElement.doScroll("left")}catch(a){return void setTimeout(d,50)}z()}})(window); \ No newline at end of file diff --git a/src/assets/icons/iconfont.json b/src/assets/icons/iconfont.json index b1363dc9..11cfd41c 100644 --- a/src/assets/icons/iconfont.json +++ b/src/assets/icons/iconfont.json @@ -5,6 +5,20 @@ "css_prefix_text": "icon-", "description": "", "glyphs": [ + { + "icon_id": "42105733", + "name": "置顶", + "font_class": "top-up", + "unicode": "e7a1", + "unicode_decimal": 59297 + }, + { + "icon_id": "42097665", + "name": "置底", + "font_class": "bottom-up", + "unicode": "e7a0", + "unicode_decimal": 59296 + }, { "icon_id": "7561087", "name": "域名服务", @@ -21,7 +35,7 @@ }, { "icon_id": "38735708", - "name": "yinyong-shangchuan", + "name": "文件上传", "font_class": "upload-file", "unicode": "e72d", "unicode_decimal": 59181 @@ -302,14 +316,14 @@ { "icon_id": "40047124", "name": "进销存左箭头", - "font_class": "arrow-left1", + "font_class": "arrow-left", "unicode": "e73f", "unicode_decimal": 59199 }, { "icon_id": "40047129", "name": "进销存右箭头", - "font_class": "arrow-right1", + "font_class": "arrow-right", "unicode": "e737", "unicode_decimal": 59191 }, @@ -985,13 +999,6 @@ "unicode": "e6d4", "unicode_decimal": 59092 }, - { - "icon_id": "37356823", - "name": "箭头-向左", - "font_class": "arrow-left", - "unicode": "e6d1", - "unicode_decimal": 59089 - }, { "icon_id": "37354114", "name": "扫一扫", @@ -1118,13 +1125,6 @@ "unicode": "e6c1", "unicode_decimal": 59073 }, - { - "icon_id": "37288621", - "name": "箭头-向右", - "font_class": "arrow-right", - "unicode": "e6c2", - "unicode_decimal": 59074 - }, { "icon_id": "37272530", "name": "zhibo-shixiao", @@ -1156,7 +1156,7 @@ { "icon_id": "37217394", "name": "分类更多", - "font_class": "categroy-more", + "font_class": "category-more", "unicode": "e6b7", "unicode_decimal": 59063 }, diff --git a/src/assets/icons/iconfont.svg b/src/assets/icons/iconfont.svg index decb359b..60c0e3ee 100644 --- a/src/assets/icons/iconfont.svg +++ b/src/assets/icons/iconfont.svg @@ -14,11 +14,15 @@ /> + + + + - + @@ -98,9 +102,9 @@ - + - + @@ -294,8 +298,6 @@ - - @@ -332,8 +334,6 @@ - - @@ -342,7 +342,7 @@ - + diff --git a/src/assets/icons/iconfont.ttf b/src/assets/icons/iconfont.ttf index e235418a..25c07d2d 100644 Binary files a/src/assets/icons/iconfont.ttf and b/src/assets/icons/iconfont.ttf differ diff --git a/src/assets/icons/iconfont.woff b/src/assets/icons/iconfont.woff index d8456ed3..b3e3814b 100644 Binary files a/src/assets/icons/iconfont.woff and b/src/assets/icons/iconfont.woff differ diff --git a/src/assets/icons/iconfont.woff2 b/src/assets/icons/iconfont.woff2 index cb4193b8..ba9d6da1 100644 Binary files a/src/assets/icons/iconfont.woff2 and b/src/assets/icons/iconfont.woff2 differ diff --git a/src/components/base/icon/index.vue b/src/components/base/icon/index.vue index 1d1ed7a1..9fc94ccd 100644 --- a/src/components/base/icon/index.vue +++ b/src/components/base/icon/index.vue @@ -1,5 +1,5 @@ diff --git a/src/components/common/custom-module/model-icon/model-icon-style.vue b/src/components/common/custom-module/model-icon/model-icon-style.vue index 96fa842f..10fe19a8 100644 --- a/src/components/common/custom-module/model-icon/model-icon-style.vue +++ b/src/components/common/custom-module/model-icon/model-icon-style.vue @@ -39,9 +39,9 @@ - +
diff --git a/src/components/common/custom-module/model-image/model-image-style.vue b/src/components/common/custom-module/model-image/model-image-style.vue index 202917a1..21784fc6 100644 --- a/src/components/common/custom-module/model-image/model-image-style.vue +++ b/src/components/common/custom-module/model-image/model-image-style.vue @@ -26,9 +26,9 @@ - +
diff --git a/src/components/common/custom-module/model-lines/model-lines-style.vue b/src/components/common/custom-module/model-lines/model-lines-style.vue index bfa17240..6f70de76 100644 --- a/src/components/common/custom-module/model-lines/model-lines-style.vue +++ b/src/components/common/custom-module/model-lines/model-lines-style.vue @@ -31,9 +31,9 @@ - +
diff --git a/src/components/common/custom-module/model-panel/model-panel-style.vue b/src/components/common/custom-module/model-panel/model-panel-style.vue index e12942d8..359fc89b 100644 --- a/src/components/common/custom-module/model-panel/model-panel-style.vue +++ b/src/components/common/custom-module/model-panel/model-panel-style.vue @@ -20,9 +20,9 @@ - + diff --git a/src/components/common/custom-module/model-text/index.vue b/src/components/common/custom-module/model-text/index.vue index a17c8792..5c5f48e2 100644 --- a/src/components/common/custom-module/model-text/index.vue +++ b/src/components/common/custom-module/model-text/index.vue @@ -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`; diff --git a/src/components/common/custom-module/model-text/model-text-style.vue b/src/components/common/custom-module/model-text/model-text-style.vue index 5118642e..e8c379a2 100644 --- a/src/components/common/custom-module/model-text/model-text-style.vue +++ b/src/components/common/custom-module/model-text/model-text-style.vue @@ -59,9 +59,9 @@ - +
diff --git a/src/components/model-article-list/index.vue b/src/components/model-article-list/index.vue index 1e96014c..c0eed159 100644 --- a/src/components/model-article-list/index.vue +++ b/src/components/model-article-list/index.vue @@ -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 { diff --git a/src/components/model-custom/components/index-default.ts b/src/components/model-custom/components/index-default.ts index b78cc02e..483d60ed 100644 --- a/src/components/model-custom/components/index-default.ts +++ b/src/components/model-custom/components/index-default.ts @@ -36,7 +36,7 @@ export const text_com_data = { border_size: 1, direction: '90deg', color_list: [{ color: '', color_percentage: undefined }], - bottom_up: '0', + z_index: 0 } // 图片的默认值 export const img_com_data = { @@ -68,7 +68,7 @@ export const img_com_data = { radius_bottom_right: 0, }, border_size: 1, - bottom_up: '0', + z_index: 0 } // 线条的默认值 export const line_com_data = { @@ -80,7 +80,7 @@ export const line_com_data = { line_width: 306, line_size: 1, line_color: '#000', - bottom_up: '1', + z_index: 0, } // icon的默认值 @@ -120,7 +120,7 @@ export const icon_com_data = { border_size: 1, direction: '90deg', color_list: [{ color: '', color_percentage: undefined }], - bottom_up: '0', + z_index: 0 } // 面板的默认值 @@ -144,7 +144,7 @@ export const panel_com_data = { border_size: 1, direction: '90deg', color_list: [{ color: '#fff', color_percentage: undefined }], - bottom_up: '0', + z_index: 0 } // 判断两个矩形是否有交集或者被包裹 diff --git a/src/components/model-custom/components/index.scss b/src/components/model-custom/components/index.scss index 73b6ff02..f389730e 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,33 +131,9 @@ .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; - display: flex; - flex-direction: column; - gap: 2rem; - padding: 2rem 1.2rem; - color: #fff; - border-radius: 0.4rem; - z-index: 2; - & > i { - cursor: pointer; - } - & > i.disabled { - color: #5db2ff; - cursor: not-allowed; - } - & .icon-arrow-top, - & .icon-arrow-bottom { - height: 0.9rem; - } - } .area-box { position: absolute; background: rgba(42, 148, 255, 0.25); @@ -147,10 +169,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 +259,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; } @@ -248,4 +270,52 @@ .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 { + height: 4rem; + cursor: move; + } + .drawer-drag:hover { + background: #f2f8ff; + .draggable-icon { + opacity: 1 !important; + } + } + .draggable-icon { + display: flex; + align-items: center; + gap: 1rem; + right: 1rem; + color: #8a8a8a; + cursor: pointer; + } +} + +.break{ + word-wrap: break-word; + word-break:break-all; +} + +.plug-in-show-component-line::after { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + border: 0.1rem dashed #999; + border-radius: inherit; + pointer-events: none; /* 防止影子部分阻止鼠标事件 */ } \ 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 14f5ae51..d3913144 100644 --- a/src/components/model-custom/components/index.vue +++ b/src/components/model-custom/components/index.vue @@ -20,13 +20,38 @@ 组件高度 -
已选组件清除选中
-
-
-
{{ item.name }}
+
+
已选组件 +
+ {{ !is_show_component_line ? '显示' : '关闭' }}参考线 + 清除选中 +
-
- +
+ + + +
+ +
+
+
@@ -34,19 +59,16 @@
+
- + - -
- - -
-
+ +
@@ -89,6 +111,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 传递参数和传出数据的处理 @@ -109,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, }, ], @@ -139,6 +167,23 @@ const url_computer = (name: string) => { return new_url; }; //#endregion +//#region 组件边线相关 +const is_show_component_line = ref(false); +const show_computer_line = () => { + is_show_component_line.value = !is_show_component_line.value; + // set_show_tabs(0); + cancel(); +}; +//#endregion +//#region 左侧处理逻辑 +const select_index = ref(null); +// 任何行动都会触发 +const on_sort = (item: SortableEvent) => { + let index = item?.newIndex || 0; + // 设置对应的位置为显示 + set_show_tabs(index); +}; +//#endregion //#region 中间区域的处理逻辑 const diy_data = toRef(props.list); @@ -149,55 +194,188 @@ 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: 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 (typeof index === 'number' && !isNaN(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 (typeof index === 'number' && !isNaN(index)) { + app?.appContext.config.globalProperties.$common.message_box('删除后不可恢复,确定继续吗?', 'warning').then(() => { + ElMessage({ + type: 'success', + message: '删除成功!', + }); + 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', {}); + } + } else { + diy_data.value.splice(index, 1); } - set_show_tabs(new_index); - } else { - emits('rightUpdate', {}); - } - }); + }); + } }; +//前置一层 + 1 +const previous_layer = (index: number) => { + if (diy_data.value.length > 0) { + const old_z_index = cloneDeep(diy_data.value[index].com_data.z_index); + // 数据排序 + const list = cloneDeep(diy_data.value).sort((a, b) => a.com_data.z_index - b.com_data.z_index); + // 找到当前元素的索引 + const regular_index = list.findIndex(item => item.com_data.z_index == old_z_index); + if (regular_index + 1 <= diy_data.value.length - 1) { + // 取出上一个的值 + const new_z_index = list[regular_index + 1].com_data.z_index; + // 替换原始数组中的值 + const new_regular_index_1 = diy_data.value.findIndex(item => item.com_data.z_index == old_z_index); + const new_regular_index_2 = diy_data.value.findIndex(item => item.com_data.z_index == new_z_index); + // 数据互换 + diy_data.value[new_regular_index_1].com_data.z_index = new_z_index; + diy_data.value[new_regular_index_2].com_data.z_index = old_z_index; + } + } +} + +//后置一层 - 1 +const underlying_layer = (index: number) => { + if (diy_data.value.length > 0) { + const old_z_index = cloneDeep(diy_data.value[index].com_data.z_index); + // 数据排序 + const list = cloneDeep(diy_data.value).sort((a, b) => a.com_data.z_index - b.com_data.z_index); + // 找到当前元素的索引 + const regular_index = list.findIndex(item => item.com_data.z_index == old_z_index); + if (regular_index - 1 >= 0) { + // 取出上一个的值 + const new_z_index = list[regular_index - 1].com_data.z_index; + // 替换原始数组中的值 + const new_regular_index_1 = diy_data.value.findIndex(item => item.com_data.z_index == old_z_index); + const new_regular_index_2 = diy_data.value.findIndex(item => item.com_data.z_index == new_z_index); + // 数据互换 + diy_data.value[new_regular_index_1].com_data.z_index = new_z_index; + diy_data.value[new_regular_index_2].com_data.z_index = old_z_index; + } + } +} +//组件置顶 +const top_up = (index: number) => { + if (!isEmpty(diy_data.value[index])) { + const new_z_index = top_z_index.value + 1; + diy_data.value[index].com_data.z_index = new_z_index; + top_z_index.value = new_z_index; + } +} + +//组件置底 +const bottom_up = (index: number) => { + if (!isEmpty(diy_data.value[index])) { + const new_z_index = z_index.value - 1; + diy_data.value[index].com_data.z_index = new_z_index; + z_index.value = new_z_index; + } +} + // 获取当前传递过来的index对应的diy_data中的数据 const get_diy_index_data = (index: number) => { return (diy_data.value)[index.toString()]; }; // 设置当前选中的是那个 const set_show_tabs = (index: number) => { + is_show_component_line.value = false; diy_data.value.forEach((item, for_index) => { // 先将全部的设置为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(null); +const left_activeCard = ref(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 +389,7 @@ const cancel = () => { diy_data.value.forEach((item) => { item.show_tabs = '0'; }); + select_index.value = null; emits('rightUpdate', {}); }; //#endregion @@ -219,14 +398,17 @@ const center_height = defineModel('height', { type: Number, default: 0 }); const drag_area_height = computed(() => center_height.value + 'px'); const draggable_container = ref(true); let data = reactive([]); - +// 最低的层级 +const z_index = ref(0); +// 最高的层级 +const top_z_index = ref(0); watch(() => center_height.value, () => { data = diy_data.value; // 从 DOM 中删除组件 draggable_container.value = false; nextTick(() => { // 在 DOM 中添加组件 - diy_data.value = data.map((item) => ({ + diy_data.value = data.map((item, index) => ({ ...item, show_tabs: '0', location: { @@ -238,9 +420,27 @@ watch(() => center_height.value, () => { }, com_data: { ...item.com_data, + z_index: typeof item.com_data.z_index === 'number' && !isNaN(item.com_data.z_index) ? item.com_data.z_index : 0, com_height: item.com_data.staging_height, }, })); + if (diy_data.value.length > 0) { + const list = diy_data.value.sort((a, b) => a.com_data.z_index - b.com_data.z_index); + // 将z-index重置为初始效果 + let list_z_index = -1; + // 设置默认值 + list.forEach((item) => { + if (item.com_data.z_index == 0) { + const new_z_index = list_z_index + 1; + item.com_data.z_index = new_z_index; + list_z_index = new_z_index; + } + }); + // 获取更新后的数据 + const new_list = list.sort((a, b) => a.com_data.z_index - b.com_data.z_index); + z_index.value = new_list[0].com_data.z_index || 0; + top_z_index.value = new_list[new_list.length - 1].com_data.z_index || 0; + } // 容器高度变化时,组件不绑定右侧数据 emits('rightUpdate', {}); draggable_container.value = true; @@ -250,6 +450,7 @@ watch(() => center_height.value, () => { //#region 左侧拖拽过来的处理 let draggedItem = ref({}); const dragStart = (item: any, event: any) => { + const new_z_index = top_z_index.value + 1; // 初始化拖拽的数据 draggedItem.value = { name: item.name, @@ -260,8 +461,12 @@ const dragStart = (item: any, event: any) => { id: get_math(), key: item.key, is_hot: '0', - com_data: cloneDeep(item.com_data), + com_data: { + ...cloneDeep(item.com_data), + z_index: new_z_index, + }, }; + top_z_index.value = new_z_index; // 拖拽的时候清空热区 hot_list.data = []; }; @@ -387,6 +592,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 }; diff --git a/src/components/model-custom/components/right-side-operation/index.vue b/src/components/model-custom/components/right-side-operation/index.vue new file mode 100644 index 00000000..03bbd88f --- /dev/null +++ b/src/components/model-custom/components/right-side-operation/index.vue @@ -0,0 +1,88 @@ + + + + \ No newline at end of file diff --git a/src/components/model-custom/index.vue b/src/components/model-custom/index.vue index edf1b2bf..5bc1952d 100644 --- a/src/components/model-custom/index.vue +++ b/src/components/model-custom/index.vue @@ -2,7 +2,7 @@
-
+
diff --git a/src/components/model-custom/model-custom-content.vue b/src/components/model-custom/model-custom-content.vue index ccbb2b26..b563f5c7 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) { @@ -159,6 +159,19 @@ const accomplish = () => { if (!draglist.value) { return; } else { + // 规整数据逻辑 + const list = draglist.value.diy_data.sort((a, b) => a.com_data.z_index - b.com_data.z_index); + // 将z-index重置为初始效果 + let z_index = 0; + if (list.length > 0) { + list.forEach((item) => { + if (item.com_data.z_index < 0) { + const new_z_index = z_index - 1; + item.com_data.z_index = new_z_index; + z_index = new_z_index; + } + }); + } form.custom_list = draglist.value.diy_data; } form.height = center_height.value; diff --git a/src/components/model-goods-list/index.vue b/src/components/model-goods-list/index.vue index 3b5ac937..b17f78c1 100644 --- a/src/components/model-goods-list/index.vue +++ b/src/components/model-goods-list/index.vue @@ -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) => ({ 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 9add5985..1677bc35 100644 --- a/src/config/const/goods-tabs.ts +++ b/src/config/const/goods-tabs.ts @@ -94,7 +94,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', },