Просмотр исходного кода

feat:【infra】优化 codegen 的 vben 模版

YunaiV месяцев назад: 11
Родитель
Сommit
11dd2308b3

+ 1 - 1
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/general/views/index.vue.vm

@@ -123,7 +123,7 @@ const [FormModal, formModalApi] = useVbenModal({
 
 /** 创建${table.classComment} */
 function handleCreate() {
-  formModalApi.setData({}).open();
+  formModalApi.setData(null).open();
 }
 
 /** 编辑${table.classComment} */

+ 0 - 2
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_erp.vue.vm

@@ -43,7 +43,6 @@
       if (!valid) {
         return;
       }
-
       modalApi.lock();
       // 提交表单
       const data = (await formApi.getValues()) as ${apiName}.${subSimpleClassName};
@@ -63,7 +62,6 @@
         formData.value = undefined;
         return;
       }
-
       // 加载数据
       let data = modalApi.getData<${apiName}.${subSimpleClassName}>();
       if (!data) {

+ 4 - 4
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/form_sub_normal.vue.vm

@@ -38,7 +38,7 @@ function onActionClick({
 }: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
   switch (code) {
     case 'delete': {
-      onDelete(row);
+      handleDelete(row);
       break;
     }
   }
@@ -64,12 +64,12 @@ gridOptions: {
 });
 
 /** 添加${subTable.classComment} */
-const onAdd = async () => {
+const handleAdd = async () => {
   await gridApi.grid.insertAt({} as ${apiName}.${subSimpleClassName}, -1);
 }
 
 /** 删除${subTable.classComment} */
-const onDelete =  async (row: ${apiName}.${subSimpleClassName}) => {
+const handleDelete =  async (row: ${apiName}.${subSimpleClassName}) => {
   await gridApi.grid.remove(row);
 }
 
@@ -188,7 +188,7 @@ watch(
       #end
   </Grid>
   <div class="flex justify-center -mt-4">
-    <Button :icon="h(Plus)" type="primary" ghost @click="onAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
+    <Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
       {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
     </Button>
   </div>

+ 3 - 2
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm

@@ -13,7 +13,7 @@ import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}
 #if ($table.templateType == 11) ## erp
 import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
 #end
-import { useVbenModal } from '@vben/common-ui';
+import { confirm, useVbenModal } from '@vben/common-ui';
 import { message } from 'ant-design-vue';
 import { ref, computed, nextTick,watch } from 'vue';
 import { $t } from '#/locales';
@@ -74,8 +74,9 @@ async function handleDelete(row: ${apiName}.${subSimpleClassName}) {
 #if ($deleteBatchEnable)
 /** 批量删除${subTable.classComment} */
 async function handleDeleteBatch() {
+  await confirm($t('ui.actionMessage.deleteBatchConfirm'));
   const hideLoading = message.loading({
-    content: $t('ui.actionMessage.deleting'),
+    content: $t('ui.actionMessage.deletingBatch'),
     duration: 0,
   });
   try {

+ 1 - 3
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/index.vue.vm

@@ -123,7 +123,7 @@ const [FormModal, formModalApi] = useVbenModal({
 
 /** 创建${table.classComment} */
 function handleCreate() {
-  formModalApi.setData({}).open();
+  formModalApi.setData(null).open();
 }
 
 /** 编辑${table.classComment} */
@@ -142,7 +142,6 @@ function handleAppend(row: ${simpleClassName}Api.${simpleClassName}) {
 async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
   const loadingInstance = ElLoading.service({
     text: $t('ui.actionMessage.deleting', [row.id]),
-    background: 'rgba(0, 0, 0, 0.7)',
   });
   try {
     await delete${simpleClassName}(row.id as number);
@@ -158,7 +157,6 @@ async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
 async function handleDeleteBatch() {
   const loadingInstance = ElLoading.service({
     text: $t('ui.actionMessage.deleting'),
-    background: 'rgba(0, 0, 0, 0.7)',
   });
   try {
     await delete${simpleClassName}List(checkedIds.value);

+ 0 - 2
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/general/views/modules/list_sub_erp.vue.vm

@@ -69,7 +69,6 @@ function handleEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
 async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
   const loadingInstance = ElLoading.service({
     text: $t('ui.actionMessage.deleting', [row.id]),
-    background: 'rgba(0, 0, 0, 0.7)',
   });
   try {
     await delete${subSimpleClassName}(row.id as number);
@@ -85,7 +84,6 @@ async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
 async function handleDeleteBatch() {
   const loadingInstance = ElLoading.service({
     text: $t('ui.actionMessage.deleting'),
-    background: 'rgba(0, 0, 0, 0.7)',
   });
   try {
     await delete${subSimpleClassName}List(checkedIds.value);