import { getRatios } from '@/api/device'
import {
  getSchedules,
  deleteSchedule
} from '@/api/calendar'
import { State } from '@/constant'

export default {
  props: {
    type: {
      type: Number,
      default: 0
    },
    status: {
      type: Number,
      default: State.READY
    }
  },
  computed: {
    schema () {
      return {
        condition: {
          type: this.type,
          resolutionRatio: void 0,
          status: this.status,
          name: ''
        },
        list: getSchedules,
        filters: [
          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
          { key: 'name', type: 'search', placeholder: '名称' }
        ],
        cols: [
          { prop: 'name', label: '名称', 'min-width': 120 },
          { prop: 'resolutionRatio', label: '分辨率' },
          { label: '审核状态', type: 'tag', render ({ status }) {
            return {
              type: [void 0, 'warning', 'success'][status],
              label: ['待提交', '未审核', '已审核'][status]
            }
          } },
          { prop: 'createTime', label: '创建时间', 'min-width': 90 },
          { type: 'invoke', width: 160, render: this.invokes }
        ]
      }
    }
  },
  methods: {
    onView ({ id }) {
      this.$refs.scheduleDialog.show(id)
    },
    onDel (item) {
      deleteSchedule(item).then(() => {
        this.$refs.table.decrease(1)
      })
    }
  }
}
