<!--
  @description: 收货订单管理-订单详情
  @author: 王俊楠
  @routerPath: /procurement/procurementOrderReceiveHandleDetail
  @date： 2020-11-10 17:10:12
-->
<template>
  <div>
    <section class="title title_border p0-16">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      收货处理详情
    </section>
    <div class="p0-16">
      <!-- 订单基本信息 -->
      <procurementOrderBasicCompDetail
        :order-info-data="detailInfoData.orderInfoList"
      />
      <!-- 订单行项目信息 -->
      <template>
        <procurementOrderLineItemCompDetail
          :line-item-info-data="detailInfoData.lineItemInfoList"
          :line-data="lineData"
        />
        <pagination :pagination-data="paginationLineData" @change="getLineItemData" />
      </template>

      <!-- 订单发货信息 -->
      <template>
        <procurementOrderDeliverCompDetail
          :delivery-info-data="detailInfoData.deliveryInfoList"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click.stop="viewReceipts(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </procurementOrderDeliverCompDetail>
        <pagination :pagination-data="paginationDeliverData" @change="getDeliveryData" />
      </template>

      <!-- 订单收款信息 -->
      <template>
        <procurementOrderCollectionCompDetail
          :collection-info-data="detailInfoData.collectionInfoList"
        >
          <!-- 收款表操作按钮 -->
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click.stop="viewCollection(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </procurementOrderCollectionCompDetail>
        <pagination :pagination-data="paginationCollectionData" @change="getCollectionData" />
      </template>
      <!--验收情况-->
      <procurementOrderAcceptanceCompDetail />
    </div>
  </div>
</template>

<script>
/* api接口*/
import {
  queryProcurementOrderInfo, // 基本信息
  listProcurementOrderProductPages, // 行项目
  listSupplierProcurementSendGoodsPages, // 发货信息
  listSupplierConsigneeApplicationPages // 收款信息
} from '@/api/procurement/procurementOrder'
/** 引入Mixins */
import { procurementOrderGroupMixins } from '@/views/procurement/procurementOrder/mixins/procurementOrderGroupMixins.js' // 引入mixins
// import { ListMixin } from '@/mixins/ListMixin' // 分页

/* 组件*/
import procurementOrderBasicCompDetail from '@/views/procurement/procurementOrder/procurementOrderInfo/procurementOrderBasicComp-detail.vue' // 订单的基本信息组件
import procurementOrderLineItemCompDetail from '@/views/procurement/procurementOrder/procurementOrderInfo/procurementOrderLineItemComp-detail.vue' // 订单行项目信息列表组件
import procurementOrderDeliverCompDetail from '@/views/procurement/procurementOrder/procurementOrderInfo/procurementOrderDeliverComp-detail.vue' // 订单发货列表组件
import procurementOrderCollectionCompDetail from '@/views/procurement/procurementOrder/procurementOrderInfo/procurementOrderCollectionComp-detail.vue' // 收款申请信息列表组件
import procurementOrderAcceptanceCompDetail from '@/views/procurement/procurementOrder/procurementOrderInfo/procurementOrderAcceptanceComp-detail.vue' // 验收情况

/*  公用*/
import pagination from '@comp/common/pagination/pagination' // 分页组件
export default {
  name: 'ProcurementOrderReceiveHandleDetail',
  components: {
    procurementOrderBasicCompDetail, // 订单基本信息
    procurementOrderLineItemCompDetail, // 行项目列表组件
    procurementOrderDeliverCompDetail, // 订单发货信息列表组件
    procurementOrderCollectionCompDetail, // 订单收款信息列表组件
    procurementOrderAcceptanceCompDetail, // 验收情况
    pagination
  },
  mixins: [procurementOrderGroupMixins], // 引入mixins

  data() {
    return {
      orderId: '',
      // 页面数据
      detailInfoData: {
        orderInfoList: {}, // 订单基本信息
        lineItemInfoList: [], // 行项目信息
        deliveryInfoList: [], // 发货信息
        collectionInfoList: [] // 收款信息
      },
      lineData: {
        orderTotalMoney: '', // 订单净总价
        orderTotalTaxMoney: '', // 订单含税总价
        currency: '' // 币种
      },
      // 行项目分页信息
      paginationLineData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      },
      // 发货信息分页信息
      paginationDeliverData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      },
      // 收款信息行项目分页信息
      paginationCollectionData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  computed: {
  },
  watch: {
  },
  created() {
    // 获取路由传参 订单Id
    // this.orderId = this.$route.params.orderId
    this.sessSet()
    this.getBaseInfoData() // 基础信息
    this.getLineItemData() // 行项目信息
    this.getDeliveryData() // 发货信息
    this.getCollectionData() // 收款信息
  },
  methods: {
    // 参数存储
    sessSet() {
      const orderid = this.$route.params.orderId
      if (orderid) {
        this.orderId = orderid
        sessionStorage.setItem('orderId', orderid)
      } else {
        this.orderId = sessionStorage.getItem('orderId')
      }
    },
    // 返回收货订单页面
    back() {
      this.$router.push({
        path: '/procurement/procurementOrderReceiveList'
      })
    },
    // 收货详情
    viewReceipts(row) {
      this.$router.push({
        name: 'ProcurementOrderReceiveDetail',
        params: {
          goodsId: row.id,
          orderId: this.orderId
        }
      })
    },
    // 收款确认详情
    viewCollection(row) {
      this.$router.push({
        name: 'ProcurementOrderCollectionConfirmDetail',
        params: {
          conAppliId: row.id // 订单Id
        }
      })
    },
    // 基本信息
    getBaseInfoData() {
      const params = {
        orderId: this.orderId
      }
      queryProcurementOrderInfo(params).then((response) => {
        this.detailInfoData.orderInfoList = response.data
        this.lineData.currency = response.data.currency // 币种
        this.lineData.orderTotalTaxMoney = response.data.orderTotalTaxMoney // 订单含税总价
        this.lineData.orderTotalMoney = response.data.orderTotalMoney // 订单净总价
      })
    },
    // 获取行项目信息
    getLineItemData() {
      const params = {
        orderId: this.orderId,
        pageNo: this.paginationLineData.pageNo,
        pageSize: this.paginationLineData.pageSize
      }
      listProcurementOrderProductPages(params).then(response => {
        this.loading = false
        this.detailInfoData.lineItemInfoList = response.data.records
        this.paginationLineData.total = response.data.total
      }).catch(() => {
      })
    },
    // 获取发货信息
    getDeliveryData() {
      const params = {
        orderId: this.orderId,
        pageNo: this.paginationDeliverData.pageNo,
        pageSize: this.paginationDeliverData.pageSize
      }
      listSupplierProcurementSendGoodsPages(params).then(response => {
        this.loading = false
        this.detailInfoData.deliveryInfoList = response.data.records
        this.paginationDeliverData.total = response.data.total
      }).catch(() => {
      })
    },
    // 收款信息
    getCollectionData() {
      const params = {
        orderId: this.orderId,
        pageNo: this.paginationCollectionData.pageNo,
        pageSize: this.paginationCollectionData.pageSize
      }
      listSupplierConsigneeApplicationPages(params).then(response => {
        this.loading = false
        this.detailInfoData.collectionInfoList = response.data.records
        this.paginationCollectionData.total = response.data.total
      }).catch(() => {
      })
    }
  }
}
</script>

<style lang="less" scoped>
</style>

