feat:新增LMS 生箔点位库存管理。

This commit is contained in:
2026-07-20 10:36:06 +08:00
parent 2582c4e474
commit 50f9e47630
16 changed files with 1214 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';
import { requestClient } from '#/api/request';
export namespace LmsRawFoilPointIVTApi {
/** 生箔点位库存信息 */
export interface RawFoilPointIVT {
pointId: number; // 点位标识
pointCode: string; // 点位编码
vehicleCode: string; // 载具编码
productionArea: string; // 生产区域
pointLocation: string; // 位置
extCode: string; // 外部编码
remark: string; // 备注
isUsed: string; // 是否启用
creator: string; // 创建人
createTime: string | Dayjs; // 创建时间
updater: string; // 修改人
updateTime: string | Dayjs; // 修改时间
}
}
/** 查询生箔点位库存分页 */
export function getRawFoilPointIVTPage(params: PageParam) {
return requestClient.get<PageResult<LmsRawFoilPointIVTApi.RawFoilPointIVT>>(
'/lms/raw-foil-point-IVT/page',
{ params },
);
}
/** 查询生箔点位库存详情 */
export function getRawFoilPointIVT(id: number) {
return requestClient.get<LmsRawFoilPointIVTApi.RawFoilPointIVT>(
`/lms/raw-foil-point-IVT/get?id=${id}`,
);
}
/** 新增生箔点位库存 */
export function createRawFoilPointIVT(data: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
return requestClient.post('/lms/raw-foil-point-IVT/create', data);
}
/** 修改生箔点位库存 */
export function updateRawFoilPointIVT(data: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
return requestClient.put('/lms/raw-foil-point-IVT/update', data);
}
/** 删除生箔点位库存 */
export function deleteRawFoilPointIVT(id: number) {
return requestClient.delete(`/lms/raw-foil-point-IVT/delete?id=${id}`);
}
/** 批量删除生箔点位库存 */
export function deleteRawFoilPointIVTList(ids: number[]) {
return requestClient.delete(
`/lms/raw-foil-point-IVT/delete-list?ids=${ids.join(',')}`,
);
}
/** 导出生箔点位库存 */
export function exportRawFoilPointIVT(params: any) {
return requestClient.download('/lms/raw-foil-point-IVT/export-excel', { params });
}

View File

@@ -0,0 +1,220 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsRawFoilPointIVTApi } from '#/api/lms/rawfoilpointivt';
import {DICT_TYPE} from "@vben/constants";
import { getDictOptions } from '@vben/hooks';
import {z} from "#/adapter/form";
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'pointId',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'pointCode',
label: '点位编码',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入点位编码',
},
},
{
fieldName: 'vehicleCode',
label: '载具编码',
component: 'Input',
componentProps: {
placeholder: '请输入载具编码',
},
},
{
fieldName: 'productionArea',
label: '生产区域',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.PRODUCT_AREA),
placeholder: '请选择生产区域',
},
},
{
fieldName: 'pointLocation',
label: '位置',
component: 'Input',
componentProps: {
placeholder: '请输入位置',
},
},
{
fieldName: 'extCode',
label: '外部编码',
component: 'Input',
componentProps: {
placeholder: '请输入外部编码',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'TextArea',
componentProps: {
placeholder: '请输入备注',
},
},
{
fieldName: 'isUsed',
label: '是否启用',
rules: z.string().default('1'),
component: 'RadioGroup',
componentProps: {
options: [{ label: '是', value: '1' }, { label: '否', value: '0' }],
buttonStyle: 'solid',
optionType: 'button',
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'pointCode',
label: '点位编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入点位编码',
},
},
{
fieldName: 'vehicleCode',
label: '载具编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入载具编码',
},
},
{
fieldName: 'productionArea',
label: '生产区域',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.PRODUCT_AREA),
placeholder: '请选择生产区域',
},
},
{
fieldName: 'pointLocation',
label: '位置',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入位置',
},
},
{
fieldName: 'extCode',
label: '外部编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入外部编码',
},
},
{
fieldName: 'isUsed',
label: '是否启用',
component: 'Select',
componentProps: {
allowClear: true,
options: [
{ label: '是', value: '1' },
{ label: '否', value: '0' },
],
placeholder: '请选择是否启用',
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<LmsRawFoilPointIVTApi.RawFoilPointIVT>['columns'] {
return [
{ type: 'checkbox', width: 40 },
{
field: 'pointCode',
title: '点位编码',
minWidth: 120,
},
{
field: 'vehicleCode',
title: '载具编码',
minWidth: 120,
},
{
field: 'productionArea',
title: '生产区域',
minWidth: 120,
},
{
field: 'pointLocation',
title: '位置',
minWidth: 120,
},
{
field: 'extCode',
title: '外部编码',
minWidth: 120,
},
{
field: 'remark',
title: '备注',
minWidth: 120,
},
{
field: 'isUsed',
title: '是否启用',
minWidth: 120,
formatter: ({ cellValue }: { cellValue: string }) => (cellValue === '1' ? '是' : '否')
},
{
field: 'creator',
title: '创建人',
minWidth: 120,
},
{
field: 'createTime',
title: '创建时间',
minWidth: 120,
formatter: 'formatDateTime',
},
{
field: 'updater',
title: '修改人',
minWidth: 120,
},
{
field: 'updateTime',
title: '修改时间',
minWidth: 120,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 200,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,186 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsRawFoilPointIVTApi } from '#/api/lms/rawfoilpointivt';
import { ref } from 'vue';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { message } from 'antdv-next';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteRawFoilPointIVT,
deleteRawFoilPointIVTList,
exportRawFoilPointIVT,
getRawFoilPointIVTPage,
} from '#/api/lms/rawfoilpointivt';
import { $t } from '#/locales';
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(null).open();
}
/** 编辑生箔点位库存 */
function handleEdit(row: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
formModalApi.setData(row).open();
}
/** 删除生箔点位库存 */
async function handleDelete(row: LmsRawFoilPointIVTApi.RawFoilPointIVT) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.pointId]),
duration: 0,
});
try {
await deleteRawFoilPointIVT(row.pointId!);
message.success($t('ui.actionMessage.deleteSuccess', [row.pointId]));
handleRefresh();
} finally {
hideLoading();
}
}
/** 批量删除生箔点位库存 */
async function handleDeleteBatch() {
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
const hideLoading = message.loading({
content: $t('ui.actionMessage.deletingBatch'),
duration: 0,
});
try {
await deleteRawFoilPointIVTList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: LmsRawFoilPointIVTApi.RawFoilPointIVT[];
}) {
checkedIds.value = records.map((item) => item.pointId!);
}
/** 导出表格 */
async function handleExport() {
const data = await exportRawFoilPointIVT(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) => {
return await getRawFoilPointIVTPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<LmsRawFoilPointIVTApi.RawFoilPointIVT>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
checkboxChange: handleRowCheckboxChange,
},
});
</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: ['lms:raw-foil-point-IVT:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['lms:raw-foil-point-IVT:export'],
onClick: handleExport,
},
{
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['lms:raw-foil-point-IVT:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['lms:raw-foil-point-IVT:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['lms:raw-foil-point-IVT:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.pointId]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,82 @@
<script lang="ts" setup>
import type { LmsRawFoilPointIVTApi } from '#/api/lms/rawfoilpointivt';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'antdv-next';
import { useVbenForm } from '#/adapter/form';
import { createRawFoilPointIVT, getRawFoilPointIVT, updateRawFoilPointIVT } from '#/api/lms/rawfoilpointivt';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<LmsRawFoilPointIVTApi.RawFoilPointIVT>();
const getTitle = computed(() => {
return formData.value?.pointId
? $t('ui.actionTitle.edit', ['生箔点位库存'])
: $t('ui.actionTitle.create', ['生箔点位库存']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 80,
},
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as LmsRawFoilPointIVTApi.RawFoilPointIVT;
try {
await (formData.value?.pointId ? updateRawFoilPointIVT(data) : createRawFoilPointIVT(data));
// 关闭并提示
await modalApi.close();
emit('success');
message.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData<LmsRawFoilPointIVTApi.RawFoilPointIVT>();
if (!data || !data.pointId) {
return;
}
modalApi.lock();
try {
formData.value = await getRawFoilPointIVT(data.pointId);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>