!1351 feat:【INFRA 基础设施】vben5-antd-general 新增 general 标准模式批量删除
Merge pull request !1351 from puhui999/vben5-antd-general
This commit is contained in:
commit
c8ee7adeca
|
@ -89,6 +89,13 @@ export function delete${simpleClassName}(id: number) {
|
||||||
return requestClient.delete(`${baseURL}/delete?id=${id}`);
|
return requestClient.delete(`${baseURL}/delete?id=${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
/** 批量删除${table.classComment} */
|
||||||
|
export function delete${simpleClassName}ListByIds(ids: number[]) {
|
||||||
|
return requestClient.delete(`${baseURL}/delete-list?ids=${ids.join(',')}`)
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
/** 导出${table.classComment} */
|
/** 导出${table.classComment} */
|
||||||
export function export${simpleClassName}(params: any) {
|
export function export${simpleClassName}(params: any) {
|
||||||
return requestClient.download('${baseURL}/export-excel', params);
|
return requestClient.download('${baseURL}/export-excel', params);
|
||||||
|
@ -144,6 +151,13 @@ export function delete${subSimpleClassName}(id: number) {
|
||||||
return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete?id=${id}`);
|
return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete?id=${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
/** 批量删除${subTable.classComment} */
|
||||||
|
export function delete${subSimpleClassName}ListByIds(ids: number[]) {
|
||||||
|
return requestClient.delete(`${baseURL}/${subSimpleClassName_strikeCase}/delete-list?ids=${ids.join(',')}`)
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
/** 获得${subTable.classComment} */
|
/** 获得${subTable.classComment} */
|
||||||
export function get${subSimpleClassName}(id: number) {
|
export function get${subSimpleClassName}(id: number) {
|
||||||
return requestClient.get<${simpleClassName}Api.${subSimpleClassName}>(`${baseURL}/${subSimpleClassName_strikeCase}/get?id=${id}`);
|
return requestClient.get<${simpleClassName}Api.${subSimpleClassName}>(`${baseURL}/${subSimpleClassName_strikeCase}/get?id=${id}`);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Inpu
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||||
import ${simpleClassName}Form from './modules/form.vue';
|
import ${simpleClassName}Form from './modules/form.vue';
|
||||||
import { Download, Plus, RefreshCw, Search } from '@vben/icons';
|
import { Download, Plus, RefreshCw, Search, Trash2 } from '@vben/icons';
|
||||||
import { ContentWrap } from '#/components/content-wrap';
|
import { ContentWrap } from '#/components/content-wrap';
|
||||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||||
import { TableToolbar } from '#/components/table-toolbar';
|
import { TableToolbar } from '#/components/table-toolbar';
|
||||||
|
@ -29,7 +29,8 @@ import { $t } from '#/locales';
|
||||||
import { handleTree,isEmpty } from '@vben/utils'
|
import { handleTree,isEmpty } from '@vben/utils'
|
||||||
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
#else## 标准表接口
|
#else## 标准表接口
|
||||||
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { isEmpty } from '@vben/utils';
|
||||||
|
import { get${simpleClassName}Page, delete${simpleClassName},#if ($deleteBatchEnable) delete${simpleClassName}ListByIds,#end export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
#end
|
#end
|
||||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
|
@ -152,11 +153,38 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
await getList();
|
await getList();
|
||||||
} catch {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
/** 批量删除${table.classComment} */
|
||||||
|
async function onDeleteBatch() {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting'),
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await delete${simpleClassName}ListByIds(deleteIds.value);
|
||||||
|
message.success( $t('ui.actionMessage.deleteSuccess') );
|
||||||
|
await getList();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteIds = ref<number[]>([]) // 待删除${table.classComment} ID
|
||||||
|
function setDeleteIds({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: ${simpleClassName}Api.${simpleClassName}[];
|
||||||
|
}) {
|
||||||
|
deleteIds.value = records.map((item) => item.id);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
/** 导出表格 */
|
/** 导出表格 */
|
||||||
async function onExport() {
|
async function onExport() {
|
||||||
try {
|
try {
|
||||||
|
@ -302,6 +330,19 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.export') }}
|
{{ $t('ui.actionTitle.export') }}
|
||||||
</Button>
|
</Button>
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
<Button
|
||||||
|
:icon="h(Trash2)"
|
||||||
|
type="primary"
|
||||||
|
danger
|
||||||
|
class="ml-2"
|
||||||
|
:disabled="isEmpty(deleteIds)"
|
||||||
|
@click="onDeleteBatch"
|
||||||
|
v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:delete']"
|
||||||
|
>
|
||||||
|
批量删除
|
||||||
|
</Button>
|
||||||
|
#end
|
||||||
</TableToolbar>
|
</TableToolbar>
|
||||||
</template>
|
</template>
|
||||||
<vxe-table
|
<vxe-table
|
||||||
|
@ -326,7 +367,14 @@ onMounted(() => {
|
||||||
#end
|
#end
|
||||||
show-overflow
|
show-overflow
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
@checkboxAll="setDeleteIds"
|
||||||
|
@checkboxChange="setDeleteIds"
|
||||||
|
#end
|
||||||
>
|
>
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
<vxe-column type="checkbox" width="40"></vxe-column>
|
||||||
|
#end
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||||
<!-- 子表的列表 -->
|
<!-- 子表的列表 -->
|
||||||
|
@ -421,7 +469,6 @@ onMounted(() => {
|
||||||
</div>
|
</div>
|
||||||
#end
|
#end
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp情况
|
#if ($table.templateType == 11) ## erp情况
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<!-- 子表的表单 -->
|
<!-- 子表的表单 -->
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils';
|
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
||||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||||
import { reactive,ref, h, nextTick,watch,onMounted } from 'vue';
|
import { reactive,ref, h, nextTick,watch,onMounted } from 'vue';
|
||||||
import { cloneDeep, formatDateTime } from '@vben/utils';
|
import { cloneDeep, formatDateTime } from '@vben/utils';
|
||||||
|
@ -22,15 +22,15 @@
|
||||||
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
import { Tinymce as RichTextarea } from '#/components/tinymce';
|
||||||
import { ImageUpload, FileUpload } from "#/components/upload";
|
import { ImageUpload, FileUpload } from "#/components/upload";
|
||||||
import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
|
import { message,Button, Tabs,Pagination, Form, Input, Textarea, Select, RadioGroup, Radio, CheckboxGroup, Checkbox,RangePicker, DatePicker, TreeSelect } from 'ant-design-vue';
|
||||||
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
|
import { Plus, Trash2 } from '@vben/icons';
|
||||||
import { Plus } from '@vben/icons';
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { TableToolbar } from '#/components/table-toolbar';
|
import { TableToolbar } from '#/components/table-toolbar';
|
||||||
import { useTableToolbar } from '#/hooks';
|
import { useTableToolbar } from '#/hooks';
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import { delete${subSimpleClassName}, get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}ListByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
|
||||||
|
import { isEmpty } from '@vben/utils';
|
||||||
#else
|
#else
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
@ -76,11 +76,38 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
|
||||||
key: 'action_process_msg',
|
key: 'action_process_msg',
|
||||||
});
|
});
|
||||||
getList();
|
await getList();
|
||||||
} catch {
|
} finally {
|
||||||
hideLoading();
|
hideLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
/** 批量删除${subTable.classComment} */
|
||||||
|
async function onDeleteBatch() {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting'),
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await delete${subSimpleClassName}ListByIds(deleteIds.value);
|
||||||
|
message.success( $t('ui.actionMessage.deleteSuccess') );
|
||||||
|
await getList();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteIds = ref<number[]>([]) // 待删除${subTable.classComment} ID
|
||||||
|
function setDeleteIds({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
|
}) {
|
||||||
|
deleteIds.value = records.map((item) => item.id);
|
||||||
|
}
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const loading = ref(true) // 列表的加载中
|
const loading = ref(true) // 列表的加载中
|
||||||
|
@ -277,6 +304,19 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.create', ['${table.classComment}']) }}
|
{{ $t('ui.actionTitle.create', ['${table.classComment}']) }}
|
||||||
</Button>
|
</Button>
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
<Button
|
||||||
|
:icon="h(Trash2)"
|
||||||
|
type="primary"
|
||||||
|
danger
|
||||||
|
class="ml-2"
|
||||||
|
:disabled="isEmpty(deleteIds)"
|
||||||
|
@click="onDeleteBatch"
|
||||||
|
v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:delete']"
|
||||||
|
>
|
||||||
|
批量删除
|
||||||
|
</Button>
|
||||||
|
#end
|
||||||
</TableToolbar>
|
</TableToolbar>
|
||||||
</template>
|
</template>
|
||||||
<vxe-table
|
<vxe-table
|
||||||
|
@ -284,7 +324,14 @@ onMounted(() => {
|
||||||
:data="list"
|
:data="list"
|
||||||
show-overflow
|
show-overflow
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
@checkboxAll="setDeleteIds"
|
||||||
|
@checkboxChange="setDeleteIds"
|
||||||
|
#end
|
||||||
>
|
>
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
<vxe-column type="checkbox" width="40"></vxe-column>
|
||||||
|
#end
|
||||||
#foreach($column in $subColumns)
|
#foreach($column in $subColumns)
|
||||||
#if ($column.listOperationResult)
|
#if ($column.listOperationResult)
|
||||||
#set ($dictType=$column.dictType)
|
#set ($dictType=$column.dictType)
|
||||||
|
|
Loading…
Reference in New Issue