<template>
  <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="1200">
    <BasicTable @register="registerTable"
  /></BasicModal>
</template>

<script lang="ts" setup>
  import { computed, ref, unref } from 'vue';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { formSchema, columns } from './WbSurveyRiskReport.data';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  // Emits声明
  const emit = defineEmits(['register', 'success']);
  //表单配置
  const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
    labelWidth: 80,
    schemas: formSchema,
    showActionButtonGroup: false,
    baseColProps: { span: 24 },
  });
  //表单赋值
  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
    //重置表单
    // await resetFields();
    setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
    //表单赋值
    await setFieldsValue({
      ...data.record,
    });
    // 隐藏底部时禁用整个表单
    setProps({ disabled: !data?.showFooter });
  });
  //设置标题
  const title = '查看详情';
  //注册table数据
  const { tableContext } = useListPage({
    // designScope: 'basic-table-demo',
    tableProps: {
      title: '',
      useSearchForm: false,
      showTableSetting: false,
      dataSource: [
        {
          key: '1',
          name: '恒大集团',
          risk_level: '警示信息',
          news_type: '开庭公告',
          news: '新增（2024）川0105民初7693号修理合同纠纷案件',
          time: '2024-05-08',
        },
        {
          key: '2',
          name: '恒大集团',
          risk_level: '提示信息',
          news_type: '招投标',
          news: '新增数据管控系统配合新核心改造采购项目成交公示',
          time: '2024-05-06',
        },
        {
          key: '3',
          name: '恒大集团',
          risk_level: '提示信息',
          news_type: '专利信息',
          news: '数据库查询语句的生成方法、装置、设备及介质',
          time: '2024-05-25',
        },
      ],
      columns: columns,
      size: 'small',
      actionColumn: {
        ifShow: false,
        width: 100,
      },
    },
  });
  // BasicTable绑定注册
  const [registerTable] = tableContext;
</script>

<style scoped></style>
