<!--
  @description: 发货订单管理-订单详情
  @author: 王俊楠
  @routerPath: /procurement/procurementOrderDeliverHandleDetail
  @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="orderLinpPagData" @change="getLineItemData" />
      </template>

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

      <!-- 订单收款信息 -->
      <template>
        <procurementOrderCollectionCompDetail
          :collection-info-data="detailInfoData.collectionInfoList"
        >
          <template slot-scope="data">
            <el-link
              type="primary"
              @click.stop="viewCollection(data.row)"
            >
              [查看]
            </el-link>
            <!--          <el-link
              type="primary"
            >
              [日志]
            </el-link>-->
          </template>
        </procurementOrderCollectionCompDetail>
        <pagination :pagination-data="orderColpagtionData" @change="getCollectionData" />
      </template>
    </div>
  </div>
</template>

<script>
/* api接口*/
import {
  queryProcurementOrderInfo, // 基本信息
  listProcurementOrderProductPages, // 行项目
  listSupplierProcurementSendGoodsPages, // 发货信息
  listSupplierConsigneeApplicationPages // 收款信息
} from '@/api/procurement/procurementOrder'

/* 组件*/
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 { ListMixin } from '@/mixins/ListMixin' // 分页
import pagination from '@comp/common/pagination/pagination' // 分页组件

export default {
  name: 'ProcurementOrderDeliverHandleDetail',
  components: {
    procurementOrderBasicCompDetail, // 订单基本信息
    procurementOrderLineItemCompDetail, // 行项目列表组件
    procurementOrderDeliverCompDetail, // 订单发货信息列表组件
    procurementOrderCollectionCompDetail, // 订单收款信息列表组件
    pagination // 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      detailInfoData: {
        orderInfoList: {}, // 订单基本信息
        lineItemInfoList: [], // 行项目信息
        deliveryInfoList: [], // 发货信息
        collectionInfoList: [] // 收款信息
      },
      lineData: {
        orderTotalMoney: '', // 订单净总价
        orderTotalTaxMoney: '', // 订单含税总价
        currency: '' // 币种
      },
      // 订单处理行项目信息分页
      orderLinpPagData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      },
      // 订单处理发货分页信息
      orderDevPagData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      },
      // 订单处理收款分页信息
      orderColpagtionData: {
        pageNo: 1,
        pageSize: 10,
        total: 0
      },
      orderId: ''
    }
  },
  created() {
    // 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')
      }
    },
    // 获取基本信息
    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.orderLinpPagData.pageNo,
        pageSize: this.orderLinpPagData.pageSize
      }
      listProcurementOrderProductPages(params).then(response => {
        this.loading = false
        this.detailInfoData.lineItemInfoList = response.data.records
        this.orderLinpPagData.total = response.data.total
      }).catch(() => {
      })
    },
    // 获取发货信息
    getDeliveryData() {
      const params = {
        orderId: this.orderId,
        pageNo: this.orderDevPagData.pageNo,
        pageSize: this.orderDevPagData.pageSize
      }
      listSupplierProcurementSendGoodsPages(params).then(response => {
        this.loading = false
        this.detailInfoData.deliveryInfoList = response.data.records
        this.orderDevPagData.total = response.data.total
      }).catch(() => {
      })
    },
    // 收款信息
    getCollectionData() {
      const params = {
        orderId: this.orderId,
        pageNo: this.orderColpagtionData.pageNo,
        pageSize: this.orderColpagtionData.pageSize
      }
      listSupplierConsigneeApplicationPages(params).then(response => {
        this.loading = false
        this.detailInfoData.collectionInfoList = response.data.records
        this.orderColpagtionData.total = response.data.total
      }).catch(() => {
      })
    },
    // 返回发货订单处理详情页面
    back() {
      this.$router.push({
        path: '/procurement/procurementOrderDeliverList'
      })
    },
    // 发货订单管理-收款详情
    viewCollection(row) {
      this.$router.push({
        name: 'ProcurementOrderCollectionDetail',
        params: {
          conAppliId: row.id
        }
      })
    },
    // 发货订单管理-发货详情
    viewDelivery(row) {
      this.$router.push({
        name: 'ProcurementOrderDeliverDetail',
        params: {
          goodsId: row.id, // 订单Id
          orderId: this.orderId
        }
      })
    }
  }
}
</script>

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

