antdesign-vue表格点击获取行数据

  • Post author:
  • Post category:vue


<div>
    <a-table
      rowKey="id"
      key="list"
      style="width: 100vw"
      :columns="columns"
      :data-source="tableData"
      :customRow="customRow" //选中绑定重点
      :pagination="false"
      :scroll="{ y: '72vh', x: 250 }"
    />
    <div class="returnbut">
      <van-button @click="$router.go(-1)">返回</van-button>
    </div>
  </div>

方法

data() {
    return {
     // 重点
     customRow: (record, index) => {
        return {
          on: {
            click: () => {
             console.log(record,index);// ok
              tableSelectRow(record.qisOpnChecklistHeadId,record.qisOpnChecklistDistributionId).then(res=>{
              
                if(res){
 
                this.$router.push({
                  name: "Implementation",
                  query: {...record},
                });
                }else{
                  
                  this.$router.push({
                  name: "InspectionFrequency",
                  query: {...record},
                });
                }
              })
            
              
            },
          },
        };
      },

      columns: [
        {
          dataIndex: "checklistName",
          key: "checklistName",
          id: "1",
          title: this.$t("table.ChecklistName"),
          width: 150,
          fixed: "left",
          scopedSlots: { customRender: "name" },
        },
        {
          title: this.$t("table.ManufacturingProcess"),
          dataIndex: "productionProcess",
          key: "productionProcess",
          fixed: "left",
          width: 100,
          id: "2",
        },
        {
          title: this.$t("table.base"),
          dataIndex: "site",
          key: "site",
          width: 150,
          id: "3",
        },
        {
          title: this.$t("table.FactoryArea"),
          key: "plant",
          dataIndex: "plant",
          width: 150,
          scopedSlots: { customRender: "tags" },
          id: "4",
        },
        {
          title: this.$t("table.StayWire"),
          key: "line",
          dataIndex: "line",
          width: 250,
          scopedSlots: { customRender: "line" },
          id: "5",
        },
        {
          title: this.$t("table.varieties"),
          key: "productBo",
          dataIndex: "productBo",
          width: 150,
          scopedSlots: { customRender: "productBo" },
          id: "6",
        },
        {
          title: this.$t("table.entryName"),
          key: "projectName",
          dataIndex: "projectName",
          width: 150,
          scopedSlots: { customRender: "projectName" },
          id: "7",
        },
      ],
      tableData: [],
    };
  },



版权声明:本文为qq_41792374原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。