Commit 50112533 by pangchong

feat: 对比逻辑修改

parent f8b097f2
...@@ -20,6 +20,7 @@ declare module 'vue' { ...@@ -20,6 +20,7 @@ declare module 'vue' {
NLayoutHeader: typeof import('naive-ui')['NLayoutHeader'] NLayoutHeader: typeof import('naive-ui')['NLayoutHeader']
NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModalProvider: typeof import('naive-ui')['NModalProvider'] NModalProvider: typeof import('naive-ui')['NModalProvider']
NResult: typeof import('naive-ui')['NResult']
NSpace: typeof import('naive-ui')['NSpace'] NSpace: typeof import('naive-ui')['NSpace']
NTree: typeof import('naive-ui')['NTree'] NTree: typeof import('naive-ui')['NTree']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
<!--Arbortext, Inc., 1988-2013, v.4002--> <!--Arbortext, Inc., 1988-2013, v.4002-->
<!DOCTYPE JOBCARD PUBLIC "-//CEA-TEXT//DTD JOBCARD-VER1//EN" "JOBCARD.dtd" [ <!DOCTYPE JOBCARD PUBLIC "-//CEA-TEXT//DTD JOBCARD-VER1//EN" "JOBCARD.dtd" [
<!ENTITY nbsp "&#160;"> <!ENTITY nbsp "&#160;">
<!ENTITY rsquo "&#8217;"> <!ENTITY rsquo "&#8217;">
]> ]>
<JOBCARD> <JOBCARD>
<EOTK-HEADER></EOTK-HEADER> <EOTK-HEADER></EOTK-HEADER>
<CEP> <CEP>
<EFFECT EFFRG="001999"></EFFECT> <EFFECT EFFRG="001999"></EFFECT>
<TITLEC>发动机QEC拆卸(V2500-A5系列)</TITLEC> <TITLEC>发动机QEC拆卸(V2500-A5系列)</TITLEC>
<TITLE>Remove the Engine's QEC(V2500-A5 series)XXX</TITLE> <TITLE>Remove the Engine's QEC(V2500-A5 series) 测试修改</TITLE>
<TOPIC CK-LEVEL="C"> <TOPIC CK-LEVEL="C">
<TITLEC>飞机/发动机基本信息</TITLEC> <TITLEC>飞机/发动机基本信息</TITLEC>
<TITLE>AIRCRAFT/ENGINE INFORMATION</TITLE> <TITLE>AIRCRAFT/ENGINE INFORMATION</TITLE>
......
import { h, VNode } from 'snabbdom' import { h, VNode } from 'snabbdom'
import { IDomEditor, IModuleConf, SlateElement } from '@wangeditor/editor' import { IDomEditor, IModuleConf, SlateElement } from '@wangeditor/editor'
import { nodeSet } from '@/configs/node.config' import { nodeSet } from '@/configs/node.config'
import { handleMouseEnter, handleMouseLeave } from '@/views/editor/functions/compare' import { handleClickDom } from '@/views/editor/functions/compare'
const renderElem = (type: string, style = { display: 'block' }) => { const renderElem = (type: string, style = { display: 'block' }) => {
return (elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode => { return (elem: SlateElement, children: VNode[] | null, editor: IDomEditor): VNode => {
...@@ -16,12 +16,9 @@ const renderElem = (type: string, style = { display: 'block' }) => { ...@@ -16,12 +16,9 @@ const renderElem = (type: string, style = { display: 'block' }) => {
style, style,
attrs: { 'data-key': dataKey }, attrs: { 'data-key': dataKey },
on: { on: {
mouseenter(event: Event) { click(event: Event) {
handleMouseEnter(event) handleClickDom(event)
}, },
mouseleave() {
handleMouseLeave()
}
} }
}, },
children children
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
preset="card" preset="card"
:showFooter="false" :showFooter="false"
> >
<div class="flex h-full" ref="compareContainerRef"> <div class="flex h-full relative" ref="compareContainerRef">
<div class="choose-row bg-progressRailColor" ref="chooseRowRef"></div>
<GlobalEditor <GlobalEditor
ref="compareLeftRef" ref="compareLeftRef"
v-model="compareLeftData" v-model="compareLeftData"
...@@ -27,7 +28,22 @@ ...@@ -27,7 +28,22 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { showCompare, compareLeftRef, compareRightRef, compareLeftData, compareRightData, compareContainerRef } from '../constants/compare' import {
showCompare,
compareLeftRef,
compareRightRef,
compareLeftData,
compareRightData,
compareContainerRef,
chooseRowRef
} from '../constants/compare'
import { handleScrollTopLeft, handleScrollTopRight } from '../functions/compare' import { handleScrollTopLeft, handleScrollTopRight } from '../functions/compare'
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped>
.choose-row {
width: 100%;
position: absolute;
z-index: 99;
opacity: 0.6;
}
</style>
...@@ -4,3 +4,4 @@ export const compareRightRef = ref() ...@@ -4,3 +4,4 @@ export const compareRightRef = ref()
export const compareLeftData = ref('') export const compareLeftData = ref('')
export const compareRightData = ref('') export const compareRightData = ref('')
export const compareContainerRef = ref() export const compareContainerRef = ref()
export const chooseRowRef = ref()
import { NewTreeModification, OldTreeModification, TreeRenderResult } from '@/lib/XMLProcessor/src/typing' import { NewTreeModification, OldTreeModification, TreeRenderResult } from '@/lib/XMLProcessor/src/typing'
import { compareContainerRef, compareLeftRef, compareRightRef, showCompare } from '../constants/compare' import { chooseRowRef, compareContainerRef, compareLeftRef, compareRightRef, showCompare } from '../constants/compare'
import { debounce } from 'lodash' import { uniqBy } from 'lodash'
export const handleMouseEnter = debounce((event: any) => { export const handleClickDom = (event: any) => {
if (!showCompare.value) return if (!showCompare.value) return
const width = compareContainerRef.value?.clientWidth const element = event.target
const x = event.clientX const container = compareContainerRef.value
const y = event.clientY const elementRect = element.getBoundingClientRect()
const element1 = document.elementFromPoint(x, y) const containerRect = container.getBoundingClientRect()
const element2 = document.elementFromPoint(width - x, y) const distance = elementRect.top - containerRect.top
element1?.classList.add('bg-progressRailColor') chooseRowRef.value.style.top = distance + 'px'
element2?.classList.add('bg-progressRailColor') chooseRowRef.value.style.height = event.target.offsetHeight + 'px'
}, 250)
export const handleMouseLeave = () => {
if (!showCompare.value) return
const elements = document.querySelectorAll('.bg-progressRailColor')
elements.forEach((element) => {
element.classList.remove('bg-progressRailColor')
})
} }
export const handleScrollTopLeft = (event: Event) => { export const handleScrollTopLeft = (event: Event) => {
const scrollTop = (event.target as HTMLInputElement).scrollTop const scrollTop = (event.target as HTMLInputElement).scrollTop
compareRightRef.value?.handleScrollTop(scrollTop) compareRightRef.value?.handleScrollTop(scrollTop)
chooseRowRef.value.style.height = '0px'
} }
export const handleScrollTopRight = (event: Event) => { export const handleScrollTopRight = (event: Event) => {
const scrollTop = (event.target as HTMLInputElement).scrollTop const scrollTop = (event.target as HTMLInputElement).scrollTop
compareLeftRef.value?.handleScrollTop(scrollTop) compareLeftRef.value?.handleScrollTop(scrollTop)
chooseRowRef.value.style.height = '0px'
} }
export const handleLeftDifferent = (dataForOld: OldTreeModification, treeNew: TreeRenderResult[]) => { export const handleLeftDifferent = (dataForOld: OldTreeModification, treeNew: TreeRenderResult[]) => {
nextTick(() => { nextTick(() => {
const containerLeft = compareLeftRef.value?.editorRef.getEditableContainer() const containerLeft = compareLeftRef.value?.editorRef.getEditableContainer()
const containerRight = compareRightRef.value?.editorRef.getEditableContainer() const containerRight = compareRightRef.value?.editorRef.getEditableContainer()
//新增 //新增
dataForOld.Deleted.map((item) => { uniqBy(dataForOld.Deleted, 'key').map((item: any) => {
const node = containerLeft!.querySelector(`[data-key="${item.key}"]`) const node = containerLeft!.querySelector(`[data-key="${item.key}"]`)
if (node.childNodes.length == 1 && node.childNodes[0].nodeName == 'SPAN') {
//处理左边 //处理左边
node.classList.add('bg-errorColorSuppl') node.classList.add('bg-errorColorSuppl')
//处理右边 //处理右边
...@@ -47,7 +41,6 @@ export const handleLeftDifferent = (dataForOld: OldTreeModification, treeNew: Tr ...@@ -47,7 +41,6 @@ export const handleLeftDifferent = (dataForOld: OldTreeModification, treeNew: Tr
newDiv.style.height = `${node.offsetHeight}px` newDiv.style.height = `${node.offsetHeight}px`
newDiv.classList.add('bg-dividerColor') newDiv.classList.add('bg-dividerColor')
parentNode && parentNode.insertBefore(newDiv, parentNode.childNodes[index]) parentNode && parentNode.insertBefore(newDiv, parentNode.childNodes[index])
}
}) })
//修改 //修改
dataForOld.Changed.map((item) => { dataForOld.Changed.map((item) => {
...@@ -63,9 +56,8 @@ export const handleRightDifferent = (dataForNew: NewTreeModification, treeOld: T ...@@ -63,9 +56,8 @@ export const handleRightDifferent = (dataForNew: NewTreeModification, treeOld: T
const containerLeft = compareLeftRef.value?.editorRef.getEditableContainer() const containerLeft = compareLeftRef.value?.editorRef.getEditableContainer()
const containerRight = compareRightRef.value?.editorRef.getEditableContainer() const containerRight = compareRightRef.value?.editorRef.getEditableContainer()
//新增 //新增
dataForNew.Added.map((item: any) => { uniqBy(dataForNew.Added, 'key').map((item: any) => {
const node = containerRight!.querySelector(`[data-key="${item.key}"]`) const node = containerRight!.querySelector(`[data-key="${item.key}"]`)
if (node.childNodes.length == 1 && node.childNodes[0].nodeName == 'SPAN') {
//处理右边 //处理右边
node.classList.add('bg-errorColorSuppl') node.classList.add('bg-errorColorSuppl')
//处理左边 //处理左边
...@@ -78,7 +70,6 @@ export const handleRightDifferent = (dataForNew: NewTreeModification, treeOld: T ...@@ -78,7 +70,6 @@ export const handleRightDifferent = (dataForNew: NewTreeModification, treeOld: T
newDiv.style.height = `${node.offsetHeight}px` newDiv.style.height = `${node.offsetHeight}px`
newDiv.classList.add('bg-dividerColor') newDiv.classList.add('bg-dividerColor')
parentNode && parentNode.insertBefore(newDiv, parentNode.childNodes[index]) parentNode && parentNode.insertBefore(newDiv, parentNode.childNodes[index])
}
}) })
//修改 //修改
dataForNew.Changed.map((item: any) => { dataForNew.Changed.map((item: any) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment