<!--
  @description: 订单-订单计划退回处理
  @author: 郝定康
  @routerPath:/procurement/purOrderPlanReturnDetail
  @date： 2021-02-23 14:26:17
-->
<template>
  <div class="p0-16">
    <section v-if="!flowStatus" class="title title_border">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      <span v-if="pageType === '01'">订单计划退回处理</span>
    </section>
    <!-- 订单基本信息 -->
    <procurementOrderBasicCompDetail
      :order-info-data="detailInfoData.orderInfoList"
    />
    <!-- 行项目信息 -->
    <template>
      <procurementOrderLineItemCompDetail
        ref="orderLineItem"
        :line-item-info-data="detailInfoData.lineItemInfoList"
        :line-data="lineData"
        :page-type="pageType"
        operation-type="01"
      />
      <pagination :pagination-data="paginationData" @change="loadData" />
    </template>
    <table class="tableData mb10">
      <tr>
        <td>
          退回意见
        </td>
        <td colspan="3">
          {{ detailInfoData.orderInfoList.releaseReason }}
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
/* api接口*/
import {
  queryProcurementOrderInfo, // 基本信息
  listProcurementOrderProductPages // 行项目
} 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 { ListMixin } from '@/mixins/ListMixin' // 分页
import pagination from '@comp/common/pagination/pagination' // 分页组件
export default {
  name: 'ProcurementOrderPlanReturnDetail',
  components: {
    procurementOrderBasicCompDetail, // 订单基本信息
    procurementOrderLineItemCompDetail, // 行项目列表组件
    pagination // 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      pageType: '01', // 00 订单确认页 01 订单行项目退回页
      flowStatus: this.$route.query.flowStatus, // 工作流进入状态
      returnLineItemData: {
        opinion: '' // 意见
      },
      // 页面数据
      detailInfoData: {
        orderInfoList: {}, // 订单基本信息
        lineItemInfoList: [] // 行项目信息
      },
      lineData: {
        orderTotalMoney: '', // 订单净总价
        orderTotalTaxMoney: '', // 订单含税总价
        currency: '' // 币种
      },
      orderId: this.$route.query.id, // 获取路由传参 订单Id
      confirmLoading: false, // 确认按钮加载
      purchaseUnitList: [], // 计量单位字典列表
      typeList: [] // 类别
    }
  },
  computed: {
  },
  watch: {
  },
  created() {
    this.getBaseInfoData() // 基础信息
    this.loadData() // 行项目信息
  },
  methods: {
    // 获取行项目信息
    loadData() {
      const params = {
        orderId: this.orderId,
        releaseFlag: '02',
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      listProcurementOrderProductPages(params).then(response => {
        this.loading = false
        this.detailInfoData.lineItemInfoList = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
      })
    },
    // 基本信息
    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 // 订单净总价
      })
    }
  }
}
</script>

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