<template>
  <a-table
    :columns="columns"
    :data-source="data"
    row-key="id"
    size="small"
    bordered
    :loading="loading">
    <template slot="slot" slot-scope="text,record">
      {{ text }}({{week[record.calWeek]}})
    </template>
  </a-table>
</template>
<script>
import { getAction } from '@api/manage'

export default {
  name: 'MaintenancePlan',
  data() {
    return {
      loading: false,
      data: [],
      week: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      columns: [
        { title: '计划时间', dataIndex: 'calDay',align:"center", scopedSlots: {customRender: 'slot'} },
        { title: '计划内容', dataIndex: 'rapairRange_dictText',align:"center", },
        { title: '负责人', dataIndex: 'coordinator_dictText',align:"center" }
      ]
    }
  },
  methods: {
    fetchData(deviceId) {
      this.loading = true
      // 加载检修计划数据
      getAction("/plan/plan/devicePlan", {deviceId:deviceId}).then((res) => {
        if(res.success) {
          this.data = res.result;
        }
      }).finally(()=>{
        this.loading = false;
      });
    }
  }
}
</script>
