2026-06-26 20b96473f2520590a0dca6b775b81e3ea06a77a0
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
  <view class="yd-page-container">
    <!-- 顶部导航栏 -->
    <wd-navbar
      title="${table.classComment}详情"
      left-arrow placeholder safe-area-inset-top fixed
      @click-left="handleBack"
    />
 
    <!-- 详情内容 -->
    <view>
      <wd-cell-group border>
#foreach($column in $columns)
  #if ($column.primaryKey || $column.listOperationResult || $column.createOperation || $column.updateOperation)
    #set ($javaField = $column.javaField)
    #set ($comment = $column.columnComment)
    #if ($column.dictType && "" != $column.dictType)
        <wd-cell title="${comment}">
          <dict-tag :type="DICT_TYPE.${column.dictType.toUpperCase()}" :value="formData?.${javaField}" />
        </wd-cell>
    #elseif ($column.javaType == "LocalDateTime")
        <wd-cell title="${comment}" :value="formatDateTime(formData?.${javaField}) || '-'" />
    #else
        <wd-cell title="${comment}" :value="formData?.${javaField} ?? '-'" />
    #end
  #end
#end
      </wd-cell-group>
    </view>
 
    <!-- 底部操作按钮 -->
    <view class="yd-detail-footer">
      <view class="yd-detail-footer-actions">
        <wd-button
          v-if="hasAccessByCodes(['${permissionPrefix}:update'])"
          class="flex-1" type="warning" @click="handleEdit"
        >
          编辑
        </wd-button>
        <wd-button
          v-if="hasAccessByCodes(['${permissionPrefix}:delete'])"
          class="flex-1" type="error" :loading="deleting" @click="handleDelete"
        >
          删除
        </wd-button>
      </view>
    </view>
  </view>
</template>
 
<script lang="ts" setup>
#set ($hasDict = 0)
#foreach($column in $columns)
  #if ($hasDict == 0 && $column.dictType && "" != $column.dictType)
    #set ($hasDict = 1)
  #end
#end
#set ($hasDateTime = 0)
#foreach($column in $columns)
  #if ($hasDateTime == 0 && $column.javaType == "LocalDateTime")
    #set ($hasDateTime = 1)
  #end
#end
import type { ${simpleClassName} } from '@/api/${table.moduleName}/${table.businessName}'
import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { delete${simpleClassName}, get${simpleClassName} } from '@/api/${table.moduleName}/${table.businessName}'
import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils'
#if ($hasDict == 1)
import { DICT_TYPE } from '@/utils/constants'
#end
#if ($hasDateTime == 1)
import { formatDateTime } from '@/utils/date'
#end
 
const props = defineProps<{
  id?: number | any
}>()
 
definePage({
  style: {
    navigationBarTitleText: '',
    navigationStyle: 'custom',
  },
})
 
const { hasAccessByCodes } = useAccess()
const toast = useToast()
const formData = ref<${simpleClassName}>()
const deleting = ref(false)
 
/** 返回上一页 */
function handleBack() {
  navigateBackPlus('/pages-${table.moduleName}/${table.businessName}/index')
}
 
/** 加载${table.classComment}详情 */
async function getDetail() {
  if (!props.id) {
    return
  }
  try {
    toast.loading('加载中...')
    formData.value = await get${simpleClassName}(props.id)
  } finally {
    toast.close()
  }
}
 
/** 编辑${table.classComment} */
function handleEdit() {
  uni.navigateTo({
    url: `/pages-${table.moduleName}/${table.businessName}/form/index?id=#[[${]]#props.id#[[}]]#`,
  })
}
 
/** 删除${table.classComment} */
function handleDelete() {
  if (!props.id) {
    return
  }
  uni.showModal({
    title: '提示',
    content: '确定要删除该${table.classComment}吗?',
    success: async (res) => {
      if (!res.confirm) {
        return
      }
      deleting.value = true
      try {
        await delete${simpleClassName}(props.id)
        toast.success('删除成功')
        setTimeout(() => {
          handleBack()
        }, 500)
      } finally {
        deleting.value = false
      }
    },
  })
}
 
/** 初始化 */
onMounted(() => {
  getDetail()
})
</script>
 
<style lang="scss" scoped>
</style>