<template>
  <div class="ele-body">
     <el-card shadow="never" v-loading="loading">
	   <work-search @search="reload">
	   </work-search>
	   <!-- 数据表格 -->
	   <ele-pro-table
	     ref="table"
	     :columns="columns"
	     :datasource="datasource"
	     cache-key="systemRoleTable"
	   >
	     <!-- 表头工具栏 -->
	     <template v-slot:toolbar>
		   <el-button
		     size="small"
		     type="primary"
		     class="ele-btn-icon"
		     @click="goDetail()"
		   >
		     详情
		   </el-button>
	     </template>
			 <!-- 操作列 -->
			 <template v-slot:action="{ row }">
				 <el-link
					 type="primary"
					 :underline="false"
					 icon="el-icon-edit"
					 >
					 报工
				 </el-link>
				 <el-link
					 type="primary"
					 :underline="false"
					 icon="el-icon-edit"
					@click="toRedeploy(row)"
				 >
					转派
				 </el-link>
			 </template>
	   </ele-pro-table>
     </el-card>
	 <!-- 转派弹窗 -->
	 <redeployOther ref="redeployOtherRef" @refresh="reload" />
  </div>
</template>

<script>
  import WorkSearch from './components/work-search.vue';
  import { pageRoles } from '@/api/system/role'; 
  import redeployOther from '@/views/maintenance/components/redeployOther.vue';
  export default {
    components: {
      WorkSearch,
	  redeployOther
    },
    data () {
      return {
		// 表格列配置
		columns: [
		  {
		    columnKey: 'index',
		    label: '序号',
		    type: 'index',
		    width: 55,
		    align: 'center',
		    showOverflowTooltip: true,
		    fixed: 'left'
		  },
		  {
		    prop: 'code',
		    label: '工单单号',
		    align: 'center',	
		    showOverflowTooltip: true,
		    minWidth: 110
		  },
		  {
		    prop: 'planCode',
		    label: '计划单号',
		    align: 'center',	
		    showOverflowTooltip: true,
		    slot: 'planCode',
		    minWidth: 110
		  },
			{
			  prop: 'planName',
			  label: '保养名称',
			  align: 'center',
			  showOverflowTooltip: true,
			  minWidth: 110
			},
		  {
		    prop: 'executorDeptName',
		    label: '保养部门',
		    align: 'center',	
		    showOverflowTooltip: true,
		    minWidth: 110
		  },
			{
			  prop: 'executeUserName',
			  label: '保养人员',
			  align: 'center',	
			  showOverflowTooltip: true,
			  minWidth: 110
			},
			{
			  prop: 'acceptTime',
			  label: '开工时间',
			  align: 'center',	
			  showOverflowTooltip: true,
			  minWidth: 110
			},
		  {
		    prop: 'finishTime',
		    label: '报工时间',
		    align: 'center',	
		    showOverflowTooltip: true,
		    minWidth: 110
		  },
		  {
		    prop: 'sj',
		    label: '时间工时',
		    align: 'center',	
		    showOverflowTooltip: true,
		    minWidth: 110
		  },
		  {
		    prop: 'status',
		    label: '状态',
		    align: 'center',
		    showOverflowTooltip: true,
		    minWidth: 110
		  },
		  {
		    prop: 'executeResult',
		    label: '执行结果',
		    align: 'center',
		    showOverflowTooltip: true,
		    minWidth: 110
		  },
		  {
		    columnKey: 'action',
		    label: '操作',
		    width: 150,
		    align: 'center',
		    resizable: false,
		    slot: 'action',
		    showOverflowTooltip: true
		  }
		],
        // 加载状态
        loading: false,
        pageType: 'add',
        dialogTitle: '',
		isBindPlan:false,
      };
    },
    computed: {

    },
    methods: {
      /* 表格数据源 */
      datasource({ page, limit, where, order }) {
        return pageRoles({ pageNum: page, size: limit, ...where });
      },
      async changeEnable(row) {
        const res = await putRoles(row);
        if (res.code == 0) {
          this.$message({
            type: 'success',
            message: '修改成功',
            customClass: 'ele-message-border'
          });
          this.reload();
        }
      },
      /* 刷新表格 */
      reload(where) {
        this.$refs.table.reload({ page: 1, where });
      },
	  
	  
	  goDetail(){
		  this.$router.push({
		    path: '/maintenance/equipment/work/details',
		    // query: {
		    //   id
		    // }
		  })
	  },
	  toRedeploy(row) {
	    this.$refs.redeployOtherRef.open(row);
	  },
	  
    }
  };
</script>

<style lang="scss" scoped>

</style>
