Browse Source

巡检上传图片

wyx
fp 1 month ago
parent
commit
be1747750c
  1. 54
      pages/tabBar/xjPage/xj.vue

54
pages/tabBar/xjPage/xj.vue

@ -77,7 +77,8 @@
import {
queryDeptDropdownList,
} from "@/common/rec";
import { getdeptList,addInspection } from '@/common/api.js';
import { getdeptList,addInspection } from '@/common/api';
import { uploadImage } from '@/pages/api';
import { getDicts } from "@/common/system/dict/data";
import { baseUrl } from "@/utils/config";
export default {
@ -115,17 +116,52 @@ export default {
this.getDictType()
},
methods: {
afterRead(event) {
// let files = Array.isArray(event) ? event : [event]
this.fileList = this.fileList.concat(event.file)
// console.log(this.fileList);
this.fileList.forEach( file => {
this.uploadFile(file)
async afterRead(event) {
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
const result = await uploadImage(lists[i].url);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result.url,
})
);
fileListLen++;
}
var arry = [];
this.fileList.filter((v, i) => {
arry.push({
name: '',
format: v.type,
url:v.url
});
});
this.form.imageList = arry
},
onDelete(event) {
this.fileList.splice(event.index, 1)
this.form.imageList.splice(event.index, 1)
this[`fileList${event.name}`].splice(event.index, 1);
var arry = [];
this.fileList.filter((v, i) => {
arry.push({
name: '',
format: v.type,
url:v.url
});
});
this.form.imageList = arry
},
getDictType(){
getDicts('inspection_question_type').then((res) => {

Loading…
Cancel
Save