<!--
  @description: 订单管理-订单退回记录详情
  @author: lxl
  @date： 2021-3-16 15:30: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.formData"
      /> -->
      <template>
        <table class="tableData mb16">
          <tr>
            <td>订单编号</td>
            <td>{{ formData.orderCode }}</td>
            <td>
              <p>
                订单名称
              </p>
            </td>
            <td>
              <p>
                {{ formData.orderName }}
              </p>
            </td>
          </tr>
          <tr>
            <td>供应商名称</td>
            <td>{{ formData.winningDepartName }}</td>
            <td>采购人</td>
            <td>{{ formData.purchaseDepartName }}</td>
          </tr>
          <!-- <tr>
            <td>订单净总价(元)</td>
            <td>{{ formData.orderTotalMoney?moneyFormat(formData.orderTotalMoney.toFixed(2)):formData.orderTotalMoney }}</td>
            <td>订单含税总价(元)</td>
            <td>{{ formData.orderTotalTaxMoney && moneyFormat(formData.orderTotalTaxMoney.toFixed(2)) }}</td>
          </tr>
          <tr>
            <td>创建日期</td>
            <td>{{ $Moment(formData.createTime).format(momentDate) }}</td>
            <td>状态</td>
            <td>
              {{ filterDictText(procurementOrderOrderStatusList, formData.orderStatus) }}
            </td>
          </tr> -->
          <tr>
            <td>订单来源</td>
            <td>
              {{ filterDictText(tender_methodList,formData.tenderMethod) }}
            </td>
            <td>
              <p>
                送货地址
              </p>
            </td>
            <td>
              {{ formData.deliveryAddress }}
            </td>
          </tr>
        </table>
      </template>
      <!-- 订单行项目信息 -->
      <template>
        <procurementOrderLineItemCompDetail
          :line-item-info-data="lineItemInfoList"
          :money-flag="false"
          :line-data="lineData"
        />
        <pagination :pagination-data="paginationData" @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> -->
      <table class="tableData mb10 mt10">
        <tr>
          <td>
            退回意见
          </td>
          <td colspan="3">
            {{ formData.releaseReason }}
          </td>
        </tr>
      </table>
      <el-table :data="flowList">
        <el-table-column header-align="center" prop="processNodeName" label="角色/岗位" />
        <el-table-column header-align="center" prop="processUserRname" label="处理人" />
        <el-table-column
          :formatter="formatTeviewType"
          header-align="center"
          prop="teviewType"
          align="center"
          label="处理意见"
        />
        <el-table-column header-align="center" prop="endDate" align="center" label="处理时间" />
        <el-table-column header-align="center" prop="comment" label="意见说明" />
      </el-table>
      <!-- <flowAuditList class="mb10 mt10" :biz-id="orderId" flow-type="00" /> -->
    </div>
  </div>
</template>
<script>
/*  api*/
import {
  queryProcurementOrderInfo, // 基本信息
  // listProcurementOrderProductPages // 行项目
  releaseListProcurementOrderProductPages
  // listSupplierProcurementSendGoodsPages, // 发货信息
  // listSupplierConsigneeApplicationPages // 收款信息
} from '@/api/procurement/procurementOrder'
import { historyFlowListByBizId } from '@/api/work/work'
/* 组件*/
// 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 flowAuditList from '@views/work/process/flowAudit-list' // 审核列表
/* 公用*/
import pagination from '@comp/common/pagination/pagination' // 分页组件
import { filterDictText, moneyFormat } from '@/assets/js/utils' // 深拷贝
import { ListMixin } from '@/mixins/ListMixin'
import { procurementOrderGroupMixins } from '@/views/procurement/procurementOrder/mixins/procurementOrderGroupMixins.js'
/* 审批信息*/
import { workCommonGroup } from '@views/work/mixins/workCommonGroup'

export default {
  name: 'OrderBackHistoryDetail',
  components: {
    procurementOrderLineItemCompDetail,
    // procurementOrderBasicCompDetail,
    // procurementOrderDeliverCompDetail,
    // procurementOrderCollectionCompDetail,
    flowAuditList,
    pagination
  },
  mixins: [procurementOrderGroupMixins, ListMixin, workCommonGroup],
  data() {
    return {
      // orderStatus: this.$route.params.orderStatus, // 订单状态
      orderId: this.$route.params.orderId,
      formData: {

      },
      lineItemInfoList: [], // 行项目信息
      flowList: [], // 审核信息
      // detailInfoData: {
      //   formData: {}, // 订单基本信息

      //   // deliveryInfoList: [], // 发货信息
      //   // collectionInfoList: [] // 收款信息
      // },
      // 行项目信息金额数据
      lineData: {
        currency: '', // 币种
        orderTotalMoney: '', // 订单净总价
        orderTotalTaxMoney: '' // 含税总价
      }
      // 行项目分页信息
      // paginationData: {
      //   pageNo: 1,
      //   pageSize: 10,
      //   total: 0
      // }
      // 发货信息分页信息
      // paginationDeliverData: {
      //   pageNo: 1,
      //   pageSize: 10,
      //   total: 0
      // },
      // 收款信息行项目分页信息
      // paginationCollectionData: {
      //   pageNo: 1,
      //   pageSize: 10,
      //   total: 0
      // }
    }
  },
  created() {
    this.getBaseInfoData() // 基础信息
    this.getLineItemData() // 行项目信息
    this.getHistoryFlowListBy() // 审批信息
    // this.getDeliveryData() // 发货信息
    // this.getCollectionData() // 收款信息
  },
  methods: {
    filterDictText,
    moneyFormat,
    // 收货详情
    // 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.formData = response.data
        this.lineData.currency = response.data.currency // 币种
        this.lineData.orderTotalMoney = response.data.orderTotalMoney // 订单净总价
        this.lineData.orderTotalTaxMoney = response.data.orderTotalTaxMoney // 订单含税总价
      })
    },
    // 获取行项目信息
    getLineItemData() {
      const params = {
        orderId: this.$route.params.id,
        pageNo: this.paginationData.pageNo,
        pageSize: this.paginationData.pageSize
      }
      // 订单退回
      releaseListProcurementOrderProductPages(params).then(response => {
        this.loading = false
        this.lineItemInfoList = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 获取审批信息
    getHistoryFlowListBy() {
      const params = {
        bizId: this.$route.params.bizId
      }
      historyFlowListByBizId(params).then((res) => {
        this.flowList = res.data.data
      })
    },
    // 处理字典信息，处理意见
    formatTeviewType(row, column, cellValue) {
      return filterDictText(this.teviewTypeList, cellValue)
    },
    // 获取发货信息
    // 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(() => {
    //   })
    // },
    back() {
      this.$router.push({
        path: '/procurement/procurementOrderQueryList'
      })
    }
  }
}
</script>
