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

<script>
import { State } from '@/constant'
import mixin from './mixin'

export default {
  name: 'WorkflowReviewSchedule',
  mixins: [mixin],
  data () {
    return {
      type: 'program'
    }
  },
  computed: {
    schema () {
      return {
        condition: { pageSize: this.list.length },
        list: this.getList,
        cols: [
          { prop: 'name', label: '排期名称' },
          { prop: 'resolutionRatio', label: '分辨率' },
          ...this.reviewCol
        ]
      }
    }
  },
  created () {
    this.list = this.transform([this.workflow.programCalendar])
    if (!this.list.some(({ pass }) => !pass)) {
      this.$emit('next')
    }
  },
  methods: {
    transform (arr) {
      return arr.map(this.transformItem)
    },
    transformItem ({ id, status, name, resolutionRatio }) {
      return { pass: status !== State.SUBMITTED, id, status, name, resolutionRatio }
    },
    onView ({ id }) {
      this.$refs.scheduleDialog.show(id)
    }
  }
}
</script>
