Kaynağa Gözat

feat: 上传列表组件 取消事件传参改为uid

任一存 4 yıl önce
ebeveyn
işleme
b6db3f4072

+ 7 - 4
src/views/material/components/uploadList1.1.0.vue

@@ -35,7 +35,7 @@
             v-show="(taskItem.status === 'LOADING' && taskItem.ifKnowProgress) || taskItem.status === 'FAIL'"
             class="cancel-btn"
             :src="require('@/assets/images/icons/material_preview_upload_cancel@2x.png')"
-            @click="onClickCancel(index)"
+            @click="onClickCancel(taskItem.uid)"
           />
         </div>
         <div class="progress-bar" v-if="taskItem.ifKnowProgress && taskItem.status === 'LOADING'" :style="{width: Math.round(taskItem.progress * 100) + '%'}"></div>
@@ -60,7 +60,8 @@ export default {
        *  ifKnowProgress: Boolean // false则进度条效果是loading而不是具体进度
        *  progress:Number // 进度,0到1之间。
        *  status: 'FAIL' | 'LOADING' // 将来可能还需要:'SUCCESS', 'CANCELLED'
-       *  statusText
+       *  statusText,
+       *  uid: String,
        * }
        */
       type: Array,
@@ -72,6 +73,7 @@ export default {
       //     progress: '0.3',
       //     status: 'LOADING',
       //     statusText: '上传中',
+      //     uid: 'a'
       //   },
       //   {
       //     title: '标题',
@@ -79,6 +81,7 @@ export default {
       //     progress: '0.3',
       //     status: 'LOADING',
       //     statusText: '后台处理中',
+      //     uid: 'b'
       //   },
       //   {
       //     title: '标题',
@@ -113,8 +116,8 @@ export default {
     onClickExpand() {
       this.expandSwitch = !this.expandSwitch
     },
-    onClickCancel(index) {
-      this.$emit('cancel-task', index)
+    onClickCancel(uid) {
+      this.$emit('cancel-task', uid)
     },
   }
 }