<template>

  <Dialog :title="dialogTitle" v-model="dialogVisible" width="70%">
    <ContentWrap v-loading="formLoading" style="max-height:550px;min-height:550px;overflow-y: auto;border:none ;">
      <div class="left ">
        <SPuUploadImg v-model="picUrl" :disabled="true" />
        <el-tabs v-model="activeName" tab-position="left" class="child-tabs">
          <el-tab-pane label="基本信息" name="info" />
          <el-tab-pane label="支付信息" name="pay" />
          <el-tab-pane label="异步回调内容" name="return" />
        </el-tabs>
      </div>
      <div class="right">
        <PayOrderBaseInfo :obj="userObj" title :isDetail="isDetail" :openType="openType" :picUrl="picUrl"
          v-if="activeName == 'info'" />
        <PayOrderPayInfo :obj="userObj" title :isDetail="isDetail" :openType="openType" :picUrl="picUrl"
            v-if="activeName == 'pay'" />
        <PayOrderReturnInfo :obj="userObj" title :isDetail="isDetail" :openType="openType" :picUrl="picUrl"
          v-if="activeName == 'return'" />
      </div>

      <div style="clear: both;"></div>

    </ContentWrap>

  </Dialog>


</template>

<script lang="ts" setup>
import Dialog from '@/components/Dialog/src/Dialog.vue'
import PayOrderBaseInfo from './components/PayOrderBaseInfo.vue'
import PayOrderPayInfo from './components/PayOrderPayInfo.vue'
import PayOrderReturnInfo from './components/PayOrderReturnInfo.vue'
const { t } = useI18n() // 国际化
const formLoading = ref(false) // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
const activeName = ref('info') // Tag 激活的窗口
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const isDetail = ref(false)
const openType = ref('view')
const userObj = ref({})
const picUrl = ref('picUrl') //头像
/** 打开弹窗 */
const open = async (type: string, obj: object) => {
  console.log(obj)
  if (obj.picUrl == '' || obj.picUrl == null) {
    picUrl.value = "默认图片"
  } else {
    picUrl.value = obj.picUrl
  }
  userObj.value = obj
  openType.value = type
  dialogTitle.value = t('action.' + type)
  if (type == "view") {
    dialogTitle.value = "查看"
  }
  // 判断打开状态，如果是view那就只能查看 否则可以编辑
  if ('view' == type) {
    isDetail.value = true
  } else {
    isDetail.value = false
    activeName.value = 'info'
  }
  dialogVisible.value = true
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
const emit = defineEmits(['success']) // 定义 success 事件，用于操作成功后的回调
const userFormRef = ref() // 表单 Ref
const userFormSubmit = async () => {
  if (await userFormRef.value?.submitForm()) {
    emit('success')
    dialogVisible.value = false
  }
}


</script>

<style lang="scss">
.el-dialog__body {
  padding: 0;
}

.left {
  width: 106px;
  float: left;
}

.child-tabs {
  border-top: 2px solid #e4e7ef;
  margin-top: -7px;
}

.child-tabs .el-tabs__item {
  width: 106px;
  justify-content: center;
}

.right {
  padding: 10px 0 0 10px;
  border-left: 2px solid #e4e7ee;
  margin-left: -2px;
  float: left;
  width: calc(100% - 120px);
}
</style>