<template>
  <schema-table
    ref="table"
    :schema="schema"
  >
    <schedule-dialog ref="scheduleDialog" />
  </schema-table>
</template>

<script>
import {
  getSchedules,
  resolveSchedule
} from '@/api/calendar'
import {
  ScheduleType,
  State
} from '@/constant'
import mixin from './mixin'

export default {
  name: 'ReviewSchedule',
  mixins: [mixin],
  data () {
    return {
      schema: {
        condition: {
          type: ScheduleType.COMPLEX,
          status: State.REVIEW
        },
        list: getSchedules,
        cols: [
          { prop: 'name', label: '排期名称', 'min-width': 100 },
          { prop: 'resolutionRatio', label: '分辨率' },
          { prop: 'createBy', label: '申请人' },
          { prop: 'createTime', label: '提交时间' },
          { type: 'invoke', width: 160, render: [
            { label: '查看', on: this.onView },
            { label: '通过', on: this.onResolve },
            { label: '驳回', on: this.onReject }
          ] }
        ]
      }
    }
  },
  methods: {
    resolve: resolveSchedule,
    onView ({ id }) {
      this.$refs.scheduleDialog.show(id)
    }
  }
}
</script>
