导入拆分结果

This commit is contained in:
caoyang
2022-04-01 09:25:13 +08:00
parent 2af0c7beae
commit 3f5ba1fddc
5 changed files with 100 additions and 67 deletions
@@ -34,7 +34,8 @@
:wrapper-col="wrapperCol"
>
<a-form-model-item ref="file" :label="$t('splitFile')" prop="file">
<split-upload ref="uploadFile" :accept="accept" :disabled="disabled" :module="'split'" @uploadSuccess="uploadSuccess"></split-upload>
<split-upload ref="uploadFile" :accept="accept" :disabled="disabled" :module="'split'" @uploadSuccess="uploadSuccess"></split-upload>
<!-- <a-input v-model="form.file" >{{form.file}}</a-input>-->
<!-- <a-button type="primary" class="button-text"-->
<!-- @click="fileUpload()">-->
@@ -123,7 +124,7 @@
form:{},
rules:{
file:[
{ required: true, message: this.$t('pleaseUploadFile'), trigger: 'blur' },
{ required: true, message: this.$t('pleaseUploadFile'), trigger: 'change' },
],
},
spinning:false, //loading标识
@@ -227,70 +228,92 @@
//保存
handleSubmit(){
// console.log('seleced',this.selectedRowKeys,this.rows)
console.log('this.form.file,',this.form.file)
if(this.rows.length===0){
this.$message.warning(this.$t('PleaseSelectData'))
}else if(this.rows&&this.rows.length>1){
this.$message.warning(this.$t('OnlyOneSelected'))
}else if(this.rows&&this.rows.length===1){
this.$refs.ruleForm.validate(valid=>{
if(valid){
this.flag=true
if(this.flag){
let params={
connectId:this.rows[0].connect_id,
splitFileId:this.form.file,
fileName:this.rows[0].file_name,
serialNumber:this.rows[0].serial_number,
title:this.rows[0].title,
let params={
connectId:this.rows[0].connect_id,
splitFileId:this.form.file,
fileName:this.rows[0].file_name,
serialNumber:this.rows[0].serial_number,
title:this.rows[0].title,
}
if(this.rows[0].text_info=='发布稿(必读)'){
params.fileType='1'
}else if(this.rows[0].text_info=='增补件(必读)'){
params.fileType='2'
}else if(this.rows[0].text_info=='报批稿'){
params.fileType='3'
}else if(this.rows[0].text_info=='征求意见稿'){
params.fileType='4'
}else if(this.rows[0].text_info=='测试程序'){
params.fileType='5'
}else if(this.rows[0].text_info=='相关资料'){
params.fileType='6'
}
let formData = new FormData()
Object.keys(params).forEach((key) => {
console.log('key',key,params[key])
formData.append(key, params[key]);
});
console.log('formData',params,formData.getAll)
axios({
url: '/jero-boot/split/sarFileSplitItems/importSplitResult',
method: 'post',
data:formData,
// data: params,
// transformRequest: [function (data) {
// // Do whatever you want to transform the data
// let ret = ''
// for (let it in data) {
// ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
// }
// return ret
// }],
headers: {
'Content-Type': 'multipart/form-data',
// 'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token':this.token
}
}).then(res => {
if (res.data.success) {
}
if(this.rows[0].text_info=='发布稿(必读)'){
params.fileType='1'
}else if(this.rows[0].text_info=='增补件(必读)'){
params.fileType='2'
}else if(this.rows[0].text_info=='报批稿'){
params.fileType='3'
}else if(this.rows[0].text_info=='征求意见稿'){
params.fileType='4'
}else if(this.rows[0].text_info=='测试程序'){
params.fileType='5'
}else if(this.rows[0].text_info=='相关资料'){
params.fileType='6'
}
let formData = new FormData()
Object.keys(params).forEach((key) => {
console.log('key',key,params[key])
formData.append(key, params[key]);
});
console.log('formData',params,formData.getAll)
if(!this.form.file) {
this.$refs.ruleForm.validate(valid => {
if (valid) {
this.flag = true
if (this.flag) {
}
}).finally(()=>[
this.flag=false
])
axios({
url: '/jero-boot/split/sarFileSplitItems/importSplitResult',
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
// 'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': this.token
}
}).then(res => {
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
eventBUs.$emit('searchReset')
}else{
this.$message.warning(res.data.message)
}
}).finally(() => [
this.flag = false
])
}
}
})
}else {
this.flag = true
this.$refs.ruleForm.clearValidate()
if (this.flag) {
axios({
url: '/jero-boot/split/sarFileSplitItems/importSplitResult',
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
// 'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': this.token
}
}).then(res => {
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
eventBUs.$emit('searchReset')
}else{
this.$message.warning(res.data.message)
}
}).finally(() => [
this.flag = false
])
}
})
}
}
}
}