<template>
<div style="background-color: #f0f2f5; padding-bottom: 20px; min-height: 100%; " >
    <div style="padding: 20px; background-color: #fff;">
      支付详情
    </div>
<div class="contentx" v-if="item!=null">
      <div class="desct">
        支付信息
      </div>

        <div class="" v-if="item.status==0" style="float: right;margin: 5px;">
           <el-button size="mini" @click="getPayStatus()" >同步支付状态</el-button>
        </div>
        <div class="" v-if="item.status>=0" style="float: right; margin: 5px;" v-hasPermi="['his:storePayment:refund']" >
           <el-button size="mini" @click="payRefund()" >退款</el-button>
        </div>
        <el-descriptions title="" :column="3" border>
            <el-descriptions-item label="支付订单号" >
                <span v-if="item!=null">{{item.payCode}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="支付类型" >
                <span v-if="item!=null">{{item.payTypeCode}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="支付金额" >
                <span v-if="item!=null">{{item.payMoney}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="外部订单号" >
                <span v-if="item!=null">{{item.tradeNo}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="用户昵称" >
                <span v-if="item!=null">{{item.nickName}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="OPENID" >
                <span v-if="item!=null">{{item.openId}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="用户电话" >
                <span v-if="item!=null">{{item.phone}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="店铺名称" >
                <span v-if="item!=null">{{item.storeName}}</span>
            </el-descriptions-item>

            <el-descriptions-item label="交易单号" >
                <span v-if="item!=null">{{item.bankTransactionId}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="银行流水号" >
                <span v-if="item!=null">{{item.bankSerialNo}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="退款金额" >
                <span v-if="item!=null">{{item.refundMoney}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="退款时间" >
                <span v-if="item!=null">{{item.refundTime}}</span>
            </el-descriptions-item>

            <el-descriptions-item label="业务类型" >
             <span v-if="item!=null">
                   <dict-tag :options="busineOptions" :value="item.businessType"/>
             </span>
            </el-descriptions-item>
            <el-descriptions-item label="状态" >
             <span v-if="item!=null">
                   <dict-tag :options="statusOptions" :value="item.status"/>
             </span>
            </el-descriptions-item>
            <el-descriptions-item label="创建时间" >
                <span v-if="item!=null">{{item.createTime}}</span>
            </el-descriptions-item>
            <el-descriptions-item label="支付时间" >
                <span v-if="item!=null">{{item.payTime}}</span>
            </el-descriptions-item>
        </el-descriptions>
    </div>
    </div>
</template>

<script>
import { refund,listStorePayment,getStatus, getStorePayment, delStorePayment, addStorePayment, updateStorePayment, exportStorePayment } from "@/api/his/storePayment";
  export default {
    name: "depdetails",
    props:["data"],
    data() {
      return {
        statusOptions: [],
        busineOptions: [],
        item:null,

      }
    },
    created() {
     this.getDicts("sys_store_payment_status").then(response => {
       this.statusOptions = response.data;
     });
  this.getDicts("sys_store_payment_business_type").then(response => {
    this.busineOptions = response.data;
  });


    },
    methods: {
      getDetails(orderId) {
        this.item=null;
        getStorePayment(orderId).then(response => {
              this.item = response.data;
        });
      },
      getPayStatus(){
          var that=this;
          this.$confirm('是否确认同步支付状态?', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function() {
            return getStatus(that.item.paymentId);
          }).then(() => {
            getStorePayment(that.item.paymentId).then(response => {
                  that.item = response.data;
            });
             this.msgSuccess("操作成功");
          }).catch(function() {});
      },


      payRefund(){
          var that=this;
          this.$confirm('是否确认退款?', "警告", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(function() {
            return refund(that.item.paymentId);
          }).then(() => {
            getStorePayment(that.item.paymentId).then(response => {
                  that.item = response.data;
            });
             this.msgSuccess("操作成功");
          }).catch(function() {});
      },
    }
  }
</script>
<style>

  .contentx{
      height: 100%;
      background-color: #fff;
      padding: 0px 20px 20px;


      margin: 20px;
  }
  .el-descriptions-item__label.is-bordered-label{
    font-weight: normal;
  }
  .el-descriptions-item__content {
    max-width: 150px;
    min-width: 100px;
  }
  .desct{
      padding-top: 20px;
      padding-bottom: 20px;
      color: #524b4a;
      font-weight: bold;
    }

</style>
