<!--
  通用 【签约开通】页面

  @author terrfly
  @site https://www.jeequan.com
  @date 2022/11/03 08:35
-->

<template>
  <div v-if="vdata.recordId">
    <div v-if="configMode == 'mgrApplyment'">
      <a-alert
        message="注意"
        description="已经开通过支付产品的不要重复开通"
        type="warning"
        show-icon
      />
      <a-form layout="vertical">
        <JeepayPaywayRatePanel
          ref="jeepayPaywayRatePanelRef"
          configMode="mgrApplyment"
          :infoId="vdata.recordId + '_' + vdata.detailData.mchNo"
          :selectIfCode="vdata.detailData.ifCode"
          onlyRate="true"
        />
      </a-form>

      <div class="drawer-btn-center jeepay-m-drawer">
        <a-button class="jeepay-m-btn" data-type="block" type="primary" :loading="vdata.btnLoading" @click="payConfAddFunc"><check-outlined />保存</a-button>
      </div>
    </div>
    <div v-else>
      <a-result title="暂无更多操作">
        <template #icon>
          <smile-twoTone />
        </template>
      </a-result>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { $payConfAdd } from '@/api/manage'
import {reactive, ref, inject, getCurrentInstance} from 'vue'
const { $infoBox } = getCurrentInstance()!.appContext.config.globalProperties

const jeepayPaywayRatePanelRef = ref()

// 接收父组件的参数注入： 配置方式 (判断是 运营平台  代理商 还是商户 )
let configMode : any = inject('configMode')

// 接收父组件的参数注入： 进件详细欣欣
let applyRecord : any = inject('applyRecord')

const vdata : any = reactive({
  recordId: null, // 更新对象ID
  detailData: null,

})

function pageRender (recordId) { // 弹层打开事件
  vdata.detailData = applyRecord

  vdata.recordId = recordId
}


function payConfAddFunc(){

  // 放置费率配置项
  let paywayFeeList = jeepayPaywayRatePanelRef.value.getReqMchRatePaywayFeeList()
  if (!paywayFeeList) {
    return
  }

  $payConfAdd(vdata.recordId, { paywayFeeList: paywayFeeList }).then((res) => {
    $infoBox.message.success('新增成功 ')
  })

}

defineExpose({ pageRender })
</script>
<style scoped>

.form-item-content{
  width: 70%
}

</style>
