研发图纸文件管理系统-前端项目
chenghongxing
2020-07-16 e6fb49260d1509144c389db89a6f5f95d882bbe3
feat: add support for scopedSlots in StandardTable.vue; :star2:
新增:StandardTable.vue 组件增加 scopedSlots 的支持;
2个文件已修改
27 ■■■■ 已修改文件
src/components/table/StandardTable.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/list/QueryList.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/table/StandardTable.vue
@@ -25,6 +25,9 @@
      :pagination="pagination"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: updateSelect}"
    >
      <template slot-scope="text, record, index" :slot="slot" v-for="slot in scopedSlots">
        <slot :name="slot" v-bind="{text, record, index}"></slot>
      </template>
    </a-table>
  </div>
</template>
@@ -36,7 +39,8 @@
  data () {
    return {
      needTotalList: [],
      selectedRowKeys: []
      selectedRowKeys: [],
      scopedSlots: []
    }
  },
  methods: {
@@ -61,9 +65,14 @@
        }
      })
      return totalList
    },
    getScopedSlots(columns) {
      return columns.filter(item => item.scopedSlots && item.scopedSlots.customRender)
        .map(item => item.scopedSlots.customRender)
    }
  },
  created () {
    this.scopedSlots = this.getScopedSlots(this.columns)
    this.needTotalList = this.initTotalList(this.columns)
  },
  watch: {
src/pages/list/QueryList.vue
@@ -97,7 +97,14 @@
        :dataSource="dataSource"
        :selectedRows="selectedRows"
        @change="onchange"
      />
      >
        <div slot="description" slot-scope="{text}">
          {{text}}
        </div>
        <div slot="action" slot-scope="{text, record, index}">
          <a-icon type="edit" />{{index}}
        </div>
      </standard-table>
    </div>
  </a-card>
</template>
@@ -111,7 +118,8 @@
  },
  {
    title: '描述',
    dataIndex: 'description'
    dataIndex: 'description',
    scopedSlots: { customRender: 'description' }
  },
  {
    title: '服务调用次数',
@@ -129,6 +137,10 @@
    title: '更新时间',
    dataIndex: 'updatedAt',
    sorter: true
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]