Преглед изворни кода

站点基本信息站点照片上传回显,删除等功能完善

ming пре 3 година
родитељ
комит
34438590cf
1 измењених фајлова са 34 додато и 55 уклоњено
  1. 34 55
      src/views/siteManage/basicInfo/index.vue

+ 34 - 55
src/views/siteManage/basicInfo/index.vue

@@ -264,6 +264,7 @@ export default defineComponent({
     const ruleForm = ref({})
 
     const newArray = ref([])
+    const dataSetRe=ref([])
 
     function handlePictureCardPreview(file) {
       console.log('file')
@@ -290,27 +291,42 @@ export default defineComponent({
 
     //上传成功的回调
     function handleUpAvatar(res) {
-       newArray.value=[]
-      //新上传的
-      dataSet.fileList.push(res.data)
 
-      //回显的图片
-      var bb = []
-      var aa = fileListImages.value
-      aa.forEach(function (item) {
-        bb.push(item.url.substring(27))
+      dataSetRe.value=[]
+      dataSet.fileList=[]
+      newArray.value=[]
+
+      dataSet.fileList.push(res.data)
+ 
+      dataSet.fileList.forEach(function (item) {
+        dataSetRe.value.push({ url: fileImages.value + item })
       })
 
-      //新上传加回显组合的新数组
-      newArray.value = dataSet.fileList.concat(bb)
-      console.log(newArray.value)
-      console.log('newArray.value')
+      if (fileListImages.value) {
+        fileListImages.value = fileListImages.value.concat(dataSetRe.value)
+      }else{
+        fileListImages.value=dataSetRe.value
+      }
+
+
+     fileListImages.value.forEach(function(item){
+       
+       newArray.value.push(item.url.substring(27))
+     })
+
+    console.log('newArray.value')
+    console.log(newArray.value)
+
+
     }
 
     //删除照片
     function handleRemove(res) {
+      newArray.value=[]
       console.log('删除')
       console.log(res)
+      console.log('fileListImages.value')
+      console.log(fileListImages.value)
 
       Array.prototype.indexOf = function (val) {
         for (var i = 0; i < this.length; i++) {
@@ -328,52 +344,11 @@ export default defineComponent({
       fileListImages.value = fileListImages.value.filter(
         (v) => v.url !== res.url
       )
-      var bb = []
       fileListImages.value.forEach(function (item) {
-        bb.push(item.url.substring(27))
+        newArray.value.push(item.url.substring(27))
       })
 
-      if (res.name) {
-        // alert('新增的删除')
-        dataSet.fileList.remove(res.name)
-        console.log('新增的删除后')
-        console.log(dataSet.fileList)
-      } else {
-        // alert('回显的删除')
-
-        bb.remove(res.url)
-        console.log('回显的删除后')
-        console.log(bb)
-
-        // if (dataSet.fileList) {
-        //   console.log('删除回显有新增时,回显的列表要加上新增的数据')
-        //   console.log(dataSet.fileList)
-        //   let uu = []
-        //   dataSet.fileList.forEach(function (item) {
-        //     uu.push({ url: window.PLATFROM_CONFIG.images + item, name: item })
-        //   })
-        //   console.log('uu')
-        //   console.log(uu)
-
-        //   fileListImages.value = fileListImages.value.concat(uu)
-        //   console.log( 'fileListImages.value')
-        //   console.log( fileListImages.value)
-
-        // }
-      }
-
-      if (dataSet.fileList) {
-        newArray.value = dataSet.fileList.concat(bb)
-      }
-      if (bb) {
-        newArray.value = bb.concat(dataSet.fileList)
-      }
-
-      if (dataSet.fileList && bb) {
-        newArray.value = dataSet.fileList.concat(bb)
-      }
-
-      console.log('新增和回显所有删除后组成的新数组')
+   
       console.log('newArray.value')
       console.log(newArray.value)
     }
@@ -580,6 +555,8 @@ export default defineComponent({
         console.log(newVal)
         if (props.activeName == 'first') {
           dataSet.fileList=[]
+          newArray.value=[]
+          
 
           getSite()
           dynamicPropertiesDroplist(2)
@@ -593,6 +570,7 @@ export default defineComponent({
       (newVal) => {
         if (newVal == 'first') {
           dataSet.fileList=[]
+          newArray.value=[]
           getSite()
           dynamicPropertiesDroplist(2)
           dynamicPropertiesDroplist(1)
@@ -770,6 +748,7 @@ export default defineComponent({
       isDisable,
 
       newArray,
+      dataSetRe
     }
   },
 })