<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, WORK_REPORT_MOCK_DATA, queryFormSchema } from './ordersReceiveNum-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 workReportGridOptions: VxeGridProps = {
  columns: tableColumns,
  height: '800px',
  proxyConfig: {
    autoLoad: true,
    ajax: {
      query: async () => ({ items: WORK_REPORT_MOCK_DATA, total: WORK_REPORT_MOCK_DATA.length }),
    },
  },
  rowConfig: { keyField: 'id' },
  pagerConfig: { enabled: true, pageSize: 100, pageSizes: [10, 20, 50, 100] },
};

// 创建表格实例
const [WorkReportTable, { handleQuery, handleReset }] = useVbenVxeGrid({ formOptions, gridOptions: workReportGridOptions });

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

<template>
  <Page :auto-content-height="true">
    <div class="task-report-container">
      <!-- 接单人数据统计表格 -->
      <div class="table-container">
        <WorkReportTable table-title="接单人数据统计">
          <template #toolbar-tools>
            <ElSpace>
              <ElButton 
                type="primary"
                @click="handleQuery"
                v-access:code="['system:workDataStatistics:query']"
              >
                查询
              </ElButton>
              <ElButton 
                @click="handleReset"
                v-access:code="['system:workDataStatistics:reset']"
              >
                重置
              </ElButton>
              <ElButton 
                @click="handleExport"
                v-access:code="['system:workDataStatistics:export']"
              >
                导出
              </ElButton>
            </ElSpace>
          </template>
        </WorkReportTable>
      </div>
    </div>
  </Page>
</template>

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