<template>
  <el-dialog :visible.sync="dialog" append-to-body title="收货详情" width="88%">
    <!-- 搜索 -->
    <div class="head-container">
      <!-- 导出 -->
      <div style="display: inline-block;">
        <el-button
          :loading="downloadLoading"
          size="mini"
          class="filter-item"
          type="warning"
          icon="el-icon-download"
          @click="downloadMethod"
        >导出
        </el-button>
      </div>
    </div>
    <!--表格渲染-->
    <el-table v-loading="loading" :data="data" style="width: 100%;margin-top: -10px;">
      <el-table-column type="index" :index="indexMethod" label="序号"/>
      <el-table-column :show-overflow-tooltip="true" prop="itemCode" label="物料编码">
        <template slot-scope="scope">
          <div>{{ scope.row.item.code }}</div>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="itemName" label="物料名称">
        <template slot-scope="scope">
          <div>{{ scope.row.item.name }}</div>
        </template>
      </el-table-column>
      <el-table-column prop="srcStockCode" label="容器编码"/>
      <el-table-column prop="dstPointCode" label="目标点位编码"/>
      <el-table-column prop="taskStatus" label="任务状态">
        <template slot-scope="scope">
          {{ dict.label.task_status[scope.row.taskStatus] }}
        </template>
      </el-table-column>
      <el-table-column prop="planQty" label="计划数量"/>
      <el-table-column prop="moveQty" label="移位数量"/>
      <el-table-column prop="createBy" label="创建人"/>
      <el-table-column prop="createTime" label="创建时间"/>
    </el-table>
    <el-dialog :visible.sync="errorDialog" append-to-body title="异常详情" width="85%">
      <pre>{{ errorInfo }}</pre>
    </el-dialog>
    <!--分页组件-->
    <el-pagination
      :total="total"
      :current-page="page + 1"
      :page-size="6"
      style="margin-top:8px;"
      layout="total, prev, pager, next"
      @size-change="sizeChange"
      @current-change="pageChange"
    />
  </el-dialog>
</template>

<script>
import crud from '@/mixins/crud'
import DateRangePicker from '@/components/DateRangePicker'
import {getTaskInfo} from "@/api/task";

export default {
  components: {DateRangePicker},
  mixins: [crud],
  dicts: ['task_status'],
  data() {
    return {
      title: '任务日志',
      errorInfo: '', errorDialog: false,
      enabledTypeOptions: [
        {key: 'true', display_name: '成功'},
        {key: 'false', display_name: '失败'}
      ]
    }
  },
  methods: {
    doInit(id) {
      getTaskInfo(id).then(res => {
        this.data = res;
        this.loading = false;
        return true;
      })
    },
    indexMethod(index) {
      return index * 1 + 1;
    }
  }
}
</script>

<style scoped>
.java.hljs {
  color: #444;
  background: #ffffff !important;
}

::v-deep .el-dialog__body {
  padding: 0 20px 10px 20px !important;
}
</style>
