vue Antd的Table组件嵌套Table以及选择框联动

<template>

  <a-drawer

    title="为模板添加产品"

    width="70%"

    :visible="visible"

    :body-style="{ paddingBottom: '80px' }"

    @close="visible = false"

    :maskClosable="false"

    :keyboard="false"

  >

    <a-input v-model.lazy="searchGoodName" placeholder="搜索产品" allowClear>

      <a-icon slot="prefix" type="search" />

    </a-input>

    <scroll-load class="scroll-load"></scroll-load>

    <!-- 页脚 -->

    <div

      :style="{

        position: 'absolute',

        right: 0,

        bottom: 0,

        width: '100%',

        borderTop: '1px solid #e9e9e9',

        padding: '10px 16px',

        background: '#fff',

        textAlign: 'right',

        zIndex: 1,

      }"

    >

      <a-button :style="{ marginRight: '8px' }" @click="visible = false">取消</a-button>

      <a-button type="primary" @click="handleOkClick">保存</a-button>

    </div>

  </a-drawer>

</template>

<script>

import scrollLoad from '@/components/ScrollLoad/index'

const columns = [

  { title: '序号', customRender: (text, record, index) => `${index + 1}`, fixed: 'left', width: 70, align: 'center' },

  {

    title: '产品主图',

    dataIndex: 'image_link',

    key: 'image_link',

    scopedSlots: { customRender: 'image_link' },

    width: 100,

  },

  {

    title: '商品名',

    dataIndex: 'goods_name',

    key: 'goods_name',

  },

]

export default {

  name: 'AddGoods',

  components: {

    scrollLoad

  },

  data() {

    return {

      visible: false,

      searchGoodName: '',

      columns,

      selectedRowKeys: []

    }

  },

  computed: {

    rowSelection() {

      const _this = this

      const { selectedRowKeys } = this

      return {

        selectedRowKeys,

        onChange: (selectedRowKeys) => {

          _this.selectedRowKeys = selectedRowKeys

        },

      }

    },

  },

  methods: {

    handleOkClick() {},

  },

}

</script>

<style lang="stylus" scoped>

.scroll-load {

  margin-top: 30px;

}

</style>

复制直接格式化一下就可以用

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容