import { taskStatus } from '@/utils/status'

export const columns = (_this) => [
  {
    prop: 'taskName',
    label: '任务名称',
    align: 'left',
    width: '200px'
  },
  {
    prop: 'taskCode',
    label: '任务代号'
  },
  {
    prop: 'taskTime',
    label: '任务时间'
  },
  {
    prop: 'taskDuration',
    label: '任务时长'
  },
  {
    prop: 'env',
    label: '环境'
  },
  {
    prop: 'taskType',
    label: '任务类型'
  },
  {
    prop: 'status',
    label: '状态',
    render: (h, params) => taskStatus(h, params.row.status)
  },
  {
    prop: 'aircraftIntactRatio',
    label: '装备完好率',
    render: (h, params) => {
      return h('span', {}, params.row.aircraftIntactRatio + '%')
    }
  },
  {
    button: true,
    label: '操作',
    group: [
      {
        name: '查看',
        type: 'text',
        round: false,
        plain: false,
        onClick: (row, index, scope) => {
          _this.look(row)
        }
      },
      {
        name: '登记',
        type: 'text',
        round: false,
        plain: false,
        statusKey: 'status',
        unDisableKey: [7, 8],
        showType: '1', //0:父级；1：子级
        onClick: (row, index, scope) => {
          _this.toRegistering(row)
        }
      },
      {
        name: '确认',
        type: 'text',
        round: false,
        plain: false,
        statusKey: 'status',
        unDisableKey: [7, 8],
        onClick: (row, index, scope) => {
          _this.completion(row)
        }
      }
    ]
  }
]

export const options = {
  treeProps: {
    children: 'children',
    hasChildren: 'hasChildren'
  },
  rowKey: 'taskId',
  stripe: true, // 斑马纹
  mutiSelect: false, // 多选框
  index: false, // 显示序号， 多选则 mutiSelect
  loading: false, // 表格动画
  initTable: true, // 是否一挂载就加载数据
  border: true,
  height: 'calc(100vh - 240px)'
}
