<template>
  <el-dialog
      v-model="props.visible"
      title="短信日志详情"

      width="700"
      :close-on-click-modal="false"
      :before-close="dialogClose"
  >
  <el-descriptions  column="2" border>
    <el-descriptions-item label="日志标题:" label-class-name="des-width">{{formData.title}}</el-descriptions-item>
    <el-descriptions-item label="日志类型:" label-class-name="des-width">{{getTyepText(formData.type)}}</el-descriptions-item>
    <el-descriptions-item label="模板编号:">{{formData.number}}</el-descriptions-item>
    <el-descriptions-item label="接收人手机:">{{formData.receiveMobile}}</el-descriptions-item>
    <el-descriptions-item label="接收人类型:">{{getReviceType(formData.receiveType)}}</el-descriptions-item>
    <el-descriptions-item label="请求耗时:">{{formData.consumeTime}}s</el-descriptions-item>
    <el-descriptions-item label="业务类型:">{{formData.bizType?(formData.bizType==1?'订单':'其他'):''}}</el-descriptions-item>
    <el-descriptions-item label="业务ID:">{{formData.bizId}}</el-descriptions-item>
    <el-descriptions-item label="日志状态:">{{formData.status==1?'已读':'未读'}}</el-descriptions-item>
    <el-descriptions-item label="请求状态" label-class-name="des-width">
       {{  formData.status?'失败':'成功'}}
      </el-descriptions-item>
</el-descriptions>
<el-descriptions class="margin-top" :column="1" border>
      <el-descriptions-item label="业务内容" label-class-name="des-width">
        {{formData.bizContent}}
      </el-descriptions-item>
    </el-descriptions>
<el-descriptions class="margin-top" :column="1" border>
    <el-descriptions-item label="请求参数" label-class-name="des-width">
      {{formData.param}}
    </el-descriptions-item>
  </el-descriptions>
    <el-descriptions class="margin-top" :column="1" border>
    <el-descriptions-item label="返回结果" label-class-name="des-width">
      {{formData.result}}
    </el-descriptions-item>
    </el-descriptions>
    <el-descriptions class="margin-top" :column="1" border>
    <el-descriptions-item label="错误描述" label-class-name="des-width">
      {{formData.error}}
    </el-descriptions-item>
    </el-descriptions>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogClose">关闭</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script lang="ts" setup>
import type {FormInstance} from "element-plus";
import {getSmsLogDetail} from "@/api/logger/smsLog";
import {onMounted, ref, shallowRef} from "vue";
import {message} from "@/utils/auth";
import {useLockFn} from "@/utils/useLockFn";

const emit = defineEmits(["success", "update:visible"]);
const formRef = shallowRef<FormInstance>();
const formData = ref({});

const props = defineProps({
  visible: {
    type: Boolean,
    required: true,
    default: false
  },
  smsId: {
    type: Number,
    required: true,
    default: 0
  }
});


const dialogClose = () => {
  emit("update:visible", false);
};

const setFormData = async () => {
  const data = await getSmsLogDetail(props.smsId);
  formData.value = data
};
const getReviceType =(type)=>{
  let typeText = ''
    switch (type) {
      case 1:
        typeText='系统用户'
        break;
      case 2:
        typeText='会员用户'
        break;
      case 3:
        typeText='其他'
        break;
      default:
        break
    }
    return typeText 
}
const getTyepText =(type)=>{
  let typeText = ''
    switch (type) {
      case 1:
          typeText='登录'
          break;
        case 2:
          typeText='注册'
          break;
        case 3:
          typeText='找回密码'
          break;
        case 4:
          typeText='业务'
          break;
        case 5:
          typeText='其他'
          break;
      default:
        break
    }
    return typeText 
}

onMounted(() => {
  if (props.smsId) {
    setFormData();
  }
});

</script>
<style lang="scss" scoped>
:deep(.des-width) {
  width:120px;
}
:deep(.el-descriptions__body .el-descriptions__table .el-descriptions__cell)  {
  word-break: break-all;
}
</style>