import { getQuestionType } from '@/api/task/index.js'
import { dataToSelect } from '@/utils/handleData.js'
import { setQuestion, removeQuestion } from './question.js'
import { ref } from 'vue'

export const QUESTION_TYPE = ref([])
export const QUESTION_TYPE_ALL = ref([{ label: '全部', value: 'all' }])

export const TASK_STATUS = [
  { label: '待飞行', value: 1 },
  { label: '飞行中', value: 2 },
  { label: '飞行失败', value: 3 },
  { label: '飞行完成', value: 4 }
]

export const TASK_MODE = [
  { label: '机场服务', value: 1 },
  { label: '人工巡检', value: 2 }
]

export const TASK_TYPE = [
  { label: '日常巡检', value: 1 },
  { label: '应急巡检', value: 2 }
]

export const QUESTION_STATUS = [
  { label: '已确认', value: 1 },
  { label: '已忽略', value: 2 },
  { label: '待确认', value: 3 }
]

export const ORDER_STATUS = [
  { label: '待生成', value: 0 },
  { label: '已生成', value: 1 },
  { label: '待分配', value: 5 },
  { label: '已分配', value: 10 },
  { label: '已完成', value: 15 }
]

export const ORDER_STATUS2 = [
  { label: '待分配', value: 5 },
  { label: '已分配', value: 10 },
  { label: '已完成', value: 15 }
]

export const ORDER_STATUS3 = [
  { label: '处理中', value: 10 },
  { label: '已完成', value: 15 }
]

export const QUES_STATUS = [
  { label: '待处理', value: 0 },
  { label: '已处理', value: 1 }
]

export const USER_STATUS = [
  { label: '正常', value: 1 },
  { label: '禁用', value: 2 }
]

export const MENU_TYPE = [
  { label: '菜单', value: 0 },
  { label: '按钮', value: 1 }
]

export const MENU_OPEN = [
  { label: '内部', value: '1' },
  { label: '外部', value: '2' }
]

export const MENU_VISIBLE = [
  { label: '可见', value: 0 },
  { label: '不可见', value: 1 }
]

export const MENU_STATUS = [
  { label: '在用', value: 1 },
  { label: '停用', value: 2 }
]

export const getQuestionList = async function() {
  const res = await getQuestionType()
  if (res.code === 0) {
    const data = dataToSelect(res.data, { label: 'content', value: 'code' })
    setQuestion(data)
    QUESTION_TYPE.value = data
    QUESTION_TYPE_ALL.value = [{ label: '全部', value: 'all' }].concat(data)
  }
}

removeQuestion()
