fix(版本对比): 版本对比算法加类型

--user=郭雨琦 版本对比算法加类型
This commit is contained in:
guoyuqi 2022-01-19 18:03:58 +08:00 committed by song-tianyang
parent 1c1f396b08
commit 9ace668e32
4 changed files with 37 additions and 23 deletions

View File

@ -1406,8 +1406,12 @@ export default {
getApiScenario() {
this.loading = true;
this.stepEnable = true;
if (this.currentScenario.tags != undefined && this.currentScenario.tags && !(this.currentScenario.tags instanceof Array)) {
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
if (this.currentScenario.tags !== undefined && this.currentScenario.tags ) {
if(!(this.currentScenario.tags instanceof Array)){
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
}
}else{
this.$set(this.currentScenario,'tags',[])
}
if (!this.currentScenario.variables) {
this.currentScenario.variables = [];
@ -1771,14 +1775,20 @@ export default {
}
}
res.data.userName = response.data.userName
this.dealWithTag(res.data);
this.newData = res.data;
this.dealWithTag();
this.closeExpansion()
this.dialogVisible = true;
}
});
})
},
dealWithTag(){
dealWithTag(newScenario){
if(newScenario.tags){
if(Object.prototype.toString.call(newScenario.tags)==="[object String]"){
newScenario.tags = JSON.parse(newScenario.tags);
}
}
if(this.currentScenario.tags){
if(Object.prototype.toString.call(this.currentScenario.tags)==="[object String]"){
this.currentScenario.tags = JSON.parse(this.currentScenario.tags);

View File

@ -69,7 +69,10 @@ export default {
watch: {
innerTags() {
this.currentScenario[this.prop] = this.innerTags;
}
},
'currentScenario.tags'() {
this.innerTags = this.currentScenario.tags
},
},
methods: {
foucusTagInput() {

View File

@ -138,7 +138,7 @@
</div>
<!-- 场景步骤内容 -->
<div ref="stepInfo">
<div ref="stepInfo" id="stepInfo">
<el-tooltip :content="$t('api_test.automation.open_expansion')" placement="top" effect="light">
<i class="el-icon-circle-plus-outline ms-open-btn ms-open-btn-left" @click="openExpansion('old')"/>
</el-tooltip>
@ -302,21 +302,21 @@
</div>
<!-- 场景步骤内容 -->
<div ref="stepInfo">
<div ref="newStepInfo">
<el-tooltip :content="$t('api_test.automation.open_expansion')" placement="top" effect="light">
<i class="el-icon-circle-plus-outline ms-open-btn ms-open-btn-left" @click="openExpansion('new')"/>
</el-tooltip>
<el-tooltip :content="$t('api_test.automation.close_expansion')" placement="top" effect="light">
<i class="el-icon-remove-outline ms-open-btn" size="mini" @click="closeExpansion('new')"/>
</el-tooltip>
<el-tree node-key="newResourceId" :props="props" :data="newScenarioDefinition" class="ms-tree"
<el-tree node-key="resourceId" :props="props" :data="newScenarioDefinition" class="ms-tree"
:expand-on-click-node="false"
:default-expanded-keys="newExpandedNode"
highlight-current
@node-expand="nodeExpand"
@node-collapse="nodeCollapse"
@node-expand="nodeExpand(newScenarioDefinition,null,'new')"
@node-collapse="nodeCollapse(newScenarioDefinition,null,'new')"
@node-click="nodeClick"
draggable ref="stepTree" >
draggable ref="newStepTree" >
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
<!-- 步骤组件-->
<ms-component-config
@ -341,10 +341,12 @@
<el-dialog
:fullscreen="true"
:visible.sync="dialogVisible"
:destroy-on-close="true"
append-to-body
width="100%"
>
<scenario-child-diff
v-if="dialogVisible"
:old-data="leftChildData"
:new-data="rightChildData"
:old-node="leftChildNode"
@ -524,32 +526,31 @@ export default{
nodes[i].active = false;
}
if (nodes[i].hashTree !== undefined && nodes[i].hashTree.length > 0) {
this.changeNodeStatus(nodes[i].hashTree);
this.changeNodeStatus(nodes[i].hashTree,source);
}
}
}
},
openExpansion(source) {
this.expandedNode = [];
this.newExpandedNode = [];
this.oldExpandedNode = [];
this.expandedStatus = true;
let scenarioDefinition;
if(source==="new"){
scenarioDefinition = this.newScenarioDefinition;
this.changeNodeStatus(this.newScenarioDefinition,source);
}else {
scenarioDefinition = this.oldScenarioDefinition;
this.changeNodeStatus(this.oldScenarioDefinition,source);
}
this.changeNodeStatus(scenarioDefinition,source);
},
closeExpansion(source) {
this.expandedStatus = false;
this.expandedNode = [];
let scenarioDefinition;
this.newExpandedNode = [];
this.oldExpandedNode = [];
if(source==="new"){
scenarioDefinition = this.newScenarioDefinition;
this.changeNodeStatus( this.newScenarioDefinition,source);
}else {
scenarioDefinition = this.oldScenarioDefinition;
this.changeNodeStatus( this.oldScenarioDefinition,source);
}
this.changeNodeStatus(scenarioDefinition,source);
this.showHide();
},
showHide() {

View File

@ -288,7 +288,7 @@ function diffDetail(oldVnode,newVnode,diffNode){
diffNode.nodeArray.push(newVnode.elm);
}
}else if(isDef(oldVnode.tag)&&isDef(newVnode.tag)){
if(oldVnode.tag==='input'&&newVnode.tag==='input'){
if((oldVnode.tag==='input'&&newVnode.tag==='input')||(oldVnode.tag==='textarea'&&newVnode.tag==='textarea')){
if(oldVnode.elm.value!==newVnode.elm.value){
diffNode.oldNodeArray.push(oldVnode.elm);
diffNode.nodeArray.push(newVnode.elm);