// @ts-ignore: 忽略
import type { FormSchemaGetter } from '#/adapter/form';
// @ts-ignore: 忽略
import type { VxeGridProps } from '#/adapter/vxe-table';

// 抽屉表单配置
export const drawerFormSchema: any | FormSchemaGetter = () => [
  {
    component: 'DatePicker',
    componentProps: {
      placeholder: '请选择调查时间',
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      width: '100%',
    },
    fieldName: 'surveyDate',
    label: '调查时间',
    rules: 'required',
  },
  // {
  //   component: 'DatePicker',
  //   componentProps: {
  //     placeholder: '请选择调查结束时间',
  //     type: 'datetime',
  //     format: 'YYYY-MM-DD HH:mm:ss',
  //     valueFormat: 'YYYY-MM-DD HH:mm:ss',
  //     width: '100%',
  //   },
  //   fieldName: 'surveyEndTime',
  //   label: '调查结束时间',
  //   rules: 'required',
  // },
  {
    component: 'SectionTitle',
    fieldName: '_section_title',
    hideLabel: true,
    componentProps: {
      title: '油站策略',
    },
  },
  {
    fieldName: 'stationInfoTable',
    label: '油站基本信息',
    hideLabel: true,
    renderComponentContent: () => {
      return {
        default: () => [],
      };
    },
  },
  {
    component: 'SectionTitle',
    fieldName: '_section_title',
    hideLabel: true,
    componentProps: {
      title: '价格销售',
    },
  },
  {
    fieldName: 'oilPriceTable',
    label: '油品价格和销量差',
    hideLabel: true,
    renderComponentContent: () => {
      return {
        default: () => [],
      };
    },
  },
];

// 油站基本信息表格列配置
export const stationInfoColumns: VxeGridProps['columns'] = [
  {
    field: 'competitorName',
    title: '油站',
    width: 120,
    fixed: 'left',
    formatter: ({ row }) => {
      return row.competitorName || row.stationName || '-';
    },
  },
  {
    field: 'stationNatureName',
    title: '油站性质',
    width: 100,
    formatter: ({ row }) => {
      return row.stationNatureName || '-';
    },
  },
  {
    field: 'isCompetitor',
    title: '竞争关系',
    width: 120,
    formatter: ({ row }) => {
      return row.isCompetitor === 1 ? '是' : '否';
    },
  },
  {
    field: 'distanceKm',
    title: '距离(KM)',
    width: 100,
  },
  {
    field: 'promotionActivities',
    title: '优惠活动',
    width: 200,
    editRender: { name: 'textarea' },
  },
  {
    field: 'valueAddedServices',
    title: '增值服务',
    width: 200,
    editRender: { name: 'textarea' },
  },
  {
    field: 'equipmentConfigChanges',
    title: '油站设备配置变化',
    width: 200,
    editRender: { name: 'textarea' },
  },
];

// 油品价格和销量差表格列配置
export const oilPriceColumns: VxeGridProps['columns'] = [
  {
    field: 'oilType',
    title: '油品',
    width: 100,
    fixed: 'left',
  },
  {
    field: 'listingPrice',
    title: '挂牌价',
    width: 100,
    children: [],
  },
  {
    field: 'discountPrice',
    title: '优惠价',
    width: 100,
    children: [],
  },
  {
    field: 'salesDifference',
    title: '销量差',
    width: 120,
    children: [],
  },
];

// 默认表格列配置（兼容旧代码，实际使用上面两个表格）
export const defautTableColumns: VxeGridProps['columns'] = stationInfoColumns;
