图片上传前端逻辑修改

master
maxw@mesnac.com 8 months ago
parent 806e739ac2
commit 18e677ee36

@ -287,6 +287,11 @@ export default {
},
//
handleRemove(file, fileList) {
const url = file.url;
console.log(url);
const i = this.imgAddress.findIndex((x)=> x.url === url);
this.imgAddress.splice(i,1);
console.log(this.imgAddress)
//filefileListPut
if(this.fileListPut.length > 0){
this.fileListPut = this.fileListPut.filter((item, index)=>{
@ -311,6 +316,7 @@ export default {
//
this.fileListPut.push(currentFile);
console.log(this.fileListPut)
console.log(this.imgAddress)
},
@ -372,6 +378,9 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
console.log(this.imgAddress.length)
this.imgAddress.length=0;
// this.form.fileUrls.length=0;
this.fileListShow = [];
this.reset();
this.open = true;
@ -379,9 +388,14 @@ export default {
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const knowledgeRepairId = row.knowledgeRepairId || this.ids
getKnowledgeRepair(knowledgeRepairId).then(response => {
console.log(response.data.systemFiles)
for (let element of response.data.systemFiles) {
this.imgAddress.push(element.url)
}
this.form = response.data;
this.fileListShow = response.data.systemFiles
console.log(this.fileListShow)
@ -394,13 +408,18 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.knowledgeRepairId != null) {
this.form.fileUrls = [];
this.form.fileUrls = this.imgAddress;
console.log(this.form.fileUrls)
updateKnowledgeRepair(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.imgAddress.length = 0;
this.form.fileUrls.length=0;
this.open = false;
this.getList();
});
} else {
// this.form.fileUrls.length=0;
this.form.fileUrls = this.imgAddress;
addKnowledgeRepair(this.form).then(response => {
this.$modal.msgSuccess("新增成功");

@ -329,6 +329,11 @@ export default {
},
//
handleRemove(file, fileList) {
const url = file.url;
console.log(url);
const i = this.imgAddress.findIndex((x)=> x.url === url);
this.imgAddress.splice(i,1);
console.log(this.imgAddress)
//filefileListPut
if(this.fileListPut.length > 0){
this.fileListPut = this.fileListPut.filter((item, index)=>{
@ -353,6 +358,7 @@ export default {
//
this.fileListPut.push(currentFile);
console.log(this.fileListPut)
console.log(this.imgAddress)
},
@ -427,6 +433,8 @@ export default {
},
/** 新增按钮操作 */
handleAdd() {
console.log(this.imgAddress.length)
this.imgAddress.length=0;
this.reset();
this.fileListShow = [];
this.open = true;
@ -437,8 +445,13 @@ export default {
this.reset();
const knowledgeMaintId = row.knowledgeMaintId || this.ids
getKonwledgeMaint(knowledgeMaintId).then(response => {
console.log(response.data.systemFiles)
for (let element of response.data.systemFiles) {
this.imgAddress.push(element.url)
}
this.form = response.data;
this.fileListShow = response.data.systemFiles
console.log(this.fileListShow)
this.open = true;
this.title = "修改保养知识库";
});
@ -448,21 +461,23 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.knowledgeMaintId != null) {
this.form.fileUrls = [];
this.form.fileUrls = this.imgAddress;
updateKonwledgeMaint(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.imgAddress.length = 0;
this.form.fileUrls.length=0;
this.open = false;
// this.imgAddress.length = 0;
this.getList();
});
} else {
this.form.fileUrls = this.imgAddress;
addKonwledgeMaint(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.imgAddress.length = 0;
this.open = false;
console.log(this.imgAddress)
this.imgAddress.length = 0;
this.getList();
});
}

Loading…
Cancel
Save