Forráskód Böngészése

feat(schematable): support column filtering

Casper Dai 3 éve
szülő
commit
b8a7cc4bdd
2 módosított fájl, 19 hozzáadás és 13 törlés
  1. 4 1
      src/components/table/Table/index.vue
  2. 15 12
      src/views/platform/media/index.vue

+ 4 - 1
src/components/table/Table/index.vue

@@ -77,7 +77,7 @@
       v-on="$listeners"
     >
       <schema-table-column
-        v-for="(col, index) in schema.cols"
+        v-for="(col, index) in cols"
         :key="index"
         :schema="col"
       />
@@ -115,6 +115,9 @@ export default {
   computed: {
     preventCopy () {
       return !!this.$listeners['row-dblclick']
+    },
+    cols () {
+      return this.schema.cols.filter(val => val)
     }
   }
 }

+ 15 - 12
src/views/platform/media/index.vue

@@ -63,6 +63,7 @@
         />
       </el-tabs>
       <schema-table
+        v-if="type"
         ref="table"
         class="has-padding"
         :schema="schema"
@@ -118,28 +119,30 @@ export default {
         [State.SUBMITTED]: createListOptions({ type: AssetType.AUDIO, status: State.SUBMITTED }),
         [State.REJECTED]: createListOptions({ type: AssetType.AUDIO, status: State.REJECTED })
       },
-      mediaAsset: null,
-      schema: {
+      mediaAsset: null
+    }
+  },
+  computed: {
+    schema () {
+      return {
         list: getAssets,
         transform: this.transform,
         cols: [
-          { prop: 'file', label: '缩略图', type: 'asset', on: this.onViewAsset },
+          this.isAudio ? null : { prop: 'file', label: '缩略图', type: 'asset', on: this.onViewAsset },
           { prop: 'name', label: '文件名' },
-          { prop: 'duration', label: '时长' },
+          this.isImage ? null : { prop: 'duration', label: '时长' },
           { prop: 'size', label: '文件大小' },
           { prop: 'createTime', label: '上传时间' },
           {
             type: 'invoke', render: [
               { label: '查看', on: this.onView },
-              { label: '提交', render: this.canSubmit, on: this.onSubmit },
+              { label: '提交', render ({ status }) { return status === State.READY }, on: this.onSubmit },
               { label: '删除', on: this.onDel }
             ]
           }
         ]
       }
-    }
-  },
-  computed: {
+    },
     currOptions: {
       get () {
         return this[this.type][this.active]
@@ -173,12 +176,12 @@ export default {
         this.$refs.table.pageTo(1)
       }
     },
-    canSubmit () {
-      return this.status === State.READY
-    },
     to (type) {
       if (this.type !== AssetType[type]) {
-        this.type = AssetType[type]
+        this.type = null
+        this.$nextTick(() => {
+          this.type = AssetType[type]
+        })
       }
     },
     transform (asset) {