Kaynağa Gözat

Merge branch 'master' into test-dev

duy 2 ay önce
ebeveyn
işleme
065a7413f5

+ 15 - 2
src/views/data-fill/components/HcUpload.vue

@@ -152,7 +152,16 @@ watch(() => [
 },
 { immediate: true },
 )
+watch(() => [
+    props.typevalue,
+  
+], ([ type]) => {
+    typevalue.value = type
+         emit('change', { type: 'success' })
 
+},
+{ immediate: true },
+)
 // 在watch中添加对fileList的深度监听
 watch(() => props.fileList, (newVal) => {
   fileListData.value = [...newVal] // 使用新数组保证响应性
@@ -206,8 +215,11 @@ const handleFileChange = async (file, fileList) => {
         url:'',
       }))
 
-    
-    fileListData.value = fileList.filter(file => isFileSize(file?.size, 60))
+    fileListData.value = fileList.filter(file => {
+      // 检查 size 属性是否存在且等于 60M,或者 size 属性不存在
+      return (file.size !== undefined && isFileSize(file?.size, 60)) || file.size === undefined
+    })
+  
     const pdfUrLArray = await getPdfUrl(fileListData.value)
     fileListData.value.forEach((item, index) => {
         if (item.raw && pdfUrLArray[index]) {
@@ -216,6 +228,7 @@ const handleFileChange = async (file, fileList) => {
         }
       })
 
+      
 }
 //上传文件前预览pdf
 const pdfLoading = ref(false)

+ 22 - 2
src/views/data-fill/wbs.vue

@@ -1417,7 +1417,7 @@
 </template>
 
 <script setup>
-import { nextTick, onMounted, ref, watch } from 'vue'
+import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { useAppStore } from '~src/store'
 import { HcIsButton } from '~src/plugins/IsButtons'
@@ -3119,6 +3119,7 @@ const getAttachmentList = async () => {
 
 // 新增拖拽相关代码
 const attachmentListRefs = ref([])
+const sortableInstances = ref([]) 
 
 const setAttachmentListRef = (el) => {
   if (el) {
@@ -3130,7 +3131,7 @@ const setAttachmentListRef = (el) => {
 const initSortable = () => {
   nextTick(() => {
     attachmentListRefs.value.forEach((el, index) => {
-      new Sortable(el, {
+      const sortable = new Sortable(el, {
         animation: 150,
         ghostClass: 'sortable-ghost',
         handle: '.hc-attachment-item', // 整个条目可拖拽
@@ -3147,10 +3148,29 @@ const initSortable = () => {
           }
         },
       })
+      sortableInstances.value.push(sortable) // 存储 Sortable 实例引用
     })
   })
 }
+// 销毁 Sortable 实例
+const destroySortableInstances = () => {
+  sortableInstances.value.forEach(instance => {
+    instance.destroy()
+  })
+  sortableInstances.value = [] // 清空引用数组
+}
 
+// 监听 attachmentModal 的变化
+watch(attachmentModal, (newVal) => {
+  if (!newVal) {
+    destroySortableInstances() // 关闭弹窗时销毁 Sortable 实例
+  } else {
+    initSortable() // 打开弹窗时初始化 Sortable
+  }
+})
+onUnmounted(() => {
+  destroySortableInstances()
+})
 // 保存文件顺序到后端
 const saveFileOrderLoad = ref(false)
 const saveFileOrder = async () => {