<template>
  <div class="div-container">
    <div class="top">
      <a-button type="primary" style="margin: 0 12px 0 0" @click="addInfo"
        ><PlusOutlined />新增</a-button
      >
      <a-button type="primary" danger><DeleteOutlined />删除</a-button>
    </div>
    <div class="table-body">
      <wtable :tableData="tableData" />
    </div>
    <dialogForm ref="dialog" />
  </div>
</template>
<script setup lang="ts">
  import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue';
  import { ref, reactive, onMounted } from 'vue';
  import wtable from '/@/views/lifeline/compt/wtable.vue';
  import dialogForm from './dialogForm.vue';

  const dialog = ref();
  // const value = ref('');
  onMounted(() => {
    console.log(dialog.value); // Proxy {…}
  });
  let tableData = reactive({
    columns: [
      {
        title: '序号',
        width: '100px',
        dataIndex: 'index',
        key: 'index',
        customRender: (text) => {
          return text.index + 1;
        },
      },
      {
        title: '所属领域',
        dataIndex: 'name',
      },
      {
        title: '所属行业',
        dataIndex: 'age',
      },
      {
        title: '预警类型',
        dataIndex: 'address',
      },
      {
        title: '操作',
        width: '200px',
        dataIndex: 'operation',
        key: 'operation',
        slots: { customRender: 'action' },
      },
    ],
  });

  function addInfo() {
    dialog.value.show();
  }
</script>

<style lang="less" scoped>
  .div-container {
    width: 100%;
    height: 100%;
    background: #fff;
    padding: 20px;
    margin-right: 0;
    overflow: hidden;

    .top {
      width: 100%;
      height: 40px;
      background: #fff;
      line-height: 40px;
      margin-bottom: 20px;
    }

    .ant-input {
      width: 240px;
      height: 30px;
    }

    .table-body {
      height: 100%;
    }
  }
</style>
