import { BasicColumn, FormSchema } from '/@/components/Table';
// import { sysDictQueryList } from '/@/api/sys/sysDictApi';
import { DescItem } from '/@/components/Description';
import { listDictModel } from '/@/api/common';
import { h } from 'vue';
export const columns: BasicColumn[] = [
  // {
  //   title: '任务编号',
  //   dataIndex: 'jobId',
  // },
  {
    title: '任务名称',
    dataIndex: 'jobName',
  },
  {
    title: '任务分组',
    dataIndex: 'jobGroup',
  },
  {
    title: '调用目标字符串',
    dataIndex: 'invokeTarget',
  },
  {
    title: '执行表达式',
    dataIndex: 'cronExpression',
  },
  {
    title: '任务状态',
    dataIndex: 'status',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
    fixed: 'right',
  },
];
// 搜索框
export const searchFormSchema: FormSchema[] = [
  {
    field: 'jobName',
    label: '任务名称',
    component: 'Input',
    componentProps: {
      placeholder: '请输入表描述',
    },
  },

  {
    field: 'jobStats',
    label: '任务状态',
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'quartz_job_status',
      },
    },
  },
];
export const helpText =
  "Bean调用示例：ryTask.ryParams('ry')\r\nClass类调用示例：com.ruoyi.quartz.task.RyTask.ryParams('ry')参数说明：支持字符串，布尔类型，长整型，浮点型，整型";
// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '任务名称',
    field: 'jobName',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '任务名称',
    },
  },
  {
    label: '调用目标字符串',
    field: 'invokeTarget',
    labelWidth: '200',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '调用目标字符串',
    },
    itemProps: {
      extra: h('div', [
        h('div', [
          // h('div', { class: 'iconfont icon-unlock' }),
          h('div', "Bean调用示例：ryTask.ryParams('tr')"),
        ]),
        h('div', "Class类调用示例：com.tuoren.quartz.task.RyTask.ryParams('tr')"),
        h('div', '参数说明：支持字符串，布尔类型，长整型，浮点型，整型'),
      ]),
    },
  },
  {
    label: '执行表达式',
    field: 'cronExpression',
    required: true,
    component: 'Input',
    itemProps: {
      extra: h('span', [
        h('span', '如果不知道CRON 怎么写, 请点击'),
        h(
          'a',
          { href: 'https://www.bejson.com/othertools/cron/', target: '_blank' },
          'CRON 在线生成器',
        ),
        h('span', '查看.'),
      ]),
    },
  },
  {
    label: '执行策略',
    field: 'misfirePolicy', //未知
    component: 'ApiRadioGroup',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'misfire_policy',
      },
    },
    defaultValue: '1',
  },

  {
    label: '任务状态',
    field: 'status',
    component: 'ApiRadioGroup',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'quartz_job_status',
      },
    },
    defaultValue: '0',
  },
  {
    label: '并发策略',
    field: 'concurrent',
    component: 'ApiRadioGroup',
    componentProps: {
      options: [
        { label: '正常', value: 1 },
        { label: '禁止', value: 0 },
      ],
    },
    defaultValue: 1,
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入备注',
    },
  },
];
export const viewSchema: DescItem[] = [
  {
    label: '任务名称',
    field: 'jobName',
  },
  {
    label: '任务分组',
    field: 'jobGroup',
  },
  {
    label: '调用目标字符串',
    field: 'invokeTarget',
  },
  {
    label: '执行表达式',
    field: 'cronExpression',
  },
  {
    label: '任务状态',
    field: 'status',
  },
  {
    label: '创建时间',
    field: 'createTime',
  },
];
