mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-23 23:39:47 +08:00
chore: 优化代码生成模板
This commit is contained in:
20
docs/template/soy.index.vue.vm
vendored
20
docs/template/soy.index.vue.vm
vendored
@ -1,11 +1,11 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { fetchGet${BusinessName}List, fetchDelete${BusinessName}, fetchBatchDelete${BusinessName} } from '@/service/api/${moduleName}/${businessName}';
|
||||
import { fetchGet${BusinessName}List, fetchBatchDelete${BusinessName} } from '@/service/api/${moduleName}/${businessName}';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import ${BusinessName}OperateDrawer from './modules/${businessName}-operate-drawer.vue';
|
||||
import ${BusinessName}Search from './modules/${businessName}-search.vue';
|
||||
import ${BusinessName}OperateDrawer from './modules/${business_name}-operate-drawer.vue';
|
||||
import ${BusinessName}Search from './modules/${business_name}-search.vue';
|
||||
|
||||
defineOptions({
|
||||
name: '${BusinessName}List'
|
||||
@ -65,10 +65,10 @@ const {
|
||||
width: 130,
|
||||
render: row => (
|
||||
<div class="flex-center gap-8px">
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.id)}>
|
||||
<NButton type="primary" ghost size="small" onClick={() => edit(row.#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end!)}>
|
||||
{$t('common.edit')}
|
||||
</NButton>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.id)}>
|
||||
<NPopconfirm onPositiveClick={() => handleDelete(row.#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end!)}>
|
||||
{{
|
||||
default: () => $t('common.confirmDelete'),
|
||||
trigger: () => (
|
||||
@ -97,20 +97,20 @@ const {
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
const { error } = await fetchDelete${BusinessName}(checkedRowKeys.value)
|
||||
const { error } = await fetchBatchDelete${BusinessName}(checkedRowKeys.value)
|
||||
if (error) return;
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
async function handleDelete(id: number) {
|
||||
async function handleDelete(#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end: CommonType.IdType) {
|
||||
// request
|
||||
const { error } = await fetchBatchDelete${BusinessName}([id])
|
||||
const { error } = await fetchBatchDelete${BusinessName}([#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end])
|
||||
if (error) return;
|
||||
onDeleted();
|
||||
}
|
||||
|
||||
async function edit(id: number) {
|
||||
handleEdit('#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end', id);
|
||||
async function edit(id: CommonType.IdType) {
|
||||
handleEdit('#foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end', #foreach($column in $columns)#if($column.isPk == '1')$column.javaField#end#end);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
8
docs/template/typings/soy.api.d.ts.vm
vendored
8
docs/template/typings/soy.api.d.ts.vm
vendored
@ -6,7 +6,7 @@
|
||||
* backend api module: "${ModuleName}"
|
||||
*/
|
||||
namespace ${ModuleName} {
|
||||
/** ${businessName} */
|
||||
/** ${businessname} */
|
||||
type ${BusinessName} = Api.Common.CommonRecord<{
|
||||
#foreach($column in $columns)#if(!$BaseEntity.contains($column.javaField))
|
||||
/** $column.columnComment */
|
||||
@ -14,7 +14,7 @@ namespace ${ModuleName} {
|
||||
#end#end
|
||||
}>;
|
||||
|
||||
/** ${businessName} search params */
|
||||
/** ${businessname} search params */
|
||||
type ${BusinessName}SearchParams = Api.CommonType.RecordNullable<
|
||||
Pick<
|
||||
Api.${ModuleName}.${BusinessName},
|
||||
@ -27,7 +27,7 @@ namespace ${ModuleName} {
|
||||
Api.Common.CommonSearchParams<${BusinessName}>
|
||||
>;
|
||||
|
||||
/** ${businessName} operate params */
|
||||
/** ${businessname} operate params */
|
||||
type ${BusinessName}OperateParams = Api.CommonType.RecordNullable<
|
||||
Pick<
|
||||
Api.${ModuleName}.${BusinessName},
|
||||
@ -39,6 +39,6 @@ namespace ${ModuleName} {
|
||||
>
|
||||
>;
|
||||
|
||||
/** ${businessName} list */
|
||||
/** ${businessname} list */
|
||||
type ${BusinessName}List = Api.Common.PaginatingQueryRecord<${BusinessName}>;
|
||||
}
|
||||
|
Reference in New Issue
Block a user