import { ref, reactive, computed } from 'vue'
import { TASK_STATUS } from '@/utils/dictionary'
import { PilotPlatform } from '@/api/task/index'

const platformList = ref([])

export const search = reactive({
  search: [
    {
      label: '任务状态',
      type: 'select',
      key: 'status',
      props: {
        placeholder: '请输入任务状态',
        options: TASK_STATUS
      }
    },
    {
      label: '平台名称',
      type: 'select',
      key: 'platformName',
      props: {
        placeholder: '请输入平台名称',
        options: platformList
      }
    },
    {
      label: '客户名称',
      key: 'tenantName',
      props: {
        placeholder: '请输入客户名称'
      }
    },
    {
      label: '选择日期',
      type: 'date',
      key: 'taskStartTime',
      props: {
        placeholder: '请选择日期'
      }
    },
    {
      label: '任务名称',
      key: 'taskName',
      props: {
        placeholder: '请选择任务名称'
      }
    }
  ]
})

export const getPlatform = () => {
  PilotPlatform().then(({ data }) => {
    platformList.value = data?.records.map(it => ({
      ...it,
      label: it.platformName,
      value: it.platformName
    }))
  })
}

