Browse Source

巡检上报接口对接

wyx
fp 1 month ago
parent
commit
321b1bac4d
  1. 12
      common/api.js
  2. 4
      pages/login/login.vue
  3. 68
      pages/tabBar/xjPage/xj.vue

12
common/api.js

@ -30,15 +30,3 @@ export function listWaitingReleaseRooms() {
method: "get", method: "get",
}); });
} }
// 上传文件
export function uploadFile(data) {
return request({
url: '/common/upload',
method: 'post',
data: data,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}

4
pages/login/login.vue

@ -73,8 +73,8 @@ export default {
data() { data() {
return { return {
form: { form: {
username: "", username: "admin",
password: "", password: "!Aa12345",
code: "", code: "",
uuid: "", uuid: "",
rememberMe: false, rememberMe: false,

68
pages/tabBar/xjPage/xj.vue

@ -79,10 +79,11 @@ import {
} from "@/common/rec"; } from "@/common/rec";
import { getdeptList,addInspection,uploadFile } from '@/common/api.js'; import { getdeptList,addInspection,uploadFile } from '@/common/api.js';
import { getDicts } from "@/common/system/dict/data"; import { getDicts } from "@/common/system/dict/data";
import { baseUrl } from "@/utils/config";
export default { export default {
data () { data () {
return { return {
uploadUlr: 'http://219.146.91.110:30801/mz-api/common/upload', uploadUlr: baseUrl + '/common/upload',
wtlxShow: false, wtlxShow: false,
lysqShow: false, lysqShow: false,
deptOptions: [], deptOptions: [],
@ -115,19 +116,16 @@ export default {
}, },
methods: { methods: {
afterRead(event) { afterRead(event) {
let files = Array.isArray(event) ? event : [event] let files = Array.isArray(event) ? event.file : [event.file]
this.fileList = this.fileList.concat(files) this.fileList = this.fileList.concat(files)
event.file.forEach(item=>{ // console.log(this.fileList);
this.form.imageList.push({ this.fileList.forEach( item => {
url:item.url, this.uploadFile(item[0])
name: '', });
format: item.type
})
})
console.log(this.form.imageList);
}, },
onDelete(event) { onDelete(event) {
this.fileList.splice(event.index, 1) this.fileList.splice(event.index, 1)
this.form.imageList.splice(event.index, 1)
}, },
getDictType(){ getDictType(){
getDicts('inspection_question_type').then((res) => { getDicts('inspection_question_type').then((res) => {
@ -163,25 +161,49 @@ export default {
}, },
uploadFile(file){ uploadFile(file){
uploadFile(file).then((res) => { let that = this
console.log(res); 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 () { handleBtn () {
console.log(this.form); // console.log(this.form);
let parmas = JSON.parse(JSON.stringify(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.apartmentName
delete parmas.questionName delete parmas.questionName
addInspection(parmas).then(res=>{ addInspection(parmas).then(res=>{
console.log(res); uni.showToast({
icon: 'success',
title: '提交成功!'
})
}) })
}, },
handleTreeSelect (e) { handleTreeSelect (e) {

Loading…
Cancel
Save