<script lang="ts" setup>
// 导入部分
import type { VbenFormProps } from '@vben/common-ui';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { ElButton, ElSpace } from 'element-plus';
import { tableColumns, DISTRICT_INSPECT_MOCK_DATA, queryFormSchema } from './districtInspect-data';

// 表单配置
const formOptions: VbenFormProps = {
  commonConfig: {
    labelWidth: 80,
    componentProps: { allowClear: true },
  },
  schema: queryFormSchema(),
  wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-4',
};

// 片区检查表格配置
const districtInspectGridOptions: VxeGridProps = {
  columns: tableColumns,
  height: '800px',
  proxyConfig: {
    autoLoad: true,
    ajax: {
      query: async () => ({ items: DISTRICT_INSPECT_MOCK_DATA, total: DISTRICT_INSPECT_MOCK_DATA.length }),
    },
  },
  rowConfig: { keyField: 'id' },
  pagerConfig: { enabled: true, pageSize: 100, pageSizes: [10, 20, 50, 100] },
};

// 创建表格实例
const [DistrictInspectTable] = useVbenVxeGrid({ formOptions, gridOptions: districtInspectGridOptions });

// 导出按钮点击事件
const handleExport = () => {
  console.log('导出数据');
  // TODO: 添加导出逻辑
};
</script>

<template>
  <Page :auto-content-height="true">
    <div class="district-inspect-container">
      <!-- 片区检查表格 -->
      <div class="table-container">
        <DistrictInspectTable table-title="片区检查列表">
          <template #toolbar-tools>
            <ElSpace>
              <ElButton 
                @click="handleExport"
                v-access:code="['system:districtInspect:export']"
              >
                导出
              </ElButton>
            </ElSpace>
          </template>
          </DistrictInspectTable>
      </div>
    </div>
  </Page>
</template>

<style scoped lang="scss">
.district-inspect-container {
  min-height: calc(100vh - 120px);
  padding: 16px;
  background-color: #fff;
}
</style>
