169 lines
4.8 KiB
Vue
169 lines
4.8 KiB
Vue
<script lang="ts" setup>
|
||
import type { VxeGridListeners } from '#/adapter/vxe-table';
|
||
|
||
import { ref } from 'vue';
|
||
|
||
import { Page, useVbenModal } from '@vben/common-ui';
|
||
|
||
import { Button, Image, message } from 'ant-design-vue';
|
||
|
||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||
import { TableAction } from '#/components/table-action';
|
||
|
||
import { deleteSupplier } from './api';
|
||
import FormModalDemo from './components/modal.vue';
|
||
import { formOptions } from './config/search';
|
||
import { gridOptions } from './config/table';
|
||
|
||
const hasTopTableDropDownActions = ref(false);
|
||
|
||
const gridEvents: VxeGridListeners<any> = {
|
||
checkboxChange() {
|
||
// eslint-disable-next-line no-use-before-define
|
||
const records = gridApi.grid.getCheckboxRecords();
|
||
hasTopTableDropDownActions.value = records.length > 0;
|
||
},
|
||
checkboxAll() {
|
||
// eslint-disable-next-line no-use-before-define
|
||
const records = gridApi.grid.getCheckboxRecords();
|
||
hasTopTableDropDownActions.value = records.length > 0;
|
||
},
|
||
};
|
||
|
||
const [Grid, gridApi] = useVbenVxeGrid({
|
||
formOptions,
|
||
gridOptions,
|
||
gridEvents,
|
||
});
|
||
|
||
const [FormModal, formModalApi] = useVbenModal({
|
||
connectedComponent: FormModalDemo,
|
||
});
|
||
|
||
const showModal = (data = {}, isUpdate = false) => {
|
||
formModalApi.setData({
|
||
// 表单值
|
||
values: data,
|
||
update: isUpdate,
|
||
gridApi,
|
||
});
|
||
formModalApi.open();
|
||
};
|
||
|
||
const deleteApi = (row: any) => {
|
||
let ids = [];
|
||
if (row) {
|
||
ids.push(row);
|
||
} else {
|
||
ids = gridApi.grid.getCheckboxRecords().map((item) => item.id);
|
||
}
|
||
deleteSupplier({ ids }).then(() => {
|
||
message.success('删除成功!');
|
||
gridApi.query();
|
||
});
|
||
};
|
||
</script>
|
||
|
||
<template>
|
||
<Page auto-content-height title="供应商管理">
|
||
<FormModal />
|
||
<Grid>
|
||
<template #toolbar-actions>
|
||
<TableAction
|
||
:actions="[
|
||
{
|
||
label: '新增',
|
||
type: 'primary',
|
||
icon: 'ant-design:plus-outlined',
|
||
// auth: ['超级供应商', 'sys:user:save'],
|
||
onClick: showModal.bind(null),
|
||
},
|
||
]"
|
||
:drop-down-actions="[
|
||
{
|
||
label: '删除',
|
||
icon: 'ant-design:delete-outlined',
|
||
ifShow: hasTopTableDropDownActions,
|
||
// auth: ['超级供应商', 'sys:user:save'],
|
||
popConfirm: {
|
||
title: '确定删除吗?',
|
||
confirm: deleteApi.bind(null, false),
|
||
},
|
||
},
|
||
]"
|
||
>
|
||
<template #more>
|
||
<Button style="margin-left: 16px">
|
||
批量操作
|
||
<Icon icon="ant-design:down-outlined" />
|
||
</Button>
|
||
</template>
|
||
</TableAction>
|
||
</template>
|
||
<template #logo="{ row }">
|
||
<Image :src="row.logo" height="30" width="30" />
|
||
</template>
|
||
<template #open_business_license="{ row }">
|
||
<Image :src="row.open_business_license" height="30" width="30" />
|
||
</template>
|
||
<template #business_license="{ row }">
|
||
<Image :src="row.business_license" height="30" width="30" />
|
||
</template>
|
||
<template #product_registration_certificate="{ row }">
|
||
<Image
|
||
:src="row.product_registration_certificate"
|
||
height="30"
|
||
width="30"
|
||
/>
|
||
</template>
|
||
<template #toolbar-tools></template>
|
||
<template #action="{ row }">
|
||
<TableAction
|
||
:actions="[
|
||
{
|
||
label: '编辑',
|
||
type: 'link',
|
||
icon: 'uil:edit',
|
||
size: 'small',
|
||
// auth: ['supplier', 'sys:role:detail'],
|
||
onClick: showModal.bind(null, row, true),
|
||
},
|
||
{
|
||
label: '删除',
|
||
type: 'link',
|
||
icon: 'ant-design:delete-outlined',
|
||
size: 'small',
|
||
// auth: ['supplier', 'sys:role:detail'],
|
||
popConfirm: {
|
||
title: '确定删除吗?',
|
||
confirm: deleteApi.bind(null, row.id),
|
||
},
|
||
},
|
||
]"
|
||
:drop-down-actions="[
|
||
// {
|
||
// label: '编辑',
|
||
// type: 'link',
|
||
// icon: 'ant-design:delete-outlined',
|
||
// size: 'small',
|
||
// // auth: ['supplier', 'sys:role:detail'],
|
||
// onClick: showModal.bind(null, row, true),
|
||
// },
|
||
// {
|
||
// label: '删除',
|
||
// type: 'link',
|
||
// icon: 'ant-design:delete-outlined',
|
||
// size: 'small',
|
||
// // auth: ['supplier', 'sys:role:detail'],
|
||
// popConfirm: {
|
||
// title: '确定删除吗?',
|
||
// confirm: deleteApi.bind(null, row.id),
|
||
// },
|
||
// },
|
||
]"
|
||
/>
|
||
</template>
|
||
</Grid>
|
||
</Page>
|
||
</template>
|