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 { import {
queryDeptDropdownList, queryDeptDropdownList,
} from "@/common/rec"; } 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 { getDicts } from "@/common/system/dict/data";
import { baseUrl } from "@/utils/config"; import { baseUrl } from "@/utils/config";
export default { export default {
@ -115,17 +116,52 @@ export default {
this.getDictType() this.getDictType()
}, },
methods: { methods: {
afterRead(event) { async afterRead(event) {
// let files = Array.isArray(event) ? event : [event] let lists = [].concat(event.file);
this.fileList = this.fileList.concat(event.file) let fileListLen = this[`fileList${event.name}`].length;
// console.log(this.fileList); lists.map((item) => {
this.fileList.forEach( file => { this[`fileList${event.name}`].push({
this.uploadFile(file) ...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) { onDelete(event) {
this.fileList.splice(event.index, 1) this[`fileList${event.name}`].splice(event.index, 1);
this.form.imageList.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(){ getDictType(){
getDicts('inspection_question_type').then((res) => { getDicts('inspection_question_type').then((res) => {

Loading…
Cancel
Save