فهرست منبع

上传附件修改

duy 1 سال پیش
والد
کامیت
a7d8c082db
2فایلهای تغییر یافته به همراه39 افزوده شده و 10 حذف شده
  1. 37 9
      src/views/data-fill/components/HcUpload.vue
  2. 2 1
      src/views/data-fill/wbs.vue

+ 37 - 9
src/views/data-fill/components/HcUpload.vue

@@ -7,14 +7,21 @@
         :on-exceed="uploadExceed" :on-preview="uploadPreview" :on-progress="uploadprogress"
         :on-remove="uploadRemove" :on-success="uploadSuccess" class="hc-upload-border"
         drag multiple
+        :auto-upload="autoUpload"
     >
-        <div v-loading="uploadDisabled" :element-loading-text="loadingText" class="hc-upload-loading">
-            <HcIcon name="backup" ui="text-5xl mt-4" />
-            <div class="el-upload__text">拖动文件到这里 或 <em>点击这里选择文件</em> 并上传</div>
-        </div>
+        <template #trigger>
+            <div v-loading="uploadDisabled" :element-loading-text="loadingText" class="hc-upload-loading" @click="submitUpload">
+                <HcIcon name="backup" ui="text-5xl mt-4" />
+                <div class="el-upload__text">拖动文件到这里 或 <em>点击这里选择文件</em></div>
+            </div>
+        </template>
+      
         <template #tip>
             <div class="el-upload__tip" style="font-size: 14px;">
                 {{ acceptTip }}
+                <el-button v-if="!autoUpload" class="right-3 absolute" type="primary" @click="submitUpload">
+                    确认上传
+                </el-button>
             </div>
         </template>
     </el-upload>
@@ -53,7 +60,14 @@ const props = defineProps({
         type:String,
         default:'允许格式:jpg/png/pdf/excel/word, 文件大小 小于 60MB',
     },
-
+    autoUpload:{
+        type:Boolean,
+        default:true,
+    },
+    typevalue:{
+        type:[String, Number],
+        default:'',
+    }, //附件类型
 
 })
 
@@ -67,6 +81,8 @@ const accept = ref(props.accept)
 const acceptTip = ref(props.acceptTip)
 const uploadDisabled = ref(false)
 const isCanuploadVal = ref(props.isCanupload)
+const autoUpload = ref(props.autoUpload)
+const typevalue = ref(props.typevalue)
 
 
 //监听
@@ -77,15 +93,18 @@ watch(() => [
     props.action,
     props.accept,
     props.acceptTip,
+    props.autoUpload,
+    props.typevalue,
 
-], ([fileList, datas, isCanupload, Action, Accept, Tip]) => {
+], ([fileList, datas, isCanupload, Action, Accept, Tip, auto, type]) => {
     uploadData.value = datas
     fileListData.value = fileList
     isCanuploadVal.value = isCanupload
     action.value = Action
     accept.value = Accept
     acceptTip.value = Tip
-
+    autoUpload.value = auto
+    typevalue.value = type
 })
 
 //渲染完成
@@ -155,7 +174,7 @@ const delUploadData = async (res) => {
     const { id, status } = res
 
     if (accept.value === 'application/pdf') {
-        if (status === 'uploading') {
+        if (!id || status === 'uploading') {
             uploadRef.value.abort()
             uploadDisabled.value = false
             return true
@@ -175,7 +194,7 @@ const delUploadData = async (res) => {
         }
         
     } else {
-        if (status === 'uploading') {
+        if (!id || status === 'uploading') {
             uploadRef.value.abort()
             uploadDisabled.value = false
             return true
@@ -202,4 +221,13 @@ const uploadRemove = () => {
         emit('change', { type: 'del' })
     }
 }
+
+const submitUpload = () => {
+    if (!typevalue.value && !autoUpload.value) {
+        window.$message.warning('请先选择附件类型')
+        return
+    }
+
+  uploadRef.value.submit()
+}
 </script>

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

@@ -526,7 +526,8 @@
             </div>
             <HcUpload
                 :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-manager/exceltab/add-bussfile-node" accept="application/pdf" accept-tip="允许格式:pdf"
-                :disabled="!typevalue"
+                :auto-upload="false"
+                :typevalue="typevalue"
                 @change="uploadChange"
                 @close="uploadModalClose"
             />