<template>
  <div class="bulkWarehousingOrderDetail-wrap">
    <a-page-header :ghost="false" :backIcon="false" class="bulkWarehousingOrderDetail-cont" >
      <!-- 自定义的二级文字标题 -->
      <template slot="subTitle">
        <a id="bulkWarehousingOrderDetail-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
        <p style=" display: inline-block;margin: 0 0 0 60px;color: #000;font-size: 16px;font-weight: 600;">单号：{{ (basicInfoData&&basicInfoData.sparePartsPurchaseSn) || '' }}</p>
      </template>
      <template slot="tags">
        <a-tag color="purple" v-if="basicInfoData&&basicInfoData.stateDictValue">{{ basicInfoData.stateDictValue }}</a-tag>
        <a-tag color="orange" v-if="basicInfoData&&basicInfoData.settleStateDictValue">{{ basicInfoData.settleStateDictValue }}</a-tag>
      </template>
      <!-- 操作区，位于 title 行的行尾 -->
      <template slot="extra">
        <a-button key="2" id="bulkWarehousingOrderDetail-preview-btn">打印预览</a-button>
        <a-button key="1" type="primary" id="bulkWarehousingOrderDetail-print-btn">快速打印</a-button>
      </template>
    </a-page-header>
    <!-- 基础信息 -->
    <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="基础信息">
          <a-descriptions :column="3">
            <a-descriptions-item label="供应商">{{ (basicInfoData&&basicInfoData.supplierName) || '' }}</a-descriptions-item>
            <a-descriptions-item label="散件入库类型">{{ (basicInfoData&&basicInfoData.sparePartsTypeName) || '' }}</a-descriptions-item>
            <a-descriptions-item label="备注">{{ (basicInfoData&&basicInfoData.remarks) || '' }}</a-descriptions-item>
            <a-descriptions-item label="联系人">{{ (basicInfoData&&basicInfoData.supplierName) || '' }}</a-descriptions-item>
            <a-descriptions-item label="联系地址">{{ (basicInfoData&&basicInfoData.supplierName) || '' }}</a-descriptions-item>
          </a-descriptions>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
    <!-- 产品详情 -->
    <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="产品详情">
          <!-- 总计 -->
          <a-alert type="info" showIcon style="margin-bottom:15px">
            <div slot="message">产品款数 <strong>6</strong> ，采购数量合计 <strong>6</strong> ，采购金额合计￥<strong>6.33</strong></div>
          </a-alert>
          <!-- 列表 -->
          <s-table
            class="sTable"
            ref="table"
            size="default"
            :rowKey="(record) => record.id"
            :columns="columns"
            :data="loadData"
            :scroll="{ x: 1080, y: 300 }"
            bordered>
            <!-- 采购数量 -->
            <template slot="purchaseNum" slot-scope="text, record">
              <span>{{ record.purchaseNum }}</span>
            </template>
            <!-- 缺货数量 -->
            <template slot="outOfStockNum" slot-scope="text, record">
              <span>{{ record.outOfStockNum }}</span>
            </template>
          </s-table>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
    <!-- 单据记录 -->
    <a-card size="small" :bordered="false" class="bulkWarehousingOrderDetail-cont">
      <a-collapse :activeKey="['1']">
        <a-collapse-panel key="1" header="单据记录">
          <a-timeline class="timeline-box">
            <a-timeline-item>2021-02-01 15:22:38   王凯   审核通过</a-timeline-item>
            <a-timeline-item>
              <p>2021-02-01 15:22:38   王凯   审核通过</p>
              <p class="auxiliary-txt">产品编号JA-11076P的采购数量，由【10】修改为【5】</p>
              <p class="auxiliary-txt">产品编号JA-11076P的采购数量，由【10】修改为【5】</p>
            </a-timeline-item>
            <a-timeline-item>Technical testing 2015-09-01</a-timeline-item>
            <a-timeline-item>Network problems being solved 2015-09-01</a-timeline-item>
          </a-timeline>
        </a-collapse-panel>
      </a-collapse>
    </a-card>
  </div>
</template>

<script>
import { STable, VSelect } from '@/components'
import { sparePartsPurDetail, sparePartsPurDetailList } from '@/api/sparePartsPur'
export default {
  components: { STable, VSelect },
  data () {
    return {
      // 表头
      columns: [
        { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
        { title: '产品编码', dataIndex: 'creatDate', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '产品名称', dataIndex: 'custName', align: 'center', customRender: function (text) { return text || '--' } },
        { title: '采购单价', dataIndex: 'totalNums', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '采购数量', dataIndex: 'totaslNums', width: 100, align: 'center' },
        { title: '单位', dataIndex: 'mementPay', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
        { title: '采购金额', dataIndex: 'shDate', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
        { title: '仓库', dataIndex: 'shD3ate', width: 100, align: 'center' },
        { title: '仓位', dataIndex: 'shDaste', width: 100, align: 'center' }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        this.disabled = true
        return sparePartsPurDetailList(Object.assign(parameter, this.queryParam)).then(res => {
          const data = res.data
          const no = (data.pageNo - 1) * data.pageSize
          for (var i = 0; i < data.list.length; i++) {
            data.list[i].no = no + i + 1
          }
          this.disabled = false
          return data
        })
      },
      basicInfoData: null //  基本信息
    }
  },
  methods: {
    //  返回列表
    handleBack () {
      this.$router.push({ path: '/bulkManagement/bulkWarehousingOrder/list' })
    },
    // 基本信息
    getDetail () {
      sparePartsPurDetail({ id: this.$route.params.id }).then(res => {
        if (res.status == 200) {
          this.basicInfoData = res.data
        } else {
          this.basicInfoData = null
        }
      })
    }
  },
  beforeRouteEnter (to, from, next) {
    next(vm => {
      vm.openModal = false
      vm.getDetail()
    })
  }
}
</script>

<style lang="less">
  .bulkWarehousingOrderDetail-cont{
    margin-bottom: 15px;
    .timeline-box{
      margin-top: 30px;
      .auxiliary-txt{
        color: #808695;
      }
    }
  }
</style>
