<template>
  <a-card :bordered="false" :title="modalTitle" v-show="visible">
    <a-row :gutter="48" slot="extra">
      <a-col :md="48" :sm="48">
        <span class="table-page-search-submitButtons" style="float: right">
          <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
        </span>
      </a-col>
    </a-row>
    <title-divider title="基本信息" width="90px"></title-divider>
    <detail-list title="" :col="2">
      <detail-list-item term="合同编号">{{ model.no }}</detail-list-item>
      <detail-list-item term="公司名称">{{ model.companyName }}</detail-list-item>
      <detail-list-item term="项目编码">{{ model.projectCode }}</detail-list-item>
      <detail-list-item term="项目名称">{{ model.projectName }}</detail-list-item>
      <detail-list-item term="项目记账主币">{{ BaseTool.Object.getField(moneyTypeMap,model.projectMoneyType) }}</detail-list-item>
      <detail-list-item term="供应商编码">{{ model.supplierCode }}</detail-list-item>
      <detail-list-item term="合同签订时间">{{ model.signDate }}</detail-list-item>
      <detail-list-item term="合同签订地">{{ model.signAddress }}</detail-list-item>
      <detail-list-item term="交付周期（工作日）">{{ model.leadTime }}</detail-list-item>
      <detail-list-item term="交货地点">{{ model.deliveryPlace }}</detail-list-item>
      <detail-list-item term="延迟期限（日）">{{ model.delayTime }}</detail-list-item>
      <detail-list-item term="甲方名称">{{ model.sellerName }}</detail-list-item>
      <detail-list-item term="甲方送达地址">{{ model.sellerDeliveryAddress }}</detail-list-item>
      <detail-list-item term="甲方单位地址">{{ model.sellerUnitAddress }}</detail-list-item>
      <detail-list-item term="甲方联系电话">{{ model.sellerPhone }}</detail-list-item>
      <detail-list-item term="甲方税号">{{ model.sellerTaxNo }}</detail-list-item>
      <detail-list-item term="甲方开户银行">{{ model.sellerBankName }}</detail-list-item>
      <detail-list-item term="甲方帐号">{{ model.sellerBankNo }}</detail-list-item>
      <detail-list-item term="乙方名称">{{ model.buyerName }}</detail-list-item>
      <detail-list-item term="乙方送达地址">{{ model.buyerDeliveryAddress }}</detail-list-item>
      <detail-list-item term="乙方单位地址">{{ model.buyerUnitAddress }}</detail-list-item>
      <detail-list-item term="乙方联系电话">{{ model.buyerPhone }}</detail-list-item>
      <detail-list-item term="乙方税号">{{ model.buyerTaxNo }}</detail-list-item>
      <detail-list-item term="乙方开户银行">{{ model.buyerBankName }}</detail-list-item>
      <detail-list-item term="乙方帐号">{{ model.buyerBankNo }}</detail-list-item>
      <detail-list-item term="数量">{{ BaseTool.Amount.formatter(model.quantity) }}</detail-list-item>
      <detail-list-item term="金额类型">{{ BaseTool.Object.getField(moneyTypeMap,model.moneyType) }}</detail-list-item>
      <detail-list-item term="总价">{{ BaseTool.Amount.formatter(model.totalMoney) }} ({{ BaseTool.Object.getField(moneyTypeMap,model.moneyType) }})</detail-list-item>
      <detail-list-item term="总价(按记账主币)">{{ BaseTool.Amount.formatter(model.accountTotalMoney)+ BaseTool.Number.divForDollar(model.accountTotalMoney, model.dollarExchangeRate, 2) }}</detail-list-item>
      <detail-list-item term="真实合同" v-if="model.actualUrl"><div :key="model.actualUrl"><a target="_blank" :href="model.actualUrl">查看</a></div></detail-list-item>
      <detail-list-item term="备注">{{ model.remark }}</detail-list-item>
      <detail-list-item term="更新人名称">{{ model.updateUserName }}</detail-list-item>
      <detail-list-item term="更新时间">{{ model.updateTime }}</detail-list-item>
    </detail-list>
    <title-divider title="合同内容" width="90px"></title-divider>
    <a-row class="form-row" :gutter="16">
      <iframe
        :src="model.url"
        id="mobsf"
        scrolling="auto"
        style="overflow-y: auto"
        frameborder="0"
        allowtransparency="true"
        width="800px"
        height="800px"></iframe>
    </a-row>

  </a-card>
</template>

<script>
import DetailList from '@/components/tools/DetailList'
const DetailListItem = DetailList.Item

export default {
  name: 'PurchaseContractDetail',
  components: {
    DetailList,
    DetailListItem
  },
  data () {
    return {
      confirmLoading: false,
      mdl: {},
      modalTitle: null,
      visible: false,
      // 下拉框map
      moneyTypeMap: {},
      model: {
        'no': null,
        'purchaseApplyId': null,
        'purchasePlanId': null,
        'demandPlanId': null,
        'purchaseOrderId': null,
        'companyId': null,
        'companyName': null,
        'projectCode': null,
        'projectId': null,
        'projectName': null,
        'projectMoneyType': null,
        'dollarExchangeRate': null,
        'supplierCode': null,
        'supplierId': null,
        'supplierName': null,
        'signDate': null,
        'signAddress': null,
        'moneyType': null,
        'leadTime': null,
        'deliveryPlace': null,
        'delayTime': null,
        'sellerName': null,
        'sellerDeliveryAddress': null,
        'sellerUnitAddress': null,
        'sellerPhone': null,
        'sellerTaxNo': null,
        'sellerBankName': null,
        'sellerBankNo': null,
        'buyerName': null,
        'buyerDeliveryAddress': null,
        'buyerUnitAddress': null,
        'buyerPhone': null,
        'buyerTaxNo': null,
        'buyerBankName': null,
        'buyerBankNo': null,
        'quantity': null,
        'totalMoney': null,
        'accountTotalMoney': null,
        'content': null,
        'status': null,
        'url': null,
        'actualUrl': null,
        'remark': null,
        'delFlag': null,
        'createdUserId': null,
        'updateUserId': null,
        'updateUserName': null,
        'updateTime': null
      }
    }
  },
  created () {
    // 下拉框map
    this.moneyTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.MONEY_TYPE)
  },
  methods: {
    base (record) {
      this.visible = true
      this.modalTitle = '合同详情'
      this.model = record
      let dollarExchangeRate = 1
      if (record.projectMoneyType === this.DictCache.VALUE.MONEY_TYPE.RMB) {
        dollarExchangeRate = this.dollarExchangeRate
      }
      this.model.dollarExchangeRate = dollarExchangeRate
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
      this.$emit('ok', {})
    }

  }
}
</script>
