<template>
  <div class="message-list">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column type="index" width="50"> </el-table-column>
      <el-table-column prop="jrid" label="信息ID"> </el-table-column>
      <el-table-column prop="jraddressesid" label="地址ID"> </el-table-column>
      <el-table-column prop="jrname" label="姓名"> </el-table-column>
      <el-table-column prop="jrlevel" label="等级ID"> </el-table-column>
      <el-table-column prop="jrtel" label="电话号码"> </el-table-column>
      <el-table-column prop="levelname" label="等级名称"> </el-table-column>
      <el-table-column prop="addressname" label="地址名称"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="updateRow(scope.row)"
            type="text"
            size="small"
          >
            修改
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getMessage } from "@/api/message";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  methods: {
    //获取信息接口
    getMessageList() {
      getMessage().then((res) => {
        console.log(res);
        this.tableData = res.data;
      });
    },
    updateRow(row){
      console.log(row)
      this.$router.push({
        path: '/message/addMessage',
        query: {
          id: row.jrid
        }
      })
    }
  },
  created() {
    this.getMessageList();
  },
};
</script>

<style scoped>
.message-list {
  width: 80%;
  margin: 120px auto;
}
</style>