liusuyi
2026-05-12 9f327c33730ba10cb2d89aff99b727502232e968
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<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 name="${BusinessName}ViewDrawer">
import { get${BusinessName} } from '@/api/${moduleName}/${businessName}'
 
#if(${dicts} != '')
#set($dictsNoSymbol=$dicts.replace("'", ""))
const { ${dictsNoSymbol} } = useDict(${dicts})
#end
 
const visible = ref(false)
const loading = ref(false)
const info = reactive({})
 
const open = async (${pkColumn.javaField}) => {
  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
  }
}
 
function handleClose() {
  visible.value = false
  Object.keys(info).forEach(key => delete info[key])
}
 
defineExpose({ open })
</script>