|
@@ -4,7 +4,7 @@ import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.bu
|
|
|
|
|
|
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
|
|
import { Button, message,Tabs } from 'ant-design-vue';
|
|
import { Button, message,Tabs } from 'ant-design-vue';
|
|
|
-import { Download, Plus } from '@vben/icons';
|
|
|
|
|
|
|
+import { Download, Plus, Trash2 } from '@vben/icons';
|
|
|
import Form from './modules/form.vue';
|
|
import Form from './modules/form.vue';
|
|
|
|
|
|
|
|
## 特殊:主子表专属逻辑
|
|
## 特殊:主子表专属逻辑
|
|
@@ -16,15 +16,15 @@ import Form from './modules/form.vue';
|
|
|
#end
|
|
#end
|
|
|
#end
|
|
#end
|
|
|
|
|
|
|
|
-import { ref, h } from 'vue';
|
|
|
|
|
|
|
+import { ref, h, computed } from 'vue';
|
|
|
import { $t } from '#/locales';
|
|
import { $t } from '#/locales';
|
|
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
|
#if (${table.templateType} == 2)## 树表接口
|
|
#if (${table.templateType} == 2)## 树表接口
|
|
|
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
|
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
|
|
#else## 标准表接口
|
|
#else## 标准表接口
|
|
|
-import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
|
|
|
|
|
|
+import { get${simpleClassName}Page, delete${simpleClassName},delete${simpleClassName}ByIds, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
|
|
#end
|
|
#end
|
|
|
-import { downloadFileFromBlobPart } from '@vben/utils';
|
|
|
|
|
|
|
+import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
|
|
|
|
|
|
|
import { useGridColumns, useGridFormSchema } from './data';
|
|
import { useGridColumns, useGridFormSchema } from './data';
|
|
|
|
|
|
|
@@ -87,11 +87,31 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
|
|
await delete${simpleClassName}(row.id as number);
|
|
await delete${simpleClassName}(row.id as number);
|
|
|
message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
|
|
message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
|
|
|
onRefresh();
|
|
onRefresh();
|
|
|
- } catch {
|
|
|
|
|
|
|
+ } finally {
|
|
|
hideLoading();
|
|
hideLoading();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#if ($table.templateType != 2 && $table.deleteBatch)
|
|
|
|
|
+const deleteIds = ref<number[]>([]) // 待删除${table.classComment} ID
|
|
|
|
|
+const showDeleteBatchBtn = computed(() => isEmpty(deleteIds.value));
|
|
|
|
|
+/** 批量删除${table.classComment} */
|
|
|
|
|
+async function onDeleteBatch() {
|
|
|
|
|
+ const hideLoading = message.loading({
|
|
|
|
|
+ content: $t('ui.actionMessage.deleting'),
|
|
|
|
|
+ duration: 0,
|
|
|
|
|
+ key: 'action_process_msg',
|
|
|
|
|
+ });
|
|
|
|
|
+ try {
|
|
|
|
|
+ await delete${simpleClassName}ByIds(deleteIds.value);
|
|
|
|
|
+ message.success( $t('ui.actionMessage.deleteSuccess') );
|
|
|
|
|
+ onRefresh();
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ hideLoading();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+#end
|
|
|
|
|
+
|
|
|
/** 导出表格 */
|
|
/** 导出表格 */
|
|
|
async function onExport() {
|
|
async function onExport() {
|
|
|
const data = await export${simpleClassName}(await gridApi.formApi.getValues());
|
|
const data = await export${simpleClassName}(await gridApi.formApi.getValues());
|
|
@@ -177,11 +197,21 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|
|
search: true,
|
|
search: true,
|
|
|
},
|
|
},
|
|
|
} as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
|
|
} as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
|
|
|
-#if (${table.templateType} == 11)
|
|
|
|
|
|
|
+#if (${table.templateType} == 11 || $table.deleteBatch)
|
|
|
gridEvents:{
|
|
gridEvents:{
|
|
|
|
|
+ #if(${table.templateType} == 11)
|
|
|
cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => {
|
|
cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => {
|
|
|
select${simpleClassName}.value = row;
|
|
select${simpleClassName}.value = row;
|
|
|
},
|
|
},
|
|
|
|
|
+ #end
|
|
|
|
|
+ #if($table.deleteBatch)
|
|
|
|
|
+ checkboxAll: ({records,}: { records: ${simpleClassName}Api.${simpleClassName}[];}) => {
|
|
|
|
|
+ deleteIds.value = records.map((item) => item.id);
|
|
|
|
|
+ },
|
|
|
|
|
+ checkboxChange: ({records,}: { records: ${simpleClassName}Api.${simpleClassName}[];}) => {
|
|
|
|
|
+ deleteIds.value = records.map((item) => item.id);
|
|
|
|
|
+ },
|
|
|
|
|
+ #end
|
|
|
}
|
|
}
|
|
|
#end
|
|
#end
|
|
|
});
|
|
});
|
|
@@ -229,6 +259,19 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|
|
>
|
|
>
|
|
|
{{ $t('ui.actionTitle.export') }}
|
|
{{ $t('ui.actionTitle.export') }}
|
|
|
</Button>
|
|
</Button>
|
|
|
|
|
+#if ($table.templateType != 2 && $table.deleteBatch)
|
|
|
|
|
+ <Button
|
|
|
|
|
+ :icon="h(Trash2)"
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ danger
|
|
|
|
|
+ class="ml-2"
|
|
|
|
|
+ :disabled="showDeleteBatchBtn"
|
|
|
|
|
+ @click="onDeleteBatch"
|
|
|
|
|
+ v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:delete']"
|
|
|
|
|
+ >
|
|
|
|
|
+ 批量删除
|
|
|
|
|
+ </Button>
|
|
|
|
|
+#end
|
|
|
</template>
|
|
</template>
|
|
|
</Grid>
|
|
</Grid>
|
|
|
|
|
|