<template>
  <div>
    <Modal title="历史沿革" footer-hide :width="64" v-model="isShow">
      <Button
        type="primary"
        style="margin-bottom: 10px"
        @click="
          $refs['addHistory'].setRow(row),
            $refs['addHistory'].setType('add'),
            $refs['addHistory'].show()
        "
        >新增记录</Button
      >
      <xy-table
        :btn-width="120"
        style="width: 100%"
        :auths="['delete', 'edit']"
        :height="360"
        :is-page="false"
        ref="xyTable"
        :list="row.id_his_evolutions_land_id_relation || []"
        :table-item="table"
        @delete="destroy"
        @editor="
          (row1) => {
            $refs['addHistory'].setId(row1.id),
             $refs['addHistory'].setType('editor');
            $refs['addHistory'].setRow(row);
            $refs['addHistory'].show();
          }
        "
      ></xy-table>
    </Modal>

    <addHistory ref="addHistory"></addHistory>
  </div>
</template>

<script>
import { index, destroy } from "@/api/system/baseForm";

import addHistory from "@/views/assets/component/addHistory.vue";
export default {
  components: {
    addHistory,
  },
  data() {
    return {
      id: "",
      isShow: false,
      row: {},

      table: [
        {
          prop: "mianjitiaozheng",
          label: "面积调整",
          width: 200,
          align: "left",
        },
        {
          prop: "qitashuoming",
          label: "其他说明",
          width: 220,
          align: "left",
        },
        {
          prop: "zichanlaiyuan",
          label: "资产来源",
          width: 220,
          align: "left",
        },
      ],
    };
  },
  methods: {
    setRow(row) {
      this.row = row;
    },
    show() {
      this.isShow = true;
    },
    hide() {
      this.isShow = false;
    },
    setId(id) {
      if (typeof id === "number") {
        this.id = id;
        this.select.filter[0].value = id;
      }
    },
    destroy (row) {
      destroy({
        id: row.id,
        table_name: 'his_evolutions'
      })
    }
  },
  computed: {},
  watch: {
    isShow(newVal) {
      if (newVal) {
        this.$refs["xyTable"].getTableData(true);
      }
    },
  },
};
</script>

<style scoped lang="scss"></style>
