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",
});
}
// 上传文件
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() {
return {
form: {
username: "",
password: "",
username: "admin",
password: "!Aa12345",
code: "",
uuid: "",
rememberMe: false,

68
pages/tabBar/xjPage/xj.vue

@ -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) {

Loading…
Cancel
Save