|
|
|
@ -268,7 +268,7 @@ export default {
|
|
|
|
|
this.isCommonName = true;
|
|
|
|
|
const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'; // 允许JPG和PNG格式
|
|
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2;
|
|
|
|
|
//判断是否有相同的图片,如何有即提示并添加失败
|
|
|
|
|
// 判断是否有相同的图片,如何有即提示并添加失败
|
|
|
|
|
if(this.fileListPut.length > 0){
|
|
|
|
|
this.fileListPut.forEach((item,index)=>{
|
|
|
|
|
if(item.name == file.name){
|
|
|
|
@ -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)
|
|
|
|
|
//根据传进来删除的file里图片,同时删除保存在fileListPut的相同图片
|
|
|
|
|
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("新增成功");
|
|
|
|
|