import { BasicColumn, FormSchema } from '@/components/Table';
import { Tag } from 'ant-design-vue';
import { h } from 'vue';

export const columns: BasicColumn[] = [
  {
    title: '所属班组',
    dataIndex: 'areaName',
    width: 200,
  },
  {
    title: '护林员',
    dataIndex: 'name',
  },
  {
    title: '手机号码',
    dataIndex: 'account',
  },
  {
    title: '打卡次数',
    dataIndex: 'dakacishu',
  },
  {
    title: '巡检次数',
    dataIndex: 'xunjian',
  },
  {
    title: '打卡点数量',
    dataIndex: 'dakadian',
  },
];

export const InspectionColumns: BasicColumn[] = [
  {
    title: '乡镇/村庄',
    dataIndex: 'townName',
  },
  {
    title: '护林员姓名',
    dataIndex: 'name',
  },
  {
    title: '在线状态',
    dataIndex: 'state',
    customRender: ({ record }) => {
      const state = record.state;
      const enable = ~~state === '在线';
      const color = enable ? 'green' : 'red';
      const text = state;
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '离线时长',
    dataIndex: 'onLineTime',
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    component: 'Input',
    ifShow: false,
  },
  {
    field: 'pointName',
    label: '打卡点名称',
    component: 'Input',
  },
  {
    field: 'areaId',
    label: '行政区划',
    required: true,
    slot: 'areaId',
  },
  {
    field: 'userId',
    label: '责任人',
    slot: 'userId',
    required: true,
  },
];
