Commit da89a871 authored by zhang's avatar zhang

feat: (任务处理/待办任务/开始任务) 新增上传文件

parent 0218fcc9
<template> <template>
<el-dialog <el-dialog
:visible.sync="dialogManger.dialogVisible" :visible.sync="dialogManger.dialogVisible"
title="选择测试场景" title="开始车型校验子任务"
width="80%" width="40%"
class="start_mession_dialog"
append-to-body append-to-body
destroy-on-close destroy-on-close
:close-on-click-modal="false" :close-on-click-modal="false"
...@@ -11,27 +12,29 @@ ...@@ -11,27 +12,29 @@
<el-form v-loading="loading"> <el-form v-loading="loading">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="请选择测试场景(可多选)" prop="testScenarioList"> <el-form-item prop="testScenarioList">
<footer-button <span v-show="uploadVisble" style="font-size: 15px;"><span style="color: red;">*</span>请上传检测方案</span>
style="width: 80px; height: 25px" <span v-show="!uploadVisble">已上传文件:{{ fileName }}</span>
type="primary" <br>
@click="selectAll" <el-button v-show="!uploadVisble" type="primary" size="default" @click="removeAll">撤销上传文件</el-button>
> <el-upload
全部选择 ref="upload"
</footer-button> class="upload-demo"
<div class="test-scenario-container"> :action="uploadUrl"
<div :limit="1"
v-for="(item, index) in testScenarioList" :on-exceed="handleExceed"
:key="index" v-model:file-list="fileList"
:class="{ :on-success="uploadSucess"
'test-scenario': item.check === false, :on-change="uploadChange"
'check-test-scenario': item.check === true :on-error="handleError"
}" accept=".xls, .xlsx"
@click="handleTestScenario(item)" :headers="headers"
:show-file-list="false"
> >
<div>{{ item.label }}</div> <el-button v-show="uploadVisble" size="medium " type="default" style="font-size: 15px;padding: 15px 30px;font-weight: bold;">上传文件</el-button>
</div> <div v-show="uploadVisble" slot="tip" class="el-upload__tip" style="font-size: 15px">支持格式: .xls .xlsx,单个文件不能超过20MB</div>
</div> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
...@@ -49,6 +52,8 @@ import { ...@@ -49,6 +52,8 @@ import {
createProject, createProject,
getUseCaseListByScenario getUseCaseListByScenario
} from '@/api/task/task' } from '@/api/task/task'
import { getToken } from '@/utils/auth'
export default { export default {
props: { props: {
dialogManger: { dialogManger: {
...@@ -63,13 +68,22 @@ export default { ...@@ -63,13 +68,22 @@ export default {
}, },
data() { data() {
return { return {
uploadUrl:process.env.VUE_APP_BASE_API+'/task/uploadExcel',//上传文件接口
headers: { // 头文件
Authorization: 'Bearer ' + getToken()
},
fileName: '',// 已上传文件名字
model: { model: {
searchFields: { searchFields: {
scenario: [] scenario: []
} }
}, },
loading: false, loading: false,
testScenarioList: [] testScenarioList: [],
fileList: [],// 文件集合
testCaseObj: [],// 用例编号数组
uploadVisble:true
} }
}, },
watch: { watch: {
...@@ -82,27 +96,85 @@ export default { ...@@ -82,27 +96,85 @@ export default {
} }
} }
} }
},
'fileList'(newValue){
if(newValue.length<1){
this.uploadVisble = true
}else{
this.uploadVisble = false
}
} }
}, },
created() {},
methods: { methods: {
handleClose() { handleClose() {
this.$emit('close', '123') this.$emit('close', '123')
}, },
async handleSubmit() { uploadSucess(response,file,fileList){ // 当表中没有用例编号一列时清除所有文件,提示错误
this.loading = true if(response.code === 200){
const params = { this.testCaseObj = response.data
id: this.dialogManger.item.id this.fileName = file.name
}else{
this.$message({
message: response.msg,
type: 'warning'
});
this.fileList = []
this.$refs.upload.clearFiles();
} }
const res = await getUseCaseListByScenario(this.model)
if (res.code === 200) { },
const resp = await this.newFileTest({ uploadChange(response,file,fileList){
/**
* 文件大小限制
*/
console.log(file)
let imgSize = Number(file.size / 1024 / 1024);
if (imgSize > 20) {
this.$message({
title: "",
message: "文件大小不能超过20MB,请重新上传。",
type: "warning",
});
return;
}
this.fileList = this.$refs.upload.uploadFiles
},
removeAll(){
this.fileList = []
this.$refs.upload.clearFiles();
},
handleExceed(files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
},
handleError(response,file,fileList){
this.$message.error('文件大小不能超过20MB');
},
async handleSubmit() {
if(this.fileList.length < 1){
this.$message({
message: '请导入一个文件',
type: 'warning'
});
}else{
this.loading = true
if(this.testCaseObj && this.testCaseList!=''){
console.log(this.testCaseObuseCaseListj)
const resp = await this.newFileTest({
name: this.dialogManger.item.taskName, name: this.dialogManger.item.taskName,
caseIdList: res.data caseIdList: this.testCaseObj.useCaseList
}) })
const params = {
id: this.dialogManger.item.id
}
params.testSchemeId = resp.data params.testSchemeId = resp.data
this.startTaskModel(params) this.startTaskModel(params)
}
//const res = await getUseCaseListByScenario(this.model)
} }
}, },
/** /**
* 开始 * 开始
...@@ -163,7 +235,10 @@ export default { ...@@ -163,7 +235,10 @@ export default {
this.model.searchFields.scenario = this.testScenarioList.map(obj => { this.model.searchFields.scenario = this.testScenarioList.map(obj => {
return obj.label return obj.label
}) })
} },
} }
} }
</script> </script>
<style lang="scss" scoped>
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment