  <template>
  <div class="relation">
    <el-row>
      <el-col :span="12">
        <div class="top">
          <h5>关系范围</h5>
          <el-button
            type="primary"
            size="small"
            icon="el-icon-circle-plus"
            @click="addItem"
            >添加</el-button
          >
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="date" label="日期" width="180">
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="180">
          </el-table-column>
          <el-table-column prop="address" label="地址"> </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <i
                class="el-icon-delete"
                @click="handleEdit(scope.$index, scope.row)"
              ></i>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <!-- 新增弹框 -->
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <span>这是一段信息</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { dict_rels } from "@/api/workScope.js";
export default {
  data() {
    return {
      dialogVisible: false,
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
    };
  },
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    handleEdit() {
      this.dialogVisible = true;
    },
    addItem() {
      this.dialogVisible = true;
    },
    //获取关系范围
    getRelation() {
      dict_rels({ target: "rtn" }).then((res) => {
        console.log(res);
      });
    },
  },
  mounted() {
    this.getRelation();
  },
};
</script>

<style lang="less" scoped>
.relation {
  .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
}
</style>