|
|
@ -79,10 +79,11 @@ import { |
|
|
|
} from "@/common/rec"; |
|
|
|
import { getdeptList,addInspection,uploadFile } from '@/common/api.js'; |
|
|
|
import { getDicts } from "@/common/system/dict/data"; |
|
|
|
import { baseUrl } from "@/utils/config"; |
|
|
|
export default { |
|
|
|
data () { |
|
|
|
return { |
|
|
|
uploadUlr: 'http://219.146.91.110:30801/mz-api/common/upload', |
|
|
|
uploadUlr: baseUrl + '/common/upload', |
|
|
|
wtlxShow: false, |
|
|
|
lysqShow: false, |
|
|
|
deptOptions: [], |
|
|
@ -115,19 +116,16 @@ export default { |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
afterRead(event) { |
|
|
|
let files = Array.isArray(event) ? event : [event] |
|
|
|
let files = Array.isArray(event) ? event.file : [event.file] |
|
|
|
this.fileList = this.fileList.concat(files) |
|
|
|
event.file.forEach(item=>{ |
|
|
|
this.form.imageList.push({ |
|
|
|
url:item.url, |
|
|
|
name: '', |
|
|
|
format: item.type |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log(this.form.imageList); |
|
|
|
// console.log(this.fileList); |
|
|
|
this.fileList.forEach( item => { |
|
|
|
this.uploadFile(item[0]) |
|
|
|
}); |
|
|
|
}, |
|
|
|
onDelete(event) { |
|
|
|
this.fileList.splice(event.index, 1) |
|
|
|
this.form.imageList.splice(event.index, 1) |
|
|
|
}, |
|
|
|
getDictType(){ |
|
|
|
getDicts('inspection_question_type').then((res) => { |
|
|
@ -163,25 +161,49 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
uploadFile(file){ |
|
|
|
uploadFile(file).then((res) => { |
|
|
|
console.log(res); |
|
|
|
}); |
|
|
|
let that = this |
|
|
|
console.log('uploadFile',file); |
|
|
|
uni.uploadFile({ |
|
|
|
url: this.uploadUlr, |
|
|
|
filePath: file.url, |
|
|
|
name: 'file', //对应后台接口参数名 |
|
|
|
method: 'post', |
|
|
|
header: { |
|
|
|
"Authorization": uni.getStorageSync('token') |
|
|
|
}, |
|
|
|
formData: { |
|
|
|
//要上传的文件 |
|
|
|
file: file |
|
|
|
}, |
|
|
|
success(res) { |
|
|
|
let data = JSON.parse(res.data) |
|
|
|
console.log(data); |
|
|
|
if (data.url) { |
|
|
|
that.form.imageList.push({ |
|
|
|
url:data.url, |
|
|
|
name: '', |
|
|
|
format: file.type |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
fail(res) { |
|
|
|
uni.showToast({ |
|
|
|
icon: 'error', |
|
|
|
title: '图片上传失败!' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleBtn () { |
|
|
|
console.log(this.form); |
|
|
|
// console.log(this.form); |
|
|
|
let parmas = JSON.parse(JSON.stringify(this.form)) |
|
|
|
this.fileList.forEach(item => { |
|
|
|
// parmas.imageList.push({ |
|
|
|
// url:item.file.url, |
|
|
|
// name: '', |
|
|
|
// format: item.file.type |
|
|
|
// }) |
|
|
|
this.uploadFile(item.file) |
|
|
|
}); |
|
|
|
delete parmas.apartmentName |
|
|
|
delete parmas.questionName |
|
|
|
addInspection(parmas).then(res=>{ |
|
|
|
console.log(res); |
|
|
|
uni.showToast({ |
|
|
|
icon: 'success', |
|
|
|
title: '提交成功!' |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleTreeSelect (e) { |
|
|
|