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() { getApiScenario() {
this.loading = true; this.loading = true;
this.stepEnable = true; this.stepEnable = true;
if (this.currentScenario.tags != undefined && this.currentScenario.tags && !(this.currentScenario.tags instanceof Array)) { if (this.currentScenario.tags !== undefined && this.currentScenario.tags ) {
this.currentScenario.tags = JSON.parse(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) { if (!this.currentScenario.variables) {
this.currentScenario.variables = []; this.currentScenario.variables = [];
@ -1771,14 +1775,20 @@ export default {
} }
} }
res.data.userName = response.data.userName res.data.userName = response.data.userName
this.dealWithTag(res.data);
this.newData = res.data; this.newData = res.data;
this.dealWithTag(); this.closeExpansion()
this.dialogVisible = true; 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(this.currentScenario.tags){
if(Object.prototype.toString.call(this.currentScenario.tags)==="[object String]"){ if(Object.prototype.toString.call(this.currentScenario.tags)==="[object String]"){
this.currentScenario.tags = JSON.parse(this.currentScenario.tags); this.currentScenario.tags = JSON.parse(this.currentScenario.tags);

View File

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

View File

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

View File

@ -288,7 +288,7 @@ function diffDetail(oldVnode,newVnode,diffNode){
diffNode.nodeArray.push(newVnode.elm); diffNode.nodeArray.push(newVnode.elm);
} }
}else if(isDef(oldVnode.tag)&&isDef(newVnode.tag)){ }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){ if(oldVnode.elm.value!==newVnode.elm.value){
diffNode.oldNodeArray.push(oldVnode.elm); diffNode.oldNodeArray.push(oldVnode.elm);
diffNode.nodeArray.push(newVnode.elm); diffNode.nodeArray.push(newVnode.elm);