mirror of
https://gitee.com/y_project/RuoYi-Vue.git
synced 2026-06-19 04:59:22 +08:00
85 lines
2.6 KiB
Plaintext
85 lines
2.6 KiB
Plaintext
<template>
|
||
<el-drawer title="${functionName}详情" v-model="visible" direction="rtl" size="60%" append-to-body :before-close="handleClose" class="detail-drawer">
|
||
<div v-loading="loading" class="drawer-content">
|
||
<h4 class="section-header">基本信息</h4>
|
||
#set($i = 0)
|
||
#foreach($column in $columns)
|
||
#if(!$column.pk && $column.list)
|
||
#set($dictType=$column.dictType)
|
||
#set($javaField=$column.javaField)
|
||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||
#if($parentheseIndex != -1)
|
||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||
#else
|
||
#set($comment=$column.columnComment)
|
||
#end
|
||
#if($i % 2 == 0)
|
||
<el-row :gutter="20" class="mb8">
|
||
#end
|
||
<el-col :span="12">
|
||
<div class="info-item">
|
||
<label class="info-label">${comment}:</label>
|
||
<span class="info-value plaintext">
|
||
#if("" != $dictType)
|
||
#if($column.htmlType == "checkbox")
|
||
<dict-tag :options="${dictType}" :value="info.${javaField} ? info.${javaField}.split(',') : []" />
|
||
#else
|
||
<dict-tag :options="${dictType}" :value="info.${javaField}" />
|
||
#end
|
||
#elseif($column.htmlType == "datetime")
|
||
{{ parseTime(info.${javaField}, '{y}-{m}-{d}') }}
|
||
#elseif($column.htmlType == "imageUpload")
|
||
<image-preview :src="info.${javaField}" :width="60" :height="60" />
|
||
#else
|
||
{{ info.${javaField} }}
|
||
#end
|
||
</span>
|
||
</div>
|
||
</el-col>
|
||
#set($i = $i + 1)
|
||
#if($i % 2 == 0)
|
||
</el-row>
|
||
#end
|
||
#end
|
||
#end
|
||
#if($i % 2 != 0)
|
||
</el-row>
|
||
#end
|
||
</div>
|
||
</el-drawer>
|
||
</template>
|
||
|
||
<script setup lang="ts" name="${BusinessName}ViewDrawer">
|
||
import type { ${ClassName} } from "@/types/api/${moduleName}/${businessName}"
|
||
import { get${BusinessName} } from '@/api/${moduleName}/${businessName}'
|
||
#if(${dicts} != '')
|
||
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||
|
||
const { ${dictsNoSymbol} } = useDict(${dicts})
|
||
#end
|
||
|
||
const visible = ref<boolean>(false)
|
||
const loading = ref<boolean>(false)
|
||
const info = reactive<Partial<${ClassName}>>({})
|
||
|
||
const open = async (#if($pkColumn.javaType == "Long" || $pkColumn.javaType == "Integer")${pkColumn.javaField}: number#else${pkColumn.javaField}: string#end): Promise<void> => {
|
||
visible.value = true
|
||
loading.value = true
|
||
try {
|
||
const res = await get${BusinessName}(${pkColumn.javaField})
|
||
Object.assign(info, res.data ?? {})
|
||
} catch (error) {
|
||
console.error('获取${functionName}信息失败:', error)
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
const handleClose = (): void => {
|
||
visible.value = false
|
||
Object.keys(info).forEach(key => delete (info as any)[key])
|
||
}
|
||
|
||
defineExpose({ open })
|
||
</script>
|