refactor: 接口自动化模块树重构

This commit is contained in:
chenjianxing 2020-12-15 18:17:23 +08:00
parent 43a7912fc9
commit 07d3ae45d0
21 changed files with 795 additions and 441 deletions

View File

@ -1,6 +1,7 @@
package io.metersphere.api.dto.automation; package io.metersphere.api.dto.automation;
import io.metersphere.base.domain.ApiScenarioModule; import io.metersphere.base.domain.ApiScenarioModule;
import io.metersphere.track.dto.TreeNodeDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -8,9 +9,5 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
public class ApiScenarioModuleDTO extends ApiScenarioModule { public class ApiScenarioModuleDTO extends TreeNodeDTO<ApiScenarioModuleDTO> {
private String label;
private List<ApiScenarioModuleDTO> children;
} }

View File

@ -104,7 +104,7 @@ public class ApiAutomationService {
checkNameExist(request); checkNameExist(request);
final ApiScenario scenario = new ApiScenario(); final ApiScenario scenario = new ApiScenario();
scenario.setId(request.getId()); scenario.setId(UUID.randomUUID().toString());
scenario.setName(request.getName()); scenario.setName(request.getName());
scenario.setProjectId(request.getProjectId()); scenario.setProjectId(request.getProjectId());
scenario.setTagId(request.getTagId()); scenario.setTagId(request.getTagId());

View File

@ -10,10 +10,12 @@ import io.metersphere.base.domain.ApiScenarioModule;
import io.metersphere.base.domain.ApiScenarioModuleExample; import io.metersphere.base.domain.ApiScenarioModuleExample;
import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ApiScenarioModuleMapper; import io.metersphere.base.mapper.ApiScenarioModuleMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper;
import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.service.NodeTreeService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
@ -27,65 +29,22 @@ import java.util.stream.Collectors;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public class ApiScenarioModuleService { public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleDTO> {
@Resource @Resource
ApiScenarioModuleMapper apiScenarioModuleMapper; ApiScenarioModuleMapper apiScenarioModuleMapper;
@Resource @Resource
ExtApiScenarioModuleMapper extApiScenarioModuleMapper;
@Resource
ApiAutomationService apiAutomationService; ApiAutomationService apiAutomationService;
@Resource @Resource
SqlSessionFactory sqlSessionFactory; SqlSessionFactory sqlSessionFactory;
public List<ApiScenarioModuleDTO> getNodeTreeByProjectId(String projectId) { public List<ApiScenarioModuleDTO> getNodeTreeByProjectId(String projectId) {
ApiScenarioModuleExample example = new ApiScenarioModuleExample(); List<ApiScenarioModuleDTO> nodes = extApiScenarioModuleMapper.getNodeTreeByProjectId(projectId);
example.createCriteria().andProjectIdEqualTo(projectId);
example.setOrderByClause("create_time asc");
List<ApiScenarioModule> nodes = apiScenarioModuleMapper.selectByExample(example);
return getNodeTrees(nodes); return getNodeTrees(nodes);
} }
public List<ApiScenarioModuleDTO> getNodeTrees(List<ApiScenarioModule> nodes) {
List<ApiScenarioModuleDTO> nodeTreeList = new ArrayList<>();
Map<Integer, List<ApiScenarioModule>> nodeLevelMap = new HashMap<>();
nodes.forEach(node -> {
Integer level = node.getLevel();
if (nodeLevelMap.containsKey(level)) {
nodeLevelMap.get(level).add(node);
} else {
List<ApiScenarioModule> apiScenarioModules = new ArrayList<>();
apiScenarioModules.add(node);
nodeLevelMap.put(node.getLevel(), apiScenarioModules);
}
});
List<ApiScenarioModule> rootNodes = Optional.ofNullable(nodeLevelMap.get(1)).orElse(new ArrayList<>());
rootNodes.forEach(rootNode -> nodeTreeList.add(buildNodeTree(nodeLevelMap, rootNode)));
return nodeTreeList;
}
/**
* 递归构建节点树
*/
private ApiScenarioModuleDTO buildNodeTree(Map<Integer, List<ApiScenarioModule>> nodeLevelMap, ApiScenarioModule rootNode) {
ApiScenarioModuleDTO nodeTree = new ApiScenarioModuleDTO();
BeanUtils.copyBean(nodeTree, rootNode);
nodeTree.setLabel(rootNode.getName());
List<ApiScenarioModule> lowerNodes = nodeLevelMap.get(rootNode.getLevel() + 1);
if (lowerNodes == null) {
return nodeTree;
}
List<ApiScenarioModuleDTO> children = Optional.ofNullable(nodeTree.getChildren()).orElse(new ArrayList<>());
lowerNodes.forEach(node -> {
if (node.getParentId() != null && node.getParentId().equals(rootNode.getId())) {
children.add(buildNodeTree(nodeLevelMap, node));
nodeTree.setChildren(children);
}
});
return nodeTree;
}
public String addNode(ApiScenarioModule node) { public String addNode(ApiScenarioModule node) {
validateNode(node); validateNode(node);
node.setCreateTime(System.currentTimeMillis()); node.setCreateTime(System.currentTimeMillis());
@ -227,5 +186,4 @@ public class ApiScenarioModuleService {
sqlSession.flushStatements(); sqlSession.flushStatements();
} }
} }

View File

@ -19,5 +19,7 @@ public class ApiScenarioModule implements Serializable {
private Long updateTime; private Long updateTime;
private Double pos;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -563,6 +563,66 @@ public class ApiScenarioModuleExample {
addCriterion("update_time not between", value1, value2, "updateTime"); addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andPosIsNull() {
addCriterion("pos is null");
return (Criteria) this;
}
public Criteria andPosIsNotNull() {
addCriterion("pos is not null");
return (Criteria) this;
}
public Criteria andPosEqualTo(Double value) {
addCriterion("pos =", value, "pos");
return (Criteria) this;
}
public Criteria andPosNotEqualTo(Double value) {
addCriterion("pos <>", value, "pos");
return (Criteria) this;
}
public Criteria andPosGreaterThan(Double value) {
addCriterion("pos >", value, "pos");
return (Criteria) this;
}
public Criteria andPosGreaterThanOrEqualTo(Double value) {
addCriterion("pos >=", value, "pos");
return (Criteria) this;
}
public Criteria andPosLessThan(Double value) {
addCriterion("pos <", value, "pos");
return (Criteria) this;
}
public Criteria andPosLessThanOrEqualTo(Double value) {
addCriterion("pos <=", value, "pos");
return (Criteria) this;
}
public Criteria andPosIn(List<Double> values) {
addCriterion("pos in", values, "pos");
return (Criteria) this;
}
public Criteria andPosNotIn(List<Double> values) {
addCriterion("pos not in", values, "pos");
return (Criteria) this;
}
public Criteria andPosBetween(Double value1, Double value2) {
addCriterion("pos between", value1, value2, "pos");
return (Criteria) this;
}
public Criteria andPosNotBetween(Double value1, Double value2) {
addCriterion("pos not between", value1, value2, "pos");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

View File

@ -9,6 +9,7 @@
<result column="level" jdbcType="INTEGER" property="level" /> <result column="level" jdbcType="INTEGER" property="level" />
<result column="create_time" jdbcType="BIGINT" property="createTime" /> <result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" /> <result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="pos" jdbcType="DOUBLE" property="pos" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -69,7 +70,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, project_id, `name`, parent_id, `level`, create_time, update_time id, project_id, `name`, parent_id, `level`, create_time, update_time, pos
</sql> </sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultMap="BaseResultMap">
select select
@ -104,10 +105,10 @@
<insert id="insert" parameterType="io.metersphere.base.domain.ApiScenarioModule"> <insert id="insert" parameterType="io.metersphere.base.domain.ApiScenarioModule">
insert into api_scenario_module (id, project_id, `name`, insert into api_scenario_module (id, project_id, `name`,
parent_id, `level`, create_time, parent_id, `level`, create_time,
update_time) update_time, pos)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{parentId,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{createTime,jdbcType=BIGINT}, #{parentId,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{createTime,jdbcType=BIGINT},
#{updateTime,jdbcType=BIGINT}) #{updateTime,jdbcType=BIGINT}, #{pos,jdbcType=DOUBLE})
</insert> </insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioModule"> <insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioModule">
insert into api_scenario_module insert into api_scenario_module
@ -133,6 +134,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time, update_time,
</if> </if>
<if test="pos != null">
pos,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -156,6 +160,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
#{updateTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
</if> </if>
<if test="pos != null">
#{pos,jdbcType=DOUBLE},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="io.metersphere.base.domain.ApiScenarioModuleExample" resultType="java.lang.Long">
@ -188,6 +195,9 @@
<if test="record.updateTime != null"> <if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT},
</if> </if>
<if test="record.pos != null">
pos = #{record.pos,jdbcType=DOUBLE},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -201,7 +211,8 @@
parent_id = #{record.parentId,jdbcType=VARCHAR}, parent_id = #{record.parentId,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER}, `level` = #{record.level,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=BIGINT}, create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT} update_time = #{record.updateTime,jdbcType=BIGINT},
pos = #{record.pos,jdbcType=DOUBLE}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -227,6 +238,9 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT},
</if> </if>
<if test="pos != null">
pos = #{pos,jdbcType=DOUBLE},
</if>
</set> </set>
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
@ -237,7 +251,8 @@
parent_id = #{parentId,jdbcType=VARCHAR}, parent_id = #{parentId,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER}, `level` = #{level,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=BIGINT}, create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT} update_time = #{updateTime,jdbcType=BIGINT},
pos = #{pos,jdbcType=DOUBLE}
where id = #{id,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR}
</update> </update>
</mapper> </mapper>

View File

@ -0,0 +1,10 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.api.dto.automation.ApiScenarioModuleDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtApiScenarioModuleMapper {
List<ApiScenarioModuleDTO> getNodeTreeByProjectId(@Param("projectId") String projectId);
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ext.ExtApiScenarioModuleMapper">
<select id="getNodeTreeByProjectId" resultType="io.metersphere.api.dto.automation.ApiScenarioModuleDTO">
select
<include refid="io.metersphere.base.mapper.ApiScenarioModuleMapper.Base_Column_List"/>
from api_scenario_module
where api_module.project_id = #{projectId}
order by create_time asc
</select>
</mapper>

@ -1 +1 @@
Subproject commit 1fe20ba15a7ca3fe9f77ddf866021e7c7dfe5969 Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6

View File

@ -32,6 +32,7 @@ CREATE TABLE `api_scenario_module` (
`name` varchar(64) NOT NULL COMMENT 'Node name', `name` varchar(64) NOT NULL COMMENT 'Node name',
`parent_id` varchar(50) DEFAULT NULL COMMENT 'Parent node ID', `parent_id` varchar(50) DEFAULT NULL COMMENT 'Parent node ID',
`level` int(10) DEFAULT '1' COMMENT 'Node level', `level` int(10) DEFAULT '1' COMMENT 'Node level',
`pos` double DEFAULT NULL COMMENT 'Node order',
`create_time` bigint(13) NOT NULL COMMENT 'Create timestamp', `create_time` bigint(13) NOT NULL COMMENT 'Create timestamp',
`update_time` bigint(13) NOT NULL COMMENT 'Update timestamp', `update_time` bigint(13) NOT NULL COMMENT 'Update timestamp',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)

View File

@ -64,7 +64,7 @@
<!--要生成的数据库表 --> <!--要生成的数据库表 -->
<table tableName="api_module"/> <table tableName="api_scenario_module"/>
<!--<table tableName="api_scenario_report"/>--> <!--<table tableName="api_scenario_report"/>-->
</context> </context>

View File

@ -1,14 +1,24 @@
<template> <template>
<ms-container> <ms-container>
<ms-aside-container> <ms-aside-container>
<ms-api-scenario-module @selectModule="selectModule" @getApiModuleTree="initTree" <!--<ms-api-scenario-module @selectModule="selectModule" @getApiModuleTree="initTree"-->
@refresh="refresh" @saveAsEdit="editScenario"/> <!--@refresh="refresh" @saveAsEdit="editScenario"/>-->
<ms-api-scenario-module
@nodeSelectEvent="nodeChange"
@refreshTable="refresh"
@saveAsEdit="editScenario"
@setModuleOptions="setModuleOptions"
@enableTrash="enableTrash"
:type="'edit'"
ref="nodeTree"/>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
<el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="removeTab"> <el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="removeTab">
<el-tab-pane name="default" :label="$t('api_test.automation.scenario_test')"> <el-tab-pane name="default" :label="$t('api_test.automation.scenario_test')">
<ms-api-scenario-list <ms-api-scenario-list
:current-module="currentModule" :select-node-ids="selectNodeIds"
:trash-enable="trashEnable"
@edit="editScenario" @edit="editScenario"
ref="apiScenarioList"/> ref="apiScenarioList"/>
</el-tab-pane> </el-tab-pane>
@ -55,6 +65,8 @@
currentModule: null, currentModule: null,
moduleOptions: {}, moduleOptions: {},
tabs: [], tabs: [],
trashEnable: false,
selectNodeIds: [],
} }
}, },
watch: {}, watch: {},
@ -97,15 +109,22 @@
this.setTabLabel(data); this.setTabLabel(data);
this.$refs.apiScenarioList.search(data); this.$refs.apiScenarioList.search(data);
}, },
initTree(data) {
this.moduleOptions = data;
},
refresh(data) { refresh(data) {
this.$refs.apiScenarioList.search(data); this.$refs.apiScenarioList.search(data);
}, },
editScenario(row) { editScenario(row) {
this.addTab({name: 'edit', currentScenario: row}); this.addTab({name: 'edit', currentScenario: row});
}, },
nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds;
},
setModuleOptions(data) {
this.moduleOptions = data;
},
enableTrash(data) {
this.trashEnable = data;
}
} }
} }
</script> </script>

View File

@ -0,0 +1,440 @@
<template>
<div>
<el-input style="width: 275px;" :placeholder="$t('test_track.module.search')" v-model="filterText"
size="small">
<template v-slot:append>
<el-button icon="el-icon-folder-add" @click="addScenario"/>
</template>
</el-input>
<el-tree :data="data"
class="filter-tree node-tree"
node-key="id"
:default-expanded-keys="expandedNode"
:expand-on-click-node="false"
@node-expand="nodeExpand"
@node-collapse="nodeCollapse"
@node-click="selectModule"
@node-drag-end="handleDragEnd"
:filter-node-method="filterNode"
draggable
:allow-drop="allowDrop"
:allow-drag="allowDrag" ref="tree">
<span class="custom-tree-node father"
slot-scope="{ node, data }">
<!-- 如果是编辑状态 -->
<template v-if="data.isEdit === 1">
<el-input ref="input"
@blur="() => submitEdit(node,data)"
v-model="newLabel"
class="ms-el-input" size="mini"></el-input>
</template>
<!-- 如果不是编辑状态 -->
<i class="el-icon-delete" v-if="data.isEdit!=1 && data.id==='gc'"/>
<i class="el-icon-folder" v-if="data.isEdit!=1 && data.id!='gc'"/>
<span class="node-title" v-if="data.isEdit!=1" v-text="data.name"></span>
<span class="node-operate child">
<el-tooltip
v-if="data.id!=='root' && data.id!=='gc'"
class="item"
effect="dark"
:open-delay="200"
:content="$t('test_track.module.rename')"
placement="top">
<i @click.stop="() => edit(node,data)" class="el-icon-edit"></i>
</el-tooltip>
<el-tooltip
v-if="data.id!=='gc'"
class="item"
effect="dark"
:open-delay="200"
:content="$t('test_track.module.add_submodule')"
placement="top">
<i @click.stop="() => append(node,data)" class="el-icon-circle-plus-outline"></i>
</el-tooltip>
<el-tooltip
v-if="data.id!=='root' && data.id!=='gc'"
class="item"
effect="dark"
:open-delay="200"
:content="$t('commons.delete')"
placement="top">
<i @click.stop="() => remove(node, data)" class="el-icon-delete"></i>
</el-tooltip>
</span>
</span>
</el-tree>
<ms-add-basis-scenario ref="basisScenario"/>
</div>
</template>
<script>
import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import {getCurrentProjectID} from "@/common/js/utils";
export default {
name: 'MsApiScenarioModule',
components: {
MsAddBasisScenario,
SelectMenu,
},
data() {
return {
httpVisible: false,
expandedNode: [],
filterText: "",
nextFlag: true,
currentModule: {},
newLabel: "",
data: [{
"id": "gc",
"name": "回收站",
"level": 1,
"children": [],
}, {
"id": "root",
"name": "默认模块",
"level": 0,
"children": [],
}]
}
},
mounted() {
this.changeProtocol();
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
methods: {
getApiModuleTree() {
this.nextFlag = true;
let projectId = getCurrentProjectID();
if (projectId) {
if (this.expandedNode.length === 0) {
this.expandedNode.push("root");
}
this.$get("/api/automation/module/list/" + projectId, response => {
if (response.data !== undefined && response.data !== null) {
this.data[1].children = response.data;
let moduleOptions = [];
this.data[1].children.forEach(node => {
this.buildNodePath(node, {path: ''}, moduleOptions);
});
this.$emit('getApiModuleTree', moduleOptions);
}
});
}
},
buildNodePath(node, option, moduleOptions) {
//
option.id = node.id;
option.path = option.path + '/' + node.name;
node.path = option.path;
moduleOptions.push(option);
if (node.children) {
for (let i = 0; i < node.children.length; i++) {
this.buildNodePath(node.children[i], {path: option.path}, moduleOptions);
}
}
},
findTreeByNodeId(rootNode, nodeId) {
if (rootNode.id === nodeId) {
return rootNode;
}
if (rootNode.children) {
for (let i = 0; i < rootNode.children.length; i++) {
if (this.findTreeByNodeId(rootNode.children[i], nodeId)) {
return rootNode;
}
}
}
},
buildParam(draggingNode, dropNode, dropType) {
let param = {};
param.id = draggingNode.data.id;
param.name = draggingNode.data.name;
param.projectId = draggingNode.data.projectId;
if (dropType === "inner") {
param.parentId = dropNode.data.id;
param.level = dropNode.data.level;
} else {
if (!dropNode.parent.id || dropNode.parent.id === 0) {
param.parentId = 0;
param.level = 1;
} else {
param.parentId = dropNode.parent.data.id;
param.level = dropNode.parent.data.level;
}
}
let nodeIds = [];
this.getChildNodeId(draggingNode.data, nodeIds);
if (dropNode.level === 1 && dropType !== "inner") {
param.nodeTree = draggingNode.data;
} else {
for (let i = 0; i < this.data.length; i++) {
param.nodeTree = this.findTreeByNodeId(this.data[i], dropNode.data.id);
if (param.nodeTree) {
break;
}
}
}
param.nodeIds = nodeIds;
return param;
},
getTreeNode(nodes, id, list) {
if (!nodes) {
return;
}
for (let i = 0; i < nodes.length; i++) {
if (nodes[i].id === id) {
i - 1 >= 0 ? list[0] = nodes[i - 1].id : list[0] = "";
list[1] = nodes[i].id;
i + 1 < nodes.length ? list[2] = nodes[i + 1].id : list[2] = "";
return;
}
if (nodes[i].children) {
this.getTreeNode(nodes[i].children, id, list);
}
}
},
handleDragEnd(draggingNode, dropNode, dropType) {
if (dropNode.data.id === "root" || dropType === "none" || dropType === undefined) {
return;
}
let param = this.buildParam(draggingNode, dropNode, dropType);
this.list = [];
if (param.parentId === "root") {
param.parentId = null;
}
this.getTreeNode(this.data, draggingNode.data.id, this.list);
this.$post("/api/automation/module/drag", param, () => {
this.getApiModuleTree();
}, () => {
this.getApiModuleTree();
});
},
allowDrop(draggingNode, dropNode) {
return dropNode.data.id !== "root";
},
allowDrag(draggingNode) {
//
return draggingNode.data.id !== "root";
},
append(node, data) {
if (this.nextFlag === true) {
const newChild = {
id: "newId",
isEdit: 0,
name: "",
children: []
}
if (!data.children) {
this.$set(data, 'children', [])
}
this.nextFlag = false;
data.children.push(newChild)
this.edit(node, newChild);
} else {
this.$message.warning(this.$t('commons.please_save'));
}
},
remove(node, data) {
if (data.name === "") {
this.nextFlag = true;
}
let delIds = [];
this.getChildNodeId(data, delIds);
delIds.push(data.id);
this.$post("/api/automation/module/delete", delIds, () => {
this.$success(this.$t('commons.save_success'));
//
const parent = node.parent
const children = parent.data.children || parent.data
const index = children.findIndex(d => d.id !== undefined && data.id !== undefined && d.id === data.id)
children.splice(index, 1);
this.getApiModuleTree();
});
},
edit(node, data) {
this.$set(data, 'isEdit', 1)
this.newLabel = data.name
this.$nextTick(() => {
})
},
submitEdit(node, data) {
//
if (this.newLabel === "") {
this.nextFlag = false;
this.$message.warning(this.$t('commons.input_name'));
return;
}
this.$set(data, 'name', this.newLabel)
let flag = this.editApiModule(node, data);
if (flag === false) {
this.$set(data, 'isEdit', 1)
return;
}
this.$set(data, 'isEdit', 0)
this.newLabel = ""
this.nextFlag = true;
},
cancelEdit(node, data) {
this.newLabel = ""
this.$set(data, 'isEdit', 0)
},
getChildNodeId(rootNode, nodeIds) {
//ID
nodeIds.push(rootNode.id);
this.nodePath += rootNode.name + "/";
if (rootNode.children) {
for (let i = 0; i < rootNode.children.length; i++) {
this.getChildNodeId(rootNode.children[i], nodeIds);
}
}
},
//
editApiModule(node, data) {
let projectId = getCurrentProjectID();
if (!projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
let url = "";
if (data.id === "newId") {
url = '/api/automation/module/add';
data.level = 1;
if (node.parent && node.parent.key !== "root") {
data.parentId = node.parent.key;
data.level = node.parent.level;
}
} else {
url = '/api/automation/module/edit';
let ids = [];
this.getChildNodeId(data, ids);
data.nodeIds = ids;
}
data.protocol = this.protocol;
data.projectId = projectId;
this.$post(url, data, () => {
this.$success(this.$t('commons.save_success'));
this.getApiModuleTree();
this.nextFlag = true;
return true;
});
return false;
},
selectModule(data) {
if (data.id !== "root") {
if (data.path !== undefined && !data.path.startsWith("/")) {
data.path = "/" + data.path;
}
if (data.path !== undefined && data.path.endsWith("/")) {
data.path = data.path.substr(0, data.path.length - 1);
}
let nodeIds = [];
this.getChildNodeId(data, nodeIds);
data.ids = nodeIds;
this.currentModule = data;
}
this.$emit('selectModule', data);
},
refresh(data) {
this.$emit('refresh', data);
},
saveAsEdit(data) {
this.$emit('saveAsEdit', data);
},
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
addScenario() {
this.$refs.basisScenario.open(this.currentModule);
},
nodeExpand(data) {
if (data.id) {
this.expandedNode.push(data.id);
}
},
nodeCollapse(data) {
if (data.id) {
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
}
},
changeProtocol() {
this.getApiModuleTree();
this.$emit('changeProtocol', this.protocol);
}
}
}
</script>
<style scoped>
.node-tree {
margin-top: 15px;
margin-bottom: 15px;
}
.ms-el-input {
height: 25px;
line-height: 25px;
}
.custom-tree-node {
flex: 1 1 auto;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
width: 100%;
}
.father .child {
display: none;
}
.father:hover .child {
display: block;
}
.node-title {
width: 0;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1 1 auto;
padding: 0 5px;
overflow: hidden;
}
.node-operate > i {
color: #409eff;
margin: 0 5px;
}
/deep/ .el-tree-node__content {
height: 33px;
}
.ms-api-buttion {
width: 30px;
}
</style>

View File

@ -49,7 +49,7 @@
show-overflow-tooltip/> show-overflow-tooltip/>
<el-table-column :label="$t('commons.operating')" width="200px" v-if="!referenced"> <el-table-column :label="$t('commons.operating')" width="200px" v-if="!referenced">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<div v-if="currentModule!=undefined && currentModule.id === 'gc'"> <div v-if="trashEnable">
<el-button type="text" @click="reductionApi(row)">恢复</el-button> <el-button type="text" @click="reductionApi(row)">恢复</el-button>
<el-button type="text" @click="remove(row)">{{ $t('api_test.automation.remove') }}</el-button> <el-button type="text" @click="remove(row)">{{ $t('api_test.automation.remove') }}</el-button>
</div> </div>
@ -95,10 +95,14 @@
name: "MsApiScenarioList", name: "MsApiScenarioList",
components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons, MsTestPlanList}, components: {MsTablePagination, MsTableMoreBtn, ShowMoreBtn, MsTableHeader, MsTag, MsApiReportDetail, MsScenarioExtendButtons, MsTestPlanList},
props: { props: {
currentModule: Object,
referenced: { referenced: {
type: Boolean, type: Boolean,
default: false, default: false,
},
selectNodeIds: Array,
trashEnable: {
type: Boolean,
default: false,
} }
}, },
data() { data() {
@ -133,24 +137,27 @@
this.search(); this.search();
}, },
watch: { watch: {
currentModule() { selectNodeIds() {
this.search(); this.search();
}, },
trashEnable() {
if (this.trashEnable) {
this.search();
}
},
}, },
methods: { methods: {
search() { search() {
this.loading = true; this.loading = true;
this.condition.filters = ["Prepare", "Underway", "Completed"]; this.condition.filters = ["Prepare", "Underway", "Completed"];
if (this.currentModule != null) {
if (this.currentModule.id === "root") { this.condition.moduleIds = this.selectNodeIds;
this.condition.moduleIds = [];
} else if (this.currentModule.id === "gc") { if (this.trashEnable) {
this.condition.moduleIds = []; this.condition.filters = ["Trash"];
this.condition.filters = ["Trash"]; this.condition.moduleIds = [];
} else {
this.condition.moduleIds = this.currentModule.ids;
}
} }
if (this.projectId != null) { if (this.projectId != null) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
@ -242,7 +249,7 @@
this.reportId = row.reportId; this.reportId = row.reportId;
}, },
remove(row) { remove(row) {
if (this.currentModule !== undefined && this.currentModule != null && this.currentModule.id === "gc") { if (this.trashEnable) {
this.$get('/api/automation/delete/' + row.id, () => { this.$get('/api/automation/delete/' + row.id, () => {
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.search(); this.search();

View File

@ -1,72 +1,28 @@
<template> <template>
<div> <div>
<el-input style="width: 275px;" :placeholder="$t('test_track.module.search')" v-model="filterText"
size="small">
<template v-slot:append>
<el-button icon="el-icon-folder-add" @click="addScenario"/>
</template>
</el-input>
<el-tree :data="data" <ms-node-tree
class="filter-tree node-tree" v-loading="result.loading"
node-key="id" :tree-nodes="data"
:default-expanded-keys="expandedNode" :type="'edit'"
:expand-on-click-node="false" @add="add"
@node-expand="nodeExpand" @edit="edit"
@node-collapse="nodeCollapse" @drag="drag"
@node-click="selectModule" @remove="remove"
@node-drag-end="handleDragEnd" @nodeSelectEvent="nodeChange"
:filter-node-method="filterNode" ref="nodeTree">
draggable
:allow-drop="allowDrop" <template v-slot:header>
:allow-drag="allowDrag" ref="tree"> <el-input style="width: 275px;" :placeholder="$t('test_track.module.search')" v-model="condition.filterText"
<span class="custom-tree-node father" size="small">
slot-scope="{ node, data }"> <template v-slot:append>
<!-- 如果是编辑状态 --> <el-button icon="el-icon-folder-add" @click="addScenario"/>
<template v-if="data.isEdit === 1">
<el-input ref="input"
@blur="() => submitEdit(node,data)"
v-model="newLabel"
class="ms-el-input" size="mini"></el-input>
</template> </template>
<!-- 如果不是编辑状态 --> </el-input>
<i class="el-icon-delete" v-if="data.isEdit!=1 && data.id==='gc'"/> <module-trash-button :condition="condition" :exe="enableTrash"/>
<i class="el-icon-folder" v-if="data.isEdit!=1 && data.id!='gc'"/> </template>
<span class="node-title" v-if="data.isEdit!=1" v-text="data.name"></span>
<span class="node-operate child"> </ms-node-tree>
<el-tooltip
v-if="data.id!=='root' && data.id!=='gc'"
class="item"
effect="dark"
:open-delay="200"
:content="$t('test_track.module.rename')"
placement="top">
<i @click.stop="() => edit(node,data)" class="el-icon-edit"></i>
</el-tooltip>
<el-tooltip
v-if="data.id!=='gc'"
class="item"
effect="dark"
:open-delay="200"
:content="$t('test_track.module.add_submodule')"
placement="top">
<i @click.stop="() => append(node,data)" class="el-icon-circle-plus-outline"></i>
</el-tooltip>
<el-tooltip
v-if="data.id!=='root' && data.id!=='gc'"
class="item"
effect="dark"
:open-delay="200"
:content="$t('commons.delete')"
placement="top">
<i @click.stop="() => remove(node, data)" class="el-icon-delete"></i>
</el-tooltip>
</span>
</span>
</el-tree>
<ms-add-basis-scenario ref="basisScenario"/> <ms-add-basis-scenario ref="basisScenario"/>
</div> </div>
@ -77,312 +33,165 @@
import SelectMenu from "../../../track/common/SelectMenu"; import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario"; import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../track/common/NodeTree";
import {buildNodePath} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
export default { export default {
name: 'MsApiScenarioModule', name: 'MsApiScenarioModule',
components: { components: {
ModuleTrashButton,
MsNodeTree,
MsAddBasisScenario, MsAddBasisScenario,
SelectMenu, SelectMenu,
}, },
data() { data() {
return { return {
httpVisible: false, // httpVisible: false,
expandedNode: [], // expandedNode: [],
filterText: "", // filterText: "",
nextFlag: true, // nextFlag: true,
// currentModule: {},
// newLabel: "",
// data: [{
// "id": "gc",
// "name": "",
// "level": 1,
// "children": [],
// }, {
// "id": "root",
// "name": "",
// "level": 0,
// "children": [],
// }]
result: {},
condition: {
filterText: "",
trashEnable: false
},
projectId: "",
data: [],
currentModule: {}, currentModule: {},
newLabel: "",
data: [{
"id": "gc",
"name": "回收站",
"level": 1,
"children": [],
}, {
"id": "root",
"name": "默认模块",
"level": 0,
"children": [],
}]
} }
}, },
mounted() { mounted() {
this.changeProtocol(); this.projectId = getCurrentProjectID();
this.list();
}, },
watch: { watch: {
filterText(val) { 'condition.filterText'(val) {
this.$refs.tree.filter(val); this.$refs.nodeTree.filter(val);
} },
}, },
methods: { methods: {
getApiModuleTree() {
this.nextFlag = true; list() {
let projectId = getCurrentProjectID(); if (this.projectId) {
if (projectId) { this.result = this.$get("/api/automation/module/list/" + this.projectId + "/", response => {
if (this.expandedNode.length === 0) { if (response.data != undefined && response.data != null) {
this.expandedNode.push("root"); this.data = response.data;
}
this.$get("/api/automation/module/list/" + projectId, response => {
if (response.data !== undefined && response.data !== null) {
this.data[1].children = response.data;
let moduleOptions = []; let moduleOptions = [];
this.data[1].children.forEach(node => { this.data.forEach(node => {
this.buildNodePath(node, {path: ''}, moduleOptions); buildNodePath(node, {path: ''}, moduleOptions);
}); });
this.$emit('getApiModuleTree', moduleOptions); this.$emit('setModuleOptions', moduleOptions);
} }
}); });
} }
}, },
buildNodePath(node, option, moduleOptions) { edit(param) {
// param.projectId = this.projectId;
option.id = node.id; param.protocol = this.condition.protocol;
option.path = option.path + '/' + node.name; this.$post("/api/automation/module/edit", param, () => {
node.path = option.path; this.$success(this.$t('commons.save_success'));
moduleOptions.push(option); this.list();
if (node.children) { this.refresh();
for (let i = 0; i < node.children.length; i++) { }, (error) => {
this.buildNodePath(node.children[i], {path: option.path}, moduleOptions); this.list();
} });
}
}, },
findTreeByNodeId(rootNode, nodeId) { add(param) {
if (rootNode.id === nodeId) { param.projectId = this.projectId;
return rootNode; param.protocol = this.condition.protocol;
} this.$post("/api/automation/module/add", param, () => {
if (rootNode.children) { this.$success(this.$t('commons.save_success'));
for (let i = 0; i < rootNode.children.length; i++) { this.list();
if (this.findTreeByNodeId(rootNode.children[i], nodeId)) { }, (error) => {
return rootNode; this.list();
} });
}
}
}, },
buildParam(draggingNode, dropNode, dropType) { remove(nodeIds) {
let param = {}; this.$post("/api/automation/module/delete", nodeIds, () => {
param.id = draggingNode.data.id; this.list();
param.name = draggingNode.data.name; this.refresh();
param.projectId = draggingNode.data.projectId; }, (error) => {
if (dropType === "inner") { this.list();
param.parentId = dropNode.data.id; });
param.level = dropNode.data.level;
} else {
if (!dropNode.parent.id || dropNode.parent.id === 0) {
param.parentId = 0;
param.level = 1;
} else {
param.parentId = dropNode.parent.data.id;
param.level = dropNode.parent.data.level;
}
}
let nodeIds = [];
this.getChildNodeId(draggingNode.data, nodeIds);
if (dropNode.level === 1 && dropType !== "inner") {
param.nodeTree = draggingNode.data;
} else {
for (let i = 0; i < this.data.length; i++) {
param.nodeTree = this.findTreeByNodeId(this.data[i], dropNode.data.id);
if (param.nodeTree) {
break;
}
}
}
param.nodeIds = nodeIds;
return param;
}, },
getTreeNode(nodes, id, list) { drag(param, list) {
if (!nodes) {
return;
}
for (let i = 0; i < nodes.length; i++) {
if (nodes[i].id === id) {
i - 1 >= 0 ? list[0] = nodes[i - 1].id : list[0] = "";
list[1] = nodes[i].id;
i + 1 < nodes.length ? list[2] = nodes[i + 1].id : list[2] = "";
return;
}
if (nodes[i].children) {
this.getTreeNode(nodes[i].children, id, list);
}
}
},
handleDragEnd(draggingNode, dropNode, dropType) {
if (dropNode.data.id === "root" || dropType === "none" || dropType === undefined) {
return;
}
let param = this.buildParam(draggingNode, dropNode, dropType);
this.list = [];
if (param.parentId === "root") {
param.parentId = null;
}
this.getTreeNode(this.data, draggingNode.data.id, this.list);
this.$post("/api/automation/module/drag", param, () => { this.$post("/api/automation/module/drag", param, () => {
this.getApiModuleTree(); // this.$post("/api/module/pos", list); //todo
}, () => { this.list();
this.getApiModuleTree(); }, (error) => {
this.list();
}); });
}, },
nodeChange(node, nodeIds, pNodes) {
allowDrop(draggingNode, dropNode) { this.currentModule = node.data;
return dropNode.data.id !== "root"; this.condition.trashEnable = false;
}, if (node.data.id === 'root') {
allowDrag(draggingNode) { this.$emit("nodeSelectEvent", node, [], pNodes);
//
return draggingNode.data.id !== "root";
},
append(node, data) {
if (this.nextFlag === true) {
const newChild = {
id: "newId",
isEdit: 0,
name: "",
children: []
}
if (!data.children) {
this.$set(data, 'children', [])
}
this.nextFlag = false;
data.children.push(newChild)
this.edit(node, newChild);
} else { } else {
this.$message.warning(this.$t('commons.please_save')); this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
} }
}, },
// exportAPI() {
remove(node, data) { // this.$emit('exportAPI');
if (data.name === "") { // },
this.nextFlag = true; // debug() {
} // this.$emit('debug');
let delIds = []; // },
this.getChildNodeId(data, delIds);
delIds.push(data.id);
this.$post("/api/automation/module/delete", delIds, () => {
this.$success(this.$t('commons.save_success'));
//
const parent = node.parent
const children = parent.data.children || parent.data
const index = children.findIndex(d => d.id !== undefined && data.id !== undefined && d.id === data.id)
children.splice(index, 1);
this.getApiModuleTree();
});
},
edit(node, data) {
this.$set(data, 'isEdit', 1)
this.newLabel = data.name
this.$nextTick(() => {
})
},
submitEdit(node, data) {
//
if (this.newLabel === "") {
this.nextFlag = false;
this.$message.warning(this.$t('commons.input_name'));
return;
}
this.$set(data, 'name', this.newLabel)
let flag = this.editApiModule(node, data);
if (flag === false) {
this.$set(data, 'isEdit', 1)
return;
}
this.$set(data, 'isEdit', 0)
this.newLabel = ""
this.nextFlag = true;
},
cancelEdit(node, data) {
this.newLabel = ""
this.$set(data, 'isEdit', 0)
},
getChildNodeId(rootNode, nodeIds) {
//ID
nodeIds.push(rootNode.id);
this.nodePath += rootNode.name + "/";
if (rootNode.children) {
for (let i = 0; i < rootNode.children.length; i++) {
this.getChildNodeId(rootNode.children[i], nodeIds);
}
}
},
//
editApiModule(node, data) {
let projectId = getCurrentProjectID();
if (!projectId) {
this.$error(this.$t('api_test.select_project'));
return;
}
let url = "";
if (data.id === "newId") {
url = '/api/automation/module/add';
data.level = 1;
if (node.parent && node.parent.key !== "root") {
data.parentId = node.parent.key;
data.level = node.parent.level;
}
} else {
url = '/api/automation/module/edit';
let ids = [];
this.getChildNodeId(data, ids);
data.nodeIds = ids;
}
data.protocol = this.protocol;
data.projectId = projectId;
this.$post(url, data, () => {
this.$success(this.$t('commons.save_success'));
this.getApiModuleTree();
this.nextFlag = true;
return true;
});
return false;
},
selectModule(data) {
if (data.id !== "root") {
if (data.path !== undefined && !data.path.startsWith("/")) {
data.path = "/" + data.path;
}
if (data.path !== undefined && data.path.endsWith("/")) {
data.path = data.path.substr(0, data.path.length - 1);
}
let nodeIds = [];
this.getChildNodeId(data, nodeIds);
data.ids = nodeIds;
this.currentModule = data;
}
this.$emit('selectModule', data);
},
refresh(data) {
this.$emit('refresh', data);
},
saveAsEdit(data) { saveAsEdit(data) {
this.$emit('saveAsEdit', data); this.$emit('saveAsEdit', data);
}, },
filterNode(value, data) { refresh() {
if (!value) return true; this.$emit("refreshTable");
return data.name.indexOf(value) !== -1;
}, },
addScenario() { addScenario() {
this.$refs.basisScenario.open(this.currentModule); this.$refs.basisScenario.open(this.currentModule);
}, },
nodeExpand(data) { enableTrash() {
if (data.id) { this.condition.trashEnable = true;
this.expandedNode.push(data.id); this.$emit('enableTrash', this.condition.trashEnable);
}
},
nodeCollapse(data) {
if (data.id) {
this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
}
},
changeProtocol() {
this.getApiModuleTree();
this.$emit('changeProtocol', this.protocol);
} }
// refresh(data) {
// this.$emit('refresh', data);
// },
// saveAsEdit(data) {
// this.$emit('saveAsEdit', data);
// },
// filterNode(value, data) {
// if (!value) return true;
// return data.name.indexOf(value) !== -1;
// },
// addScenario() {
// this.$refs.basisScenario.open(this.currentModule);
// },
// nodeExpand(data) {
// if (data.id) {
// this.expandedNode.push(data.id);
// }
// },
// nodeCollapse(data) {
// if (data.id) {
// this.expandedNode.splice(this.expandedNode.indexOf(data.id), 1);
// }
// },
// changeProtocol() {
// this.getApiModuleTree();
// this.$emit('changeProtocol', this.protocol);
// }
} }
} }
</script> </script>

View File

@ -720,6 +720,7 @@
this.currentScenario.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null; this.currentScenario.modulePath = this.currentModule.method !== undefined ? this.currentModule.method : null;
this.currentScenario.apiScenarioModuleId = this.currentModule.id; this.currentScenario.apiScenarioModuleId = this.currentModule.id;
} }
this.currentScenario.projectId = this.projectId;
}, },
runRefresh() { runRefresh() {
this.debugVisible = true; this.debugVisible = true;

View File

@ -188,12 +188,12 @@
initApiTable() { initApiTable() {
this.selectRows = new Set(); this.selectRows = new Set();
this.condition.filters = ["Prepare", "Underway", "Completed"]; this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) { if (this.trashEnable) {
this.condition.filters = ["Trash"]; this.condition.filters = ["Trash"];
this.condition.moduleIds = []; this.condition.moduleIds = [];
} }
this.condition.moduleIds = this.selectNodeIds;
if (this.projectId != null) { if (this.projectId != null) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }

View File

@ -55,14 +55,9 @@
filterText: "", filterText: "",
trashEnable: false trashEnable: false
}, },
httpVisible: false,
expandedNode: [],
nextFlag: true,
projectId: "", projectId: "",
data: [], data: [],
currentModule: {}, currentModule: {},
newLabel: ""
} }
}, },
mounted() { mounted() {
@ -135,7 +130,7 @@
}); });
}, },
nodeChange(node, nodeIds, pNodes) { nodeChange(node, nodeIds, pNodes) {
this.currentModule = node; this.currentModule = node.data;
this.condition.trashEnable = false; this.condition.trashEnable = false;
if (node.data.id === 'root') { if (node.data.id === 'root') {
this.$emit("nodeSelectEvent", node, [], pNodes); this.$emit("nodeSelectEvent", node, [], pNodes);

View File

@ -24,9 +24,7 @@
</template> </template>
</el-input> </el-input>
<div @click="enableTrash" class="recycle" :class="{'is-active': condition.trashEnable}"> <module-trash-button :condition="condition" :exe="enableTrash"/>
<i class="el-icon-delete"> 回收站</i>
</div>
<ms-add-basis-api <ms-add-basis-api
:current-protocol="condition.protocol" :current-protocol="condition.protocol"
@ -41,10 +39,11 @@
import {OPTIONS} from "../../model/JsonData"; import {OPTIONS} from "../../model/JsonData";
import MsAddBasisApi from "../basis/AddBasisApi"; import MsAddBasisApi from "../basis/AddBasisApi";
import ApiImport from "../import/ApiImport"; import ApiImport from "../import/ApiImport";
import ModuleTrashButton from "./ModuleTrashButton";
export default { export default {
name: "ApiModuleHeader", name: "ApiModuleHeader",
components: {ApiImport, MsAddBasisApi}, components: {ModuleTrashButton, ApiImport, MsAddBasisApi},
data() { data() {
return { return {
options: OPTIONS, options: OPTIONS,
@ -110,22 +109,4 @@
width: 175px; width: 175px;
padding-left: 3px; padding-left: 3px;
} }
.recycle {
padding-left: 25px;
margin-top: 15px;
height: 26px;
line-height: 26px;
margin-bottom: -10px;
}
.recycle:hover {
color: #6d317c;
cursor: pointer;
}
.is-active {
background-color: #f3f6f9;
}
</style> </style>

View File

@ -0,0 +1,48 @@
<template>
<div @click="exe" class="recycle" :class="{'is-active': condition.trashEnable}">
<i class="el-icon-delete"> 回收站</i>
</div>
</template>
<script>
export default {
name: "ModuleTrashButton",
props: {
condition: {
type: Object,
default() {
return {}
}
},
exe: {
type: Function
},
},
methods: {
// enableTrash() {
//
// }
}
}
</script>
<style scoped>
.recycle {
padding-left: 25px;
margin-top: 15px;
height: 26px;
line-height: 26px;
margin-bottom: -10px;
}
.recycle:hover {
color: #6d317c;
cursor: pointer;
}
.is-active {
background-color: #f3f6f9;
}
</style>

@ -1 +1 @@
Subproject commit 29a8fc09602fde5708af06582ac972d98eb69836 Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a