refactor: 统一显示标签

This commit is contained in:
Captain.B 2021-01-08 13:35:43 +08:00
parent 73f09844bb
commit 67c71ff01a
26 changed files with 406 additions and 575 deletions

View File

@ -6,6 +6,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
import java.util.Map;
@Getter @Getter
@Setter @Setter
@ -24,7 +25,7 @@ public class ApiBatchRequest extends ApiDefinitionWithBLOBs {
*/ */
private boolean isSelectAllDate; private boolean isSelectAllDate;
private List<String> filters; private Map<String, List<String>> filters;
private String name; private String name;

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 接口定义模块-批量处理请求类 * 接口定义模块-批量处理请求类
@ -24,7 +25,7 @@ public class ApiDefinitionBatchProcessingRequest {
*/ */
private boolean isSelectAllDate; private boolean isSelectAllDate;
private List<String> filters; private Map<String, List<String>> filters;
private String name; private String name;

View File

@ -23,7 +23,7 @@ public class ApiDefinitionRequest {
private String planId; private String planId;
private boolean recent = false; private boolean recent = false;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private List<String> filters; private Map<String, List<String>> filters;
private Map<String, Object> combine; private Map<String, Object> combine;
private List<String> ids; private List<String> ids;
private boolean isSelectThisWeedData = false; private boolean isSelectThisWeedData = false;

View File

@ -6,7 +6,6 @@ import io.metersphere.base.domain.Schedule;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Setter @Setter
@ -49,5 +48,5 @@ public class SaveApiDefinitionRequest {
private List<String> bodyUploadIds; private List<String> bodyUploadIds;
private List<String> tags = new ArrayList<>(); private String tags;
} }

View File

@ -4,7 +4,6 @@ import io.metersphere.api.dto.definition.request.MsTestElement;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Setter @Setter
@ -37,5 +36,5 @@ public class SaveApiTestCaseRequest {
private List<String> bodyUploadIds; private List<String> bodyUploadIds;
private List<String> tags = new ArrayList<>(); private String tags;
} }

View File

@ -29,7 +29,6 @@ import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.APITestStatus;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.ReportTriggerMode;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*; import io.metersphere.commons.utils.*;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
@ -235,7 +234,7 @@ public class ApiDefinitionService {
test.setResponse(JSONObject.toJSONString(request.getResponse())); test.setResponse(JSONObject.toJSONString(request.getResponse()));
test.setEnvironmentId(request.getEnvironmentId()); test.setEnvironmentId(request.getEnvironmentId());
test.setUserId(request.getUserId()); test.setUserId(request.getUserId());
test.setTags(JSON.toJSONString(new HashSet<>(request.getTags()))); test.setTags(request.getTags());
apiDefinitionMapper.updateByPrimaryKeySelective(test); apiDefinitionMapper.updateByPrimaryKeySelective(test);
return test; return test;
@ -266,7 +265,7 @@ public class ApiDefinitionService {
test.setUserId(request.getUserId()); test.setUserId(request.getUserId());
} }
test.setDescription(request.getDescription()); test.setDescription(request.getDescription());
test.setTags(JSON.toJSONString(new HashSet<>(request.getTags()))); test.setTags(request.getTags());
apiDefinitionMapper.insert(test); apiDefinitionMapper.insert(test);
return test; return test;
} }
@ -342,10 +341,11 @@ public class ApiDefinitionService {
/** /**
* 内部构建HashTree 定时任务发起的执行 * 内部构建HashTree 定时任务发起的执行
*
* @param request * @param request
* @return * @return
*/ */
public String run(RunDefinitionRequest request,ApiTestCaseWithBLOBs item) { public String run(RunDefinitionRequest request, ApiTestCaseWithBLOBs item) {
MsTestPlan testPlan = new MsTestPlan(); MsTestPlan testPlan = new MsTestPlan();
testPlan.setHashTree(new LinkedList<>()); testPlan.setHashTree(new LinkedList<>());
HashTree jmeterHashTree = new ListedHashTree(); HashTree jmeterHashTree = new ListedHashTree();
@ -362,12 +362,14 @@ public class ApiDefinitionService {
// 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取 // 多态JSON普通转换会丢失内容需要通过 ObjectMapper 获取
if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) { if (element != null && StringUtils.isNotEmpty(element.getString("hashTree"))) {
LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"), LinkedList<MsTestElement> elements = mapper.readValue(element.getString("hashTree"),
new TypeReference<LinkedList<MsTestElement>>() {}); new TypeReference<LinkedList<MsTestElement>>() {
});
scenario.setHashTree(elements); scenario.setHashTree(elements);
} }
if (StringUtils.isNotEmpty(element.getString("variables"))) { if (StringUtils.isNotEmpty(element.getString("variables"))) {
LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"), LinkedList<KeyValue> variables = mapper.readValue(element.getString("variables"),
new TypeReference<LinkedList<KeyValue>>() {}); new TypeReference<LinkedList<KeyValue>>() {
});
scenario.setVariables(variables); scenario.setVariables(variables);
} }
group.setEnableCookieShare(scenario.isEnableCookieShare()); group.setEnableCookieShare(scenario.isEnableCookieShare());
@ -572,9 +574,9 @@ public class ApiDefinitionService {
apiDefinitionMapper.deleteByExample(example); apiDefinitionMapper.deleteByExample(example);
} }
private List<String> getAllApiIdsByFontedSelect(List<String> filter, String name, List<String> moduleIds, String projectId, List<String> unSelectIds) { private List<String> getAllApiIdsByFontedSelect(Map<String, List<String>> filters, String name, List<String> moduleIds, String projectId, List<String> unSelectIds) {
ApiDefinitionRequest request = new ApiDefinitionRequest(); ApiDefinitionRequest request = new ApiDefinitionRequest();
request.setFilters(filter); request.setFilters(filters);
request.setName(name); request.setName(name);
request.setModuleIds(moduleIds); request.setModuleIds(moduleIds);
request.setProjectId(projectId); request.setProjectId(projectId);

View File

@ -222,7 +222,7 @@ public class ApiTestCaseService {
test.setPriority(request.getPriority()); test.setPriority(request.getPriority());
test.setUpdateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis());
test.setDescription(request.getDescription()); test.setDescription(request.getDescription());
test.setTags(JSON.toJSONString(new HashSet<>(request.getTags()))); test.setTags(request.getTags());
apiTestCaseMapper.updateByPrimaryKeySelective(test); apiTestCaseMapper.updateByPrimaryKeySelective(test);
return test; return test;
} }
@ -244,7 +244,7 @@ public class ApiTestCaseService {
test.setUpdateTime(System.currentTimeMillis()); test.setUpdateTime(System.currentTimeMillis());
test.setDescription(request.getDescription()); test.setDescription(request.getDescription());
test.setNum(getNextNum(request.getApiDefinitionId())); test.setNum(getNextNum(request.getApiDefinitionId()));
test.setTags(JSON.toJSONString(new HashSet<>(request.getTags()))); test.setTags(request.getTags());
apiTestCaseMapper.insert(test); apiTestCaseMapper.insert(test);
return test; return test;
} }

View File

@ -243,9 +243,17 @@
</foreach> </foreach>
</if> </if>
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
and api_definition.status in <foreach collection="request.filters.entrySet()" index="key" item="values">
<foreach collection="request.filters" item="value" separator="," open="(" close=")"> <if test="values != null and values.size() > 0">
#{value} <choose>
<when test="key=='status'">
and api_definition.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach> </foreach>
</if> </if>
<if test="request.apiCaseCoverage == 'uncoverage' "> <if test="request.apiCaseCoverage == 'uncoverage' ">

View File

@ -16,5 +16,4 @@ public class EditTestCaseRequest extends TestCaseWithBLOBs {
* 复制测试用例后要进行复制的文件Id list * 复制测试用例后要进行复制的文件Id list
*/ */
private List<String> fileIds = new ArrayList<>(); private List<String> fileIds = new ArrayList<>();
private List<String> caseTags = new ArrayList<>();
} }

View File

@ -585,7 +585,6 @@ public class TestCaseService {
throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
} }
request.setTags(JSON.toJSONString(new HashSet<>(request.getCaseTags())));
final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request); final TestCaseWithBLOBs testCaseWithBLOBs = addTestCase(request);
// 复制用例时传入文件ID进行复制 // 复制用例时传入文件ID进行复制
@ -642,7 +641,6 @@ public class TestCaseService {
}); });
} }
request.setTags(JSON.toJSONString(new HashSet<>(request.getCaseTags())));
editTestCase(request); editTestCase(request);
return request.getId(); return request.getId();
} }

View File

@ -24,26 +24,7 @@
<label class="ms-api-label" style="padding-left: 20px; padding-right: 20px;">{{ $t('commons.tag') }}</label> <label class="ms-api-label" style="padding-left: 20px; padding-right: 20px;">{{ $t('commons.tag') }}</label>
<el-tag <ms-input-tag :currentScenario="apiCase" ref="tag" style="float: right;margin-right: 215px;margin-top: -3px;"/>
:key="apiCase.id + '_' + index"
v-for="(tag, index) in apiCase.tags"
closable
size="mini"
:disable-transitions="false"
@close="handleClose(tag)">
{{ tag }}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="mini"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" size="mini" @click="showTagInput">+</el-button>
<div v-if="apiCase.id" style="color: #999999;font-size: 12px"> <div v-if="apiCase.id" style="color: #999999;font-size: 12px">
<span> <span>
@ -57,15 +38,15 @@
</div> </div>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<ms-tip-button @click="singleRun(apiCase)" :tip="$t('api_test.run')" icon="el-icon-video-play" <ms-tip-button @click="singleRun(apiCase)" :tip="$t('api_test.run')" icon="el-icon-video-play"
style="background-color: #409EFF;color: white" size="mini" :disabled="!apiCase.id" circle v-tester/> style="background-color: #409EFF;color: white" size="mini" :disabled="!apiCase.id" circle v-tester/>
<ms-tip-button @click="copyCase(apiCase)" :tip="$t('commons.copy')" icon="el-icon-document-copy" <ms-tip-button @click="copyCase(apiCase)" :tip="$t('commons.copy')" icon="el-icon-document-copy"
size="mini" :disabled="!apiCase.id || isCaseEdit" circle v-tester/> size="mini" :disabled="!apiCase.id || isCaseEdit" circle v-tester/>
<ms-tip-button @click="deleteCase(index,apiCase)" :tip="$t('commons.delete')" icon="el-icon-delete" <ms-tip-button @click="deleteCase(index,apiCase)" :tip="$t('commons.delete')" icon="el-icon-delete"
size="mini" :disabled="!apiCase.id || isCaseEdit" circle v-tester/> size="mini" :disabled="!apiCase.id || isCaseEdit" circle v-tester/>
<ms-api-extend-btns :is-case-edit="isCaseEdit" :environment="environment" :row="apiCase" v-tester/> <ms-api-extend-btns :is-case-edit="isCaseEdit" :environment="environment" :row="apiCase" v-tester/>
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
<el-link type="danger" v-if="apiCase.execResult && apiCase.execResult==='error'" @click="showExecResult(apiCase)"> <el-link type="danger" v-if="apiCase.execResult && apiCase.execResult==='error'" @click="showExecResult(apiCase)">
@ -112,10 +93,12 @@ import MsSqlBasisParameters from "../request/database/BasisParameters";
import MsTcpBasisParameters from "../request/tcp/BasisParameters"; import MsTcpBasisParameters from "../request/tcp/BasisParameters";
import MsDubboBasisParameters from "../request/dubbo/BasisParameters"; import MsDubboBasisParameters from "../request/dubbo/BasisParameters";
import MsApiExtendBtns from "../reference/ApiExtendBtns"; import MsApiExtendBtns from "../reference/ApiExtendBtns";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
export default { export default {
name: "ApiCaseItem", name: "ApiCaseItem",
components: { components: {
MsInputTag,
MsTag, MsTag,
MsTipButton, MsTipButton,
MsApiRequestForm, MsApiRequestForm,
@ -139,8 +122,6 @@ export default {
visible: false, visible: false,
condition: {}, condition: {},
isShowInput: false, isShowInput: false,
inputVisible: false,
inputValue: ''
} }
}, },
props: { props: {
@ -213,21 +194,25 @@ export default {
} }
}, },
saveTestCase(row) { saveTestCase(row) {
let tmp = JSON.parse(JSON.stringify(row));
this.isShowInput = false; this.isShowInput = false;
if (this.validate(row)) { if (this.validate(tmp)) {
return; return;
} }
let bodyFiles = this.getBodyUploadFiles(row); let bodyFiles = this.getBodyUploadFiles(tmp);
row.projectId = getCurrentProjectID(); tmp.projectId = getCurrentProjectID();
row.active = true; tmp.active = true;
row.request.path = this.api.path; tmp.request.path = this.api.path;
row.request.method = this.api.method; tmp.request.method = this.api.method;
row.apiDefinitionId = row.apiDefinitionId || this.api.id; tmp.apiDefinitionId = tmp.apiDefinitionId || this.api.id;
let url = "/api/testcase/create"; let url = "/api/testcase/create";
if (row.id) { if (tmp.id) {
url = "/api/testcase/update"; url = "/api/testcase/update";
} }
this.$fileUpload(url, null, bodyFiles, row, () => { if (tmp.tags instanceof Array) {
tmp.tags = JSON.stringify(tmp.tags);
}
this.$fileUpload(url, null, bodyFiles, tmp, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.$emit('refresh'); this.$emit('refresh');
}); });
@ -293,28 +278,6 @@ export default {
} }
return bodyUploadFiles; return bodyUploadFiles;
}, },
handleClose(tag) {
this.apiCase.tags.splice(this.apiCase.tags.indexOf(tag), 1);
this.saveTestCase(this.apiCase)
},
showTagInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.apiCase.tags.push(inputValue);
this.saveTestCase(this.apiCase)
}
this.inputVisible = false;
this.inputValue = '';
}
} }
} }
</script> </script>
@ -356,22 +319,4 @@ export default {
.is-selected { .is-selected {
background: #EFF7FF; background: #EFF7FF;
} }
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 20px;
/*line-height: 30px;*/
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style> </style>

View File

@ -177,9 +177,7 @@ export default {
this.addCase(); this.addCase();
} }
this.apiCaseList.forEach(apiCase => { this.apiCaseList.forEach(apiCase => {
if (!apiCase.tags) { if (apiCase.tags && apiCase.tags.length > 0) {
apiCase.tags = [];
} else {
apiCase.tags = JSON.parse(apiCase.tags); apiCase.tags = JSON.parse(apiCase.tags);
} }
}) })

View File

@ -17,8 +17,9 @@
<div v-else> <div v-else>
<el-option :key="0" :value="''"> <el-option :key="0" :value="''">
<div style="margin-left: 40px"> <div style="margin-left: 40px">
<span style="font-size: 14px;color: #606266;font-weight: 48.93">{{$t('api_test.definition.select_comp.no_data')}}, <span style="font-size: 14px;color: #606266;font-weight: 48.93">{{ $t('api_test.definition.select_comp.no_data') }},
</span><el-link type="primary" @click="createModules">{{$t('api_test.definition.select_comp.add_data')}}</el-link> </span>
<el-link type="primary" @click="createModules">{{ $t('api_test.definition.select_comp.add_data') }}</el-link>
</div> </div>
</el-option> </el-option>
</div> </div>
@ -54,27 +55,7 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('commons.tag')" prop="tag"> <el-form-item :label="$t('commons.tag')" prop="tag">
<el-tag <ms-input-tag :currentScenario="basicForm" ref="tag"/>
:key="basicForm + '_' + index"
v-for="(tag, index) in basicForm.tags"
closable
size="mini"
:disable-transitions="false"
@close="handleClose(tag)">
{{ tag }}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="mini"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" size="mini" @click="showInput">+</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
@ -94,111 +75,69 @@
<script> <script>
import {API_STATUS} from "../../model/JsonData"; import {API_STATUS} from "../../model/JsonData";
import {WORKSPACE_ID} from '../../../../../../common/js/constants'; import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
export default { export default {
name: "MsBasisApi", name: "MsBasisApi",
components: {}, components: {MsInputTag},
props: { props: {
currentProtocol: { currentProtocol: {
type: String, type: String,
default: "HTTP" default: "HTTP"
},
moduleOptions: Array,
basisData: {},
}, },
created() { moduleOptions: Array,
this.getMaintainerOptions(); basisData: {},
if (!this.basisData.tags) { },
this.basisData.tags = []; created() {
} else { this.getMaintainerOptions();
this.basisData.tags = JSON.parse(this.basisData.tags); this.basicForm = this.basisData;
} },
this.basicForm = this.basisData; data() {
}, return {
data() { basicForm: {},
return { httpVisible: false,
basicForm: {}, currentModule: {},
httpVisible: false, maintainerOptions: [],
currentModule: {}, loading: false,
maintainerOptions: [], rule: {
loading: false, name: [
rule: { {required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
name: [ {max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'}
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'}, ],
{max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'} userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}],
], moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
userId: [{required: true, message: this.$t('test_track.case.input_maintainer'), trigger: 'change'}], status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
moduleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}],
status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}],
},
value: API_STATUS[0].id,
options: API_STATUS,
inputVisible: false,
inputValue: ''
}
},
methods: {
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.maintainerOptions = response.data;
});
}, },
reload() { value: API_STATUS[0].id,
this.loading = true options: API_STATUS,
this.$nextTick(() => {
this.loading = false
})
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
},
createModules(){
this.$emit("createRootModelInTree");
},
handleClose(tag) {
this.basicForm.tags.splice(this.basicForm.tags.indexOf(tag), 1);
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.basicForm.tags.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
}
} }
},
methods: {
getMaintainerOptions() {
let workspaceId = localStorage.getItem(WORKSPACE_ID);
this.$post('/user/ws/member/tester/list', {workspaceId: workspaceId}, response => {
this.maintainerOptions = response.data;
});
},
reload() {
this.loading = true
this.$nextTick(() => {
this.loading = false
})
},
validate() {
this.$refs['basicForm'].validate((valid) => {
if (valid) {
this.$emit('callback');
}
})
},
createModules() {
this.$emit("createRootModelInTree");
},
} }
}
</script> </script>
<style scoped> <style scoped>
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 20px;
/*line-height: 30px;*/
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style> </style>

View File

@ -6,87 +6,91 @@
<el-col> <el-col>
<!--操作按钮--> <!--操作按钮-->
<div style="float: right;margin-right: 20px;margin-top: 20px"> <div style="float: right;margin-right: 20px;margin-top: 20px">
<el-button type="primary" size="small" @click="saveApi">{{$t('commons.save')}}</el-button> <el-button type="primary" size="small" @click="saveApi">{{ $t('commons.save') }}</el-button>
<el-button type="primary" size="small" @click="runTest">{{$t('commons.test')}}</el-button> <el-button type="primary" size="small" @click="runTest">{{ $t('commons.test') }}</el-button>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<!-- 基础信息 --> <!-- 基础信息 -->
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p> <p class="tip">{{ $t('test_track.plan_view.base_info') }} </p>
<br/> <br/>
<el-row> <el-row>
<el-col> <el-col>
<ms-basis-api @createRootModelInTree="createRootModelInTree" :moduleOptions="moduleOptions" :basisData="basisData" ref="basicForm" @callback="callback"/> <ms-basis-api @createRootModelInTree="createRootModelInTree" :moduleOptions="moduleOptions" :basisData="basisData" ref="basicForm"
@callback="callback"/>
</el-col> </el-col>
</el-row> </el-row>
<!-- 请求参数 --> <!-- 请求参数 -->
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-basis-parameters :showScript="false" :request="request"/> <ms-basis-parameters :showScript="false" :request="request"/>
</div> </div>
</template> </template>
<script> <script>
import MsBasisApi from "./BasisApi"; import MsBasisApi from "./BasisApi";
import MsBasisParameters from "../request/dubbo/BasisParameters"; import MsBasisParameters from "../request/dubbo/BasisParameters";
export default { export default {
name: "MsApiDubboRequestForm", name: "MsApiDubboRequestForm",
components: { components: {
MsBasisApi, MsBasisParameters MsBasisApi, MsBasisParameters
},
props: {
request: {},
basisData: {},
moduleOptions: Array,
isReadOnly: {
type: Boolean,
default: false
}
},
data() {
return {validated: false}
},
methods: {
callback() {
this.validated = true;
}, },
props: { validateApi() {
request: {}, this.validated = false;
basisData: {}, this.basisData.method = this.request.protocol;
moduleOptions: Array, this.$refs['basicForm'].validate();
isReadOnly: { },
type: Boolean, saveApi() {
default: false this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
console.log(this.basisData)
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('saveApi', this.basisData);
} }
}, },
data() { runTest() {
return {validated: false} this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
}
}, },
methods: { createRootModelInTree() {
callback() { this.$emit("createRootModelInTree");
this.validated = true;
},
validateApi() {
this.validated = false;
this.basisData.method = this.request.protocol;
this.$refs['basicForm'].validate();
},
saveApi() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
console.log(this.basisData)
this.$emit('saveApi', this.basisData);
}
},
runTest() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
}
},
createRootModelInTree(){
this.$emit("createRootModelInTree");
},
}, },
},
computed: {} computed: {}
} }
</script> </script>
<style scoped> <style scoped>
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
border-radius: 4px; border-radius: 4px;
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 0px 20px 0px; margin: 0px 20px 0px;
} }
</style> </style>

View File

@ -77,27 +77,7 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-form-item :label="$t('commons.tag')" prop="tag"> <el-form-item :label="$t('commons.tag')" prop="tag">
<el-tag <ms-input-tag :currentScenario="httpForm" ref="tag"/>
:key="httpForm + '_' + index"
v-for="(tag, index) in httpForm.tags"
closable
size="mini"
:disable-transitions="false"
@close="handleClose(tag)">
{{ tag }}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="mini"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" size="mini" @click="showInput">+</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
@ -134,10 +114,11 @@ import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {API_STATUS, REQ_METHOD} from "../../model/JsonData"; import {API_STATUS, REQ_METHOD} from "../../model/JsonData";
import MsJsr233Processor from "../processor/Jsr233Processor"; import MsJsr233Processor from "../processor/Jsr233Processor";
import {KeyValue} from "../../model/ApiTestModel"; import {KeyValue} from "../../model/ApiTestModel";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
export default { export default {
name: "MsAddCompleteHttpApi", name: "MsAddCompleteHttpApi",
components: {MsResponseText, MsApiRequestForm, MsJsr233Processor}, components: {MsResponseText, MsApiRequestForm, MsJsr233Processor, MsInputTag},
data() { data() {
let validateURL = (rule, value, callback) => { let validateURL = (rule, value, callback) => {
if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) { if (!this.httpForm.path.startsWith("/") || this.httpForm.path.match(/\s/) != null) {
@ -165,8 +146,6 @@ export default {
currentModule: {}, currentModule: {},
reqOptions: REQ_METHOD, reqOptions: REQ_METHOD,
options: API_STATUS, options: API_STATUS,
inputVisible: false,
inputValue: ''
} }
}, },
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}}, props: {moduleOptions: {}, request: {}, response: {}, basisData: {}},
@ -192,6 +171,9 @@ export default {
this.request.path = this.httpForm.path; this.request.path = this.httpForm.path;
this.request.method = this.httpForm.method; this.request.method = this.httpForm.method;
this.httpForm.request.useEnvironment = undefined; this.httpForm.request.useEnvironment = undefined;
if (this.httpForm.tags instanceof Array) {
this.httpForm.tags = JSON.stringify(this.httpForm.tags);
}
}, },
saveApi() { saveApi() {
this.$refs['httpForm'].validate((valid) => { this.$refs['httpForm'].validate((valid) => {
@ -243,26 +225,6 @@ export default {
this.$error(this.$t('api_test.request.url_invalid'), 2000); this.$error(this.$t('api_test.request.url_invalid'), 2000);
} }
}, },
handleClose(tag) {
this.httpForm.tags.splice(this.httpForm.tags.indexOf(tag), 1);
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.httpForm.tags.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
}
}, },
created() { created() {
@ -270,11 +232,6 @@ export default {
if (!this.basisData.environmentId) { if (!this.basisData.environmentId) {
this.basisData.environmentId = ""; this.basisData.environmentId = "";
} }
if (!this.basisData.tags) {
this.basisData.tags = [];
} else {
this.basisData.tags = JSON.parse(this.basisData.tags);
}
this.httpForm = JSON.parse(JSON.stringify(this.basisData)); this.httpForm = JSON.parse(JSON.stringify(this.basisData));
} }
@ -314,22 +271,4 @@ export default {
.ms-left-buttion { .ms-left-buttion {
margin: 6px 0px 8px 30px; margin: 6px 0px 8px 30px;
} }
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 20px;
/*line-height: 30px;*/
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style> </style>

View File

@ -5,84 +5,88 @@
<el-col> <el-col>
<!--操作按钮--> <!--操作按钮-->
<div style="float: right;margin-right: 20px;margin-top: 20px"> <div style="float: right;margin-right: 20px;margin-top: 20px">
<el-button type="primary" size="small" @click="saveApi">{{$t('commons.save')}}</el-button> <el-button type="primary" size="small" @click="saveApi">{{ $t('commons.save') }}</el-button>
<el-button type="primary" size="small" @click="runTest">{{$t('commons.test')}}</el-button> <el-button type="primary" size="small" @click="runTest">{{ $t('commons.test') }}</el-button>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<!-- 基础信息 --> <!-- 基础信息 -->
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p> <p class="tip">{{ $t('test_track.plan_view.base_info') }} </p>
<br/> <br/>
<el-row> <el-row>
<el-col> <el-col>
<ms-basis-api @createRootModelInTree="createRootModelInTree" :moduleOptions="moduleOptions" :basisData="basisData" ref="basicForm" @callback="callback"/> <ms-basis-api @createRootModelInTree="createRootModelInTree" :moduleOptions="moduleOptions" :basisData="basisData" ref="basicForm"
@callback="callback"/>
</el-col> </el-col>
</el-row> </el-row>
<!-- 请求参数 --> <!-- 请求参数 -->
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-basis-parameters :showScript="false" :request="request"/> <ms-basis-parameters :showScript="false" :request="request"/>
</div> </div>
</template> </template>
<script> <script>
import MsBasisApi from "./BasisApi"; import MsBasisApi from "./BasisApi";
import MsBasisParameters from "../request/database/BasisParameters"; import MsBasisParameters from "../request/database/BasisParameters";
export default { export default {
name: "MsApiSqlRequestForm", name: "MsApiSqlRequestForm",
components: { components: {
MsBasisApi, MsBasisParameters MsBasisApi, MsBasisParameters
},
props: {
request: {},
basisData: {},
moduleOptions: Array,
isReadOnly: {
type: Boolean,
default: false
}
},
data() {
return {validated: false}
},
methods: {
callback() {
this.validated = true;
}, },
props: { validateApi() {
request: {}, this.validated = false;
basisData: {}, this.$refs['basicForm'].validate();
moduleOptions: Array, },
isReadOnly: { saveApi() {
type: Boolean, this.validateApi();
default: false if (this.validated) {
this.basisData.method = this.basisData.protocol;
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('saveApi', this.basisData);
} }
}, },
runTest() {
data() { this.validateApi();
return {validated: false} if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
}
}, },
methods: { createRootModelInTree() {
callback() { this.$emit("createRootModelInTree");
this.validated = true;
},
validateApi() {
this.validated = false;
this.$refs['basicForm'].validate();
},
saveApi() {
this.validateApi();
if (this.validated) {
this.basisData.method = this.basisData.protocol;
this.$emit('saveApi', this.basisData);
}
},
runTest() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
}
},
createRootModelInTree(){
this.$emit("createRootModelInTree");
},
}, },
} },
}
</script> </script>
<style scoped> <style scoped>
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
border-radius: 4px; border-radius: 4px;
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 0px 20px 0px; margin: 0px 20px 0px;
} }
</style> </style>

View File

@ -5,22 +5,23 @@
<el-col> <el-col>
<!--操作按钮--> <!--操作按钮-->
<div style="float: right;margin-right: 20px;margin-top: 20px"> <div style="float: right;margin-right: 20px;margin-top: 20px">
<el-button type="primary" size="small" @click="saveApi">{{$t('commons.save')}}</el-button> <el-button type="primary" size="small" @click="saveApi">{{ $t('commons.save') }}</el-button>
<el-button type="primary" size="small" @click="runTest">{{$t('commons.test')}}</el-button> <el-button type="primary" size="small" @click="runTest">{{ $t('commons.test') }}</el-button>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<!-- 基础信息 --> <!-- 基础信息 -->
<p class="tip">{{$t('test_track.plan_view.base_info')}} </p> <p class="tip">{{ $t('test_track.plan_view.base_info') }} </p>
<br/> <br/>
<el-row> <el-row>
<el-col> <el-col>
<ms-basis-api @createRootModelInTree="createRootModelInTree" :moduleOptions="moduleOptions" :basisData="basisData" ref="basicForm" @callback="callback"/> <ms-basis-api @createRootModelInTree="createRootModelInTree" :moduleOptions="moduleOptions" :basisData="basisData" ref="basicForm"
@callback="callback"/>
</el-col> </el-col>
</el-row> </el-row>
<!-- 请求参数 --> <!-- 请求参数 -->
<p class="tip">{{$t('api_test.definition.request.req_param')}} </p> <p class="tip">{{ $t('api_test.definition.request.req_param') }} </p>
<ms-basis-parameters :request="request"/> <ms-basis-parameters :request="request"/>
</div> </div>
@ -28,62 +29,65 @@
</template> </template>
<script> <script>
import MsBasisApi from "./BasisApi"; import MsBasisApi from "./BasisApi";
import MsBasisParameters from "../request/tcp/BasisParameters"; import MsBasisParameters from "../request/tcp/BasisParameters";
export default { export default {
name: "MsAddCompleteTcpApi", name: "MsAddCompleteTcpApi",
components: {MsBasisApi, MsBasisParameters}, components: {MsBasisApi, MsBasisParameters},
props: { props: {
request: {}, request: {},
basisData: {}, basisData: {},
moduleOptions: Array, moduleOptions: Array,
isReadOnly: { isReadOnly: {
type: Boolean, type: Boolean,
default: false default: false
}
},
data() {
return {
validated: false,
}
},
methods: {
callback() {
this.validated = true;
},
validateApi() {
this.validated = false;
this.basisData.method = "TCP";
this.$refs['basicForm'].validate();
},
saveApi() {
this.validateApi();
if (this.validated) {
if (this.basisData.tags instanceof Array) {
this.basisData.tags = JSON.stringify(this.basisData.tags);
}
this.$emit('saveApi', this.basisData);
} }
}, },
data() { runTest() {
return { this.validateApi();
validated: false, if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
} }
}, },
createRootModelInTree() {
methods: { this.$emit("createRootModelInTree");
callback() {
this.validated = true;
},
validateApi() {
this.validated = false;
this.basisData.method = "TCP";
this.$refs['basicForm'].validate();
},
saveApi() {
this.validateApi();
if (this.validated) {
this.$emit('saveApi', this.basisData);
}
},
runTest() {
this.validateApi();
if (this.validated) {
this.basisData.request = this.request;
this.$emit('runTest', this.basisData);
}
},
createRootModelInTree(){
this.$emit("createRootModelInTree");
},
}, },
} },
}
</script> </script>
<style scoped> <style scoped>
.tip { .tip {
padding: 3px 5px; padding: 3px 5px;
font-size: 16px; font-size: 16px;
border-radius: 4px; border-radius: 4px;
border-left: 4px solid #783887; border-left: 4px solid #783887;
margin: 0px 20px 0px; margin: 0px 20px 0px;
} }
</style> </style>

View File

@ -10,6 +10,8 @@
<el-table v-loading="result.loading" <el-table v-loading="result.loading"
ref="apiDefinitionTable" ref="apiDefinitionTable"
border border
@sort-change="sort"
@filter-change="filter"
:data="tableData" row-key="id" class="test-content adjust-table ms-select-all" :data="tableData" row-key="id" class="test-content adjust-table ms-select-all"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@select="handleSelect" :height="screenHeight"> @select="handleSelect" :height="screenHeight">
@ -27,18 +29,21 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="num" label="ID" show-overflow-tooltip/> <el-table-column prop="num" label="ID" show-overflow-tooltip
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/> sortable="custom"/>
<el-table-column prop="name" :label="$t('api_test.definition.api_name')"
show-overflow-tooltip
sortable="custom"/>
<el-table-column <el-table-column
prop="status" prop="status"
column-key="api_status" column-key="status"
:label="$t('api_test.definition.api_status')" sortable="custom"
show-overflow-tooltip> :filters="statusFilters"
:label="$t('api_test.definition.api_status')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-if="scope.row.status == 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/> <span class="el-dropdown-link">
<ms-tag v-if="scope.row.status == 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/> <api-status :value="scope.row.status"/>
<ms-tag v-if="scope.row.status == 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/> </span>
<ms-tag v-if="scope.row.status == 'Trash'" type="danger" effect="plain" content="废弃"/>
</template> </template>
</el-table-column> </el-table-column>
@ -66,10 +71,9 @@
<el-table-column prop="tags" :label="$t('commons.tag')"> <el-table-column prop="tags" :label="$t('commons.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(tag, index) in scope.row.showTags" <div v-for="(itemName,index) in scope.row.tags" :key="index">
:key="tag + '_' + index" <ms-tag type="success" effect="plain" :content="itemName"/>
:effect="'light'" </div>
:content="tag"/>
</template> </template>
</el-table-column> </el-table-column>
@ -128,14 +132,16 @@ import MsBottomContainer from "../BottomContainer";
import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn"; import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit"; import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, API_STATUS, REQ_METHOD} from "../../model/JsonData"; import {API_METHOD_COLOUR, API_STATUS, REQ_METHOD} from "../../model/JsonData";
import {getCurrentProjectID} from "@/common/js/utils"; import {_filter, _sort, getCurrentProjectID} from "@/common/js/utils";
import {WORKSPACE_ID} from '@/common/js/constants'; import {WORKSPACE_ID} from '@/common/js/constants';
import ApiListContainer from "./ApiListContainer"; import ApiListContainer from "./ApiListContainer";
import MsTableSelectAll from "../../../../common/components/table/MsTableSelectAll"; import MsTableSelectAll from "../../../../common/components/table/MsTableSelectAll";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
export default { export default {
name: "ApiList", name: "ApiList",
components: { components: {
ApiStatus,
MsTableSelectAll, MsTableSelectAll,
ApiListContainer, ApiListContainer,
MsTableButton, MsTableButton,
@ -168,6 +174,12 @@ export default {
{id: 'method', name: this.$t('api_test.definition.api_type')}, {id: 'method', name: this.$t('api_test.definition.api_type')},
{id: 'userId', name: this.$t('api_test.definition.api_principal')}, {id: 'userId', name: this.$t('api_test.definition.api_principal')},
], ],
statusFilters: [
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
{text: this.$t('test_track.plan.plan_status_running'), value: 'Underway'},
{text: this.$t('test_track.plan.plan_status_completed'), value: 'Completed'},
{text: this.$t('test_track.plan.plan_status_trash'), value: 'Trash'},
],
valueArr: { valueArr: {
status: API_STATUS, status: API_STATUS,
method: REQ_METHOD, method: REQ_METHOD,
@ -208,6 +220,7 @@ export default {
}, },
}, },
created: function () { created: function () {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
this.initTable(); this.initTable();
this.getMaintainerOptions(); this.getMaintainerOptions();
}, },
@ -220,8 +233,12 @@ export default {
}, },
trashEnable() { trashEnable() {
if (this.trashEnable) { if (this.trashEnable) {
this.initTable(); this.condition.filters = {status: ["Trash"]};
this.condition.moduleIds = [];
} else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
} }
this.initTable();
} }
}, },
methods: { methods: {
@ -235,14 +252,8 @@ export default {
this.unSelection = []; this.unSelection = [];
this.selectDataCounts = 0; this.selectDataCounts = 0;
this.condition.filters = ["Prepare", "Underway", "Completed"];
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
this.condition.filters = ["Trash"];
this.condition.moduleIds = [];
}
this.condition.projectId = getCurrentProjectID(); this.condition.projectId = getCurrentProjectID();
if (this.currentProtocol != null) { if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol; this.condition.protocol = this.currentProtocol;
@ -256,15 +267,6 @@ export default {
case 'thisWeekCount': case 'thisWeekCount':
this.condition.selectThisWeedData = true; this.condition.selectThisWeedData = true;
break; break;
case 'Prepare':
this.condition.filters = [this.selectDataRange];
break;
case 'Completed':
this.condition.filters = [this.selectDataRange];
break;
case 'Underway':
this.condition.filters = [this.selectDataRange];
break;
case 'uncoverage': case 'uncoverage':
this.condition.apiCaseCoverage = 'uncoverage'; this.condition.apiCaseCoverage = 'uncoverage';
break; break;
@ -278,8 +280,10 @@ export default {
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
this.unSelection = response.data.listObject.map(s => s.id); this.unSelection = response.data.listObject.map(s => s.id);
this.tableData.forEach(row => { this.tableData.forEach(item => {
row.showTags = JSON.parse(row.tags); if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
}) })
}); });
} }
@ -342,9 +346,13 @@ export default {
this.$emit('editApi', row); this.$emit('editApi', row);
}, },
reductionApi(row) { reductionApi(row) {
row.request = null; let tmp = JSON.parse(JSON.stringify(row));
row.response = null; tmp.request = null;
let rows = [row]; tmp.response = null;
if (tmp.tags instanceof Array) {
tmp.tags = JSON.stringify(tmp.tags);
}
let rows = [tmp];
this.$post('/api/definition/reduction/', rows, () => { this.$post('/api/definition/reduction/', rows, () => {
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.search(); this.search();
@ -495,7 +503,19 @@ export default {
let rowArray = Array.from(rowSets) let rowArray = Array.from(rowSets)
let ids = rowArray.map(s => s.id); let ids = rowArray.map(s => s.id);
return ids; return ids;
} },
sort(column) {
//
if (this.condition.orders) {
this.condition.orders = [];
}
_sort(column, this.condition);
this.initTable();
},
filter(filters) {
_filter(filters, this.condition);
this.initTable();
},
}, },
} }
</script> </script>

View File

@ -0,0 +1,26 @@
<template>
<span>
<ms-tag v-if="value === 'Prepare'" type="info" effect="plain" :content="$t('test_track.plan.plan_status_prepare')"/>
<ms-tag v-if="value === 'Underway'" type="warning" effect="plain" :content="$t('test_track.plan.plan_status_running')"/>
<ms-tag v-if="value === 'Completed'" type="success" effect="plain" :content="$t('test_track.plan.plan_status_completed')"/>
<ms-tag v-if="value === 'Trash'" type="danger" effect="plain" content="废弃"/>
</span>
</template>
<script>
import MsTag from "@/business/components/common/components/MsTag";
export default {
name: "ApiStatus",
components: {MsTag},
props: {
value: {
type: String
}
}
}
</script>
<style scoped>
</style>

View File

@ -69,27 +69,7 @@
<el-row> <el-row>
<el-col :span="10" :offset="1"> <el-col :span="10" :offset="1">
<el-form-item :label="$t('commons.tag')" :label-width="formLabelWidth" prop="tag"> <el-form-item :label="$t('commons.tag')" :label-width="formLabelWidth" prop="tag">
<el-tag <ms-input-tag :currentScenario="form" ref="tag"/>
:key="form + '_' + index"
v-for="(tag, index) in form.caseTags"
closable
size="mini"
:disable-transitions="false"
@close="handleClose(tag)">
{{ tag }}
</el-tag>
<el-input
class="input-new-tag"
v-if="inputVisible"
v-model="inputValue"
ref="saveTagInput"
size="mini"
@keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"
>
</el-input>
<el-button v-else class="button-new-tag" size="mini" @click="showInput">+</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -298,10 +278,11 @@ import TestCaseAttachment from "@/business/components/track/case/components/Test
import {getCurrentProjectID} from "../../../../../common/js/utils"; import {getCurrentProjectID} from "../../../../../common/js/utils";
import {buildNodePath} from "../../../api/definition/model/NodeTree"; import {buildNodePath} from "../../../api/definition/model/NodeTree";
import CaseComment from "@/business/components/track/case/components/CaseComment"; import CaseComment from "@/business/components/track/case/components/CaseComment";
import MsInputTag from "@/business/components/api/automation/scenario/MsInputTag";
export default { export default {
name: "TestCaseEdit", name: "TestCaseEdit",
components: {CaseComment, MsDialogFooter, TestCaseAttachment}, components: {MsInputTag, CaseComment, MsDialogFooter, TestCaseAttachment},
data() { data() {
return { return {
result: {}, result: {},
@ -323,7 +304,6 @@ export default {
result: '' result: ''
}], }],
remark: '', remark: '',
caseTags: []
}, },
moduleOptions: [], moduleOptions: [],
maintainerOptions: [], maintainerOptions: [],
@ -355,8 +335,6 @@ export default {
{value: 'manual', label: this.$t('test_track.case.manual')} {value: 'manual', label: this.$t('test_track.case.manual')}
], ],
testCase: {}, testCase: {},
inputVisible: false,
inputValue: ''
}; };
}, },
props: { props: {
@ -387,7 +365,7 @@ export default {
open(testCase) { open(testCase) {
this.testCase = {}; this.testCase = {};
if (testCase) { if (testCase) {
testCase.caseTags = JSON.parse(testCase.tags); testCase.tags = JSON.parse(testCase.tags);
// //
this.testCase = testCase.isCopy ? {} : testCase; this.testCase = testCase.isCopy ? {} : testCase;
} }
@ -425,7 +403,6 @@ export default {
this.form.type = 'functional'; this.form.type = 'functional';
this.form.method = 'manual'; this.form.method = 'manual';
this.form.maintainer = user.id; this.form.maintainer = user.id;
this.form.caseTags = [];
} }
this.getSelectOptions(); this.getSelectOptions();
@ -538,6 +515,10 @@ export default {
if (param.method != 'auto') { if (param.method != 'auto') {
param.testId = null; param.testId = null;
} }
if (this.form.tags instanceof Array) {
this.form.tags = JSON.stringify(this.form.tags);
}
param.tags = this.form.tags;
return param; return param;
}, },
getOption(param) { getOption(param) {
@ -641,7 +622,6 @@ export default {
desc: '', desc: '',
result: '' result: ''
}]; }];
this.caseTags = [];
this.uploadList = []; this.uploadList = [];
this.fileList = []; this.fileList = [];
this.tableData = []; this.tableData = [];
@ -729,26 +709,6 @@ export default {
/// todo: /// todo:
return file.size > 0; return file.size > 0;
}, },
handleClose(tag) {
this.form.caseTags.splice(this.form.caseTags.indexOf(tag), 1);
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.form.caseTags.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
}
} }
} }
</script> </script>
@ -788,21 +748,4 @@ export default {
height: calc(100vh - 120px); height: calc(100vh - 120px);
} }
.el-tag + .el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 20px;
/*line-height: 30px;*/
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
</style> </style>

View File

@ -113,10 +113,9 @@
<el-table-column prop="tags" :label="$t('commons.tag')"> <el-table-column prop="tags" :label="$t('commons.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(tag, index) in scope.row.showTags" <div v-for="(itemName,index) in scope.row.tags" :key="index">
:key="tag + '_' + index" <ms-tag type="success" effect="plain" :content="itemName"/>
:effect="'light'" </div>
:content="tag"/>
</template> </template>
</el-table-column> </el-table-column>
@ -319,8 +318,10 @@ export default {
this.tableData = data.listObject; this.tableData = data.listObject;
// this.selectIds.clear(); // this.selectIds.clear();
this.selectRows.clear(); this.selectRows.clear();
this.tableData.forEach(row => { this.tableData.forEach(item => {
row.showTags = JSON.parse(row.tags); if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
}) })
}); });
} }

View File

@ -62,10 +62,9 @@
<el-table-column prop="tags" :label="$t('commons.tag')"> <el-table-column prop="tags" :label="$t('commons.tag')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="(tag, index) in scope.row.showTags" <div v-for="(itemName,index) in scope.row.tags" :key="index">
:key="tag + '_' + index" <ms-tag type="success" effect="plain" :content="itemName"/>
:effect="'light'" </div>
:content="tag"/>
</template> </template>
</el-table-column> </el-table-column>
@ -265,8 +264,10 @@ export default {
this.result = this.$post('/test/plan/api/case/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => { this.result = this.$post('/test/plan/api/case/list/' + this.currentPage + "/" + this.pageSize, this.condition, response => {
this.total = response.data.itemCount; this.total = response.data.itemCount;
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
this.tableData.forEach(row => { this.tableData.forEach(item => {
row.showTags = JSON.parse(row.tags); if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
}) })
}); });
}, },
@ -479,7 +480,4 @@ export default {
margin-right: 20px; margin-right: 20px;
} }
.el-tag {
margin-left: 10px;
}
</style> </style>

View File

@ -161,7 +161,7 @@ html,body {
overflow: visible; overflow: visible;
} }
.ms-select-all .el-icon-arrow-down { .ms-select-all th:nth-child(2) .el-icon-arrow-down {
position: absolute; position: absolute;
display: inline-block; display: inline-block;
top: -7px; top: -7px;

View File

@ -1085,6 +1085,7 @@ export default {
plan_status_prepare: "Not started", plan_status_prepare: "Not started",
plan_status_running: "Starting", plan_status_running: "Starting",
plan_status_completed: "Completed", plan_status_completed: "Completed",
plan_status_trash: "Trashed",
planned_start_time: "Scheduled Start Time", planned_start_time: "Scheduled Start Time",
planned_end_time: "Scheduled End Time", planned_end_time: "Scheduled End Time",
actual_start_time: "Actual Start Time", actual_start_time: "Actual Start Time",

View File

@ -1086,6 +1086,7 @@ export default {
plan_status_prepare: "未开始", plan_status_prepare: "未开始",
plan_status_running: "进行中", plan_status_running: "进行中",
plan_status_completed: "已完成", plan_status_completed: "已完成",
plan_status_trash: "废弃",
planned_start_time: "计划开始", planned_start_time: "计划开始",
planned_end_time: "计划结束", planned_end_time: "计划结束",
actual_start_time: "实际开始", actual_start_time: "实际开始",

View File

@ -1085,6 +1085,7 @@ export default {
plan_status_prepare: "未開始", plan_status_prepare: "未開始",
plan_status_running: "進行中", plan_status_running: "進行中",
plan_status_completed: "已完成", plan_status_completed: "已完成",
plan_status_trash: "廢棄",
planned_start_time: "計劃開始", planned_start_time: "計劃開始",
planned_end_time: "計劃結束", planned_end_time: "計劃結束",
actual_start_time: "實際開始", actual_start_time: "實際開始",