fix(接口定义): csv优化

This commit is contained in:
fit2-zhao 2021-11-09 14:17:41 +08:00 committed by fit2-zhao
parent 1bb728f475
commit 07b58b41c5
3 changed files with 151 additions and 102 deletions

View File

@ -7,9 +7,9 @@ import org.springframework.kafka.config.TopicBuilder;
@Configuration @Configuration
public class KafkaConfig { public class KafkaConfig {
// 执行内容监听 // 执行内容监听
public final static String EXEC_TOPIC = "ms-automation-exec-topic"; public final static String EXEC_TOPIC = "ms-automation-exec-topic123";
//执行结果回传 //执行结果回传
public static final String TOPICS = "ms-api-exec-topic"; public static final String TOPICS = "ms-api-exec-topic123";
@Bean @Bean
public NewTopic apiExecTopic() { public NewTopic apiExecTopic() {

View File

@ -1,125 +1,152 @@
<template> <template>
<span> <span>
<el-upload <el-row>
action="#" <el-col :span="18">
class="api-body-upload" <el-upload
list-type="picture-card" action="#"
:http-request="upload" class="api-body-upload"
:beforeUpload="uploadValidate" list-type="picture-card"
:file-list="parameter.files" :http-request="upload"
:limit="1" :beforeUpload="uploadValidate"
:on-exceed="exceed" :file-list="parameter.files"
ref="upload"> :limit="1"
:on-exceed="exceed"
ref="upload">
<div class="upload-default"> <div class="upload-default">
<i class="el-icon-plus"/> <i class="el-icon-plus"/>
</div> </div>
<div class="upload-item" slot="file" slot-scope="{file}"> <div class="upload-item" slot="file" slot-scope="{file}">
<span>{{file.file ? file.file.name : file.name}}</span> <span>{{ file.file ? file.file.name : file.name }}</span>
<span class="el-upload-list__item-actions"> <span class="el-upload-list__item-actions">
<span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)"> <span v-if="!disabled" class="el-upload-list__item-delete" @click="handleRemove(file)">
<i class="el-icon-delete"/> <i class="el-icon-delete"/>
</span> </span>
</span> </span>
</div> </div>
</el-upload> </el-upload>
</el-col>
<el-col :span="6">
<el-button size="small" style="margin: 3px 5px" @click="download">下载</el-button>
</el-col>
</el-row>
</span> </span>
</template> </template>
<script> <script>
export default { export default {
name: "MsApiBodyFileUpload", name: "MsApiBodyFileUpload",
data() { data() {
return { return {
disabled: false, disabled: false,
}; };
}, },
props: { props: {
parameter: Object, parameter: Object,
default() { default() {
return {} return {}
}
},
methods: {
download() {
//
if (this.parameter.files && this.parameter.files.length > 0 && this.parameter.files[0].file) {
console.log("local",this.parameter.files[0].file)
}
//
if (this.parameter.files && this.parameter.files.length > 0 && !this.parameter.files[0].file) {
let file = this.parameter.files[0];
let conf = {
url: "/api/automation/file/download",
method: 'post',
data: file,
responseType: 'blob',
};
this.result = this.$request(conf).then(response => {
const content = response.data;
const blob = new Blob([content]);
console.log(content)
});
} }
}, },
methods: { handleRemove(file) {
handleRemove(file) { this.$refs.upload.handleRemove(file);
this.$refs.upload.handleRemove(file); for (let i = 0; i < this.parameter.files.length; i++) {
for (let i = 0; i < this.parameter.files.length; i++) { let fileName = file.file ? file.file.name : file.name;
let fileName = file.file ? file.file.name : file.name; let paramFileName = this.parameter.files[i].file ?
let paramFileName = this.parameter.files[i].file ? this.parameter.files[i].file.name : this.parameter.files[i].name;
this.parameter.files[i].file.name : this.parameter.files[i].name; if (fileName === paramFileName) {
if (fileName === paramFileName) { this.parameter.files.splice(i, 1);
this.parameter.files.splice(i, 1); this.$refs.upload.handleRemove(file);
this.$refs.upload.handleRemove(file); break;
break;
}
} }
},
exceed() {
this.$warning(this.$t('test_track.case.import.upload_limit_count'));
},
upload(file) {
this.parameter.files.push(file);
},
uploadValidate(file) {
if (file.size / 1024 / 1024 > 500) {
this.$warning(this.$t('api_test.request.body_upload_limit_size'));
return false;
}
if (!file.name.endsWith(".csv")) {
this.$warning(this.$t('variables.cvs_info'));
return false;
}
return true;
},
},
created() {
if (!this.parameter.files) {
this.parameter.files = [];
} }
},
exceed() {
this.$warning(this.$t('test_track.case.import.upload_limit_count'));
},
upload(file) {
this.parameter.files.push(file);
},
uploadValidate(file) {
if (file.size / 1024 / 1024 > 500) {
this.$warning(this.$t('api_test.request.body_upload_limit_size'));
return false;
}
if (!file.name.endsWith(".csv")) {
this.$warning(this.$t('variables.cvs_info'));
return false;
}
return true;
},
},
created() {
if (!this.parameter.files) {
this.parameter.files = [];
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.el-upload { .el-upload {
background-color: black; background-color: black;
} }
.api-body-upload >>> .el-upload { .api-body-upload >>> .el-upload {
height: 30px; height: 30px;
width: 32px; width: 32px;
} }
.upload-default { .upload-default {
min-height: 30px; min-height: 30px;
width: 32px; width: 32px;
line-height: 32px; line-height: 32px;
} }
.el-icon-plus { .el-icon-plus {
font-size: 16px; font-size: 16px;
} }
.api-body-upload >>> .el-upload-list__item { .api-body-upload >>> .el-upload-list__item {
height: 30px; height: 30px;
width: auto; width: auto;
padding: 6px; padding: 6px;
margin-bottom: 0px; margin-bottom: 0px;
} }
.api-body-upload >>> .el-upload-list--picture-card { .api-body-upload >>> .el-upload-list--picture-card {
} }
.api-body-upload { .api-body-upload {
min-height: 30px; min-height: 30px;
border: 1px solid #EBEEF5; border: 1px solid #EBEEF5;
padding: 2px; padding: 2px;
border-radius: 4px; border-radius: 4px;
} }
.upload-item { .upload-item {
} }
</style> </style>

View File

@ -200,7 +200,7 @@ export default {
if (data) { if (data) {
let keyValues = this._handleBatchVars(data); let keyValues = this._handleBatchVars(data);
keyValues.forEach(item => { keyValues.forEach(item => {
this.format(this.headers,item); this.format(this.headers, item);
}); });
} }
}, },
@ -229,7 +229,7 @@ export default {
} }
}, },
handleClick(command) { handleClick(command) {
this.editData = {delimiter: ",",quotedData: 'false'}; this.editData = {delimiter: ",", quotedData: 'false'};
this.editData.type = command; this.editData.type = command;
this.addParameters(this.editData); this.addParameters(this.editData);
}, },
@ -298,10 +298,32 @@ export default {
this.$warning("请选择一条数据删除"); this.$warning("请选择一条数据删除");
return; return;
} }
let message = "";
ids.forEach(row => { ids.forEach(row => {
const index = this.variables.findIndex(d => d.id === row); const v = this.variables.find(d => d.id === row);
this.variables.splice(index, 1); if (v && v.type === 'CSV' && v.name) {
message += v.name + ";";
}
}); });
if (message !== "") {
message = message.substr(0, message.length - 1);
this.$alert('是否确认删除CSV【 ' + message + " 】?", '', {
confirmButtonText: this.$t('commons.confirm'),
callback: (action) => {
if (action === 'confirm') {
ids.forEach(row => {
const index = this.variables.findIndex(d => d.id === row);
this.variables.splice(index, 1);
});
}
}
});
} else {
ids.forEach(row => {
const index = this.variables.findIndex(d => d.id === row);
this.variables.splice(index, 1);
});
}
this.selection = []; this.selection = [];
this.editData = {type: "CONSTANT"}; this.editData = {type: "CONSTANT"};
}, },