<template>
  <div class="detail-container">
    <el-page-header @back="goBack" content="详情"></el-page-header>

    <div id="printData">
      <div class="main-title">
        <div class="title">预留单信息</div>
      </div>

      <div class="diy-table-1">
        <el-row>
          <el-col :span="6" class="item">
            <div class="label">单据编号：</div>
            <div class="value">{{detailData.id}}</div>
          </el-col>
          <el-col :span="6" class="item">
            <div class="label">单据日期：</div>
            <div class="value">{{detailData.orderTime}}</div>
          </el-col>
          <el-col :span="6" class="item">
            <div class="label">制单人：</div>
            <div class="value">{{detailData.createBy}}</div>
          </el-col>
          <el-col :span="6" class="item">
            <div class="label">制单日期：</div>
            <div class="value">{{detailData.createTime}}</div>
          </el-col>
          <el-col :span="24" class="item">
            <div class="label">备注：</div>
            <div class="value">{{detailData.remark}}</div>
          </el-col>
        </el-row>
      </div>

      <div class="table" style="margin-top: 20px">
        <el-table :data="detailData.reservedOrderItems" element-loading-text="Loading" border fit highlight-current-row stripe max-height="400">
          <el-table-column align="center" label="序号" type="index" width="50"></el-table-column>
          <el-table-column align="center" label="销售订单号" prop="orderId" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="订单日期" prop="theTime" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="经销商编码" prop="customerId" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="物料代码" prop="materialOldNumber" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="产品编码" prop="materialNumber" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="产品名称" prop="materialName" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="规格型号" prop="specification" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="单位" prop="unit" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="预留数量" prop="reservedNum" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="订单数量" prop="qty" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="备注" prop="reservedRemark" min-width="160" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="修改人" prop="updateBy" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="修改时间" prop="updateTime" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="关闭人" prop="closureBy" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="关闭时间" prop="closureTime" min-width="100" show-overflow-tooltip></el-table-column>
          <el-table-column align="center" label="状态" prop="status" min-width="100" show-overflow-tooltip>
            <template slot-scope="scope">
              {{scope.row.status | statusFilter}}
            </template>
          </el-table-column>
        </el-table>
      </div>
      
    </div>
    
    <div class="page-footer">
      <div class="footer" :class="classObj">
        <el-button @click="goBack">关 闭</el-button>
      </div>
    </div>

  </div>
</template>

<script>
import print from 'vue-print-nb'
import { getDetail } from "@/api/supply/reserve";

export default {
  name: 'ReserveDetail',
  componentName: 'ReserveDetail',
  props: ['listItem'],
  directives: {
    print
  },
  filters: {
    statusFilter(val) {
      const MAP = {
        0: '已关闭',
        1: '执行中',
      }
      return MAP[val];
    }
  },
  data() {
    return {
      printObj: {
        id: 'printData'
      },
      detailData: {},
    }
  },

  computed: {
    sidebar() {
      return this.$store.state.app.sidebar
    },
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened
      }
    },
  },

  created() {
    this.getDetail();
  },

  methods: {
    // 返回列表
    goBack() {
      this.$emit('backListFormDetail');
    },

    // 获取详情
    getDetail() {
      getDetail({id: this.listItem.id}).then(res => {
        this.detailData = res.data;
      })
    },
  }
}
</script>

<style scoped lang="scss">
  .detail-container {
    width: 100%;
    height: 100%;
  }
  .main-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    height: 60px;
    border-bottom: 1px solid #DCDFE6;
    margin-bottom: 20px;
    .title {
      font-size: 16px;
      font-weight: 600;
      padding-left: 10px;
    }
  }
</style>