<script setup lang="ts">
import {computed} from "vue";

defineOptions({
  name: 'OperlogView'
});

const visible = defineModel<boolean>('visible', { default: false });

const { statusOptions, typeOptions, rowData } = defineProps<{
  rowData: Api.SystemManage.Operlog | null;
  statusOptions?: Api.SystemManage.DictInfo[];
  typeOptions: Api.SystemManage.DictInfo[];
}>();

const filterStatus = computed(() => {
  const obj = statusOptions?.find(item => item.dictValue === rowData?.status.toString());
  return obj?.dictLabel || '/';
});

const filterType = computed(() => {
  const obj = typeOptions.find(item => item.dictValue === rowData?.businessType.toString());
  return obj?.dictLabel || '/';
});
</script>

<template>
  <NModal v-model:show="visible" title="操作日志详细：" preset="card" class="w-800px">
    <NScrollbar class="max-h-500px pr-20px">
      <NForm label-placement="left" require-mark-placement="left" :label-width="130">
        <NGrid responsive="screen" item-responsive>
          <NFormItemGi span="24 m:12" label="操作模块：">{{ rowData?.title }} / {{ filterType }}</NFormItemGi>
          <NFormItemGi span="24 m:12" label="请求地址：">
            {{ rowData?.operUrl }}
          </NFormItemGi>
          <NFormItemGi span="24 m:12" label="登录信息：">
            {{ rowData?.operName }} / {{ rowData?.operIp }} / {{ rowData?.operLocation }}
          </NFormItemGi>
          <NFormItemGi span="24 m:12" label="请求方式：">
            {{ rowData?.requestMethod }}
          </NFormItemGi>
          <NFormItemGi span="24 m:12" label="操作方法：">
            {{ rowData?.method }}
          </NFormItemGi>
          <NFormItemGi span="24" label="请求参数：">
            {{ rowData?.operParam }}
          </NFormItemGi>
          <NFormItemGi span="24" label="返回参数：">
            {{ rowData?.jsonResult }}
          </NFormItemGi>
          <NFormItemGi span="24 m:12" label="状态：">
            {{ filterStatus }}
          </NFormItemGi>
          <NFormItemGi span="24 m:12" label="操作时间：">
            {{ rowData?.operTime }}
          </NFormItemGi>
          <NFormItemGi v-if="rowData?.status === 1" span="24" label="异常信息：">
            {{ rowData?.errorMsg }}
          </NFormItemGi>
        </NGrid>
      </NForm>
    </NScrollbar>
    <template #footer>
      <NSpace justify="end" :size="16">
        <NButton @click="visible = false">关闭</NButton>
      </NSpace>
    </template>
  </NModal>
</template>

<style scoped>

</style>
