diff --git a/components/equData/eqDataForm.vue b/components/equData/eqDataForm.vue index d245d64..898644b 100644 --- a/components/equData/eqDataForm.vue +++ b/components/equData/eqDataForm.vue @@ -52,10 +52,11 @@ ref="ImageUpload" :is-show="isReadonly" :data="uploadDate" + @handleImageRemove="handleImageRemove" @uploadSuccess="uploadSuccess" @uploadChange="uploadChange" :maxSize="9" - :fileList="uploadOption.imgList" + :imageList="uploadOption.imgList" type="file"> @@ -222,16 +223,9 @@ export default { this.queryLaboratoryInfo(); if (this.mode === 'details') { this.form = this.currentEquData; - console.log(this.form, 'currentEquData'); let { images } = this.form; //图片填充 - if (images && images.length > 0) { - this.uploadOption.imgList = images.map((item, index) => { - return { - url: item, // 控件展示的图片用压缩版本 - }; - }); - } + this.uploadOption.imgList = images; //图表数据填充 if (this.form.data && this.form.data.length > 0) { this.$nextTick(() => { @@ -312,10 +306,16 @@ export default { handleAddTag() { this.tagSelect.visible = true; }, + handleImageRemove(artImages) { + //进行了删除图片的操作 + this.form.images = artImages.map((artImage) => { + return artImage['url']; + }); + }, //图片上传完成 uploadSuccess(data) { this.form['images'] = data.map((item) => { - return item['imgPath']; + return item['url']; }); this.handleSubmit(); }, diff --git a/equipmentData.js b/equipmentData.js index a448ddc..2201d1e 100644 --- a/equipmentData.js +++ b/equipmentData.js @@ -2,6 +2,7 @@ import { formatterMillisecond } from './utils/date'; import { EditTask } from './artUtil'; import { artApi } from './artApi'; import ArtSystem from './artSystem'; +import ArtImage from './artImage'; class EquipmentData { constructor(params) { @@ -11,7 +12,12 @@ class EquipmentData { this.id = params.id; this.name = params.name; this.equipmentId = params.equipment_id; - this.images = params.images; + this.images = []; + if (params.images) { + this.images = params.images.map((url) => { + return new ArtImage(url); + }); + } this.geometry = params.geometry; this.data = params.data; this.materialId = params.material_id || null; diff --git a/material.js b/material.js index e672c1d..1af144a 100644 --- a/material.js +++ b/material.js @@ -1,58 +1,64 @@ -import { EditTask } from "./artUtil.js"; -import { artApi } from "./artApi"; +import { EditTask } from './artUtil.js'; +import { artApi } from './artApi'; +import ArtImage from './artImage'; class Material { - constructor(params) { - if (!params) { - params = {}; + constructor(params) { + if (!params) { + params = {}; + } + this.id = params.id; + this.name = params.name; + this.description = params.description; + this.images = []; + if (params.images) { + this.images = params.images.map((url) => { + return new ArtImage(url); + }); + } + this.materialTypeId = params.material_type_id; //材料类型ID + this.materialType = params.material_type; + this.creator = params.creator; + this.updater = params.updater; + this.createTime = params.create_time; + this.updateTime = params.update_time; } - this.id = params.id; - this.name = params.name; - this.description = params.description; - this.images = params.images || null; - this.materialTypeId = params.material_type_id; //材料类型ID - this.materialType = params.material_type; - this.creator = params.creator; - this.updater = params.updater; - this.createTime = params.create_time; - this.updateTime = params.update_time; - } - //封面图(表格展示缩略图) - get imageUrlPreviewPath() { - if (this.images && this.images.length > 0) { - return this.images[0].previewPath; + //封面图(表格展示缩略图) + get imageUrlPreviewPath() { + if (this.images && this.images.length > 0) { + return this.images[0].compressionUrl; + } } - } - get imageUrlimgPath() { - if (this.images && this.images.length > 0) { - return this.images[0].imgPath; + get imageUrlimgPath() { + if (this.images && this.images.length > 0) { + return this.images[0].url; + } } - } - updateMaterial(params) { - let { name, description, images } = params; - let editTask = new EditTask(artApi.materialUpdate); - editTask.addParam("_id", this.id); - editTask.addParam("_description", description); - editTask.addParam("_name", name); - editTask.addParam("_images", images); - return new Promise((resolve, reject) => { - editTask - .execute() - .then((res) => { - if (res.data) { - let material = new Material(res.data); - resolve(material); - } - }) - .catch((err) => { - reject(err); + updateMaterial(params) { + let { name, description, images } = params; + let editTask = new EditTask(artApi.materialUpdate); + editTask.addParam('_id', this.id); + editTask.addParam('_description', description); + editTask.addParam('_name', name); + editTask.addParam('_images', images); + return new Promise((resolve, reject) => { + editTask + .execute() + .then((res) => { + if (res.data) { + let material = new Material(res.data); + resolve(material); + } + }) + .catch((err) => { + reject(err); + }); }); - }); - } - deleteMaterial(params) { - let editTask = new EditTask(artApi.materialDelete); - editTask.addParam("_id", this.id); - return editTask.execute(); - } + } + deleteMaterial(params) { + let editTask = new EditTask(artApi.materialDelete); + editTask.addParam('_id', this.id); + return editTask.execute(); + } } export default Material;