<!--
 * @Description: 详情弹框
 * @Author: Sugar.
 * @Date: 2023-11-24 13:55:00
 * @LastEditors: gcz
 * @LastEditTime: 2024-03-18 11:01:58
 * @FilePath: \great_webui\src\views\finance\InvoiceRecords\dialog\details.vue
 * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
-->
<template>
  <el-dialog
    title="开票详情"
    :visible.sync="open"
    width="70vw"
    append-to-body
    :close-on-click-modal="false"
    @close="cancel"
  >
    <div class="dialog" v-if="form">
      <div>
        <el-row>
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">订单号: <span>{{ form.orderId }}</span></div>
          </el-col>
          <el-col :span="24">
            <div style="display: flex;" class="grid-content bg-purple item-class">状态: <span style="margin-left: 10px;"><dict-tag :options="dict.type.Invoicing_type" :value="form.status"/></span></div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">申请时间: <span>{{ form.createTime }}</span></div>
          </el-col>
          <el-col :span="24">
            <div style="display: flex;" class="grid-content bg-purple item-class">开票类型: <span style="margin-left: 10px;"><dict-tag :options="dict.type.lookup_type" :value="form.handlerType"/></span></div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">申请类型: <span v-if="form.invoiceLine == 'bs'">数电专票</span><span v-else-if="form.invoiceLine == 'pc'">数电普票</span></div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">纳税人识别号: <span>￥{{ form.creditCode || '-' }}</span></div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">联系电话: <span>{{ form.mobile }}</span></div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">邮箱: <span>{{ form.email }}</span></div>
          </el-col>
          <!-- <el-col :span="24">
            <div class="grid-content bg-purple item-class">业务员: <span>{{ '' }}</span></div>
          </el-col> -->
          <el-col :span="24">
            <div class="grid-content bg-purple item-class">开票金额: <span>{{ form.invoiceAmount }}</span></div>
          </el-col>
          <el-col :span="24" v-if="form.status == 3">
            <div class="grid-content bg-purple item-class">失败原因: <span style="color: red;">{{ form.errReason }}</span></div>
          </el-col>
          <el-col :span="24">
            <div style="display: flex;" class="grid-content bg-purple item-class">
              <span style="white-space: nowrap;">附件: </span>
              <div style="color: #409eff;display: flex;flex-direction: column;margin-left: 10px;">
                <!-- <el-image 
                  v-if="form.imageUrl"
                  style="width: 100px; height: 100px"
                  :src="form.imageUrl" 
                  :preview-src-list="[form.imageUrl]">
                </el-image> -->
                
                <span v-if="form.pdfUrl"><i class="el-icon-folder-opened"></i> {{ form.pdfUrl }} <span style="margin-left: 10px;cursor: pointer;color: #67c23a;" @click="openPDF(form.pdfUrl)">参看详情</span></span>
                
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
      <div>
        <iframe width="90%" :src="form.pdfUrl" frameborder="0"></iframe>
      </div>
    </div>


    <span slot="footer" class="dialog-footer" >
      <el-button
        @click="cancel"
        v-loading.fullscreen.lock="loading"
        element-loading-text="提交中..."
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.8)"
      >
        <span>关闭</span>
      </el-button>
    </span>

  </el-dialog>
</template>

<script>
import { getInvoiceDetail } from '@/api/financeMr/InvoiceRecords'
export default {
  name: "detailsDia",
  dicts: ['Invoicing_type','lookup_type'],
  data() {
    return {
      title: "编辑",
      model: "EDIT",
      open: false,
      loading: false,
      form: {
        id: undefined,
      },
      performerVisible: false,
      performerList: [],
      refund: false,
    };
  },
  methods: {
    /**
     * 打开弹框
     * @date 2023-11-22
     * @param {any} obj
     * @returns {any}
     */
    openDialog(title, obj, type) {
      this.open = true;
      this.getInvoiceDetailApi(obj);
    },
    /** 获取详情 */
    getInvoiceDetailApi(row) {
      const id = row.orderId
      getInvoiceDetail({
        orderId: row.orderId
      }).then(response => {
        this.form = response.data;
      });
    },
    /**
     * 关闭弹框
     * @date 2023-11-22
     * @returns {any}
     */
    cancel() {
      this.open = false;
    },
    openPDF(url) {
      window.open(url)
    }
  },
};
</script>

<style lang="scss" scoped>
.dialog {
  padding: 0 30px;
  height: 60vh;
  overflow-y: auto;
}
.dialog {
  padding: 0 30px;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  >div:first-child {
    width: 400px;
    padding-right: 20px;
    box-sizing: border-box;
  }
  >div:last-child {
    width: calc( 100% - 400px );
    iframe {
      width: 100%;
      height: 100%;
    }
  }
  .upload-btn {
    width: 100px;
    height: 100px;
    background-color: #fbfdff;
    border: dashed 1px #c0ccda;
    border-radius: 5px;
    i {
      font-size: 30px;
      margin-top: 20px;
    }
    &-text {
      margin-top: -10px;
    }
  }
  .avatar {
    cursor: pointer;
  }
  .title-class{
    font-size: 16px;
    font-weight: bold;
    color: black;
    margin-bottom: 20px;
    margin-top: 20px;
  }
  .item-class{
    margin-bottom: 20px;
  }
}
</style>
