<script lang="ts" setup>
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { MesPdTechConfirmApi } from '#/api/mes/pd/tech-confirm';
|
|
import { ref } from 'vue';
|
|
import { Page, useVbenModal } from '@vben/common-ui';
|
import { $t } from '@vben/locales';
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
|
import { Button, message } from 'ant-design-vue';
|
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import {
|
deleteTechConfirm,
|
exportTechConfirm,
|
getTechConfirmPage,
|
updateTechConfirm,
|
} from '#/api/mes/pd/tech-confirm';
|
|
import { useGridColumns, useGridFormSchema } from './data';
|
import Form from './modules/form.vue';
|
|
const [FormModal, formModalApi] = useVbenModal({
|
connectedComponent: Form,
|
destroyOnClose: true,
|
});
|
|
/** 刷新表格 */
|
function handleRefresh() {
|
gridApi.query();
|
}
|
|
/** 新增 */
|
function handleCreate() {
|
formModalApi.setData({ formType: 'create' }).open();
|
}
|
|
/** 查看 */
|
function handleDetail(row: MesPdTechConfirmApi.TechConfirm) {
|
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
}
|
|
/** 编辑 */
|
function handleEdit(row: MesPdTechConfirmApi.TechConfirm) {
|
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
}
|
|
/** 删除 */
|
async function handleDelete(row: MesPdTechConfirmApi.TechConfirm) {
|
const hideLoading = message.loading({
|
content: $t('ui.actionMessage.deleting', [row.confirmNo ?? '']),
|
duration: 0,
|
});
|
try {
|
await deleteTechConfirm(row.id!);
|
message.success($t('ui.actionMessage.deleteSuccess', [row.confirmNo ?? '']));
|
handleRefresh();
|
} finally {
|
hideLoading();
|
}
|
}
|
|
/** 状态流转 */
|
async function handleStatus(row: MesPdTechConfirmApi.TechConfirm, next: number) {
|
const hideLoading = message.loading({ content: '状态更新中...', duration: 0 });
|
try {
|
await updateTechConfirm({ ...row, status: next });
|
message.success($t('ui.actionMessage.operationSuccess'));
|
handleRefresh();
|
} finally {
|
hideLoading();
|
}
|
}
|
|
/** 导出 */
|
async function handleExport() {
|
const data = await exportTechConfirm(await gridApi.formApi.getValues());
|
downloadFileFromBlobPart({ fileName: '产品技术确认函.xls', source: data });
|
}
|
|
const [Grid, gridApi] = useVbenVxeGrid({
|
formOptions: {
|
schema: useGridFormSchema(),
|
},
|
gridOptions: {
|
columns: useGridColumns(),
|
height: 'auto',
|
keepSource: true,
|
proxyConfig: {
|
ajax: {
|
query: async ({ page }, formValues) =>
|
await getTechConfirmPage({
|
pageNo: page.currentPage,
|
pageSize: page.pageSize,
|
...formValues,
|
}),
|
},
|
},
|
rowConfig: {
|
keyField: 'id',
|
isHover: true,
|
},
|
toolbarConfig: {
|
refresh: true,
|
search: true,
|
},
|
} as VxeTableGridOptions<MesPdTechConfirmApi.TechConfirm>,
|
});
|
</script>
|
|
<template>
|
<Page auto-content-height>
|
<FormModal @success="handleRefresh" />
|
<Grid table-title="产品技术确认函列表">
|
<template #toolbar-tools>
|
<TableAction
|
:actions="[
|
{
|
label: $t('ui.actionTitle.create', ['技术确认函']),
|
type: 'primary',
|
icon: ACTION_ICON.ADD,
|
auth: ['mes:pd-tech-confirm:create'],
|
onClick: handleCreate,
|
},
|
{
|
label: $t('ui.actionTitle.export'),
|
type: 'primary',
|
icon: ACTION_ICON.DOWNLOAD,
|
auth: ['mes:pd-tech-confirm:export'],
|
onClick: handleExport,
|
},
|
]"
|
/>
|
</template>
|
<template #confirmNo="{ row }">
|
<Button type="link" @click="handleDetail(row)">
|
{{ row.confirmNo }}
|
</Button>
|
</template>
|
<template #actions="{ row }">
|
<TableAction
|
:actions="[
|
{
|
label: '提交审核',
|
type: 'link',
|
icon: ACTION_ICON.AUDIT,
|
auth: ['mes:pd-tech-confirm:update'],
|
ifShow: row.status === 0,
|
onClick: handleStatus.bind(null, row, 1),
|
},
|
{
|
label: '审核通过',
|
type: 'link',
|
icon: ACTION_ICON.AUDIT,
|
auth: ['mes:pd-tech-confirm:update'],
|
ifShow: row.status === 1,
|
onClick: handleStatus.bind(null, row, 2),
|
},
|
{
|
label: '客户确认',
|
type: 'link',
|
icon: ACTION_ICON.AUDIT,
|
auth: ['mes:pd-tech-confirm:update'],
|
ifShow: row.status === 2,
|
onClick: handleStatus.bind(null, row, 3),
|
},
|
{
|
label: $t('common.edit'),
|
type: 'link',
|
icon: ACTION_ICON.EDIT,
|
auth: ['mes:pd-tech-confirm:update'],
|
onClick: handleEdit.bind(null, row),
|
},
|
{
|
label: $t('common.delete'),
|
type: 'link',
|
danger: true,
|
icon: ACTION_ICON.DELETE,
|
auth: ['mes:pd-tech-confirm:delete'],
|
popConfirm: {
|
title: $t('ui.actionMessage.deleteConfirm', [row.confirmNo ?? '']),
|
confirm: handleDelete.bind(null, row),
|
},
|
},
|
{
|
label: $t('common.detail'),
|
type: 'link',
|
icon: ACTION_ICON.VIEW,
|
auth: ['mes:pd-tech-confirm:query'],
|
onClick: handleDetail.bind(null, row),
|
},
|
]"
|
/>
|
</template>
|
</Grid>
|
</Page>
|
</template>
|