<!--
  @description: 收货订单管理-收款申请确认
  @author: 王俊楠
  @routerPath: /procurement/procurementOrderCollectionConfirm
  @date： 2020-10-30 17:10:12
-->
<template>
  <div class="p0-16">
    <section class="title title_border">
      <i class="iconfont icon-fanhui pointer" @click="back()" />
      收款申请
    </section>
    <div>
      <el-form ref="formData" :model="formData" :rules="rules" :inline-message="true">
        <p class="page-title">
          1.收款单信息
        </p>
        <table class="tableData mb16">
          <tr>
            <td>
              <el-form-item ref="orderCode" label="采购订单号" prop="orderCode" />
            </td>
            <td>
              {{ formData.orderCode }}
              <!-- <gx-input
                v-model.trim="formData.orderCode"
                style="width:96%"
                gx-placeholder="placeholderText500"
                gx-maxlength="varchar20"
              /> -->
            </td>
            <td>
              <el-form-item ref="paymentDepartName" label="付款单位" prop="paymentDepartName" />
            </td>
            <td>
              {{ formData.paymentDepartName }}
              <!-- <gx-input
                v-model.trim="formData.departName"
                style="width:96%"
                gx-placeholder="placeholderText500"
                gx-maxlength="varchar50"
              /> -->
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item label="付款方式" prop="paymentType" />
            </td>
            <td>
              {{ formData.paymentType }}
              <!-- <el-select v-model="formData.paymentType" filterable placeholder="请选择">
                <el-option
                  v-for="item in transportList"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select> -->
            </td>
            <td>
              <el-form-item label="付款账号" prop="paymentNumber" />
            </td>
            <td>
              {{ formData.paymentNumber }}
              <!-- <gx-input
                v-model.trim="formData.paymentNumber"
                placeholder="最多允许输入300个汉字(600字符)"
                gx-maxlength="varchar20"
                show-word-limit
                class="show-word-limit-padding"
              /> -->
            </td>
          </tr>
          <tr>
            <td>款项性质</td>
            <td>{{ filterDictText(nature_of_moneyList,formData.natureOfMoney) }}</td>
            <td>
              <el-form-item label="收款金额（元）" prop="consigneeAmount" />
            </td>
            <td colspan="3">
              {{ moneyFormat(formData.consigneeAmount) }}
              <!-- {{ formData.consigneeAmount?moneyFormat(formData.consigneeAmount.toFixed(2)):formData.consigneeAmount }} -->
            </td>
          </tr>
          <tr>
            <td>收款单位</td>
            <td>{{ formData.consigneeDepartName }}</td>
            <td>收款账号</td>
            <td>
              {{ formData.consigneeNumber }}
            </td>
          </tr>
          <tr>
            <td>
              收款账户开户行名称
            </td>
            <td>{{ formData.consigneeBankname }}</td>
            <td>开户行行号</td>
            <td>{{ formData.consigneeBankaccount }}</td>
          </tr>
          <tr>
            <td>
              开户行联行号
            </td>
            <td>{{ formData.consigneeUnionpayNumber }}</td>
            <td>联系人</td>
            <td>{{ formData.consigneeLinkerName }}</td>
          </tr>
          <tr>
            <td>
              联系人电话
            </td>
            <td>{{ formData.consigneeLinkerTel }}</td>
            <td>联系人邮箱</td>
            <td>{{ formData.consigneeLinkerEmali }}</td>
          </tr>
          <tr>
            <td>
              收款人备注
            </td>
            <td colspan="3">
              {{ formData.consigneeRemark }}
            </td>
          </tr>
        </table>
        <p class="page-title">
          2.采购方开票信息
        </p>
        <table class="tableData mb16">
          <tr>
            <td>发票抬头</td>
            <td>{{ formData.paymentInvoiceTitle }}</td>
            <td>
              发票税号
            </td>
            <td>
              <p>
                {{ formData.paymentTaxpayerIdentificationNumber }}
              </p>
            </td>
          </tr>
          <tr>
            <td>发票开户行、账号</td>
            <td>{{ formData.paymentBankname }}</td>
            <td>发票地址、电话</td>
            <td>{{ formData.paymentTaxpayeraddr }}</td>
          </tr>
          <tr>
            <td>开票内容</td>
            <td>{{ formData.paymentInvoiceMessage }}</td>
            <td>开票税率（%）</td>
            <td>{{ formData.paymentInvoiceRate }}</td>
          </tr>
        </table>
      </el-form>
      <!--操作按钮-->
      <div class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <el-button :loading="confirmLoading" @click.stop="sureCollection('formData','00')">
              确认
            </el-button>
            <el-button
              :loading="confirmLoading"
              type="primary"
              @click.stop="sureRetrun('formData','01')"
            >
              退回
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* api接口*/
import {
  queryConsigneeApplicationInfo, // 收款申请
  queryConsigneeApplicationConfrimInfo // 收款申请确认退回
} from '@/api/procurement/procurementOrder'
/* 公共方法 */
import { filterDictText, moneyFormat } from '@/assets/js/utils' // 字典code翻译中文
import { procurementOrderGroupMixins } from '@/views/procurement/procurementOrder/mixins/procurementOrderGroupMixins.js'
// import { characters1_auto,bankCardNumber } from '@/assets/js/validate'// 校验输入内容

/*  公共组件 */
import money from '@comp/common/money/money'// 金额组件

export default {
  name: 'ProcurementOrderCollectionAdd',
  components: {
    money// 金额组件
  },
  mixins: [procurementOrderGroupMixins],
  data() {
    return {
      orderTitle: '',
      // 收款申请页数据
      formData: {},
      confirmLoading: false,
      orderId: '',
      status: '', // 收款申请状态参数
      // 校验输入内容
      rules: {
        // orderCode: [{ required: true, validator: characters1_auto, trigger: 'blur' }], // 采购订单号
        // paymentDepartName: [{ required: true, validator: characters1_auto, trigger: 'blur' }], // 付款单位
        // paymentType: [{ required: true, validator: characters1_auto, trigger: 'blur' }], //付款方式
        // paymentNumber: [{ required: true, validator: bankCardNumber, trigger: 'blur' }], //付款账号
      }
    }
  },
  computed: {
  },
  watch: {
  },
  created() {
    // this.orderId = this.$route.params.orderId // 订单id
    this.loadData()
  },
  methods: {
    filterDictText, // 字典code翻译中文
    moneyFormat, // 金额
    // 返回收货订单处理页面
    back() {
      this.$router.push({
        path: 'procurementOrderReceiveList'
      })
    },
    // 获取数据
    loadData() {
      const params = {
        conAppliId: this.$route.params.conAppliId
      }
      queryConsigneeApplicationInfo(params).then(response => {
        this.loading = false
        this.formData = response.data
        this.orderTitle = this.formData.auditstatus === '01' ? '采购订单号' : '销售订单号'
      }).catch(() => {
        this.loading = false
      })
    },
    // 收款退回确认
    queryConfrimInfo(params) {
      this.confirmLoading = true
      queryConsigneeApplicationConfrimInfo(params).then((res) => {
        this.confirmLoading = false
        this.back()
      })
    },
    // 收款弹窗确认
    sureCollection(formName, status) {
      const params = {
        conAppliId: this.$route.params.conAppliId,
        status: status
      }
      this.$confirm('确认收款信息准确无误？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.queryConfrimInfo(params)
        // this.collectionFn(formName)
      })
      this.confirmLoading = false
    },
    // 退回弹窗确认
    sureRetrun(formName, status) {
      const params = {
        conAppliId: this.$route.params.conAppliId,
        status: status
      }
      this.$confirm('确认退回吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.queryConfrimInfo(params)
      })
      this.confirmLoading = false
    }
    // // 收款
    // collectionFn(formName) {
    //   this.$refs[formName].validate((valid) => {
    //     if (valid) {
    //       // this.formData.auditStatus = auditStatus// 保存状态
    //       // this.formData.useStatus = auditStatus // 必填 01 正式数据
    //       // this.formData.receiptInfoList.forEach(item => {
    //       //   item.orderId = this.$route.params.orderId // 订单id
    //       // })
    //       // queryProcurementSurePay(this.formData).then(res => {
    //       // 跳转处理订单详情
    //       // this.navOrderDetail()
    //       // })
    //     }
    //   })
    // }
    // // 退回
    // rejectFn(formName) {
    //   this.$refs[formName].validate((valid) => {
    //     if (valid) {
    //       // this.formData.auditStatus = auditStatus// 保存状态
    //       // this.formData.useStatus = auditStatus // 必填 01 正式数据
    //       // this.formData.receiptInfoList.forEach(item => {
    //       //   item.orderId = this.$route.params.orderId // 订单id
    //       // })
    //       // queryProcurementRejectPay(this.formData).then(res => {
    //       // 跳转处理订单详情
    //       // this.navOrderDetail()
    //       // })
    //     }
    //   })
    // }
  }
}
</script>

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

